Instead of individual hacks meant to prioritize the storage backend
drivers, register them with an optional priotity. If set, the higher
priority driver should be considered be considered first.
Prioritize UBI and MTD over the bulk of block device drivers
(partname, rootdisk) which allows removing previous hacks having the
same effect.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
static struct driver mtd_driver = {
.name = "mtd",
+ .priority = 10,
.find = mtd_volume_find,
.init = mtd_volume_init,
.erase = mtd_volume_erase,
if (!rootdev)
return NULL;
- if (strstr(rootdev, "mtdblock") ||
- strstr(rootdev, "ubiblock"))
- return NULL;
-
if (get_squashfs(&sb))
return NULL;
static struct driver ubi_driver = {
.name = "ubi",
+ .priority = 20,
.find = ubi_volume_find,
.init = ubi_volume_init,
.identify = ubi_volume_identify,
void
volume_register_driver(struct driver *d)
{
- list_add(&d->list, &drivers);
+ struct driver *cur, *tmp;
+
+ list_for_each_entry_safe(cur, tmp, &drivers, list) {
+ if (d->priority <= cur->priority)
+ continue;
+
+ _list_add(&d->list, cur->list.prev, &cur->list);
+ return;
+ }
+ list_add_tail(&d->list, &drivers);
}
struct volume* volume_find(char *name)
struct driver {
struct list_head list;
+ unsigned int priority;
char *name;
volume_probe_t probe;
volume_init_t init;