aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/rspiusb
diff options
context:
space:
mode:
authorRichard Genoud <richard.genoud@gmail.com>2009-05-17 13:06:32 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2009-06-19 11:00:54 -0700
commit14e8bcd0866a93ae1c20efa462e5d4807a1398a0 (patch)
treeffd6c5096a7c2477f62baed4635f76f20be3a02b /drivers/staging/rspiusb
parentStaging: rspiusb.c: break the huge piusb_ioctl function into several ones (diff)
downloadlinux-dev-14e8bcd0866a93ae1c20efa462e5d4807a1398a0.tar.xz
linux-dev-14e8bcd0866a93ae1c20efa462e5d4807a1398a0.zip
Staging: rspiusb: duplicate code in pixis_io
It seems that pixis_io and pixis_io2 should do the same thing. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/rspiusb')
-rw-r--r--drivers/staging/rspiusb/rspiusb.c59
1 files changed, 8 insertions, 51 deletions
diff --git a/drivers/staging/rspiusb/rspiusb.c b/drivers/staging/rspiusb/rspiusb.c
index 685ab3f33861..090bf41ebcd2 100644
--- a/drivers/staging/rspiusb/rspiusb.c
+++ b/drivers/staging/rspiusb/rspiusb.c
@@ -252,38 +252,6 @@ static int pixis_io(struct ioctl_struct *ctrl, struct device_extension *pdx,
return ctrl->numbytes;
}
-static int pixis_io2(struct ioctl_struct *ctrl, struct device_extension *pdx,
- struct ioctl_struct *arg)
-{
- unsigned char *uBuf;
- int numbytes;
- int i;
-
- uBuf = kmalloc(ctrl->numbytes, GFP_KERNEL);
- if (!uBuf) {
- dbg("Alloc for uBuf failed");
- return 0;
- }
- numbytes = (int) ctrl->numbytes;
- /* dbg( "numbytes to read = %d", numbytes ); */
- if (copy_from_user(uBuf, ctrl->pData, numbytes))
- dbg("copying ctrl->pData to dummyBuf failed");
-
- i = usb_bulk_msg(pdx->udev, pdx->hEP[ctrl->endpoint],
- uBuf, numbytes, &numbytes, HZ * 10);
- if (i) {
- dbg("Blocking ReadI/O Failed with status %d", i);
- kfree(uBuf);
- return -1;
- }
- ctrl->numbytes = numbytes;
- memcpy(ctrl->pData, uBuf, numbytes);
- if (copy_to_user(arg, ctrl, sizeof(struct ioctl_struct)))
- dbg("copy_to_user failed in IORB");
- kfree(uBuf);
- return ctrl->numbytes;
-}
-
static int pixel_data(struct ioctl_struct *ctrl, struct device_extension *pdx)
{
int i;
@@ -398,27 +366,16 @@ static int piusb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
sizeof(struct ioctl_struct)))
dev_err(&pdx->udev->dev, "copy_from_user failed\n");
- switch (ctrl.endpoint) {
- case 0: /* ST133 Pixel Data or PIXIS IO */
- if (pdx->iama == PIXIS_PID) {
- return pixis_io(&ctrl, pdx,
- (struct ioctl_struct *)arg);
- }
- /* ST133 Pixel Data */
- /* fall through */
- case 2: /* PIXIS Ping */
- /* fall through */
- case 3: /* PIXIS Pong */
+ if (((0 == ctrl.endpoint) && (PIXIS_PID == pdx->iama)) ||
+ (1 == ctrl.endpoint) || /* ST133IO */
+ (4 == ctrl.endpoint)) /* PIXIS IO */
+ return pixis_io(&ctrl, pdx,
+ (struct ioctl_struct *)arg);
+ else if ((0 == ctrl.endpoint) || /* ST133 Pixel Data */
+ (2 == ctrl.endpoint) || /* PIXIS Ping */
+ (3 == ctrl.endpoint)) /* PIXIS Pong */
return pixel_data(&ctrl, pdx);
- case 1: /* ST133IO */
- /* fall through */
- case 4: /* PIXIS IO */
- return pixis_io2(&ctrl, pdx,
- (struct ioctl_struct *)arg);
- default:
- break;
- }
break;
case PIUSB_WHATCAMERA: