aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/tablet/aiptek.c109
1 files changed, 40 insertions, 69 deletions
diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c
index f9a5f872505f..088da86f0508 100644
--- a/drivers/input/tablet/aiptek.c
+++ b/drivers/input/tablet/aiptek.c
@@ -1795,67 +1795,33 @@ static ssize_t show_firmwareCode(struct device *dev, struct device_attribute *at
1795 1795
1796static DEVICE_ATTR(firmware_code, S_IRUGO, show_firmwareCode, NULL); 1796static DEVICE_ATTR(firmware_code, S_IRUGO, show_firmwareCode, NULL);
1797 1797
1798/*********************************************************************** 1798static struct attribute *aiptek_attributes[] = {
1799 * This routine removes all existing sysfs files managed by this device 1799 &dev_attr_size.attr,
1800 * driver. 1800 &dev_attr_pointer_mode.attr,
1801 */ 1801 &dev_attr_coordinate_mode.attr,
1802static void aiptek_delete_files(struct device *dev) 1802 &dev_attr_tool_mode.attr,
1803{ 1803 &dev_attr_xtilt.attr,
1804 device_remove_file(dev, &dev_attr_size); 1804 &dev_attr_ytilt.attr,
1805 device_remove_file(dev, &dev_attr_pointer_mode); 1805 &dev_attr_jitter.attr,
1806 device_remove_file(dev, &dev_attr_coordinate_mode); 1806 &dev_attr_delay.attr,
1807 device_remove_file(dev, &dev_attr_tool_mode); 1807 &dev_attr_event_count.attr,
1808 device_remove_file(dev, &dev_attr_xtilt); 1808 &dev_attr_diagnostic.attr,
1809 device_remove_file(dev, &dev_attr_ytilt); 1809 &dev_attr_odm_code.attr,
1810 device_remove_file(dev, &dev_attr_jitter); 1810 &dev_attr_model_code.attr,
1811 device_remove_file(dev, &dev_attr_delay); 1811 &dev_attr_firmware_code.attr,
1812 device_remove_file(dev, &dev_attr_event_count); 1812 &dev_attr_stylus_lower.attr,
1813 device_remove_file(dev, &dev_attr_diagnostic); 1813 &dev_attr_stylus_upper.attr,
1814 device_remove_file(dev, &dev_attr_odm_code); 1814 &dev_attr_mouse_left.attr,
1815 device_remove_file(dev, &dev_attr_model_code); 1815 &dev_attr_mouse_middle.attr,
1816 device_remove_file(dev, &dev_attr_firmware_code); 1816 &dev_attr_mouse_right.attr,
1817 device_remove_file(dev, &dev_attr_stylus_lower); 1817 &dev_attr_wheel.attr,
1818 device_remove_file(dev, &dev_attr_stylus_upper); 1818 &dev_attr_execute.attr,
1819 device_remove_file(dev, &dev_attr_mouse_left); 1819 NULL
1820 device_remove_file(dev, &dev_attr_mouse_middle); 1820};
1821 device_remove_file(dev, &dev_attr_mouse_right);
1822 device_remove_file(dev, &dev_attr_wheel);
1823 device_remove_file(dev, &dev_attr_execute);
1824}
1825
1826/***********************************************************************
1827 * This routine creates the sysfs files managed by this device
1828 * driver.
1829 */
1830static int aiptek_add_files(struct device *dev)
1831{
1832 int ret;
1833 1821
1834 if ((ret = device_create_file(dev, &dev_attr_size)) || 1822static struct attribute_group aiptek_attribute_group = {
1835 (ret = device_create_file(dev, &dev_attr_pointer_mode)) || 1823 .attrs = aiptek_attributes,
1836 (ret = device_create_file(dev, &dev_attr_coordinate_mode)) || 1824};
1837 (ret = device_create_file(dev, &dev_attr_tool_mode)) ||
1838 (ret = device_create_file(dev, &dev_attr_xtilt)) ||
1839 (ret = device_create_file(dev, &dev_attr_ytilt)) ||
1840 (ret = device_create_file(dev, &dev_attr_jitter)) ||
1841 (ret = device_create_file(dev, &dev_attr_delay)) ||
1842 (ret = device_create_file(dev, &dev_attr_event_count)) ||
1843 (ret = device_create_file(dev, &dev_attr_diagnostic)) ||
1844 (ret = device_create_file(dev, &dev_attr_odm_code)) ||
1845 (ret = device_create_file(dev, &dev_attr_model_code)) ||
1846 (ret = device_create_file(dev, &dev_attr_firmware_code)) ||
1847 (ret = device_create_file(dev, &dev_attr_stylus_lower)) ||
1848 (ret = device_create_file(dev, &dev_attr_stylus_upper)) ||
1849 (ret = device_create_file(dev, &dev_attr_mouse_left)) ||
1850 (ret = device_create_file(dev, &dev_attr_mouse_middle)) ||
1851 (ret = device_create_file(dev, &dev_attr_mouse_right)) ||
1852 (ret = device_create_file(dev, &dev_attr_wheel)) ||
1853 (ret = device_create_file(dev, &dev_attr_execute))) {
1854 err("aiptek: killing own sysfs device files\n");
1855 aiptek_delete_files(dev);
1856 }
1857 return ret;
1858}
1859 1825
1860/*********************************************************************** 1826/***********************************************************************
1861 * This routine is called when a tablet has been identified. It basically 1827 * This routine is called when a tablet has been identified. It basically
@@ -2039,25 +2005,30 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
2039 } 2005 }
2040 } 2006 }
2041 2007
2042 /* Register the tablet as an Input Device
2043 */
2044 err = input_register_device(aiptek->inputdev);
2045 if (err)
2046 goto fail2;
2047
2048 /* Associate this driver's struct with the usb interface. 2008 /* Associate this driver's struct with the usb interface.
2049 */ 2009 */
2050 usb_set_intfdata(intf, aiptek); 2010 usb_set_intfdata(intf, aiptek);
2051 2011
2052 /* Set up the sysfs files 2012 /* Set up the sysfs files
2053 */ 2013 */
2054 aiptek_add_files(&intf->dev); 2014 err = sysfs_create_group(&intf->dev.kobj, &aiptek_attribute_group);
2015 if (err)
2016 goto fail3;
2017
2018 /* Register the tablet as an Input Device
2019 */
2020 err = input_register_device(aiptek->inputdev);
2021 if (err)
2022 goto fail4;
2055 2023
2056 return 0; 2024 return 0;
2057 2025
2026 fail4: sysfs_remove_group(&intf->dev.kobj, &aiptek_attribute_group);
2027 fail3: usb_free_urb(aiptek->urb);
2058 fail2: usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data, 2028 fail2: usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data,
2059 aiptek->data_dma); 2029 aiptek->data_dma);
2060 fail1: input_free_device(inputdev); 2030 fail1: usb_set_intfdata(intf, NULL);
2031 input_free_device(inputdev);
2061 kfree(aiptek); 2032 kfree(aiptek);
2062 return err; 2033 return err;
2063} 2034}
@@ -2077,7 +2048,7 @@ static void aiptek_disconnect(struct usb_interface *intf)
2077 */ 2048 */
2078 usb_kill_urb(aiptek->urb); 2049 usb_kill_urb(aiptek->urb);
2079 input_unregister_device(aiptek->inputdev); 2050 input_unregister_device(aiptek->inputdev);
2080 aiptek_delete_files(&intf->dev); 2051 sysfs_remove_group(&intf->dev.kobj, &aiptek_attribute_group);
2081 usb_free_urb(aiptek->urb); 2052 usb_free_urb(aiptek->urb);
2082 usb_buffer_free(interface_to_usbdev(intf), 2053 usb_buffer_free(interface_to_usbdev(intf),
2083 AIPTEK_PACKET_LENGTH, 2054 AIPTEK_PACKET_LENGTH,