]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (9638): drivers/media: use ARRAY_SIZE
authorJulia Lawall <julia@diku.dk>
Thu, 13 Nov 2008 02:18:21 +0000 (23:18 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 29 Dec 2008 19:53:34 +0000 (17:53 -0200)
ARRAY_SIZE is more concise to use when the size of an array is divided by
the size of its type or the size of its first element.

The semantic patch that makes this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@i@
@@

@depends on i using "paren.iso"@
type T;
T[] E;
@@

- (sizeof(E)/sizeof(E[...]))
+ ARRAY_SIZE(E)

@depends on i using "paren.iso"@
type T;
T[] E;
@@

- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/common/tuners/mxl5005s.c
drivers/media/video/gspca/gspca.c
drivers/media/video/gspca/mars.c
drivers/media/video/gspca/spca500.c
drivers/media/video/saa7134/saa7134-tvaudio.c

index a8878244bb3c40432fe6b3420e32e338ae32f0ad..31522d2e318ea23dbb9ca41c4fcba4b2e7141abf 100644 (file)
@@ -3598,7 +3598,7 @@ static u16 MXL_GetInitRegister(struct dvb_frontend *fe, u8 *RegNum,
                76, 77, 91, 134, 135, 137, 147,
                156, 166, 167, 168, 25 };
 
-       *count = sizeof(RegAddr) / sizeof(u8);
+       *count = ARRAY_SIZE(RegAddr);
 
        status += MXL_BlockInit(fe);
 
@@ -3630,7 +3630,7 @@ static u16 MXL_GetCHRegister(struct dvb_frontend *fe, u8 *RegNum, u8 *RegVal,
        */
 #endif
 
-       *count = sizeof(RegAddr) / sizeof(u8);
+       *count = ARRAY_SIZE(RegAddr);
 
        for (i = 0 ; i < *count; i++) {
                RegNum[i] = RegAddr[i];
@@ -3648,7 +3648,7 @@ static u16 MXL_GetCHRegister_ZeroIF(struct dvb_frontend *fe, u8 *RegNum,
 
        u8 RegAddr[] = {43, 136};
 
-       *count = sizeof(RegAddr) / sizeof(u8);
+       *count = ARRAY_SIZE(RegAddr);
 
        for (i = 0; i < *count; i++) {
                RegNum[i] = RegAddr[i];
index 78a22144d689402986e7b0aad0a6d46dc1cbb967..02d6a48ad1b276072d77de6054c91851b5f4a8cb 100644 (file)
@@ -736,7 +736,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
                        if (fmtdesc->index == index)
                                break;          /* new format */
                        index++;
-                       if (index >= sizeof fmt_tb / sizeof fmt_tb[0])
+                       if (index >= ARRAY_SIZE(fmt_tb))
                                return -EINVAL;
                }
        }
index 277ca34a881775cf8ee72a7801bb4202e2864f5c..492cdd3b5c849ff8a7f3c99c8d00686df86d9310 100644 (file)
@@ -123,7 +123,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
        cam = &gspca_dev->cam;
        cam->epaddr = 0x01;
        cam->cam_mode = vga_mode;
-       cam->nmodes = sizeof vga_mode / sizeof vga_mode[0];
+       cam->nmodes = ARRAY_SIZE(vga_mode);
        sd->qindex = 1;                 /* set the quantization table */
        return 0;
 }
index bca106c153faa3dc4708ad77a6e33eac2c73615d..09ff69791da74f9d2ceb3f7ef2db2da7630a0006 100644 (file)
@@ -633,10 +633,10 @@ static int sd_config(struct gspca_dev *gspca_dev,
        sd->subtype = id->driver_info;
        if (sd->subtype != LogitechClickSmart310) {
                cam->cam_mode = vga_mode;
-               cam->nmodes = sizeof vga_mode / sizeof vga_mode[0];
+               cam->nmodes = ARRAY_SIZE(vga_mode);
        } else {
                cam->cam_mode = sif_mode;
-               cam->nmodes = sizeof sif_mode / sizeof sif_mode[0];
+               cam->nmodes = ARRAY_SIZE(sif_mode);
        }
        sd->qindex = 5;
        sd->brightness = BRIGHTNESS_DEF;
index c5d0b44c179e02e8b8f66b4cafbb0346771300f3..76b16407b01e89ac3b7e0ef8cb8cd94869da0a03 100644 (file)
@@ -159,7 +159,7 @@ static struct saa7134_tvaudio tvaudio[] = {
                .mode          = TVAUDIO_FM_MONO,
        }
 };
-#define TVAUDIO (sizeof(tvaudio)/sizeof(struct saa7134_tvaudio))
+#define TVAUDIO ARRAY_SIZE(tvaudio)
 
 /* ------------------------------------------------------------------ */