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

Configure Feed

Select the types of activity you want to include in your feed.

Input: adxl34x - use device core to create driver-specific device attributes

Instead of creating driver-specific device attributes with
sysfs_create_group() have device core do this by setting up dev_groups
pointer in the driver structure.

Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Link: https://lore.kernel.org/r/20240610164301.1048482-1-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+10 -8
+1
drivers/input/misc/adxl34x-i2c.c
··· 132 132 static struct i2c_driver adxl34x_driver = { 133 133 .driver = { 134 134 .name = "adxl34x", 135 + .dev_groups = adxl34x_groups, 135 136 .pm = pm_sleep_ptr(&adxl34x_pm), 136 137 .of_match_table = adxl34x_of_id, 137 138 },
+1
drivers/input/misc/adxl34x-spi.c
··· 97 97 static struct spi_driver adxl34x_driver = { 98 98 .driver = { 99 99 .name = "adxl34x", 100 + .dev_groups = adxl34x_groups, 100 101 .pm = pm_sleep_ptr(&adxl34x_pm), 101 102 }, 102 103 .probe = adxl34x_spi_probe,
+7 -8
drivers/input/misc/adxl34x.c
··· 664 664 .attrs = adxl34x_attributes, 665 665 }; 666 666 667 + const struct attribute_group *adxl34x_groups[] = { 668 + &adxl34x_attr_group, 669 + NULL 670 + }; 671 + EXPORT_SYMBOL_GPL(adxl34x_groups); 672 + 667 673 static int adxl34x_input_open(struct input_dev *input) 668 674 { 669 675 struct adxl34x *ac = input_get_drvdata(input); ··· 829 823 goto err_free_mem; 830 824 } 831 825 832 - err = sysfs_create_group(&dev->kobj, &adxl34x_attr_group); 833 - if (err) 834 - goto err_free_irq; 835 - 836 826 err = input_register_device(input_dev); 837 827 if (err) 838 - goto err_remove_attr; 828 + goto err_free_irq; 839 829 840 830 AC_WRITE(ac, OFSX, pdata->x_axis_offset); 841 831 ac->hwcal.x = pdata->x_axis_offset; ··· 891 889 892 890 return ac; 893 891 894 - err_remove_attr: 895 - sysfs_remove_group(&dev->kobj, &adxl34x_attr_group); 896 892 err_free_irq: 897 893 free_irq(ac->irq, ac); 898 894 err_free_mem: ··· 903 903 904 904 void adxl34x_remove(struct adxl34x *ac) 905 905 { 906 - sysfs_remove_group(&ac->dev->kobj, &adxl34x_attr_group); 907 906 free_irq(ac->irq, ac); 908 907 input_unregister_device(ac->input); 909 908 dev_dbg(ac->dev, "unregistered accelerometer\n");
+1
drivers/input/misc/adxl34x.h
··· 26 26 void adxl34x_remove(struct adxl34x *ac); 27 27 28 28 extern const struct dev_pm_ops adxl34x_pm; 29 + extern const struct attribute_group *adxl34x_groups[]; 29 30 30 31 #endif