Re: [PATCH] USB: dynamically allocate usb_device children pointers instead of using a fix array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 12, 2012 at 10:43 PM, Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
> On Mon, Mar 12, 2012 at 02:09:35PM +0100, Michal Nazarewicz wrote:
>> On Mon, 12 Mar 2012 14:00:19 +0100, Huajun Li <huajun.li.lee@xxxxxxxxx> wrote:
>>
>> >Non-hub device has no child, and even a real USB hub has ports far
>> >less than USB_MAXCHILDREN, so there is no need using a fix array for
>> >child devices, just allocate it dynamically according real port
>> >number.
>> >
>> >Signed-off-by: Huajun Li <huajun.li.lee@xxxxxxxxx>
>> >---
>> > drivers/usb/core/hub.c |   10 +++++++---
>> > include/linux/usb.h    |    2 +-
>> > 2 files changed, 8 insertions(+), 4 deletions(-)
>> >
>> >diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
>> >index 72c51cd..28664eb 100644
>> >--- a/drivers/usb/core/hub.c
>> >+++ b/drivers/usb/core/hub.c
>> >@@ -1047,8 +1047,10 @@ static int hub_configure(struct usb_hub *hub,
>> >     dev_info (hub_dev, "%d port%s detected\n", hdev->maxchild,
>> >             (hdev->maxchild == 1) ? "" : "s");
>> >
>> >+    hdev->children = kzalloc(hdev->maxchild *
>> >+                            sizeof(struct usb_device *), GFP_KERNEL);
>>
>> kcalloc()
>
> I hate that call, kzalloc() is fine.
>
> greg k-h

Great!
Thanks for your comments, then will not resend it if there is no other issue.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux