public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Martin Waitz <tali@admingilde.org>
To: linux-mtd@lists.infradead.org
Subject: [PATCH] MTD: make mtd->name const
Date: Sun, 23 Apr 2006 21:34:39 +0200	[thread overview]
Message-ID: <20060423193438.GF29948@admingilde.org> (raw)

mtd->name is never used read-write and often holds a pointer to constant data.

Signed-off-by: Martin Waitz <tali@admingilde.org>

---

 drivers/mtd/cmdlinepart.c       |    2 +-
 drivers/mtd/devices/block2mtd.c |   10 +++++-----
 include/linux/mtd/mtd.h         |    2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

94152d03bf8d7a28519a8e7f6bf1b53c30664f8d
diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
index a7a7bfe..615ae4d 100644
--- a/drivers/mtd/cmdlinepart.c
+++ b/drivers/mtd/cmdlinepart.c
@@ -300,7 +300,7 @@ static int parse_cmdline_partitions(stru
 	unsigned long offset;
 	int i;
 	struct cmdline_mtd_partition *part;
-	char *mtd_id = master->name;
+	const char *mtd_id = master->name;
 
 	if(!cmdline)
 		return -EINVAL;
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 4160b83..adb0ae8 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -289,6 +289,7 @@ static struct block2mtd_dev *add_device(
 {
 	struct block_device *bdev;
 	struct block2mtd_dev *dev;
+	char * name;
 
 	if (!devname)
 		return NULL;
@@ -315,13 +316,12 @@ static struct block2mtd_dev *add_device(
 
 	/* Setup the MTD structure */
 	/* make the name contain the block device in */
-	dev->mtd.name = kmalloc(sizeof("block2mtd: ") + strlen(devname),
-			GFP_KERNEL);
-	if (!dev->mtd.name)
+	name = kmalloc(sizeof("block2mtd: ") + strlen(devname), GFP_KERNEL);
+	if (!name)
 		goto devinit_err;
 
-	sprintf(dev->mtd.name, "block2mtd: %s", devname);
-
+	sprintf(name, "block2mtd: %s", devname);
+	dev->mtd.name = name;
 	dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
 	dev->mtd.erasesize = erase_size;
 	dev->mtd.type = MTD_RAM;
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index b6f2fda..886f481 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -84,7 +84,7 @@ #define MTD_PROGREGION_CTRLMODE_VALID(mt
 #define MTD_PROGREGION_CTRLMODE_INVALID(mtd)  (mtd)->ecctype
 
 	// Kernel-only stuff starts here.
-	char *name;
+	const char *name;
 	int index;
 
 	// oobinfo is a nand_oobinfo structure, which can be set by iotcl (MEMSETOOBINFO)
-- 
1.3.0.gc5417

-- 
Martin Waitz

             reply	other threads:[~2006-04-23 19:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-23 19:34 Martin Waitz [this message]
2006-04-24  7:24 ` [PATCH] MTD: make mtd->name const Jörn Engel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060423193438.GF29948@admingilde.org \
    --to=tali@admingilde.org \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox