diff mbox

BUS_ID_SIZE is going away

Message ID 1245842095.25547.5380.camel@macbook.infradead.org
State New, archived
Headers show

Commit Message

David Woodhouse June 24, 2009, 11:14 a.m. UTC
On Wed, 2009-06-24 at 10:27 +0200, Kay Sievers wrote:
> On Mon, 2009-06-22 at 13:56 +0100, David Woodhouse wrote:
> > I have this queued for 2.6.31 but have been on jury duty for the last 2
> > weeks so I'm hoping to get the pull request to Linus today now that I'm
> > free.
> 
> The old one is gone, but seems you merged a new one with BUS_ID_SIZE :)
> 
>   ./drivers/mtd/maps/integrator-flash.c:#define SUBDEV_NAME_SIZE	(BUS_ID_SIZE + 2)

Hm, true :)

Catalin, can you test the following? 

Btw, I'm unconvinced by the existing error handling -- if
armflash_subdev_probe() fails, it doesn't look like _that_ subdev
actually gets cleaned up in the loop at 'subdev_err:'. So we don't
release the memory region (and neither do we free the newly-kmalloced
name).

In fact, do we still need a separate platform device and driver for ARM
systems? What does it provide that the physmap driver does (and can)
not?

Comments

Kay Sievers June 28, 2009, 11:47 a.m. UTC | #1
On Wed, Jun 24, 2009 at 13:14, David Woodhouse<dwmw2@infradead.org> wrote:
> On Wed, 2009-06-24 at 10:27 +0200, Kay Sievers wrote:
>> On Mon, 2009-06-22 at 13:56 +0100, David Woodhouse wrote:
>> > I have this queued for 2.6.31 but have been on jury duty for the last 2
>> > weeks so I'm hoping to get the pull request to Linus today now that I'm
>> > free.
>>
>> The old one is gone, but seems you merged a new one with BUS_ID_SIZE :)
>>
>>   ./drivers/mtd/maps/integrator-flash.c:#define SUBDEV_NAME_SIZE      (BUS_ID_SIZE + 2)
>
> Hm, true :)

Seems, it's the last one left. In case the "real" fix you are working
on is not ready to apply, care to push out a change, so we can finally
get rid of itl? Or let me know, and we can replace it with "20" along
with the removal from the driver core.

Thanks,
Kay
diff mbox

Patch

diff --git a/drivers/mtd/maps/integrator-flash.c b/drivers/mtd/maps/integrator-flash.c
index b08a798..b9fac5b 100644
--- a/drivers/mtd/maps/integrator-flash.c
+++ b/drivers/mtd/maps/integrator-flash.c
@@ -42,10 +42,8 @@ 
 #include <mach/hardware.h>
 #include <asm/system.h>
 
-#define SUBDEV_NAME_SIZE	(BUS_ID_SIZE + 2)
-
 struct armflash_subdev_info {
-	char			name[SUBDEV_NAME_SIZE];
+	char			*name;
 	struct mtd_info		*mtd;
 	struct map_info		map;
 	struct flash_platform_data *plat;
@@ -134,6 +132,8 @@  static void armflash_subdev_remove(struct armflash_subdev_info *subdev)
 		map_destroy(subdev->mtd);
 	if (subdev->map.virt)
 		iounmap(subdev->map.virt);
+	kfree(subdev->name);
+	subdev->name = NULL;
 	release_mem_region(subdev->map.phys, subdev->map.size);
 }
 
@@ -177,11 +177,14 @@  static int armflash_probe(struct platform_device *dev)
 
 		if (nr == 1)
 			/* No MTD concatenation, just use the default name */
-			snprintf(subdev->name, SUBDEV_NAME_SIZE, "%s",
-				 dev_name(&dev->dev));
+			subdev->name = kstrdup(dev_name(&dev->dev), GFP_KERNEL);
 		else
-			snprintf(subdev->name, SUBDEV_NAME_SIZE, "%s-%d",
-				 dev_name(&dev->dev), i);
+			subdev->name = kasprintf(GFP_KERNEL, "%s-%d",
+						 dev_name(&dev->dev), i);
+		if (!subdev->name) {
+			err = -ENOMEM;
+			break;
+		}
 		subdev->plat = plat;
 
 		err = armflash_subdev_probe(subdev, res);