[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20071114141755.GA7523@ldl.fc.hp.com>
Date: Wed, 14 Nov 2007 07:17:55 -0700
From: Alex Chiang <achiang@...com>
To: Rolf Eike Beer <eike-hotplug@...tec.de>
Cc: pcihpd-discuss@...ts.sourceforge.net, gregkh@...e.de,
kristen.c.accardi@...el.com, lenb@...nel.org, matthew@....cx,
rick.jones2@...com, linux-kernel@...r.kernel.org,
linux-pci@...ey.karlin.mff.cuni.cz, linux-acpi@...r.kernel.org
Subject: Re: [Pcihpd-discuss] [PATCH 2/5] Construct one fakephp slot per
pci slot
Hi Eike,
* Rolf Eike Beer <eike-hotplug@...tec.de>:
> Alex Chiang wrote:
> > --- a/drivers/pci/hotplug/fakephp.c
> > +++ b/drivers/pci/hotplug/fakephp.c
> > @@ -93,6 +93,7 @@ static int add_slot(struct pci_dev *dev)
> > struct dummy_slot *dslot;
> > struct hotplug_slot *slot;
> > int retval = -ENOMEM;
> > + static int count = 1;
> >
> > slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
> > if (!slot)
> > @@ -106,7 +107,8 @@ static int add_slot(struct pci_dev *dev)
> > slot->info->max_bus_speed = PCI_SPEED_UNKNOWN;
> > slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN;
> >
> > - slot->name = &dev->dev.bus_id[0];
> > + slot->name = kmalloc(8, GFP_KERNEL);
> > + sprintf(slot->name, "fake%d", count++);
> > dbg("slot->name = %s\n", slot->name);
> >
> > dslot = kmalloc(sizeof(struct dummy_slot), GFP_KERNEL);
>
> This is ugly. Please do it the way we already do e.g. for
> acpiphp: add a char[8] to "struct dummy_slot" and just
> reference that here.
I took at look at the code in acpiphp you're talking about, and
I'm not sure why you think the above is "ugly". We're talking
about a runtime vs compile time storage for the name, and doing a
kmalloc/sprintf is a pretty standard idiom.
BTW, I did incorporate both Linas' and Willy's comments, by
changing the kmalloc size to an explicit 32, and using snprintf
instead.
In any case, for your particular comment, I think I'm going to
leave it alone for now, and let Greg weigh in with the final
recommendation.
Thanks for the review.
/ac
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists