mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-24 17:59:32 +00:00
UBI: init even if MTD device cannot be attached, if built into kernel
UBI can be built into the kernel or be compiled as a kernel module. Further on the command line one can specify MTD devices to be attach to UBI while loading. In the current implementation the UBI driver refuses to load if one of the MTD devices cannot be attached. Consider: 1) UBI compiled into the kernel and 2) a MTD device specified on the command line and 3) this MTD device contains bogus data (for whatever reason). During init UBI tries to attach the MTD device is this fails the whole UBI subsystem isn't initialized. Later the userspace cannot attach any MTD to UBI because UBI isn't loaded. This patch keeps the current behaviour: if UBI is compiled as a module and a MTD device cannot be attached the UBI module cannot be loaded, but changes it for the UBI-is-built-into-the-kernel usecase. If UBI is builtin, a not attachable MTD device doen't stop UBI from initializing. This slightly modifies the behaviour if multiple MTD devices are specified on the command line. Now every MTD device is probed and, if possible, attached, i.e. a faulty MTD device doesn't stop the others from being attached. Artem: tweaked the patch Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
This commit is contained in:
parent
70d38b9625
commit
af7ad7a0a6
1 changed files with 23 additions and 2 deletions
|
@ -49,6 +49,12 @@
|
|||
/* Maximum length of the 'mtd=' parameter */
|
||||
#define MTD_PARAM_LEN_MAX 64
|
||||
|
||||
#ifdef CONFIG_MTD_UBI_MODULE
|
||||
#define ubi_is_module() 1
|
||||
#else
|
||||
#define ubi_is_module() 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* struct mtd_dev_param - MTD device parameter description data structure.
|
||||
* @name: MTD character device node path, MTD device name, or MTD device number
|
||||
|
@ -1206,9 +1212,24 @@ static int __init ubi_init(void)
|
|||
p->vid_hdr_offs);
|
||||
mutex_unlock(&ubi_devices_mutex);
|
||||
if (err < 0) {
|
||||
put_mtd_device(mtd);
|
||||
ubi_err("cannot attach mtd%d", mtd->index);
|
||||
goto out_detach;
|
||||
put_mtd_device(mtd);
|
||||
|
||||
/*
|
||||
* Originally UBI stopped initializing on any error.
|
||||
* However, later on it was found out that this
|
||||
* behavior is not very good when UBI is compiled into
|
||||
* the kernel and the MTD devices to attach are passed
|
||||
* through the command line. Indeed, UBI failure
|
||||
* stopped whole boot sequence.
|
||||
*
|
||||
* To fix this, we changed the behavior for the
|
||||
* non-module case, but preserved the old behavior for
|
||||
* the module case, just for compatibility. This is a
|
||||
* little inconsistent, though.
|
||||
*/
|
||||
if (ubi_is_module())
|
||||
goto out_detach;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue