public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v2] mtd: devices: elm: check for device's presence before configuration
@ 2013-03-03 23:57 Daniel Mack
  2013-03-04  7:47 ` Peter Korsgaard
  2013-03-11  9:19 ` Artem Bityutskiy
  0 siblings, 2 replies; 6+ messages in thread
From: Daniel Mack @ 2013-03-03 23:57 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.

Make elm_config() return an error in such cases to propagate the error
up to the user, so it can fall back to software mode.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Cc: Philip Avinash <avinashphilip@ti.com>
Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Cc: Peter Korsgaard <jacmet@sunsite.dk>
---
 drivers/mtd/devices/elm.c         | 9 ++++++++-
 drivers/mtd/nand/omap2.c          | 5 +++--
 include/linux/platform_data/elm.h | 2 +-
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/devices/elm.c b/drivers/mtd/devices/elm.c
index 2ec5da9..dccef9f 100644
--- a/drivers/mtd/devices/elm.c
+++ b/drivers/mtd/devices/elm.c
@@ -81,14 +81,21 @@ static u32 elm_read_reg(struct elm_info *info, int offset)
  * @dev:	ELM device
  * @bch_type:	Type of BCH ecc
  */
-void elm_config(struct device *dev, enum bch_ecc bch_type)
+int 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 -ENODEV;
+	}
+
 	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;
+
+	return 0;
 }
 EXPORT_SYMBOL(elm_config);
 
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 8e820dd..b97ef3b 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -1701,8 +1701,9 @@ static int omap3_init_bch(struct mtd_info *mtd, int ecc_opt)
 		elm_node = of_find_node_by_phandle(be32_to_cpup(parp));
 		pdev = of_find_device_by_node(elm_node);
 		info->elm_dev = &pdev->dev;
-		elm_config(info->elm_dev, bch_type);
-		info->is_elm_used = true;
+
+		if (elm_config(info->elm_dev, bch_type) == 0)
+			info->is_elm_used = true;
 	}
 
 	if (info->is_elm_used && (mtd->writesize <= 4096)) {
diff --git a/include/linux/platform_data/elm.h b/include/linux/platform_data/elm.h
index 1bd5244..bf0a83b 100644
--- a/include/linux/platform_data/elm.h
+++ b/include/linux/platform_data/elm.h
@@ -50,5 +50,5 @@ struct elm_errorvec {
 
 void elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc,
 		struct elm_errorvec *err_vec);
-void elm_config(struct device *dev, enum bch_ecc bch_type);
+int elm_config(struct device *dev, enum bch_ecc bch_type);
 #endif /* __ELM_H */
-- 
1.8.1.4

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

* Re: [PATCH v2] mtd: devices: elm: check for device's presence before configuration
  2013-03-03 23:57 [PATCH v2] mtd: devices: elm: check for device's presence before configuration Daniel Mack
@ 2013-03-04  7:47 ` Peter Korsgaard
  2013-03-05 10:24   ` Daniel Mack
  2013-03-11  9:19 ` Artem Bityutskiy
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Korsgaard @ 2013-03-04  7:47 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.

 Daniel> Make elm_config() return an error in such cases to propagate the error
 Daniel> up to the user, so it can fall back to software mode.

 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> Cc: Peter Korsgaard <jacmet@sunsite.dk>

Acked-by: Peter Korsgaard <jacmet@sunsite.dk>

-- 
Bye, Peter Korsgaard

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

* Re: [PATCH v2] mtd: devices: elm: check for device's presence before configuration
  2013-03-04  7:47 ` Peter Korsgaard
@ 2013-03-05 10:24   ` Daniel Mack
  2013-03-05 10:26     ` Philip, Avinash
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Mack @ 2013-03-05 10:24 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: dwmw2, linux-mtd, Artem Bityutskiy

On 04.03.2013 08:47, 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.
> 
>  Daniel> Make elm_config() return an error in such cases to propagate the error
>  Daniel> up to the user, so it can fall back to software mode.
> 
>  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> Cc: Peter Korsgaard <jacmet@sunsite.dk>
> 
> Acked-by: Peter Korsgaard <jacmet@sunsite.dk>

Philip, are you also ok with this?


Thanks,
Daniel

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

* RE: [PATCH v2] mtd: devices: elm: check for device's presence before configuration
  2013-03-05 10:24   ` Daniel Mack
@ 2013-03-05 10:26     ` Philip, Avinash
  2013-03-08 14:48       ` Daniel Mack
  0 siblings, 1 reply; 6+ messages in thread
From: Philip, Avinash @ 2013-03-05 10:26 UTC (permalink / raw)
  To: Daniel Mack, Peter Korsgaard
  Cc: dwmw2@infradead.org, linux-mtd@lists.infradead.org,
	Artem Bityutskiy

On Tue, Mar 05, 2013 at 15:54:16, Daniel Mack wrote:
> On 04.03.2013 08:47, 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.
> > 
> >  Daniel> Make elm_config() return an error in such cases to propagate the error
> >  Daniel> up to the user, so it can fall back to software mode.
> > 
> >  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> Cc: Peter Korsgaard <jacmet@sunsite.dk>
> > 
> > Acked-by: Peter Korsgaard <jacmet@sunsite.dk>
> 
> Philip, are you also ok with this?

Yes.
Thanks
Avinash

> 
> 
> Thanks,
> Daniel
> 
> 

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

* Re: [PATCH v2] mtd: devices: elm: check for device's presence before configuration
  2013-03-05 10:26     ` Philip, Avinash
@ 2013-03-08 14:48       ` Daniel Mack
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Mack @ 2013-03-08 14:48 UTC (permalink / raw)
  To: Philip, Avinash
  Cc: linux-mtd@lists.infradead.org, dwmw2@infradead.org,
	Artem Bityutskiy

On Tue, Mar 5, 2013 at 11:26 AM, Philip, Avinash <avinashphilip@ti.com> wrote:
> On Tue, Mar 05, 2013 at 15:54:16, Daniel Mack wrote:
>> On 04.03.2013 08:47, 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.
>> >
>> >  Daniel> Make elm_config() return an error in such cases to propagate the error
>> >  Daniel> up to the user, so it can fall back to software mode.
>> >
>> >  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> Cc: Peter Korsgaard <jacmet@sunsite.dk>
>> >
>> > Acked-by: Peter Korsgaard <jacmet@sunsite.dk>
>>
>> Philip, are you also ok with this?
>
> Yes.
> Thanks
> Avinash

Artem, can this go through your tree?


Thanks, everyone.

Daniel

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

* Re: [PATCH v2] mtd: devices: elm: check for device's presence before configuration
  2013-03-03 23:57 [PATCH v2] mtd: devices: elm: check for device's presence before configuration Daniel Mack
  2013-03-04  7:47 ` Peter Korsgaard
@ 2013-03-11  9:19 ` Artem Bityutskiy
  1 sibling, 0 replies; 6+ messages in thread
From: Artem Bityutskiy @ 2013-03-11  9:19 UTC (permalink / raw)
  To: Daniel Mack; +Cc: dwmw2, linux-mtd

On Mon, 2013-03-04 at 00:57 +0100, Daniel Mack wrote:
> 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.
> 
> Make elm_config() return an error in such cases to propagate the error
> up to the user, so it can fall back to software mode.
> 
> Signed-off-by: Daniel Mack <zonque@gmail.com>

Pushed to l2-mtd.git, thanks!

-- 
Best Regards,
Artem Bityutskiy

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

end of thread, other threads:[~2013-03-11  9:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-03 23:57 [PATCH v2] mtd: devices: elm: check for device's presence before configuration Daniel Mack
2013-03-04  7:47 ` Peter Korsgaard
2013-03-05 10:24   ` Daniel Mack
2013-03-05 10:26     ` Philip, Avinash
2013-03-08 14:48       ` Daniel Mack
2013-03-11  9:19 ` Artem Bityutskiy

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