Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20220903051119.1332808-2-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+4 -18
+4 -18
drivers/input/mouse/psmouse-base.c
··· 94 94 (void *) offsetof(struct psmouse, resync_time), 95 95 psmouse_show_int_attr, psmouse_set_int_attr); 96 96 97 - static struct attribute *psmouse_attributes[] = { 97 + static struct attribute *psmouse_dev_attrs[] = { 98 98 &psmouse_attr_protocol.dattr.attr, 99 99 &psmouse_attr_rate.dattr.attr, 100 100 &psmouse_attr_resolution.dattr.attr, ··· 103 103 NULL 104 104 }; 105 105 106 - static const struct attribute_group psmouse_attribute_group = { 107 - .attrs = psmouse_attributes, 108 - }; 106 + ATTRIBUTE_GROUPS(psmouse_dev); 109 107 110 108 /* 111 109 * psmouse_mutex protects all operations changing state of mouse ··· 1479 1481 struct psmouse *psmouse = serio_get_drvdata(serio); 1480 1482 struct psmouse *parent = NULL; 1481 1483 1482 - sysfs_remove_group(&serio->dev.kobj, &psmouse_attribute_group); 1483 - 1484 1484 mutex_lock(&psmouse_mutex); 1485 1485 1486 1486 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); ··· 1643 1647 if (parent && parent->pt_activate) 1644 1648 parent->pt_activate(parent); 1645 1649 1646 - error = sysfs_create_group(&serio->dev.kobj, &psmouse_attribute_group); 1647 - if (error) 1648 - goto err_pt_deactivate; 1649 - 1650 1650 /* 1651 1651 * PS/2 devices having SMBus companions should stay disabled 1652 1652 * on PS/2 side, in order to have SMBus part operable. ··· 1658 1666 mutex_unlock(&psmouse_mutex); 1659 1667 return retval; 1660 1668 1661 - err_pt_deactivate: 1662 - if (parent && parent->pt_deactivate) 1663 - parent->pt_deactivate(parent); 1664 - if (input_dev) { 1665 - input_unregister_device(input_dev); 1666 - input_dev = NULL; /* so we don't try to free it below */ 1667 - } 1668 1669 err_protocol_disconnect: 1669 1670 if (psmouse->disconnect) 1670 1671 psmouse->disconnect(psmouse); ··· 1776 1791 1777 1792 static struct serio_driver psmouse_drv = { 1778 1793 .driver = { 1779 - .name = "psmouse", 1794 + .name = "psmouse", 1795 + .dev_groups = psmouse_dev_groups, 1780 1796 }, 1781 1797 .description = DRIVER_DESC, 1782 1798 .id_table = psmouse_serio_ids,