diff options
author | Dan Carpenter <error27@gmail.com> | 2010-01-25 06:53:33 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-02 17:54:47 -0500 |
commit | f10718f5b812a2c55e37396518d426f88d5e35fc (patch) | |
tree | 6b982a4adfefc8a220679e0bfdc347372e29031f /drivers | |
parent | 5b520259ab6d661b8d5eb39dd17cc5e4e4553c62 (diff) |
USB: io_edgeport: eliminate get_string()
Johan Hovold points out that get_string() is basically just a
re-implimentation of usb_string(). It is also buggy. It does DMA on
the stack and it doesn't handle negative returns from
usb_get_descriptor(). Plus unicode_to_ascii() is a rubbish function and
moving to usb_string() avoids using it.
Let's eliminate get_string() entirely.
Reported-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/serial/io_edgeport.c | 43 |
1 files changed, 4 insertions, 39 deletions
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 09456002bac0..c055c8ba377d 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -364,43 +364,6 @@ static void update_edgeport_E2PROM(struct edgeport_serial *edge_serial) | |||
364 | release_firmware(fw); | 364 | release_firmware(fw); |
365 | } | 365 | } |
366 | 366 | ||
367 | |||
368 | /************************************************************************ | ||
369 | * * | ||
370 | * Get string descriptor from device * | ||
371 | * * | ||
372 | ************************************************************************/ | ||
373 | static int get_string(struct usb_device *dev, int Id, char *string, int buflen) | ||
374 | { | ||
375 | struct usb_string_descriptor *StringDesc = NULL; | ||
376 | struct usb_string_descriptor *pStringDesc = NULL; | ||
377 | int ret = 0; | ||
378 | |||
379 | dbg("%s - USB String ID = %d", __func__, Id); | ||
380 | |||
381 | StringDesc = kmalloc(sizeof(*StringDesc), GFP_KERNEL); | ||
382 | if (!StringDesc) | ||
383 | goto free; | ||
384 | if (usb_get_descriptor(dev, USB_DT_STRING, Id, StringDesc, sizeof(*StringDesc)) <= 0) | ||
385 | goto free; | ||
386 | |||
387 | pStringDesc = kmalloc(StringDesc->bLength, GFP_KERNEL); | ||
388 | if (!pStringDesc) | ||
389 | goto free; | ||
390 | |||
391 | if (usb_get_descriptor(dev, USB_DT_STRING, Id, pStringDesc, StringDesc->bLength) <= 0) | ||
392 | goto free; | ||
393 | |||
394 | unicode_to_ascii(string, buflen, pStringDesc->wData, pStringDesc->bLength/2); | ||
395 | ret = strlen(string); | ||
396 | dbg("%s - USB String %s", __func__, string); | ||
397 | free: | ||
398 | kfree(StringDesc); | ||
399 | kfree(pStringDesc); | ||
400 | return ret; | ||
401 | } | ||
402 | |||
403 | |||
404 | #if 0 | 367 | #if 0 |
405 | /************************************************************************ | 368 | /************************************************************************ |
406 | * | 369 | * |
@@ -2998,10 +2961,12 @@ static int edge_startup(struct usb_serial *serial) | |||
2998 | usb_set_serial_data(serial, edge_serial); | 2961 | usb_set_serial_data(serial, edge_serial); |
2999 | 2962 | ||
3000 | /* get the name for the device from the device */ | 2963 | /* get the name for the device from the device */ |
3001 | i = get_string(dev, dev->descriptor.iManufacturer, | 2964 | i = usb_string(dev, dev->descriptor.iManufacturer, |
3002 | &edge_serial->name[0], MAX_NAME_LEN+1); | 2965 | &edge_serial->name[0], MAX_NAME_LEN+1); |
2966 | if (i < 0) | ||
2967 | i = 0; | ||
3003 | edge_serial->name[i++] = ' '; | 2968 | edge_serial->name[i++] = ' '; |
3004 | get_string(dev, dev->descriptor.iProduct, | 2969 | usb_string(dev, dev->descriptor.iProduct, |
3005 | &edge_serial->name[i], MAX_NAME_LEN+2 - i); | 2970 | &edge_serial->name[i], MAX_NAME_LEN+2 - i); |
3006 | 2971 | ||
3007 | dev_info(&serial->dev->dev, "%s detected\n", edge_serial->name); | 2972 | dev_info(&serial->dev->dev, "%s detected\n", edge_serial->name); |