[staging-next 11/12] staging/easycap: use regget for register back reading

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use regget to reading back what was written to a register.
This required changning size argument to regget signature

On the way remove usless variable casting

Cc: Mike Thomas <rmthomas@xxxxxxxxxxx>
Signed-off-by: Tomas Winkler <tomas.winkler@xxxxxxxxx>
---
 drivers/staging/easycap/easycap_low.c |   37 ++++++++++----------------------
 1 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/easycap/easycap_low.c b/drivers/staging/easycap/easycap_low.c
index 39e22d5..b44c384 100644
--- a/drivers/staging/easycap/easycap_low.c
+++ b/drivers/staging/easycap/easycap_low.c
@@ -43,7 +43,7 @@
 #define GET(X, Y, Z) do { \
 	int __rc; \
 	*(Z) = (u16)0; \
-	__rc = regget(X, Y, Z); \
+	__rc = regget(X, Y, Z, sizeof(u8)); \
 	if (0 > __rc) { \
 		JOT(8, ":-(%i\n", __LINE__);  return __rc; \
 	} \
@@ -256,7 +256,8 @@ static const struct saa7113config saa7113configNTSC[256] = {
 		{0xFF, 0xFF}
 };
 
-static int regget(struct usb_device *pusb_device, u16 index, void *pvoid)
+static int regget(struct usb_device *pusb_device,
+		u16 index, void *reg, int reg_size)
 {
 	int rc;
 
@@ -264,46 +265,32 @@ static int regget(struct usb_device *pusb_device, u16 index, void *pvoid)
 		return -ENODEV;
 
 	rc = usb_control_msg(pusb_device, usb_rcvctrlpipe(pusb_device, 0),
-			(u8)0x00,
-			(u8)(USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE),
-			(u16)0x00,
-			(u16)index,
-			(void *)pvoid,
-			sizeof(u8),
-			(int)50000);
+			0x00,
+			(USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE),
+			0x00,
+			index, reg, reg_size, 50000);
 
 	return 0xFF & rc;
 }
 
 static int regset(struct usb_device *pusb_device, u16 index, u16 value)
 {
-	u16 igot;
 	int rc0, rc1;
+	u16 igot;
 
 	if (!pusb_device)
 		return -ENODEV;
 
 	rc1 = 0;  igot = 0;
 	rc0 = usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0),
-			(u8)0x01,
-			(u8)(USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE),
-			(u16)value,
-			(u16)index,
-			NULL,
-			(u16)0,
-			(int)500);
+			0x01,
+			(USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE),
+			value, index, NULL, 0, 500);
 
 #ifdef NOREADBACK
 #
 #else
-	rc1 = usb_control_msg(pusb_device, usb_rcvctrlpipe(pusb_device, 0),
-			(u8)0x00,
-			(u8)(USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE),
-			(u16)0x00,
-			(u16)index,
-			(void *)&igot,
-			(u16)sizeof(u16),
-			(int)50000);
+	rc1 = regget(pusb_device, index, &igot, sizeof(igot));
 	igot = 0xFF & igot;
 	switch (index) {
 	case 0x000:
-- 
1.7.4

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux