linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fsl_elbc_nand: fix mtd name
@ 2008-03-18 15:43 Anton Vorontsov
  2008-03-18 15:54 ` Scott Wood
  2008-03-18 15:58 ` [PATCH v2] " Anton Vorontsov
  0 siblings, 2 replies; 5+ messages in thread
From: Anton Vorontsov @ 2008-03-18 15:43 UTC (permalink / raw)
  To: linux-mtd; +Cc: Scott Wood, linuxppc-dev

Currently fsl_elbc_nand doesn't initialize mtd->name, and this causes
nand_get_flash_type() to assign name that is equal to chip type, like
this:

   root@b1:~# cat /proc/mtd
   dev:    size   erasesize  name
   mtd0: 00800000 00010000 "fe000000.flash"
   mtd1: 02000000 00004000 "NAND 32MiB 3,3V 8-bit"

mtd0 is physmap_of flash (normal name), and mtd1 is fsl_elbc_nand.

Despite inconsistency, with mtd name like this specifying paritions
from the kernel command line becomes a torture (though, I didn't tried
and not sure if mtdparts= can handle spaces at all). Plus, this causes
real bugs when multiple fsl_elbc_nand chips registered.

With this patch applied fsl_elbc_nand chip will have proper name:

   root@b1:~# cat /proc/mtd
   dev:    size   erasesize  name
   mtd0: 00800000 00010000 "fe000000.flash"
   mtd1: 02000000 00004000 "e0600000.flash"

p.s. We can't use priv->dev->bus_id as in physmap_of, because
fsl_elbc_nand pretends to be a localbus controller, so its bus_id is
"address.localbus", which is incorrect and thus will also not work
for multiple chips.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 drivers/mtd/nand/fsl_elbc_nand.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index b025dfe..54a9d83 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -974,6 +974,8 @@ static int fsl_elbc_chip_remove(struct fsl_elbc_mtd *priv)
 
 	nand_release(&priv->mtd);
 
+	kfree(priv->mtd.name);
+
 	if (priv->vbase)
 		iounmap(priv->vbase);
 
@@ -1050,6 +1052,8 @@ static int fsl_elbc_chip_probe(struct fsl_elbc_ctrl *ctrl,
 	if (ret)
 		goto err;
 
+	priv->mtd.name = kasprintf(GFP_KERNEL, "%x.flash", res.start);
+
 #ifdef CONFIG_MTD_PARTITIONS
 	/* First look for RedBoot table or partitions on the command
 	 * line, these take precedence over device tree information */
-- 
1.5.2.2

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

* Re: [PATCH] fsl_elbc_nand: fix mtd name
  2008-03-18 15:43 [PATCH] fsl_elbc_nand: fix mtd name Anton Vorontsov
@ 2008-03-18 15:54 ` Scott Wood
  2008-03-18 15:58 ` [PATCH v2] " Anton Vorontsov
  1 sibling, 0 replies; 5+ messages in thread
From: Scott Wood @ 2008-03-18 15:54 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: linuxppc-dev, linux-mtd

On Tue, Mar 18, 2008 at 06:43:44PM +0300, Anton Vorontsov wrote:
> With this patch applied fsl_elbc_nand chip will have proper name:
> 
>    root@b1:~# cat /proc/mtd
>    dev:    size   erasesize  name
>    mtd0: 00800000 00010000 "fe000000.flash"
>    mtd1: 02000000 00004000 "e0600000.flash"
> 
> p.s. We can't use priv->dev->bus_id as in physmap_of, because
> fsl_elbc_nand pretends to be a localbus controller, so its bus_id is
> "address.localbus", which is incorrect and thus will also not work
> for multiple chips.

Acked-by: Scott Wood <scottwood@freescale.com>

-Scott

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

* [PATCH v2] fsl_elbc_nand: fix mtd name
  2008-03-18 15:43 [PATCH] fsl_elbc_nand: fix mtd name Anton Vorontsov
  2008-03-18 15:54 ` Scott Wood
@ 2008-03-18 15:58 ` Anton Vorontsov
  2008-03-18 16:11   ` Scott Wood
  1 sibling, 1 reply; 5+ messages in thread
From: Anton Vorontsov @ 2008-03-18 15:58 UTC (permalink / raw)
  To: linux-mtd; +Cc: Scott Wood, linuxppc-dev

Currently fsl_elbc_nand doesn't initialize mtd->name, and this causes
nand_get_flash_type() to assign name that is equal to chip type, like
this:

   root@b1:~# cat /proc/mtd
   dev:    size   erasesize  name
   mtd0: 00800000 00010000 "fe000000.flash"
   mtd1: 02000000 00004000 "NAND 32MiB 3,3V 8-bit"

mtd0 is physmap_of flash (normal name), and mtd1 is fsl_elbc_nand.

Despite inconsistency, with mtd name like this specifying paritions
from the kernel command line becomes a torture (though, I didn't tried
and not sure if mtdparts= can handle spaces at all). Plus, this causes
real bugs when multiple fsl_elbc_nand chips registered.

With this patch applied fsl_elbc_nand chip will have proper name:

   root@b1:~# cat /proc/mtd
   dev:    size   erasesize  name
   mtd0: 00800000 00010000 "fe000000.flash"
   mtd1: 02000000 00004000 "e0600000.flash"

p.s. We can't use priv->dev->bus_id as in physmap_of, because
fsl_elbc_nand pretends to be a localbus controller, so its bus_id is
"address.localbus", which is incorrect and thus will also not work
for multiple chips.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---

Oops, forgot the NULL checking.

 drivers/mtd/nand/fsl_elbc_nand.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index b025dfe..9fff5d1 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -974,6 +974,9 @@ static int fsl_elbc_chip_remove(struct fsl_elbc_mtd *priv)
 
 	nand_release(&priv->mtd);
 
+	if (priv->mtd.name)
+		kfree(priv->mtd.name);
+
 	if (priv->vbase)
 		iounmap(priv->vbase);
 
@@ -1050,6 +1053,12 @@ static int fsl_elbc_chip_probe(struct fsl_elbc_ctrl *ctrl,
 	if (ret)
 		goto err;
 
+	priv->mtd.name = kasprintf(GFP_KERNEL, "%x.flash", res.start);
+	if (!priv->mtd.name) {
+		ret = -ENOMEM;
+		goto err;
+	}
+
 #ifdef CONFIG_MTD_PARTITIONS
 	/* First look for RedBoot table or partitions on the command
 	 * line, these take precedence over device tree information */
-- 
1.5.2.2

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

* Re: [PATCH v2] fsl_elbc_nand: fix mtd name
  2008-03-18 15:58 ` [PATCH v2] " Anton Vorontsov
@ 2008-03-18 16:11   ` Scott Wood
  2008-03-18 16:34     ` [PATCH v3] " Anton Vorontsov
  0 siblings, 1 reply; 5+ messages in thread
From: Scott Wood @ 2008-03-18 16:11 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: linuxppc-dev, linux-mtd

On Tue, Mar 18, 2008 at 06:58:14PM +0300, Anton Vorontsov wrote:
> Oops, forgot the NULL checking.
[snip] 
> +	if (priv->mtd.name)
> +		kfree(priv->mtd.name);
> +

Not needed; kfree(NULL) is a no-op.

-Scott

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

* [PATCH v3] fsl_elbc_nand: fix mtd name
  2008-03-18 16:11   ` Scott Wood
@ 2008-03-18 16:34     ` Anton Vorontsov
  0 siblings, 0 replies; 5+ messages in thread
From: Anton Vorontsov @ 2008-03-18 16:34 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, linux-mtd

Currently fsl_elbc_nand doesn't initialize mtd->name, and this causes
nand_get_flash_type() to assign name that is equal to chip type, like
this:

   root@b1:~# cat /proc/mtd
   dev:    size   erasesize  name
   mtd0: 00800000 00010000 "fe000000.flash"
   mtd1: 02000000 00004000 "NAND 32MiB 3,3V 8-bit"

mtd0 is physmap_of flash (normal name), and mtd1 is fsl_elbc_nand.

Despite inconsistency, with mtd name like this specifying paritions
from the kernel command line becomes a torture (though, I didn't tried
and not sure if mtdparts= can handle spaces at all). Plus, this causes
real bugs when multiple fsl_elbc_nand chips registered.

With this patch applied fsl_elbc_nand chip will have proper name:

   root@b1:~# cat /proc/mtd
   dev:    size   erasesize  name
   mtd0: 00800000 00010000 "fe000000.flash"
   mtd1: 02000000 00004000 "e0600000.flash"

p.s. We can't use priv->dev->bus_id as in physmap_of, because
fsl_elbc_nand pretends to be a localbus controller, so its bus_id is
"address.localbus", which is incorrect and thus will also not work
for multiple chips.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---

On Tue, Mar 18, 2008 at 11:11:39AM -0500, Scott Wood wrote:
> On Tue, Mar 18, 2008 at 06:58:14PM +0300, Anton Vorontsov wrote:
> > Oops, forgot the NULL checking.
> [snip] 
> > +	if (priv->mtd.name)
> > +		kfree(priv->mtd.name);
> > +
> 
> Not needed; kfree(NULL) is a no-op.

D'oh, right. Also, we should fill the name prior to nand_scan_ident,
otherwise if error happened between nand_scan_ident and kasprintf
then we'll kfree chip's type name.

 drivers/mtd/nand/fsl_elbc_nand.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index b025dfe..9c86d9b 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -974,6 +974,8 @@ static int fsl_elbc_chip_remove(struct fsl_elbc_mtd *priv)
 
 	nand_release(&priv->mtd);
 
+	kfree(priv->mtd.name);
+
 	if (priv->vbase)
 		iounmap(priv->vbase);
 
@@ -1034,6 +1036,12 @@ static int fsl_elbc_chip_probe(struct fsl_elbc_ctrl *ctrl,
 		goto err;
 	}
 
+	priv->mtd.name = kasprintf(GFP_KERNEL, "%x.flash", res.start);
+	if (!priv->mtd.name) {
+		ret = -ENOMEM;
+		goto err;
+	}
+
 	ret = fsl_elbc_chip_init(priv);
 	if (ret)
 		goto err;
-- 
1.5.2.2

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

end of thread, other threads:[~2008-03-18 16:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-18 15:43 [PATCH] fsl_elbc_nand: fix mtd name Anton Vorontsov
2008-03-18 15:54 ` Scott Wood
2008-03-18 15:58 ` [PATCH v2] " Anton Vorontsov
2008-03-18 16:11   ` Scott Wood
2008-03-18 16:34     ` [PATCH v3] " Anton Vorontsov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).