From patchwork Sat Jun 6 16:25:02 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: mtd: remove driver-core BUS_ID_SIZE Date: Sat, 06 Jun 2009 06:25:02 -0000 From: Atsushi Nemoto X-Patchwork-Id: 28189 Message-Id: <1244305502-20902-1-git-send-email-anemo@mba.ocn.ne.jp> To: dwmw2@infradead.org Cc: Kay Sievers , linux-mtd@lists.infradead.org, Greg Kroah-Hartman From: Kay Sievers 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 Signed-off-by: Kay Sievers Signed-off-by: Atsushi Nemoto --- drivers/mtd/nand/txx9ndfmc.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) 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;