Input: atkbd - switch to using dev_groups for driver-specific attributes
Subsystems (2)
Dmitry Torokhov
maintainerPATCH 1/3 Input: atkbd - 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.
--- drivers/input/keyboard/atkbd.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/input/keyboard/atkbd.c +6 -10
@@ -323,11 +323,13 @@ static umode_t atkbd_attr_is_visible(struct kobject *kobj,return attr->mode; } -static struct attribute_group atkbd_attribute_group = { +static const struct attribute_group atkbd_attribute_group = { .attrs = atkbd_attributes, .is_visible = atkbd_attr_is_visible, }; +__ATTRIBUTE_GROUPS (atkbd_attribute); +static const unsigned int xl_table[] = {ATKBD_RET_BAT ,ATKBD_RET_ERR ,ATKBD_RET_ACK ,ATKBD_RET_NAK ,ATKBD_RET_HANJA ,ATKBD_RET_HANGEUL ,
@@ -922,8 +924,6 @@ static void atkbd_disconnect(struct serio *serio) {struct atkbd *atkbd =serio_get_drvdata (serio); -sysfs_remove_group (&serio->dev.kobj, &atkbd_attribute_group); -atkbd_disable (atkbd);input_unregister_device (atkbd->dev);
@@ -1271,21 +1271,16 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)atkbd_set_keycode_table (atkbd);atkbd_set_device_attrs (atkbd); - err =sysfs_create_group (&serio->dev.kobj, &atkbd_attribute_group); -if (err) - goto fail3; -atkbd_enable (atkbd);if (serio->write)atkbd_activate (atkbd); err =input_register_device (atkbd->dev);if (err) - goto fail4; + goto fail3;return 0 ; - fail4:sysfs_remove_group (&serio->dev.kobj, &atkbd_attribute_group); fail3:serio_close (serio); fail2:serio_set_drvdata (serio,NULL ); fail1:input_free_device (dev);
@@ -1378,7 +1373,8 @@ MODULE_DEVICE_TABLE(serio, atkbd_serio_ids);static struct serio_driver atkbd_drv = { .driver = { - .name ="atkbd" , + .name ="atkbd" , + .dev_groups = atkbd_attribute_groups, }, .description =DRIVER_DESC , .id_table = atkbd_serio_ids,
Signature · 1 line
2.37.2.789.g6183377224-goog
Dmitry Torokhov
maintainerPATCH 2/3 Input: psmouse - 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.
--- drivers/input/mouse/psmouse-base.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-)
drivers/input/mouse/psmouse-base.c +4 -18
@@ -94,7 +94,7 @@ PSMOUSE_DEFINE_ATTR(resync_time, S_IWUSR | S_IRUGO, (void *) offsetof(struct psmouse , resync_time), psmouse_show_int_attr, psmouse_set_int_attr); -static struct attribute *psmouse_attributes[] = { +static struct attribute *psmouse_dev_attrs[] = { &psmouse_attr_protocol.dattr.attr, &psmouse_attr_rate.dattr.attr, &psmouse_attr_resolution.dattr.attr,
@@ -103,9 +103,7 @@ static struct attribute *psmouse_attributes[] = { NULL }; -static const struct attribute_group psmouse_attribute_group = { - .attrs = psmouse_attributes, -}; +ATTRIBUTE_GROUPS (psmouse_dev);/* * psmouse_mutex protects all operations changing state of mouse
@@ -1481,8 +1479,6 @@ static void psmouse_disconnect(struct serio *serio)struct psmouse *psmouse =serio_get_drvdata (serio);struct psmouse *parent =NULL ; -sysfs_remove_group (&serio->dev.kobj, &psmouse_attribute_group); -mutex_lock (&psmouse_mutex);psmouse_set_state (psmouse,PSMOUSE_CMD_MODE );
@@ -1647,10 +1643,6 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)if (parent && parent->pt_activate) parent->pt_activate (parent); - error =sysfs_create_group (&serio->dev.kobj, &psmouse_attribute_group); -if (error) - goto err_pt_deactivate; -/* * PS/2 devices having SMBus companions should stay disabled * on PS/2 side, in order to have SMBus part operable.
@@ -1666,13 +1658,6 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)mutex_unlock (&psmouse_mutex);return retval; - err_pt_deactivate: -if (parent && parent->pt_deactivate) - parent->pt_deactivate (parent); -if (input_dev) { -input_unregister_device (input_dev); - input_dev =NULL ;/* so we don't try to free it below */ - } err_protocol_disconnect:if (psmouse->disconnect) psmouse->disconnect (psmouse);
@@ -1791,7 +1776,8 @@ MODULE_DEVICE_TABLE(serio, psmouse_serio_ids);static struct serio_driver psmouse_drv = { .driver = { - .name ="psmouse" , + .name ="psmouse" , + .dev_groups = psmouse_dev_groups, }, .description =DRIVER_DESC , .id_table = psmouse_serio_ids,
Signature · 1 line
2.37.2.789.g6183377224-goog
Re: [PATCH 2/3] Input: psmouse - switch to using dev_groups for driver-specific attributes
Quoted 5 lines · Dmitry Torokhov
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.
Signed-off-by Dmitry Torokhov <[email protected]>
Dmitry Torokhov
maintainerPATCH 3/3 Input: aiptek - switch to using dev_groups for driver-specific attributes
In reply to Dmitry TorokhovThe 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.
--- drivers/input/tablet/aiptek.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/input/tablet/aiptek.c +4 -16
@@ -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 struct attribute *aiptek_attributes[] = { +static struct attribute *aiptek_dev_attrs[] = { &dev_attr_size.attr, &dev_attr_pointer_mode.attr, &dev_attr_coordinate_mode.attr,
@@ -1641,9 +1641,7 @@ static struct attribute *aiptek_attributes[] = { NULL }; -static const struct attribute_group aiptek_attribute_group = { - .attrs = aiptek_attributes, -}; +ATTRIBUTE_GROUPS (aiptek_dev);/*********************************************************************** * 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)*/ 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 */ err =input_register_device (aiptek->inputdev);if (err) {dev_warn (&intf->dev,"input_register_device returned err: %d\n" , err); - goto fail4; + goto fail3; }return 0 ; - fail4:sysfs_remove_group (&intf->dev.kobj, &aiptek_attribute_group); fail3:usb_free_urb (aiptek->urb); fail2:usb_free_coherent (usbdev,AIPTEK_PACKET_LENGTH , aiptek->data, aiptek->data_dma);
@@ -1886,7 +1874,6 @@ static void aiptek_disconnect(struct usb_interface *intf)*/ usb_kill_urb (aiptek->urb);input_unregister_device (aiptek->inputdev); -sysfs_remove_group (&intf->dev.kobj, &aiptek_attribute_group);usb_free_urb (aiptek->urb); usb_free_coherent(interface_to_usbdev(intf), AIPTEK_PACKET_LENGTH,
@@ -1900,6 +1887,7 @@ static struct usb_driver aiptek_driver = { .probe = aiptek_probe, .disconnect = aiptek_disconnect, .id_table = aiptek_ids, + .dev_groups = aiptek_dev_groups, };module_usb_driver (aiptek_driver);
Signature · 1 line
2.37.2.789.g6183377224-goog
Re: [PATCH 3/3] Input: aiptek - switch to using dev_groups for driver-specific attributes
Quoted 8 lines · Dmitry Torokhov
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.
Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/input/tablet/aiptek.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
Quoted 8 lines · Dmitry Torokhov
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.
Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/input/keyboard/atkbd.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
Wow, I had missed these in my searches as I didn't think any drivers would be using sysfs_create_groups(), thanks for noticing them and cleaning these up.