aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/media/sn9c102_core.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@nuerscht.ch>2005-12-11 10:20:08 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-04 16:51:43 -0500
commit52950ed40dc97456209979af1d8f51b63cf6dcab (patch)
tree527fb1a339889b3df9d227b1c17f87bc487f397f /drivers/usb/media/sn9c102_core.c
parentf3d34ed48c80903544b509031fee64838d29f35f (diff)
[PATCH] USB: Use ARRAY_SIZE macro
Use ARRAY_SIZE macro instead of sizeof(x)/sizeof(x[0]) and remove duplicates of ARRAY_SIZE. Some trailing whitespaces are also removed. Patch is compile-tested on i386. Signed-off-by: Tobias Klauser <tklauser@nuerscht.ch> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/media/sn9c102_core.c')
-rw-r--r--drivers/usb/media/sn9c102_core.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/drivers/usb/media/sn9c102_core.c b/drivers/usb/media/sn9c102_core.c
index 08723459da86..8d1a1c357d5a 100644
--- a/drivers/usb/media/sn9c102_core.c
+++ b/drivers/usb/media/sn9c102_core.c
@@ -1316,7 +1316,7 @@ static int sn9c102_init(struct sn9c102_device* cam)
1316 struct v4l2_control ctrl; 1316 struct v4l2_control ctrl;
1317 struct v4l2_queryctrl *qctrl; 1317 struct v4l2_queryctrl *qctrl;
1318 struct v4l2_rect* rect; 1318 struct v4l2_rect* rect;
1319 u8 i = 0, n = 0; 1319 u8 i = 0;
1320 int err = 0; 1320 int err = 0;
1321 1321
1322 if (!(cam->state & DEV_INITIALIZED)) { 1322 if (!(cam->state & DEV_INITIALIZED)) {
@@ -1352,7 +1352,7 @@ static int sn9c102_init(struct sn9c102_device* cam)
1352 return err; 1352 return err;
1353 1353
1354 if (s->pix_format.pixelformat == V4L2_PIX_FMT_SN9C10X) 1354 if (s->pix_format.pixelformat == V4L2_PIX_FMT_SN9C10X)
1355 DBG(3, "Compressed video format is active, quality %d", 1355 DBG(3, "Compressed video format is active, quality %d",
1356 cam->compression.quality) 1356 cam->compression.quality)
1357 else 1357 else
1358 DBG(3, "Uncompressed video format is active") 1358 DBG(3, "Uncompressed video format is active")
@@ -1364,9 +1364,8 @@ static int sn9c102_init(struct sn9c102_device* cam)
1364 } 1364 }
1365 1365
1366 if (s->set_ctrl) { 1366 if (s->set_ctrl) {
1367 n = sizeof(s->qctrl) / sizeof(s->qctrl[0]); 1367 for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
1368 for (i = 0; i < n; i++) 1368 if (s->qctrl[i].id != 0 &&
1369 if (s->qctrl[i].id != 0 &&
1370 !(s->qctrl[i].flags & V4L2_CTRL_FLAG_DISABLED)) { 1369 !(s->qctrl[i].flags & V4L2_CTRL_FLAG_DISABLED)) {
1371 ctrl.id = s->qctrl[i].id; 1370 ctrl.id = s->qctrl[i].id;
1372 ctrl.value = qctrl[i].default_value; 1371 ctrl.value = qctrl[i].default_value;
@@ -1388,7 +1387,7 @@ static int sn9c102_init(struct sn9c102_device* cam)
1388 init_waitqueue_head(&cam->wait_stream); 1387 init_waitqueue_head(&cam->wait_stream);
1389 cam->nreadbuffers = 2; 1388 cam->nreadbuffers = 2;
1390 memcpy(s->_qctrl, s->qctrl, sizeof(s->qctrl)); 1389 memcpy(s->_qctrl, s->qctrl, sizeof(s->qctrl));
1391 memcpy(&(s->_rect), &(s->cropcap.defrect), 1390 memcpy(&(s->_rect), &(s->cropcap.defrect),
1392 sizeof(struct v4l2_rect)); 1391 sizeof(struct v4l2_rect));
1393 cam->state |= DEV_INITIALIZED; 1392 cam->state |= DEV_INITIALIZED;
1394 } 1393 }
@@ -1810,13 +1809,12 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
1810 { 1809 {
1811 struct sn9c102_sensor* s = cam->sensor; 1810 struct sn9c102_sensor* s = cam->sensor;
1812 struct v4l2_queryctrl qc; 1811 struct v4l2_queryctrl qc;
1813 u8 i, n; 1812 u8 i;
1814 1813
1815 if (copy_from_user(&qc, arg, sizeof(qc))) 1814 if (copy_from_user(&qc, arg, sizeof(qc)))
1816 return -EFAULT; 1815 return -EFAULT;
1817 1816
1818 n = sizeof(s->qctrl) / sizeof(s->qctrl[0]); 1817 for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
1819 for (i = 0; i < n; i++)
1820 if (qc.id && qc.id == s->qctrl[i].id) { 1818 if (qc.id && qc.id == s->qctrl[i].id) {
1821 memcpy(&qc, &(s->qctrl[i]), sizeof(qc)); 1819 memcpy(&qc, &(s->qctrl[i]), sizeof(qc));
1822 if (copy_to_user(arg, &qc, sizeof(qc))) 1820 if (copy_to_user(arg, &qc, sizeof(qc)))
@@ -1852,7 +1850,7 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
1852 { 1850 {
1853 struct sn9c102_sensor* s = cam->sensor; 1851 struct sn9c102_sensor* s = cam->sensor;
1854 struct v4l2_control ctrl; 1852 struct v4l2_control ctrl;
1855 u8 i, n; 1853 u8 i;
1856 int err = 0; 1854 int err = 0;
1857 1855
1858 if (!s->set_ctrl) 1856 if (!s->set_ctrl)
@@ -1861,8 +1859,7 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
1861 if (copy_from_user(&ctrl, arg, sizeof(ctrl))) 1859 if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
1862 return -EFAULT; 1860 return -EFAULT;
1863 1861
1864 n = sizeof(s->qctrl) / sizeof(s->qctrl[0]); 1862 for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
1865 for (i = 0; i < n; i++)
1866 if (ctrl.id == s->qctrl[i].id) { 1863 if (ctrl.id == s->qctrl[i].id) {
1867 if (ctrl.value < s->qctrl[i].minimum || 1864 if (ctrl.value < s->qctrl[i].minimum ||
1868 ctrl.value > s->qctrl[i].maximum) 1865 ctrl.value > s->qctrl[i].maximum)
@@ -2544,7 +2541,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2544 unsigned int i, n; 2541 unsigned int i, n;
2545 int err = 0, r; 2542 int err = 0, r;
2546 2543
2547 n = sizeof(sn9c102_id_table)/sizeof(sn9c102_id_table[0]); 2544 n = ARRAY_SIZE(sn9c102_id_table);
2548 for (i = 0; i < n-1; i++) 2545 for (i = 0; i < n-1; i++)
2549 if (le16_to_cpu(udev->descriptor.idVendor) == 2546 if (le16_to_cpu(udev->descriptor.idVendor) ==
2550 sn9c102_id_table[i].idVendor && 2547 sn9c102_id_table[i].idVendor &&