Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: davinci: do a couple of checkpatch cleanups

- Delete an error message for a failed memory allocation
in init_vpbe_layer();

- Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding
size determination a bit safer according to the Linux coding style
convention;

- media: DaVinci-VPBE-Display: Improve a size determination in two
functions

- Adjust 12 checks for null pointers

Those issues were pointed by checkpatch.pl and Coccinelle.

[mchehab@s-opensource.com: fold three cleanup patches into one]
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

authored by

Markus Elfring and committed by
Mauro Carvalho Chehab
7a6e6c3b 5f4d3469

+15 -22
+15 -22
drivers/media/platform/davinci/vpbe_display.c
··· 122 122 int fid; 123 123 int i; 124 124 125 - if ((NULL == arg) || (NULL == disp_dev->dev[0])) 125 + if (!arg || !disp_dev->dev[0]) 126 126 return IRQ_HANDLED; 127 127 128 128 if (venc_is_second_field(disp_dev)) ··· 337 337 vb2_buffer_done(&layer->cur_frm->vb.vb2_buf, 338 338 VB2_BUF_STATE_ERROR); 339 339 } else { 340 - if (layer->cur_frm != NULL) 340 + if (layer->cur_frm) 341 341 vb2_buffer_done(&layer->cur_frm->vb.vb2_buf, 342 342 VB2_BUF_STATE_ERROR); 343 - if (layer->next_frm != NULL) 343 + if (layer->next_frm) 344 344 vb2_buffer_done(&layer->next_frm->vb.vb2_buf, 345 345 VB2_BUF_STATE_ERROR); 346 346 } ··· 947 947 if (vb2_is_busy(&layer->buffer_queue)) 948 948 return -EBUSY; 949 949 950 - if (NULL != vpbe_dev->ops.s_std) { 950 + if (vpbe_dev->ops.s_std) { 951 951 ret = vpbe_dev->ops.s_std(vpbe_dev, std_id); 952 952 if (ret) { 953 953 v4l2_err(&vpbe_dev->v4l2_dev, ··· 1000 1000 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_ENUM_OUTPUT\n"); 1001 1001 1002 1002 /* Enumerate outputs */ 1003 - 1004 - if (NULL == vpbe_dev->ops.enum_outputs) 1003 + if (!vpbe_dev->ops.enum_outputs) 1005 1004 return -EINVAL; 1006 1005 1007 1006 ret = vpbe_dev->ops.enum_outputs(vpbe_dev, output); ··· 1029 1030 if (vb2_is_busy(&layer->buffer_queue)) 1030 1031 return -EBUSY; 1031 1032 1032 - if (NULL == vpbe_dev->ops.set_output) 1033 + if (!vpbe_dev->ops.set_output) 1033 1034 return -EINVAL; 1034 1035 1035 1036 ret = vpbe_dev->ops.set_output(vpbe_dev, i); ··· 1076 1077 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_ENUM_DV_TIMINGS\n"); 1077 1078 1078 1079 /* Enumerate outputs */ 1079 - if (NULL == vpbe_dev->ops.enum_dv_timings) 1080 + if (!vpbe_dev->ops.enum_dv_timings) 1080 1081 return -EINVAL; 1081 1082 1082 1083 ret = vpbe_dev->ops.enum_dv_timings(vpbe_dev, timings); ··· 1291 1292 if (strcmp("vpbe_controller", pdev->name) == 0) 1292 1293 vpbe_disp->vpbe_dev = platform_get_drvdata(pdev); 1293 1294 1294 - if (strstr(pdev->name, "vpbe-osd") != NULL) 1295 + if (strstr(pdev->name, "vpbe-osd")) 1295 1296 vpbe_disp->osd_device = platform_get_drvdata(pdev); 1296 1297 1297 1298 return 0; ··· 1304 1305 struct video_device *vbd = NULL; 1305 1306 1306 1307 /* Allocate memory for four plane display objects */ 1307 - 1308 - disp_dev->dev[i] = 1309 - kzalloc(sizeof(struct vpbe_layer), GFP_KERNEL); 1310 - 1311 - /* If memory allocation fails, return error */ 1312 - if (!disp_dev->dev[i]) { 1313 - printk(KERN_ERR "ran out of memory\n"); 1308 + disp_dev->dev[i] = kzalloc(sizeof(*disp_dev->dev[i]), GFP_KERNEL); 1309 + if (!disp_dev->dev[i]) 1314 1310 return -ENOMEM; 1315 - } 1311 + 1316 1312 spin_lock_init(&disp_dev->dev[i]->irqlock); 1317 1313 mutex_init(&disp_dev->dev[i]->opslock); 1318 1314 ··· 1391 1397 1392 1398 printk(KERN_DEBUG "vpbe_display_probe\n"); 1393 1399 /* Allocate memory for vpbe_display */ 1394 - disp_dev = devm_kzalloc(&pdev->dev, sizeof(struct vpbe_display), 1395 - GFP_KERNEL); 1400 + disp_dev = devm_kzalloc(&pdev->dev, sizeof(*disp_dev), GFP_KERNEL); 1396 1401 if (!disp_dev) 1397 1402 return -ENOMEM; 1398 1403 ··· 1407 1414 1408 1415 v4l2_dev = &disp_dev->vpbe_dev->v4l2_dev; 1409 1416 /* Initialize the vpbe display controller */ 1410 - if (NULL != disp_dev->vpbe_dev->ops.initialize) { 1417 + if (disp_dev->vpbe_dev->ops.initialize) { 1411 1418 err = disp_dev->vpbe_dev->ops.initialize(&pdev->dev, 1412 1419 disp_dev->vpbe_dev); 1413 1420 if (err) { ··· 1475 1482 probe_out: 1476 1483 for (k = 0; k < VPBE_DISPLAY_MAX_DEVICES; k++) { 1477 1484 /* Unregister video device */ 1478 - if (disp_dev->dev[k] != NULL) { 1485 + if (disp_dev->dev[k]) { 1479 1486 video_unregister_device(&disp_dev->dev[k]->video_dev); 1480 1487 kfree(disp_dev->dev[k]); 1481 1488 } ··· 1497 1504 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_remove\n"); 1498 1505 1499 1506 /* deinitialize the vpbe display controller */ 1500 - if (NULL != vpbe_dev->ops.deinitialize) 1507 + if (vpbe_dev->ops.deinitialize) 1501 1508 vpbe_dev->ops.deinitialize(&pdev->dev, vpbe_dev); 1502 1509 /* un-register device */ 1503 1510 for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) {