Commit f4e7a254 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: aiptek - switch to using dev_groups for driver-specific attributes

The driver core now has the ability to handle the creation and removal
of device-specific sysfs files, let's use it instead of registering and
unregistering attributes by hand.
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20220903051119.1332808-3-dmitry.torokhov@gmail.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent fd30a4ba
...@@ -1617,7 +1617,7 @@ static ssize_t show_firmwareCode(struct device *dev, struct device_attribute *at ...@@ -1617,7 +1617,7 @@ static ssize_t show_firmwareCode(struct device *dev, struct device_attribute *at
static DEVICE_ATTR(firmware_code, S_IRUGO, show_firmwareCode, NULL); static DEVICE_ATTR(firmware_code, S_IRUGO, show_firmwareCode, NULL);
static struct attribute *aiptek_attributes[] = { static struct attribute *aiptek_dev_attrs[] = {
&dev_attr_size.attr, &dev_attr_size.attr,
&dev_attr_pointer_mode.attr, &dev_attr_pointer_mode.attr,
&dev_attr_coordinate_mode.attr, &dev_attr_coordinate_mode.attr,
...@@ -1641,9 +1641,7 @@ static struct attribute *aiptek_attributes[] = { ...@@ -1641,9 +1641,7 @@ static struct attribute *aiptek_attributes[] = {
NULL NULL
}; };
static const struct attribute_group aiptek_attribute_group = { ATTRIBUTE_GROUPS(aiptek_dev);
.attrs = aiptek_attributes,
};
/*********************************************************************** /***********************************************************************
* This routine is called when a tablet has been identified. It basically * This routine is called when a tablet has been identified. It basically
...@@ -1842,26 +1840,16 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) ...@@ -1842,26 +1840,16 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
*/ */
usb_set_intfdata(intf, aiptek); usb_set_intfdata(intf, aiptek);
/* Set up the sysfs files
*/
err = sysfs_create_group(&intf->dev.kobj, &aiptek_attribute_group);
if (err) {
dev_warn(&intf->dev, "cannot create sysfs group err: %d\n",
err);
goto fail3;
}
/* Register the tablet as an Input Device /* Register the tablet as an Input Device
*/ */
err = input_register_device(aiptek->inputdev); err = input_register_device(aiptek->inputdev);
if (err) { if (err) {
dev_warn(&intf->dev, dev_warn(&intf->dev,
"input_register_device returned err: %d\n", err); "input_register_device returned err: %d\n", err);
goto fail4; goto fail3;
} }
return 0; return 0;
fail4: sysfs_remove_group(&intf->dev.kobj, &aiptek_attribute_group);
fail3: usb_free_urb(aiptek->urb); fail3: usb_free_urb(aiptek->urb);
fail2: usb_free_coherent(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data, fail2: usb_free_coherent(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data,
aiptek->data_dma); aiptek->data_dma);
...@@ -1886,7 +1874,6 @@ static void aiptek_disconnect(struct usb_interface *intf) ...@@ -1886,7 +1874,6 @@ static void aiptek_disconnect(struct usb_interface *intf)
*/ */
usb_kill_urb(aiptek->urb); usb_kill_urb(aiptek->urb);
input_unregister_device(aiptek->inputdev); input_unregister_device(aiptek->inputdev);
sysfs_remove_group(&intf->dev.kobj, &aiptek_attribute_group);
usb_free_urb(aiptek->urb); usb_free_urb(aiptek->urb);
usb_free_coherent(interface_to_usbdev(intf), usb_free_coherent(interface_to_usbdev(intf),
AIPTEK_PACKET_LENGTH, AIPTEK_PACKET_LENGTH,
...@@ -1900,6 +1887,7 @@ static struct usb_driver aiptek_driver = { ...@@ -1900,6 +1887,7 @@ static struct usb_driver aiptek_driver = {
.probe = aiptek_probe, .probe = aiptek_probe,
.disconnect = aiptek_disconnect, .disconnect = aiptek_disconnect,
.id_table = aiptek_ids, .id_table = aiptek_ids,
.dev_groups = aiptek_dev_groups,
}; };
module_usb_driver(aiptek_driver); module_usb_driver(aiptek_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment