USB: core: config.c: usb_get_configuration() simplified
usb_gat_configuratio() used two pointers to point to the same memory. Code simplified, by removing one of them. Signed-off-by: Michal Nazarewicz <mina86@mina86.com> Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
65e0b49910
commit
e8f4af304e
@ -735,7 +735,6 @@ int usb_get_configuration(struct usb_device *dev)
|
|||||||
int ncfg = dev->descriptor.bNumConfigurations;
|
int ncfg = dev->descriptor.bNumConfigurations;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
unsigned int cfgno, length;
|
unsigned int cfgno, length;
|
||||||
unsigned char *buffer;
|
|
||||||
unsigned char *bigbuffer;
|
unsigned char *bigbuffer;
|
||||||
struct usb_config_descriptor *desc;
|
struct usb_config_descriptor *desc;
|
||||||
|
|
||||||
@ -764,17 +763,16 @@ int usb_get_configuration(struct usb_device *dev)
|
|||||||
if (!dev->rawdescriptors)
|
if (!dev->rawdescriptors)
|
||||||
goto err2;
|
goto err2;
|
||||||
|
|
||||||
buffer = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL);
|
desc = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL);
|
||||||
if (!buffer)
|
if (!desc)
|
||||||
goto err2;
|
goto err2;
|
||||||
desc = (struct usb_config_descriptor *)buffer;
|
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
for (; cfgno < ncfg; cfgno++) {
|
for (; cfgno < ncfg; cfgno++) {
|
||||||
/* We grab just the first descriptor so we know how long
|
/* We grab just the first descriptor so we know how long
|
||||||
* the whole configuration is */
|
* the whole configuration is */
|
||||||
result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,
|
result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,
|
||||||
buffer, USB_DT_CONFIG_SIZE);
|
desc, USB_DT_CONFIG_SIZE);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
dev_err(ddev, "unable to read config index %d "
|
dev_err(ddev, "unable to read config index %d "
|
||||||
"descriptor/%s: %d\n", cfgno, "start", result);
|
"descriptor/%s: %d\n", cfgno, "start", result);
|
||||||
@ -823,7 +821,7 @@ int usb_get_configuration(struct usb_device *dev)
|
|||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
kfree(buffer);
|
kfree(desc);
|
||||||
out_not_authorized:
|
out_not_authorized:
|
||||||
dev->descriptor.bNumConfigurations = cfgno;
|
dev->descriptor.bNumConfigurations = cfgno;
|
||||||
err2:
|
err2:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user