mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-23 20:53:53 +08:00
media: tm6000: cleanup trival coding style issues
- Delete seven error messages for a failed memory allocation - Adjust seven checks for null pointers - Use common error handling code in tm6000_usb_probe() - Adjust jump targets so that the function "kfree" will be always called with a non-null pointer. - Delete an initialisation for the local variable "dev" which became unnecessary with this refactoring. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
This commit is contained in:
parent
5bf24e08b6
commit
7e11d5027b
@ -1184,7 +1184,7 @@ static int tm6000_usb_probe(struct usb_interface *interface,
|
||||
const struct usb_device_id *id)
|
||||
{
|
||||
struct usb_device *usbdev;
|
||||
struct tm6000_core *dev = NULL;
|
||||
struct tm6000_core *dev;
|
||||
int i, rc = 0;
|
||||
int nr = 0;
|
||||
char *speed;
|
||||
@ -1194,22 +1194,21 @@ static int tm6000_usb_probe(struct usb_interface *interface,
|
||||
/* Selects the proper interface */
|
||||
rc = usb_set_interface(usbdev, 0, 1);
|
||||
if (rc < 0)
|
||||
goto err;
|
||||
goto report_failure;
|
||||
|
||||
/* Check to see next free device and mark as used */
|
||||
nr = find_first_zero_bit(&tm6000_devused, TM6000_MAXBOARDS);
|
||||
if (nr >= TM6000_MAXBOARDS) {
|
||||
printk(KERN_ERR "tm6000: Supports only %i tm60xx boards.\n", TM6000_MAXBOARDS);
|
||||
usb_put_dev(usbdev);
|
||||
return -ENOMEM;
|
||||
rc = -ENOMEM;
|
||||
goto put_device;
|
||||
}
|
||||
|
||||
/* Create and initialize dev struct */
|
||||
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
|
||||
if (dev == NULL) {
|
||||
printk(KERN_ERR "tm6000" ": out of memory!\n");
|
||||
usb_put_dev(usbdev);
|
||||
return -ENOMEM;
|
||||
if (!dev) {
|
||||
rc = -ENOMEM;
|
||||
goto put_device;
|
||||
}
|
||||
spin_lock_init(&dev->slock);
|
||||
mutex_init(&dev->usb_lock);
|
||||
@ -1313,8 +1312,7 @@ static int tm6000_usb_probe(struct usb_interface *interface,
|
||||
if (!dev->isoc_in.endp) {
|
||||
printk(KERN_ERR "tm6000: probing error: no IN ISOC endpoint!\n");
|
||||
rc = -ENODEV;
|
||||
|
||||
goto err;
|
||||
goto free_device;
|
||||
}
|
||||
|
||||
/* save our data pointer in this interface device */
|
||||
@ -1324,17 +1322,18 @@ static int tm6000_usb_probe(struct usb_interface *interface,
|
||||
|
||||
rc = tm6000_init_dev(dev);
|
||||
if (rc < 0)
|
||||
goto err;
|
||||
goto free_device;
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
free_device:
|
||||
kfree(dev);
|
||||
report_failure:
|
||||
printk(KERN_ERR "tm6000: Error %d while registering\n", rc);
|
||||
|
||||
clear_bit(nr, &tm6000_devused);
|
||||
put_device:
|
||||
usb_put_dev(usbdev);
|
||||
|
||||
kfree(dev);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ static int tm6000_start_stream(struct tm6000_core *dev)
|
||||
}
|
||||
|
||||
dvb->bulk_urb = usb_alloc_urb(0, GFP_KERNEL);
|
||||
if (dvb->bulk_urb == NULL)
|
||||
if (!dvb->bulk_urb)
|
||||
return -ENOMEM;
|
||||
|
||||
pipe = usb_rcvbulkpipe(dev->udev, dev->bulk_in.endp->desc.bEndpointAddress
|
||||
@ -133,9 +133,8 @@ static int tm6000_start_stream(struct tm6000_core *dev)
|
||||
size = size * 15; /* 512 x 8 or 12 or 15 */
|
||||
|
||||
dvb->bulk_urb->transfer_buffer = kzalloc(size, GFP_KERNEL);
|
||||
if (dvb->bulk_urb->transfer_buffer == NULL) {
|
||||
if (!dvb->bulk_urb->transfer_buffer) {
|
||||
usb_free_urb(dvb->bulk_urb);
|
||||
printk(KERN_ERR "tm6000: couldn't allocate transfer buffer!\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@ -361,7 +360,7 @@ static void unregister_dvb(struct tm6000_core *dev)
|
||||
{
|
||||
struct tm6000_dvb *dvb = dev->dvb;
|
||||
|
||||
if (dvb->bulk_urb != NULL) {
|
||||
if (dvb->bulk_urb) {
|
||||
struct urb *bulk_urb = dvb->bulk_urb;
|
||||
|
||||
kfree(bulk_urb->transfer_buffer);
|
||||
@ -400,10 +399,8 @@ static int dvb_init(struct tm6000_core *dev)
|
||||
}
|
||||
|
||||
dvb = kzalloc(sizeof(struct tm6000_dvb), GFP_KERNEL);
|
||||
if (!dvb) {
|
||||
printk(KERN_INFO "Cannot allocate memory\n");
|
||||
if (!dvb)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
dev->dvb = dvb;
|
||||
|
||||
|
@ -352,7 +352,7 @@ static int __tm6000_ir_int_start(struct rc_dev *rc)
|
||||
dprintk(1, "IR max size: %d\n", size);
|
||||
|
||||
ir->int_urb->transfer_buffer = kzalloc(size, GFP_ATOMIC);
|
||||
if (ir->int_urb->transfer_buffer == NULL) {
|
||||
if (!ir->int_urb->transfer_buffer) {
|
||||
usb_free_urb(ir->int_urb);
|
||||
return err;
|
||||
}
|
||||
|
@ -470,20 +470,16 @@ static int tm6000_alloc_urb_buffers(struct tm6000_core *dev)
|
||||
int num_bufs = TM6000_NUM_URB_BUF;
|
||||
int i;
|
||||
|
||||
if (dev->urb_buffer != NULL)
|
||||
if (dev->urb_buffer)
|
||||
return 0;
|
||||
|
||||
dev->urb_buffer = kmalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
|
||||
if (!dev->urb_buffer) {
|
||||
tm6000_err("cannot allocate memory for urb buffers\n");
|
||||
if (!dev->urb_buffer)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
dev->urb_dma = kmalloc(sizeof(dma_addr_t *)*num_bufs, GFP_KERNEL);
|
||||
if (!dev->urb_dma) {
|
||||
tm6000_err("cannot allocate memory for urb dma pointers\n");
|
||||
if (!dev->urb_dma)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_bufs; i++) {
|
||||
dev->urb_buffer[i] = usb_alloc_coherent(
|
||||
@ -507,7 +503,7 @@ static int tm6000_free_urb_buffers(struct tm6000_core *dev)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (dev->urb_buffer == NULL)
|
||||
if (!dev->urb_buffer)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < TM6000_NUM_URB_BUF; i++) {
|
||||
@ -598,15 +594,12 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev)
|
||||
dev->isoc_ctl.num_bufs = num_bufs;
|
||||
|
||||
dev->isoc_ctl.urb = kmalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
|
||||
if (!dev->isoc_ctl.urb) {
|
||||
tm6000_err("cannot alloc memory for usb buffers\n");
|
||||
if (!dev->isoc_ctl.urb)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
dev->isoc_ctl.transfer_buffer = kmalloc(sizeof(void *)*num_bufs,
|
||||
GFP_KERNEL);
|
||||
if (!dev->isoc_ctl.transfer_buffer) {
|
||||
tm6000_err("cannot allocate memory for usbtransfer\n");
|
||||
kfree(dev->isoc_ctl.urb);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user