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

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.

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

+6 -10
+6 -10
drivers/input/keyboard/atkbd.c
··· 323 323 return attr->mode; 324 324 } 325 325 326 - static struct attribute_group atkbd_attribute_group = { 326 + static const struct attribute_group atkbd_attribute_group = { 327 327 .attrs = atkbd_attributes, 328 328 .is_visible = atkbd_attr_is_visible, 329 329 }; 330 + 331 + __ATTRIBUTE_GROUPS(atkbd_attribute); 330 332 331 333 static const unsigned int xl_table[] = { 332 334 ATKBD_RET_BAT, ATKBD_RET_ERR, ATKBD_RET_ACK, ··· 924 922 { 925 923 struct atkbd *atkbd = serio_get_drvdata(serio); 926 924 927 - sysfs_remove_group(&serio->dev.kobj, &atkbd_attribute_group); 928 - 929 925 atkbd_disable(atkbd); 930 926 931 927 input_unregister_device(atkbd->dev); ··· 1271 1271 atkbd_set_keycode_table(atkbd); 1272 1272 atkbd_set_device_attrs(atkbd); 1273 1273 1274 - err = sysfs_create_group(&serio->dev.kobj, &atkbd_attribute_group); 1275 - if (err) 1276 - goto fail3; 1277 - 1278 1274 atkbd_enable(atkbd); 1279 1275 if (serio->write) 1280 1276 atkbd_activate(atkbd); 1281 1277 1282 1278 err = input_register_device(atkbd->dev); 1283 1279 if (err) 1284 - goto fail4; 1280 + goto fail3; 1285 1281 1286 1282 return 0; 1287 1283 1288 - fail4: sysfs_remove_group(&serio->dev.kobj, &atkbd_attribute_group); 1289 1284 fail3: serio_close(serio); 1290 1285 fail2: serio_set_drvdata(serio, NULL); 1291 1286 fail1: input_free_device(dev); ··· 1373 1378 1374 1379 static struct serio_driver atkbd_drv = { 1375 1380 .driver = { 1376 - .name = "atkbd", 1381 + .name = "atkbd", 1382 + .dev_groups = atkbd_attribute_groups, 1377 1383 }, 1378 1384 .description = DRIVER_DESC, 1379 1385 .id_table = atkbd_serio_ids,