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

Input: tsc2004/5 - 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20230729005133.1095051-21-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+16 -17
+4 -3
drivers/input/touchscreen/tsc2004.c
··· 63 63 64 64 static struct i2c_driver tsc2004_driver = { 65 65 .driver = { 66 - .name = "tsc2004", 67 - .of_match_table = of_match_ptr(tsc2004_of_match), 68 - .pm = pm_sleep_ptr(&tsc200x_pm_ops), 66 + .name = "tsc2004", 67 + .dev_groups = tsc200x_groups, 68 + .of_match_table = of_match_ptr(tsc2004_of_match), 69 + .pm = pm_sleep_ptr(&tsc200x_pm_ops), 69 70 }, 70 71 .id_table = tsc2004_idtable, 71 72 .probe = tsc2004_probe,
+4 -3
drivers/input/touchscreen/tsc2005.c
··· 79 79 80 80 static struct spi_driver tsc2005_driver = { 81 81 .driver = { 82 - .name = "tsc2005", 83 - .of_match_table = of_match_ptr(tsc2005_of_match), 84 - .pm = pm_sleep_ptr(&tsc200x_pm_ops), 82 + .name = "tsc2005", 83 + .dev_groups = tsc200x_groups, 84 + .of_match_table = of_match_ptr(tsc2005_of_match), 85 + .pm = pm_sleep_ptr(&tsc200x_pm_ops), 85 86 }, 86 87 .probe = tsc2005_probe, 87 88 .remove = tsc2005_remove,
+7 -11
drivers/input/touchscreen/tsc200x-core.c
··· 356 356 .attrs = tsc200x_attrs, 357 357 }; 358 358 359 + const struct attribute_group *tsc200x_groups[] = { 360 + &tsc200x_attr_group, 361 + NULL 362 + }; 363 + EXPORT_SYMBOL_GPL(tsc200x_groups); 364 + 359 365 static void tsc200x_esd_work(struct work_struct *work) 360 366 { 361 367 struct tsc200x *ts = container_of(work, struct tsc200x, esd_work.work); ··· 559 553 return error; 560 554 561 555 dev_set_drvdata(dev, ts); 562 - error = sysfs_create_group(&dev->kobj, &tsc200x_attr_group); 563 - if (error) { 564 - dev_err(dev, 565 - "Failed to create sysfs attributes, err: %d\n", error); 566 - goto disable_regulator; 567 - } 568 556 569 557 error = input_register_device(ts->idev); 570 558 if (error) { 571 559 dev_err(dev, 572 560 "Failed to register input device, err: %d\n", error); 573 - goto err_remove_sysfs; 561 + goto disable_regulator; 574 562 } 575 563 576 564 irq_set_irq_wake(irq, 1); 577 565 return 0; 578 566 579 - err_remove_sysfs: 580 - sysfs_remove_group(&dev->kobj, &tsc200x_attr_group); 581 567 disable_regulator: 582 568 regulator_disable(ts->vio); 583 569 return error; ··· 579 581 void tsc200x_remove(struct device *dev) 580 582 { 581 583 struct tsc200x *ts = dev_get_drvdata(dev); 582 - 583 - sysfs_remove_group(&dev->kobj, &tsc200x_attr_group); 584 584 585 585 regulator_disable(ts->vio); 586 586 }
+1
drivers/input/touchscreen/tsc200x-core.h
··· 70 70 71 71 extern const struct regmap_config tsc200x_regmap_config; 72 72 extern const struct dev_pm_ops tsc200x_pm_ops; 73 + extern const struct attribute_group *tsc200x_groups[]; 73 74 74 75 int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, 75 76 struct regmap *regmap,