aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen
diff options
context:
space:
mode:
authorOliver Neukum <oneukum@suse.de>2010-07-15 12:21:40 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-07-15 12:30:57 -0400
commita8aef622929bbba4d89498fb41dd445c14fae1f7 (patch)
tree839b1724cc937af7cc65fef03e951d68a1a2a0db /drivers/input/touchscreen
parent5d9efc59e689445f1f8c4eceb125c1a12898e65c (diff)
Input: usbtouchscreen - implement reset_resume
This implements reset_resume() by splitting init into allocations of private data structures and device initializations. Device initializations are repeated upon reset_resume. Signed-off-by: Oliver Neukum <oneukum@suse.de> Tested-by: Petr Štetiar <ynezz@true.cz> Tested-by: Ondrej Zary <linux@rainbow-software.org> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r--drivers/input/touchscreen/usbtouchscreen.c108
1 files changed, 76 insertions, 32 deletions
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index 77e671f8f1a4..f45f80f6d336 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -95,6 +95,7 @@ struct usbtouch_device_info {
95 int (*get_pkt_len) (unsigned char *pkt, int len); 95 int (*get_pkt_len) (unsigned char *pkt, int len);
96 96
97 int (*read_data) (struct usbtouch_usb *usbtouch, unsigned char *pkt); 97 int (*read_data) (struct usbtouch_usb *usbtouch, unsigned char *pkt);
98 int (*alloc) (struct usbtouch_usb *usbtouch);
98 int (*init) (struct usbtouch_usb *usbtouch); 99 int (*init) (struct usbtouch_usb *usbtouch);
99 void (*exit) (struct usbtouch_usb *usbtouch); 100 void (*exit) (struct usbtouch_usb *usbtouch);
100}; 101};
@@ -510,7 +511,7 @@ static int dmc_tsc10_init(struct usbtouch_usb *usbtouch)
510 int ret = -ENOMEM; 511 int ret = -ENOMEM;
511 unsigned char *buf; 512 unsigned char *buf;
512 513
513 buf = kmalloc(2, GFP_KERNEL); 514 buf = kmalloc(2, GFP_NOIO);
514 if (!buf) 515 if (!buf)
515 goto err_nobuf; 516 goto err_nobuf;
516 /* reset */ 517 /* reset */
@@ -735,11 +736,43 @@ static void nexio_ack_complete(struct urb *urb)
735{ 736{
736} 737}
737 738
739static int nexio_alloc(struct usbtouch_usb *usbtouch)
740{
741 struct nexio_priv *priv;
742 int ret = -ENOMEM;
743
744 usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_KERNEL);
745 if (!usbtouch->priv)
746 goto out_buf;
747
748 priv = usbtouch->priv;
749
750 priv->ack_buf = kmemdup(nexio_ack_pkt, sizeof(nexio_ack_pkt),
751 GFP_KERNEL);
752 if (!priv->ack_buf)
753 goto err_priv;
754
755 priv->ack = usb_alloc_urb(0, GFP_KERNEL);
756 if (!priv->ack) {
757 dbg("%s - usb_alloc_urb failed: usbtouch->ack", __func__);
758 goto err_ack_buf;
759 }
760
761 return 0;
762
763err_ack_buf:
764 kfree(priv->ack_buf);
765err_priv:
766 kfree(priv);
767out_buf:
768 return ret;
769}
770
738static int nexio_init(struct usbtouch_usb *usbtouch) 771static int nexio_init(struct usbtouch_usb *usbtouch)
739{ 772{
740 struct usb_device *dev = interface_to_usbdev(usbtouch->interface); 773 struct usb_device *dev = interface_to_usbdev(usbtouch->interface);
741 struct usb_host_interface *interface = usbtouch->interface->cur_altsetting; 774 struct usb_host_interface *interface = usbtouch->interface->cur_altsetting;
742 struct nexio_priv *priv; 775 struct nexio_priv *priv = usbtouch->priv;
743 int ret = -ENOMEM; 776 int ret = -ENOMEM;
744 int actual_len, i; 777 int actual_len, i;
745 unsigned char *buf; 778 unsigned char *buf;
@@ -758,7 +791,7 @@ static int nexio_init(struct usbtouch_usb *usbtouch)
758 if (!input_ep || !output_ep) 791 if (!input_ep || !output_ep)
759 return -ENXIO; 792 return -ENXIO;
760 793
761 buf = kmalloc(NEXIO_BUFSIZE, GFP_KERNEL); 794 buf = kmalloc(NEXIO_BUFSIZE, GFP_NOIO);
762 if (!buf) 795 if (!buf)
763 goto out_buf; 796 goto out_buf;
764 797
@@ -790,11 +823,11 @@ static int nexio_init(struct usbtouch_usb *usbtouch)
790 switch (buf[0]) { 823 switch (buf[0]) {
791 case 0x83: /* firmware version */ 824 case 0x83: /* firmware version */
792 if (!firmware_ver) 825 if (!firmware_ver)
793 firmware_ver = kstrdup(&buf[2], GFP_KERNEL); 826 firmware_ver = kstrdup(&buf[2], GFP_NOIO);
794 break; 827 break;
795 case 0x84: /* device name */ 828 case 0x84: /* device name */
796 if (!device_name) 829 if (!device_name)
797 device_name = kstrdup(&buf[2], GFP_KERNEL); 830 device_name = kstrdup(&buf[2], GFP_NOIO);
798 break; 831 break;
799 } 832 }
800 } 833 }
@@ -805,36 +838,11 @@ static int nexio_init(struct usbtouch_usb *usbtouch)
805 kfree(firmware_ver); 838 kfree(firmware_ver);
806 kfree(device_name); 839 kfree(device_name);
807 840
808 /* prepare ACK URB */
809 ret = -ENOMEM;
810
811 usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_KERNEL);
812 if (!usbtouch->priv)
813 goto out_buf;
814
815 priv = usbtouch->priv;
816
817 priv->ack_buf = kmemdup(nexio_ack_pkt, sizeof(nexio_ack_pkt),
818 GFP_KERNEL);
819 if (!priv->ack_buf)
820 goto err_priv;
821
822 priv->ack = usb_alloc_urb(0, GFP_KERNEL);
823 if (!priv->ack) {
824 dbg("%s - usb_alloc_urb failed: usbtouch->ack", __func__);
825 goto err_ack_buf;
826 }
827
828 usb_fill_bulk_urb(priv->ack, dev, usb_sndbulkpipe(dev, output_ep), 841 usb_fill_bulk_urb(priv->ack, dev, usb_sndbulkpipe(dev, output_ep),
829 priv->ack_buf, sizeof(nexio_ack_pkt), 842 priv->ack_buf, sizeof(nexio_ack_pkt),
830 nexio_ack_complete, usbtouch); 843 nexio_ack_complete, usbtouch);
831 ret = 0; 844 ret = 0;
832 goto out_buf;
833 845
834err_ack_buf:
835 kfree(priv->ack_buf);
836err_priv:
837 kfree(priv);
838out_buf: 846out_buf:
839 kfree(buf); 847 kfree(buf);
840 return ret; 848 return ret;
@@ -1125,6 +1133,7 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
1125 .rept_size = 1024, 1133 .rept_size = 1024,
1126 .irq_always = true, 1134 .irq_always = true,
1127 .read_data = nexio_read_data, 1135 .read_data = nexio_read_data,
1136 .alloc = nexio_alloc,
1128 .init = nexio_init, 1137 .init = nexio_init,
1129 .exit = nexio_exit, 1138 .exit = nexio_exit,
1130 }, 1139 },
@@ -1337,6 +1346,31 @@ static int usbtouch_resume(struct usb_interface *intf)
1337 return result; 1346 return result;
1338} 1347}
1339 1348
1349static int usbtouch_reset_resume(struct usb_interface *intf)
1350{
1351 struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
1352 struct input_dev *input = usbtouch->input;
1353 int err = 0;
1354
1355 /* reinit the device */
1356 if (usbtouch->type->init) {
1357 err = usbtouch->type->init(usbtouch);
1358 if (err) {
1359 dbg("%s - type->init() failed, err: %d",
1360 __func__, err);
1361 return err;
1362 }
1363 }
1364
1365 /* restart IO if needed */
1366 mutex_lock(&input->mutex);
1367 if (input->users)
1368 err = usb_submit_urb(usbtouch->irq, GFP_NOIO);
1369 mutex_unlock(&input->mutex);
1370
1371 return err;
1372}
1373
1340static void usbtouch_free_buffers(struct usb_device *udev, 1374static void usbtouch_free_buffers(struct usb_device *udev,
1341 struct usbtouch_usb *usbtouch) 1375 struct usbtouch_usb *usbtouch)
1342{ 1376{
@@ -1456,12 +1490,21 @@ static int usbtouch_probe(struct usb_interface *intf,
1456 usbtouch->irq->transfer_dma = usbtouch->data_dma; 1490 usbtouch->irq->transfer_dma = usbtouch->data_dma;
1457 usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1491 usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1458 1492
1459 /* device specific init */ 1493 /* device specific allocations */
1494 if (type->alloc) {
1495 err = type->alloc(usbtouch);
1496 if (err) {
1497 dbg("%s - type->alloc() failed, err: %d", __func__, err);
1498 goto out_free_urb;
1499 }
1500 }
1501
1502 /* device specific initialisation*/
1460 if (type->init) { 1503 if (type->init) {
1461 err = type->init(usbtouch); 1504 err = type->init(usbtouch);
1462 if (err) { 1505 if (err) {
1463 dbg("%s - type->init() failed, err: %d", __func__, err); 1506 dbg("%s - type->init() failed, err: %d", __func__, err);
1464 goto out_free_urb; 1507 goto out_do_exit;
1465 } 1508 }
1466 } 1509 }
1467 1510
@@ -1531,6 +1574,7 @@ static struct usb_driver usbtouch_driver = {
1531 .disconnect = usbtouch_disconnect, 1574 .disconnect = usbtouch_disconnect,
1532 .suspend = usbtouch_suspend, 1575 .suspend = usbtouch_suspend,
1533 .resume = usbtouch_resume, 1576 .resume = usbtouch_resume,
1577 .reset_resume = usbtouch_reset_resume,
1534 .id_table = usbtouch_devices, 1578 .id_table = usbtouch_devices,
1535 .supports_autosuspend = 1, 1579 .supports_autosuspend = 1,
1536}; 1580};