X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Finput%2Ftouchscreen%2Fusbtouchscreen.c;h=792b2708a137ccfc2165b90e5a8a5cc33cc09f8c;hb=15439dd37f92f930ac7fc65a4f261834e4215bb0;hp=63f9664a066f8465398f4526ca07ee4fbbbf4684;hpb=6208e77e7fa9e69f399fddc55b1cf9527fbde599;p=linux-2.6 diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index 63f9664a06..792b2708a1 100644 --- a/drivers/input/touchscreen/usbtouchscreen.c +++ b/drivers/input/touchscreen/usbtouchscreen.c @@ -262,7 +262,7 @@ static int mtouch_init(struct usbtouch_usb *usbtouch) USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d", - __FUNCTION__, ret); + __func__, ret); if (ret < 0) return ret; msleep(150); @@ -273,7 +273,7 @@ static int mtouch_init(struct usbtouch_usb *usbtouch) USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT); dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", - __FUNCTION__, ret); + __func__, ret); if (ret >= 0) break; if (ret != -EPIPE) @@ -396,9 +396,12 @@ static int gunze_read_data(struct usbtouch_usb *dev, unsigned char *pkt) static int dmc_tsc10_init(struct usbtouch_usb *usbtouch) { struct usb_device *dev = usbtouch->udev; - int ret; - unsigned char buf[2]; + int ret = -ENOMEM; + unsigned char *buf; + buf = kmalloc(2, GFP_KERNEL); + if (!buf) + goto err_nobuf; /* reset */ buf[0] = buf[1] = 0xFF; ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0), @@ -406,9 +409,11 @@ static int dmc_tsc10_init(struct usbtouch_usb *usbtouch) USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0, 0, buf, 2, USB_CTRL_SET_TIMEOUT); if (ret < 0) - return ret; - if (buf[0] != 0x06 || buf[1] != 0x00) - return -ENODEV; + goto err_out; + if (buf[0] != 0x06 || buf[1] != 0x00) { + ret = -ENODEV; + goto err_out; + } /* set coordinate output rate */ buf[0] = buf[1] = 0xFF; @@ -417,20 +422,22 @@ static int dmc_tsc10_init(struct usbtouch_usb *usbtouch) USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, TSC10_RATE_150, 0, buf, 2, USB_CTRL_SET_TIMEOUT); if (ret < 0) - return ret; + goto err_out; if ((buf[0] != 0x06 || buf[1] != 0x00) && - (buf[0] != 0x15 || buf[1] != 0x01)) - return -ENODEV; + (buf[0] != 0x15 || buf[1] != 0x01)) { + ret = -ENODEV; + goto err_out; + } /* start sending data */ ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0), TSC10_CMD_DATA1, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); - if (ret < 0) - return ret; - - return 0; +err_out: + kfree(buf); +err_nobuf: + return ret; } @@ -786,18 +793,18 @@ static void usbtouch_irq(struct urb *urb) case -ETIME: /* this urb is timing out */ dbg("%s - urb timed out - was the device unplugged?", - __FUNCTION__); + __func__); return; case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", - __FUNCTION__, urb->status); + __func__, urb->status); return; default: dbg("%s - nonzero urb status received: %d", - __FUNCTION__, urb->status); + __func__, urb->status); goto exit; } @@ -807,7 +814,7 @@ exit: retval = usb_submit_urb(urb, GFP_ATOMIC); if (retval) err("%s - usb_submit_urb failed with result: %d", - __FUNCTION__, retval); + __func__, retval); } static int usbtouch_open(struct input_dev *input) @@ -876,7 +883,7 @@ static int usbtouch_probe(struct usb_interface *intf, usbtouch->irq = usb_alloc_urb(0, GFP_KERNEL); if (!usbtouch->irq) { - dbg("%s - usb_alloc_urb failed: usbtouch->irq", __FUNCTION__); + dbg("%s - usb_alloc_urb failed: usbtouch->irq", __func__); goto out_free_buffers; } @@ -932,14 +939,14 @@ static int usbtouch_probe(struct usb_interface *intf, if (type->init) { err = type->init(usbtouch); if (err) { - dbg("%s - type->init() failed, err: %d", __FUNCTION__, err); + dbg("%s - type->init() failed, err: %d", __func__, err); goto out_free_buffers; } } err = input_register_device(usbtouch->input); if (err) { - dbg("%s - input_register_device failed, err: %d", __FUNCTION__, err); + dbg("%s - input_register_device failed, err: %d", __func__, err); goto out_free_buffers; } @@ -959,12 +966,12 @@ static void usbtouch_disconnect(struct usb_interface *intf) { struct usbtouch_usb *usbtouch = usb_get_intfdata(intf); - dbg("%s - called", __FUNCTION__); + dbg("%s - called", __func__); if (!usbtouch) return; - dbg("%s - usbtouch is initialized, cleaning up", __FUNCTION__); + dbg("%s - usbtouch is initialized, cleaning up", __func__); usb_set_intfdata(intf, NULL); usb_kill_urb(usbtouch->irq); input_unregister_device(usbtouch->input);