aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/go7007
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2010-05-13 16:00:05 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-14 17:02:56 -0400
commit7a6cb0d5497418599d2125b670926b75e673861c (patch)
treea698dc86695304ef6aefe4bc6d18fdad7f3770ee /drivers/staging/go7007
parentb5a2104c98cb603f7053e4b0309fb88f15d6be86 (diff)
Staging: Use kcalloc or kzalloc
Use kcalloc or kzalloc rather than the combination of kmalloc and memset. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ expression x,y,flags; statement S; type T; @@ x = - kmalloc + kcalloc ( - y * sizeof(T), + y, sizeof(T), flags); if (x == NULL) S -memset(x, 0, y * sizeof(T)); @@ expression x,size,flags; statement S; @@ -x = kmalloc(size,flags); +x = kzalloc(size,flags); if (x == NULL) S -memset(x, 0, size); // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk>
Diffstat (limited to 'drivers/staging/go7007')
-rw-r--r--drivers/staging/go7007/go7007-fw.c12
-rw-r--r--drivers/staging/go7007/go7007-usb.c3
-rw-r--r--drivers/staging/go7007/go7007-v4l2.c4
-rw-r--r--drivers/staging/go7007/saa7134-go7007.c3
4 files changed, 7 insertions, 15 deletions
diff --git a/drivers/staging/go7007/go7007-fw.c b/drivers/staging/go7007/go7007-fw.c
index ee622ff1707..c9a6409edfe 100644
--- a/drivers/staging/go7007/go7007-fw.c
+++ b/drivers/staging/go7007/go7007-fw.c
@@ -380,13 +380,12 @@ static int gen_mjpeghdr_to_package(struct go7007 *go, __le16 *code, int space)
380 unsigned int addr = 0x19; 380 unsigned int addr = 0x19;
381 int size = 0, i, off = 0, chunk; 381 int size = 0, i, off = 0, chunk;
382 382
383 buf = kmalloc(4096, GFP_KERNEL); 383 buf = kzalloc(4096, GFP_KERNEL);
384 if (buf == NULL) { 384 if (buf == NULL) {
385 printk(KERN_ERR "go7007: unable to allocate 4096 bytes for " 385 printk(KERN_ERR "go7007: unable to allocate 4096 bytes for "
386 "firmware construction\n"); 386 "firmware construction\n");
387 return -1; 387 return -1;
388 } 388 }
389 memset(buf, 0, 4096);
390 389
391 for (i = 1; i < 32; ++i) { 390 for (i = 1; i < 32; ++i) {
392 mjpeg_frame_header(go, buf + size, i); 391 mjpeg_frame_header(go, buf + size, i);
@@ -651,13 +650,12 @@ static int gen_mpeg1hdr_to_package(struct go7007 *go,
651 unsigned int addr = 0x19; 650 unsigned int addr = 0x19;
652 int i, off = 0, chunk; 651 int i, off = 0, chunk;
653 652
654 buf = kmalloc(5120, GFP_KERNEL); 653 buf = kzalloc(5120, GFP_KERNEL);
655 if (buf == NULL) { 654 if (buf == NULL) {
656 printk(KERN_ERR "go7007: unable to allocate 5120 bytes for " 655 printk(KERN_ERR "go7007: unable to allocate 5120 bytes for "
657 "firmware construction\n"); 656 "firmware construction\n");
658 return -1; 657 return -1;
659 } 658 }
660 memset(buf, 0, 5120);
661 framelen[0] = mpeg1_frame_header(go, buf, 0, 1, PFRAME); 659 framelen[0] = mpeg1_frame_header(go, buf, 0, 1, PFRAME);
662 if (go->interlace_coding) 660 if (go->interlace_coding)
663 framelen[0] += mpeg1_frame_header(go, buf + framelen[0] / 8, 661 framelen[0] += mpeg1_frame_header(go, buf + framelen[0] / 8,
@@ -839,13 +837,12 @@ static int gen_mpeg4hdr_to_package(struct go7007 *go,
839 unsigned int addr = 0x19; 837 unsigned int addr = 0x19;
840 int i, off = 0, chunk; 838 int i, off = 0, chunk;
841 839
842 buf = kmalloc(5120, GFP_KERNEL); 840 buf = kzalloc(5120, GFP_KERNEL);
843 if (buf == NULL) { 841 if (buf == NULL) {
844 printk(KERN_ERR "go7007: unable to allocate 5120 bytes for " 842 printk(KERN_ERR "go7007: unable to allocate 5120 bytes for "
845 "firmware construction\n"); 843 "firmware construction\n");
846 return -1; 844 return -1;
847 } 845 }
848 memset(buf, 0, 5120);
849 framelen[0] = mpeg4_frame_header(go, buf, 0, PFRAME); 846 framelen[0] = mpeg4_frame_header(go, buf, 0, PFRAME);
850 i = 368; 847 i = 368;
851 framelen[1] = mpeg4_frame_header(go, buf + i, 0, BFRAME_PRE); 848 framelen[1] = mpeg4_frame_header(go, buf + i, 0, BFRAME_PRE);
@@ -1585,13 +1582,12 @@ int go7007_construct_fw_image(struct go7007 *go, u8 **fw, int *fwlen)
1585 go->board_info->firmware); 1582 go->board_info->firmware);
1586 return -1; 1583 return -1;
1587 } 1584 }
1588 code = kmalloc(codespace * 2, GFP_KERNEL); 1585 code = kzalloc(codespace * 2, GFP_KERNEL);
1589 if (code == NULL) { 1586 if (code == NULL) {
1590 printk(KERN_ERR "go7007: unable to allocate %d bytes for " 1587 printk(KERN_ERR "go7007: unable to allocate %d bytes for "
1591 "firmware construction\n", codespace * 2); 1588 "firmware construction\n", codespace * 2);
1592 goto fw_failed; 1589 goto fw_failed;
1593 } 1590 }
1594 memset(code, 0, codespace * 2);
1595 src = (__le16 *)fw_entry->data; 1591 src = (__le16 *)fw_entry->data;
1596 srclen = fw_entry->size / 2; 1592 srclen = fw_entry->size / 2;
1597 while (srclen >= 2) { 1593 while (srclen >= 2) {
diff --git a/drivers/staging/go7007/go7007-usb.c b/drivers/staging/go7007/go7007-usb.c
index ee278f64a16..20ed930b588 100644
--- a/drivers/staging/go7007/go7007-usb.c
+++ b/drivers/staging/go7007/go7007-usb.c
@@ -670,10 +670,9 @@ static int go7007_usb_onboard_write_interrupt(struct go7007 *go,
670 "go7007-usb: WriteInterrupt: %04x %04x\n", addr, data); 670 "go7007-usb: WriteInterrupt: %04x %04x\n", addr, data);
671#endif 671#endif
672 672
673 tbuf = kmalloc(8, GFP_KERNEL); 673 tbuf = kzalloc(8, GFP_KERNEL);
674 if (tbuf == NULL) 674 if (tbuf == NULL)
675 return -ENOMEM; 675 return -ENOMEM;
676 memset(tbuf, 0, 8);
677 tbuf[0] = data & 0xff; 676 tbuf[0] = data & 0xff;
678 tbuf[1] = data >> 8; 677 tbuf[1] = data >> 8;
679 tbuf[2] = addr & 0xff; 678 tbuf[2] = addr & 0xff;
diff --git a/drivers/staging/go7007/go7007-v4l2.c b/drivers/staging/go7007/go7007-v4l2.c
index 723c1a64d87..46b4b9f6855 100644
--- a/drivers/staging/go7007/go7007-v4l2.c
+++ b/drivers/staging/go7007/go7007-v4l2.c
@@ -720,7 +720,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
720 if (count > 32) 720 if (count > 32)
721 count = 32; 721 count = 32;
722 722
723 gofh->bufs = kmalloc(count * sizeof(struct go7007_buffer), 723 gofh->bufs = kcalloc(count, sizeof(struct go7007_buffer),
724 GFP_KERNEL); 724 GFP_KERNEL);
725 725
726 if (!gofh->bufs) { 726 if (!gofh->bufs) {
@@ -728,8 +728,6 @@ static int vidioc_reqbufs(struct file *file, void *priv,
728 goto unlock_and_return; 728 goto unlock_and_return;
729 } 729 }
730 730
731 memset(gofh->bufs, 0, count * sizeof(struct go7007_buffer));
732
733 for (i = 0; i < count; ++i) { 731 for (i = 0; i < count; ++i) {
734 gofh->bufs[i].go = go; 732 gofh->bufs[i].go = go;
735 gofh->bufs[i].index = i; 733 gofh->bufs[i].index = i;
diff --git a/drivers/staging/go7007/saa7134-go7007.c b/drivers/staging/go7007/saa7134-go7007.c
index b25d7d2090e..49f0d31c118 100644
--- a/drivers/staging/go7007/saa7134-go7007.c
+++ b/drivers/staging/go7007/saa7134-go7007.c
@@ -440,10 +440,9 @@ static int saa7134_go7007_init(struct saa7134_dev *dev)
440 440
441 printk(KERN_DEBUG "saa7134-go7007: probing new SAA713X board\n"); 441 printk(KERN_DEBUG "saa7134-go7007: probing new SAA713X board\n");
442 442
443 saa = kmalloc(sizeof(struct saa7134_go7007), GFP_KERNEL); 443 saa = kzalloc(sizeof(struct saa7134_go7007), GFP_KERNEL);
444 if (saa == NULL) 444 if (saa == NULL)
445 return -ENOMEM; 445 return -ENOMEM;
446 memset(saa, 0, sizeof(struct saa7134_go7007));
447 446
448 /* Allocate a couple pages for receiving the compressed stream */ 447 /* Allocate a couple pages for receiving the compressed stream */
449 saa->top = (u8 *)get_zeroed_page(GFP_KERNEL); 448 saa->top = (u8 *)get_zeroed_page(GFP_KERNEL);