diff options
author | Joe Perches <joe@perches.com> | 2013-02-11 09:41:29 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-02-11 10:10:33 -0800 |
commit | 78110bb8dc4a7ff331bfa3cfe7d4e287cfb3f22b (patch) | |
tree | 6534f66eb765163602ad1af98c651bea6ae09416 /drivers/staging/frontier | |
parent | ad463ac42771a0bb8a706cf8a985788fe5f5c1c6 (diff) |
staging: Remove unnecessary OOM messages
alloc failures already get standardized OOM
messages and a dump_stack.
For the affected mallocs around these OOM messages:
Converted kzallocs with multiplies to kcalloc.
Converted kmallocs with multiplies to kmalloc_array.
Converted a kmalloc/strlen/strncpy to kstrdup.
Moved a spin_lock below a removed OOM message and
removed a now unnecessary spin_unlock.
Neatened alignment and whitespace.
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/frontier')
-rw-r--r-- | drivers/staging/frontier/alphatrack.c | 51 | ||||
-rw-r--r-- | drivers/staging/frontier/tranzport.c | 26 |
2 files changed, 30 insertions, 47 deletions
diff --git a/drivers/staging/frontier/alphatrack.c b/drivers/staging/frontier/alphatrack.c index 33085782689e..ea9362d7e589 100644 --- a/drivers/staging/frontier/alphatrack.c +++ b/drivers/staging/frontier/alphatrack.c @@ -678,10 +678,9 @@ static int usb_alphatrack_probe(struct usb_interface *intf, /* allocate memory for our device state and initialize it */ dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (dev == NULL) { - dev_err(&intf->dev, "Out of memory\n"); + if (dev == NULL) goto exit; - } + mutex_init(&dev->mtx); dev->intf = intf; init_waitqueue_head(&dev->read_wait); @@ -721,28 +720,21 @@ static int usb_alphatrack_probe(struct usb_interface *intf, /* FIXME - there are more usb_alloc routines for dma correctness. Needed? */ - dev->ring_buffer = - kmalloc((true_size * sizeof(struct alphatrack_icmd)), GFP_KERNEL); - - if (!dev->ring_buffer) { - dev_err(&intf->dev, - "Couldn't allocate input ring_buffer of size %d\n", - true_size); + dev->ring_buffer = kmalloc_array(true_size, + sizeof(struct alphatrack_icmd), + GFP_KERNEL); + if (!dev->ring_buffer) goto error; - } - dev->interrupt_in_buffer = - kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL); - - if (!dev->interrupt_in_buffer) { - dev_err(&intf->dev, "Couldn't allocate interrupt_in_buffer\n"); + dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, + GFP_KERNEL); + if (!dev->interrupt_in_buffer) goto error; - } + dev->oldi_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL); - if (!dev->oldi_buffer) { - dev_err(&intf->dev, "Couldn't allocate old buffer\n"); + if (!dev->oldi_buffer) goto error; - } + dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->interrupt_in_urb) { dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n"); @@ -764,20 +756,17 @@ static int usb_alphatrack_probe(struct usb_interface *intf, true_size = min(write_buffer_size, WRITE_BUFFER_SIZE); dev->interrupt_out_buffer = - kmalloc(true_size * dev->interrupt_out_endpoint_size, GFP_KERNEL); - - if (!dev->interrupt_out_buffer) { - dev_err(&intf->dev, "Couldn't allocate interrupt_out_buffer\n"); + kmalloc_array(true_size, + dev->interrupt_out_endpoint_size, + GFP_KERNEL); + if (!dev->interrupt_out_buffer) goto error; - } - - dev->write_buffer = - kmalloc(true_size * sizeof(struct alphatrack_ocmd), GFP_KERNEL); - if (!dev->write_buffer) { - dev_err(&intf->dev, "Couldn't allocate write_buffer\n"); + dev->write_buffer = kmalloc_array(true_size, + sizeof(struct alphatrack_ocmd), + GFP_KERNEL); + if (!dev->write_buffer) goto error; - } dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->interrupt_out_urb) { diff --git a/drivers/staging/frontier/tranzport.c b/drivers/staging/frontier/tranzport.c index 5196a4e053e6..04b5e66d9861 100644 --- a/drivers/staging/frontier/tranzport.c +++ b/drivers/staging/frontier/tranzport.c @@ -803,10 +803,9 @@ static int usb_tranzport_probe(struct usb_interface *intf, /* allocate memory for our device state and initialize it */ dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (dev == NULL) { - dev_err(&intf->dev, "Out of memory\n"); + if (dev == NULL) goto exit; - } + mutex_init(&dev->mtx); dev->intf = intf; init_waitqueue_head(&dev->read_wait); @@ -848,18 +847,14 @@ static int usb_tranzport_probe(struct usb_interface *intf, dev->ring_buffer = kmalloc((true_size * sizeof(struct tranzport_cmd)) + 8, GFP_KERNEL); - - if (!dev->ring_buffer) { - dev_err(&intf->dev, - "Couldn't allocate ring_buffer size %d\n", true_size); + if (!dev->ring_buffer) goto error; - } + dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL); - if (!dev->interrupt_in_buffer) { - dev_err(&intf->dev, "Couldn't allocate interrupt_in_buffer\n"); + if (!dev->interrupt_in_buffer) goto error; - } + dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->interrupt_in_urb) { dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n"); @@ -875,12 +870,11 @@ static int usb_tranzport_probe(struct usb_interface *intf, "Interrupt out endpoint size is not 8!)\n"); dev->interrupt_out_buffer = - kmalloc(write_buffer_size * dev->interrupt_out_endpoint_size, - GFP_KERNEL); - if (!dev->interrupt_out_buffer) { - dev_err(&intf->dev, "Couldn't allocate interrupt_out_buffer\n"); + kmalloc_array(write_buffer_size, + dev->interrupt_out_endpoint_size, GFP_KERNEL); + if (!dev->interrupt_out_buffer) goto error; - } + dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->interrupt_out_urb) { dev_err(&intf->dev, "Couldn't allocate interrupt_out_urb\n"); |