Commit 97f2bedb authored by Dmitry Torokhov's avatar Dmitry Torokhov

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: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20230729005133.1095051-21-dmitry.torokhov@gmail.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 6cc3ecfd
...@@ -64,6 +64,7 @@ MODULE_DEVICE_TABLE(of, tsc2004_of_match); ...@@ -64,6 +64,7 @@ MODULE_DEVICE_TABLE(of, tsc2004_of_match);
static struct i2c_driver tsc2004_driver = { static struct i2c_driver tsc2004_driver = {
.driver = { .driver = {
.name = "tsc2004", .name = "tsc2004",
.dev_groups = tsc200x_groups,
.of_match_table = of_match_ptr(tsc2004_of_match), .of_match_table = of_match_ptr(tsc2004_of_match),
.pm = pm_sleep_ptr(&tsc200x_pm_ops), .pm = pm_sleep_ptr(&tsc200x_pm_ops),
}, },
......
...@@ -80,6 +80,7 @@ MODULE_DEVICE_TABLE(of, tsc2005_of_match); ...@@ -80,6 +80,7 @@ MODULE_DEVICE_TABLE(of, tsc2005_of_match);
static struct spi_driver tsc2005_driver = { static struct spi_driver tsc2005_driver = {
.driver = { .driver = {
.name = "tsc2005", .name = "tsc2005",
.dev_groups = tsc200x_groups,
.of_match_table = of_match_ptr(tsc2005_of_match), .of_match_table = of_match_ptr(tsc2005_of_match),
.pm = pm_sleep_ptr(&tsc200x_pm_ops), .pm = pm_sleep_ptr(&tsc200x_pm_ops),
}, },
......
...@@ -356,6 +356,12 @@ static const struct attribute_group tsc200x_attr_group = { ...@@ -356,6 +356,12 @@ static const struct attribute_group tsc200x_attr_group = {
.attrs = tsc200x_attrs, .attrs = tsc200x_attrs,
}; };
const struct attribute_group *tsc200x_groups[] = {
&tsc200x_attr_group,
NULL
};
EXPORT_SYMBOL_GPL(tsc200x_groups);
static void tsc200x_esd_work(struct work_struct *work) static void tsc200x_esd_work(struct work_struct *work)
{ {
struct tsc200x *ts = container_of(work, struct tsc200x, esd_work.work); struct tsc200x *ts = container_of(work, struct tsc200x, esd_work.work);
...@@ -553,25 +559,17 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, ...@@ -553,25 +559,17 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
return error; return error;
dev_set_drvdata(dev, ts); dev_set_drvdata(dev, ts);
error = sysfs_create_group(&dev->kobj, &tsc200x_attr_group);
if (error) {
dev_err(dev,
"Failed to create sysfs attributes, err: %d\n", error);
goto disable_regulator;
}
error = input_register_device(ts->idev); error = input_register_device(ts->idev);
if (error) { if (error) {
dev_err(dev, dev_err(dev,
"Failed to register input device, err: %d\n", error); "Failed to register input device, err: %d\n", error);
goto err_remove_sysfs; goto disable_regulator;
} }
irq_set_irq_wake(irq, 1); irq_set_irq_wake(irq, 1);
return 0; return 0;
err_remove_sysfs:
sysfs_remove_group(&dev->kobj, &tsc200x_attr_group);
disable_regulator: disable_regulator:
regulator_disable(ts->vio); regulator_disable(ts->vio);
return error; return error;
...@@ -582,8 +580,6 @@ void tsc200x_remove(struct device *dev) ...@@ -582,8 +580,6 @@ void tsc200x_remove(struct device *dev)
{ {
struct tsc200x *ts = dev_get_drvdata(dev); struct tsc200x *ts = dev_get_drvdata(dev);
sysfs_remove_group(&dev->kobj, &tsc200x_attr_group);
regulator_disable(ts->vio); regulator_disable(ts->vio);
} }
EXPORT_SYMBOL_GPL(tsc200x_remove); EXPORT_SYMBOL_GPL(tsc200x_remove);
......
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
extern const struct regmap_config tsc200x_regmap_config; extern const struct regmap_config tsc200x_regmap_config;
extern const struct dev_pm_ops tsc200x_pm_ops; extern const struct dev_pm_ops tsc200x_pm_ops;
extern const struct attribute_group *tsc200x_groups[];
int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
struct regmap *regmap, struct regmap *regmap,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment