Skip to content

Commit eadcf0d

Browse files
committed
MTD: handle pci_name() being const
This changes the MTD core to handle pci_name() now returning a constant string. Cc: David Woodhouse <dwmw2@infradead.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 89bcb05 commit eadcf0d

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

‎drivers/mtd/devices/block2mtd.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
241241
{
242242
struct block_device *bdev;
243243
struct block2mtd_dev *dev;
244+
char *name;
244245

245246
if (!devname)
246247
return NULL;
@@ -279,12 +280,13 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
279280

280281
/* Setup the MTD structure */
281282
/* make the name contain the block device in */
282-
dev->mtd.name = kmalloc(sizeof("block2mtd: ") + strlen(devname),
283+
name = kmalloc(sizeof("block2mtd: ") + strlen(devname) + 1,
283284
GFP_KERNEL);
284-
if (!dev->mtd.name)
285+
if (!name)
285286
goto devinit_err;
286287

287-
sprintf(dev->mtd.name, "block2mtd: %s", devname);
288+
sprintf(name, "block2mtd: %s", devname);
289+
dev->mtd.name = name;
288290

289291
dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
290292
dev->mtd.erasesize = erase_size;

‎include/linux/mtd/map.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ typedef union {
189189
*/
190190

191191
struct map_info {
192-
char *name;
192+
const char *name;
193193
unsigned long size;
194194
resource_size_t phys;
195195
#define NO_XIP (-1UL)

‎include/linux/mtd/mtd.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ struct mtd_info {
121121
u_int32_t oobavail; // Available OOB bytes per block
122122

123123
// Kernel-only stuff starts here.
124-
char *name;
124+
const char *name;
125125
int index;
126126

127127
/* ecc layout structure pointer - read only ! */

0 commit comments

Comments
 (0)