diff mbox

mtd: remove driver-core BUS_ID_SIZE

Message ID 1244305502-20902-1-git-send-email-anemo@mba.ocn.ne.jp
State New, archived
Headers show

Commit Message

Atsushi Nemoto June 6, 2009, 4:25 p.m. UTC
From: Kay Sievers <kay.sievers@vrfy.org>

The name size limit is gone from the driver-core, the BUS_ID_SIZE
value will be removed.

[initial version by kay.sievers, reimplemented by dwmw2, adjusted by anemo]
Cc: dwmw2@infradead.org
Cc: linux-mtd@lists.infradead.org
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
 drivers/mtd/nand/txx9ndfmc.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

Comments

Atsushi Nemoto June 6, 2009, 4:42 p.m. UTC | #1
On Sun,  7 Jun 2009 01:25:02 +0900, Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> From: Kay Sievers <kay.sievers@vrfy.org>
> 
> The name size limit is gone from the driver-core, the BUS_ID_SIZE
> value will be removed.
> 
> [initial version by kay.sievers, reimplemented by dwmw2, adjusted by anemo]
> Cc: dwmw2@infradead.org
> Cc: linux-mtd@lists.infradead.org
> Cc: Greg Kroah-Hartman <gregkh@suse.de>
> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> ---
>  drivers/mtd/nand/txx9ndfmc.c |   16 ++++++++++++----
>  1 files changed, 12 insertions(+), 4 deletions(-)

Oops, sorry, I have send wrong patch.  Please ignore it.  I will send
right one soon.
diff mbox

Patch

diff --git a/drivers/mtd/nand/txx9ndfmc.c b/drivers/mtd/nand/txx9ndfmc.c
index 8124792..23f4d1f 100644
--- a/drivers/mtd/nand/txx9ndfmc.c
+++ b/drivers/mtd/nand/txx9ndfmc.c
@@ -64,7 +64,7 @@  struct txx9ndfmc_priv {
 	struct nand_chip chip;
 	struct mtd_info mtd;
 	int cs;
-	char mtdname[BUS_ID_SIZE + 2];
+	const char *mtdname;
 };
 
 #define MAX_TXX9NDFMC_DEV	4
@@ -334,16 +334,23 @@  static int __init txx9ndfmc_probe(struct platform_device *dev)
 
 		if (plat->ch_mask != 1) {
 			txx9_priv->cs = i;
-			sprintf(txx9_priv->mtdname, "%s.%u",
-				dev_name(&dev->dev), i);
+			txx9_priv->mtdname = kasprintf(GFP_KERNEL, "%s.%u",
+						       dev_name(&dev->dev), i);
+			if (!txx9_priv->mtdname) {
+				kfree(txx9_priv);
+				dev_err(&dev->dev,
+					"Unable to allocate MTD name.\n");
+				continue;
+			}
 		} else {
 			txx9_priv->cs = -1;
-			strcpy(txx9_priv->mtdname, dev_name(&dev->dev));
+			txx9_priv->mtdname = kstrdup(dev_name(&dev->dev));
 		}
 		if (plat->wide_mask & (1 << i))
 			chip->options |= NAND_BUSWIDTH_16;
 
 		if (nand_scan(mtd, 1)) {
+			kfree(txx9_priv->mtdname)
 			kfree(txx9_priv);
 			continue;
 		}
@@ -385,6 +392,7 @@  static int __exit txx9ndfmc_remove(struct platform_device *dev)
 		kfree(drvdata->parts[i]);
 #endif
 		del_mtd_device(mtd);
+		kfree(txx9_priv->mtdname);
 		kfree(txx9_priv);
 	}
 	return 0;