public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] mtd: devices: elm: check for device's presence before configuration
@ 2013-03-03 21:12 Daniel Mack
  2013-03-03 21:44 ` Peter Korsgaard
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Mack @ 2013-03-03 21:12 UTC (permalink / raw)
  To: linux-mtd; +Cc: dwmw2, Artem Bityutskiy, Daniel Mack

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

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

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: devices: elm: check for device's presence before configuration
  2013-03-03 21:12 [PATCH] mtd: devices: elm: check for device's presence before configuration Daniel Mack
@ 2013-03-03 21:44 ` Peter Korsgaard
  2013-03-03 22:03   ` Daniel Mack
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Korsgaard @ 2013-03-03 21:44 UTC (permalink / raw)
  To: Daniel Mack; +Cc: dwmw2, linux-mtd, Artem Bityutskiy

>>>>> "Daniel" == Daniel Mack <zonque@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@gmail.com>
 Daniel> Cc: Philip Avinash <avinashphilip@ti.com>
 Daniel> Cc: Artem Bityutskiy <artem.bityutskiy@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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: devices: elm: check for device's presence before configuration
  2013-03-03 21:44 ` Peter Korsgaard
@ 2013-03-03 22:03   ` Daniel Mack
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Mack @ 2013-03-03 22:03 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: dwmw2, linux-mtd, Artem Bityutskiy

On 03.03.2013 22:44, Peter Korsgaard wrote:
>>>>>> "Daniel" == Daniel Mack <zonque@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@gmail.com>
>  Daniel> Cc: Philip Avinash <avinashphilip@ti.com>
>  Daniel> Cc: Artem Bityutskiy <artem.bityutskiy@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).
> 

Yes, you're right. Will send an updated version later ...

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-03-03 22:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-03 21:12 [PATCH] mtd: devices: elm: check for device's presence before configuration Daniel Mack
2013-03-03 21:44 ` Peter Korsgaard
2013-03-03 22:03   ` Daniel Mack

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox