Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52950ed4 authored by Tobias Klauser's avatar Tobias Klauser Committed by Greg Kroah-Hartman
Browse files

[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: default avatarTobias Klauser <tklauser@nuerscht.ch>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent f3d34ed4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -138,7 +138,7 @@ static const char *const ep_name [] = {
	/* or like sa1100: two fixed function endpoints */
	"ep1out-bulk", "ep2in-bulk",
};
#define DUMMY_ENDPOINTS	(sizeof(ep_name)/sizeof(char *))
#define DUMMY_ENDPOINTS	ARRAY_SIZE(ep_name)

/*-------------------------------------------------------------------------*/

+2 −2
Original line number Diff line number Diff line
@@ -2093,7 +2093,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
	/* Programming the tablet macro keys needs to be done with a for loop
	 * as the keycodes are discontiguous.
	 */
	for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i)
	for (i = 0; i < ARRAY_SIZE(macroKeyEvents); ++i)
		set_bit(macroKeyEvents[i], inputdev->keybit);

	/*
@@ -2135,7 +2135,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
	 * not an error :-)
	 */

	for (i = 0; i < sizeof(speeds) / sizeof(speeds[0]); ++i) {
	for (i = 0; i < ARRAY_SIZE(speeds); ++i) {
		aiptek->curSetting.programmableDelay = speeds[i];
		(void)aiptek_program_tablet(aiptek);
		if (aiptek->inputdev->absmax[ABS_X] > 0) {
+1 −1
Original line number Diff line number Diff line
@@ -3457,7 +3457,7 @@ static void ibmcam_model3_setup_after_video_if(struct uvd *uvd)
	if(init_model3_input) {
		if (debug > 0)
			info("Setting input to RCA.");
		for (i=0; i < (sizeof(initData)/sizeof(initData[0])); i++) {
		for (i=0; i < ARRAY_SIZE(initData); i++) {
			ibmcam_veio(uvd, initData[i].req, initData[i].value, initData[i].index);
		}
	}
+10 −13
Original line number Diff line number Diff line
@@ -1316,7 +1316,7 @@ static int sn9c102_init(struct sn9c102_device* cam)
	struct v4l2_control ctrl;
	struct v4l2_queryctrl *qctrl;
	struct v4l2_rect* rect;
	u8 i = 0, n = 0;
	u8 i = 0;
	int err = 0;

	if (!(cam->state & DEV_INITIALIZED)) {
@@ -1364,8 +1364,7 @@ static int sn9c102_init(struct sn9c102_device* cam)
		}

	if (s->set_ctrl) {
		n = sizeof(s->qctrl) / sizeof(s->qctrl[0]);
		for (i = 0; i < n; i++)
		for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
			if (s->qctrl[i].id != 0 &&
			    !(s->qctrl[i].flags & V4L2_CTRL_FLAG_DISABLED)) {
				ctrl.id = s->qctrl[i].id;
@@ -1810,13 +1809,12 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
	{
		struct sn9c102_sensor* s = cam->sensor;
		struct v4l2_queryctrl qc;
		u8 i, n;
		u8 i;

		if (copy_from_user(&qc, arg, sizeof(qc)))
			return -EFAULT;

		n = sizeof(s->qctrl) / sizeof(s->qctrl[0]);
		for (i = 0; i < n; i++)
		for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
			if (qc.id && qc.id == s->qctrl[i].id) {
				memcpy(&qc, &(s->qctrl[i]), sizeof(qc));
				if (copy_to_user(arg, &qc, sizeof(qc)))
@@ -1852,7 +1850,7 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
	{
		struct sn9c102_sensor* s = cam->sensor;
		struct v4l2_control ctrl;
		u8 i, n;
		u8 i;
		int err = 0;

		if (!s->set_ctrl)
@@ -1861,8 +1859,7 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
		if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
			return -EFAULT;

		n = sizeof(s->qctrl) / sizeof(s->qctrl[0]);
		for (i = 0; i < n; i++)
		for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
			if (ctrl.id == s->qctrl[i].id) {
				if (ctrl.value < s->qctrl[i].minimum ||
				    ctrl.value > s->qctrl[i].maximum)
@@ -2544,7 +2541,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
	unsigned int i, n;
	int err = 0, r;

	n = sizeof(sn9c102_id_table)/sizeof(sn9c102_id_table[0]);
	n = ARRAY_SIZE(sn9c102_id_table);
	for (i = 0; i < n-1; i++)
		if (le16_to_cpu(udev->descriptor.idVendor) == 
		    sn9c102_id_table[i].idVendor &&
+1 −1
Original line number Diff line number Diff line
@@ -2958,7 +2958,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
	};

	#define V4L1_IOCTL(cmd) \
	        ((_IOC_NR((cmd)) < sizeof(v4l1_ioctls)/sizeof(char*)) ? \
	        ((_IOC_NR((cmd)) < ARRAY_SIZE(v4l1_ioctls)) ? \
	        v4l1_ioctls[_IOC_NR((cmd))] : "?")

	cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp));
Loading