[PATCH] mtd: devices: elm: check for device's presence before configuration

Peter Korsgaard jacmet at sunsite.dk
Sun Mar 3 16:44:05 EST 2013


>>>>> "Daniel" == Daniel Mack <zonque at gmail.com> writes:

 Daniel> In case the driver is not probed - due to config mismatches or errors
 Daniel> in the DTS files - dev_get_drvdata() returns NULL, leading to an Ooops
 Daniel> during boot. Better bail out with a warning in such cases.

 Daniel> Signed-off-by: Daniel Mack <zonque at gmail.com>
 Daniel> Cc: Philip Avinash <avinashphilip at ti.com>
 Daniel> Cc: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
 Daniel> ---
 Daniel>  drivers/mtd/devices/elm.c | 5 +++++
 Daniel>  1 file changed, 5 insertions(+)

 Daniel> diff --git a/drivers/mtd/devices/elm.c b/drivers/mtd/devices/elm.c
 Daniel> index 2ec5da9..a9b6d04 100644
 Daniel> --- a/drivers/mtd/devices/elm.c
 Daniel> +++ b/drivers/mtd/devices/elm.c
 Daniel> @@ -86,6 +86,11 @@ void elm_config(struct device *dev, enum bch_ecc bch_type)
 Daniel>  	u32 reg_val;
 Daniel>  	struct elm_info *info = dev_get_drvdata(dev);
 
 Daniel> +	if (!info) {
 Daniel> +		dev_err(dev, "Unable to configure elm - device not probed?\n");
 Daniel> +		return;
 Daniel> +	}
 Daniel> +

Even better would be to propagate the error message (E.G. return
-ENODEV) and let omap2.c deal with it (fall back to sw).

-- 
Bye, Peter Korsgaard



More information about the linux-mtd mailing list