Hi,
this patch series uses Dmitry's patch
57b8ff070f98 driver core: add devm_device_add_group() and friends
each of the 12 patches replaces the sysfs_create_group() function
with its managed version devm_device_add_group.
Andi
Andi Shyti (12):
Input: ad7897 - use managed devm_device_add_group
Input: ad7879 - use managed devm_device_add_group
Input: ads7846 - use managed devm_device_add_group
Input: atmel_mxt_ts - use managed devm_device_add_group
Input: edt-ft5x06 - use managed devm_device_add_group
Input: elants_i2c - use managed devm_device_add_group
Input: ili210x - use managed devm_device_add_group
Input: melfas_mip4 - use managed devm_device_add_group
Input: raydium_i2c_ts - use managed devm_device_add_group
Input: rohm_bu21023 - use managed devm_device_add_group
Input: tsc200x-core - use managed devm_device_add_group
Input: wdt87xx_i2c - use managed devm_device_add_group
drivers/input/touchscreen/ad7877.c | 8 ++------
drivers/input/touchscreen/ad7879.c | 13 +------------
drivers/input/touchscreen/ads7846.c | 8 ++------
drivers/input/touchscreen/atmel_mxt_ts.c | 3 +--
drivers/input/touchscreen/edt-ft5x06.c | 9 ++-------
drivers/input/touchscreen/elants_i2c.c | 19 +------------------
drivers/input/touchscreen/ili210x.c | 7 ++-----
drivers/input/touchscreen/melfas_mip4.c | 17 +----------------
drivers/input/touchscreen/raydium_i2c_ts.c | 18 +-----------------
drivers/input/touchscreen/rohm_bu21023.c | 17 +----------------
drivers/input/touchscreen/tsc200x-core.c | 8 ++------
drivers/input/touchscreen/wdt87xx_i2c.c | 4 +---
12 files changed, 17 insertions(+), 114 deletions(-)
--
2.14.2
Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
and friends") has added the the managed version for creating
sysfs group files.
Use devm_device_add_group instead of sysfs_create_group and
remove the relative sysfs_remove_group and goto label.
Signed-off-by: Andi Shyti <[email protected]>
---
drivers/input/touchscreen/ads7846.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index a2f45aefce08..597f4a2cca42 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -1416,13 +1416,13 @@ static int ads7846_probe(struct spi_device *spi)
else
(void) ads7846_read12_ser(&spi->dev, READ_12BIT_SER(vaux));
- err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group);
+ err = devm_device_add_group(&spi->dev, &ads784x_attr_group);
if (err)
goto err_remove_hwmon;
err = input_register_device(input_dev);
if (err)
- goto err_remove_attr_group;
+ goto err_remove_hwmon;
device_init_wakeup(&spi->dev, pdata->wakeup);
@@ -1435,8 +1435,6 @@ static int ads7846_probe(struct spi_device *spi)
return 0;
- err_remove_attr_group:
- sysfs_remove_group(&spi->dev.kobj, &ads784x_attr_group);
err_remove_hwmon:
ads784x_hwmon_unregister(spi, ts);
err_free_irq:
@@ -1462,8 +1460,6 @@ static int ads7846_remove(struct spi_device *spi)
{
struct ads7846 *ts = spi_get_drvdata(spi);
- sysfs_remove_group(&spi->dev.kobj, &ads784x_attr_group);
-
ads7846_disable(ts);
free_irq(ts->spi->irq, ts);
--
2.14.2
Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
and friends") has added the the managed version for creating
sysfs group files.
Use devm_device_add_group instead of sysfs_create_group and
remove the relative sysfs_remove_group and goto label.
CC: Michael Hennerich <[email protected]>
Signed-off-by: Andi Shyti <[email protected]>
---
drivers/input/touchscreen/ad7877.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c
index 9c250ae780d9..677ba38b4d1c 100644
--- a/drivers/input/touchscreen/ad7877.c
+++ b/drivers/input/touchscreen/ad7877.c
@@ -783,18 +783,16 @@ static int ad7877_probe(struct spi_device *spi)
goto err_free_mem;
}
- err = sysfs_create_group(&spi->dev.kobj, &ad7877_attr_group);
+ err = devm_device_add_group(&spi->dev, &ad7877_attr_group);
if (err)
goto err_free_irq;
err = input_register_device(input_dev);
if (err)
- goto err_remove_attr_group;
+ goto err_free_irq;
return 0;
-err_remove_attr_group:
- sysfs_remove_group(&spi->dev.kobj, &ad7877_attr_group);
err_free_irq:
free_irq(spi->irq, ts);
err_free_mem:
@@ -807,8 +805,6 @@ static int ad7877_remove(struct spi_device *spi)
{
struct ad7877 *ts = spi_get_drvdata(spi);
- sysfs_remove_group(&spi->dev.kobj, &ad7877_attr_group);
-
ad7877_disable(ts);
free_irq(ts->spi->irq, ts);
--
2.14.2
Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
and friends") has added the the managed version for creating
sysfs group files.
Use devm_device_add_group instead of sysfs_create_group and
remove the action that cleans the sysfs file when exiting the
driver.
Signed-off-by: Andi Shyti <[email protected]>
---
drivers/input/touchscreen/rohm_bu21023.c | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/drivers/input/touchscreen/rohm_bu21023.c b/drivers/input/touchscreen/rohm_bu21023.c
index eeaf6ff03597..bda0500c9b57 100644
--- a/drivers/input/touchscreen/rohm_bu21023.c
+++ b/drivers/input/touchscreen/rohm_bu21023.c
@@ -1103,13 +1103,6 @@ static void rohm_ts_close(struct input_dev *input_dev)
ts->initialized = false;
}
-static void rohm_ts_remove_sysfs_group(void *_dev)
-{
- struct device *dev = _dev;
-
- sysfs_remove_group(&dev->kobj, &rohm_ts_attr_group);
-}
-
static int rohm_bu21023_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -1180,20 +1173,12 @@ static int rohm_bu21023_i2c_probe(struct i2c_client *client,
return error;
}
- error = sysfs_create_group(&dev->kobj, &rohm_ts_attr_group);
+ error = devm_device_add_group(dev, &rohm_ts_attr_group);
if (error) {
dev_err(dev, "failed to create sysfs group: %d\n", error);
return error;
}
- error = devm_add_action(dev, rohm_ts_remove_sysfs_group, dev);
- if (error) {
- rohm_ts_remove_sysfs_group(dev);
- dev_err(dev, "Failed to add sysfs cleanup action: %d\n",
- error);
- return error;
- }
-
return error;
}
--
2.14.2
Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
and friends") has added the the managed version for creating
sysfs group files.
Use devm_device_add_group instead of sysfs_create_group and
remove the relative sysfs_remove_group and goto label.
Signed-off-by: Andi Shyti <[email protected]>
---
drivers/input/touchscreen/tsc200x-core.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c
index 88ea5e1b72ae..caec24265d78 100644
--- a/drivers/input/touchscreen/tsc200x-core.c
+++ b/drivers/input/touchscreen/tsc200x-core.c
@@ -559,7 +559,7 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
return error;
dev_set_drvdata(dev, ts);
- error = sysfs_create_group(&dev->kobj, &tsc200x_attr_group);
+ error = devm_device_add_group(dev, &tsc200x_attr_group);
if (error) {
dev_err(dev,
"Failed to create sysfs attributes, err: %d\n", error);
@@ -570,14 +570,12 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
if (error) {
dev_err(dev,
"Failed to register input device, err: %d\n", error);
- goto err_remove_sysfs;
+ goto disable_regulator;
}
irq_set_irq_wake(irq, 1);
return 0;
-err_remove_sysfs:
- sysfs_remove_group(&dev->kobj, &tsc200x_attr_group);
disable_regulator:
regulator_disable(ts->vio);
return error;
@@ -588,8 +586,6 @@ int tsc200x_remove(struct device *dev)
{
struct tsc200x *ts = dev_get_drvdata(dev);
- sysfs_remove_group(&dev->kobj, &tsc200x_attr_group);
-
regulator_disable(ts->vio);
return 0;
--
2.14.2
Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
and friends") has added the the managed version for creating
sysfs group files.
Use devm_device_add_group instead of sysfs_create_group and
remove the relative sysfs_remove_group and goto label.
Signed-off-by: Andi Shyti <[email protected]>
---
drivers/input/touchscreen/ili210x.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
index 6f76eeedf465..03a6aca2941f 100644
--- a/drivers/input/touchscreen/ili210x.c
+++ b/drivers/input/touchscreen/ili210x.c
@@ -266,7 +266,7 @@ static int ili210x_i2c_probe(struct i2c_client *client,
goto err_free_mem;
}
- error = sysfs_create_group(&dev->kobj, &ili210x_attr_group);
+ error = devm_device_add_group(dev, &ili210x_attr_group);
if (error) {
dev_err(dev, "Unable to create sysfs attributes, err: %d\n",
error);
@@ -276,7 +276,7 @@ static int ili210x_i2c_probe(struct i2c_client *client,
error = input_register_device(priv->input);
if (error) {
dev_err(dev, "Cannot register input device, err: %d\n", error);
- goto err_remove_sysfs;
+ goto err_free_irq;
}
device_init_wakeup(dev, 1);
@@ -287,8 +287,6 @@ static int ili210x_i2c_probe(struct i2c_client *client,
return 0;
-err_remove_sysfs:
- sysfs_remove_group(&dev->kobj, &ili210x_attr_group);
err_free_irq:
free_irq(client->irq, priv);
err_free_mem:
@@ -301,7 +299,6 @@ static int ili210x_i2c_remove(struct i2c_client *client)
{
struct ili210x *priv = i2c_get_clientdata(client);
- sysfs_remove_group(&client->dev.kobj, &ili210x_attr_group);
free_irq(priv->client->irq, priv);
cancel_delayed_work_sync(&priv->dwork);
input_unregister_device(priv->input);
--
2.14.2
Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
and friends") has added the the managed version for creating
sysfs group files.
Use devm_device_add_group instead of sysfs_create_group and
remove the action that cleans the sysfs file when exiting the
driver.
CC: Michael Hennerich <[email protected]>
Signed-off-by: Andi Shyti <[email protected]>
---
drivers/input/touchscreen/ad7879.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
index 196028c45210..7d74a0ae2c94 100644
--- a/drivers/input/touchscreen/ad7879.c
+++ b/drivers/input/touchscreen/ad7879.c
@@ -524,13 +524,6 @@ static int ad7879_parse_dt(struct device *dev, struct ad7879 *ts)
return 0;
}
-static void ad7879_cleanup_sysfs(void *_ts)
-{
- struct ad7879 *ts = _ts;
-
- sysfs_remove_group(&ts->dev->kobj, &ad7879_attr_group);
-}
-
int ad7879_probe(struct device *dev, struct regmap *regmap,
int irq, u16 bustype, u8 devid)
{
@@ -658,11 +651,7 @@ int ad7879_probe(struct device *dev, struct regmap *regmap,
__ad7879_disable(ts);
- err = sysfs_create_group(&dev->kobj, &ad7879_attr_group);
- if (err)
- return err;
-
- err = devm_add_action_or_reset(dev, ad7879_cleanup_sysfs, ts);
+ err = devm_device_add_group(dev, &ad7879_attr_group);
if (err)
return err;
--
2.14.2
Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
and friends") has added the the managed version for creating
sysfs group files.
Use devm_device_add_group instead of sysfs_create_group and
remove the action that cleans the sysfs file when exiting the
driver.
CC: Sangwon Jee <[email protected]>
Signed-off-by: Andi Shyti <[email protected]>
---
drivers/input/touchscreen/melfas_mip4.c | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c
index 05108c2fea93..6892f0e28918 100644
--- a/drivers/input/touchscreen/melfas_mip4.c
+++ b/drivers/input/touchscreen/melfas_mip4.c
@@ -1433,13 +1433,6 @@ static const struct attribute_group mip4_attr_group = {
.attrs = mip4_attrs,
};
-static void mip4_sysfs_remove(void *_data)
-{
- struct mip4_ts *ts = _data;
-
- sysfs_remove_group(&ts->client->dev.kobj, &mip4_attr_group);
-}
-
static int mip4_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
struct mip4_ts *ts;
@@ -1535,21 +1528,13 @@ static int mip4_probe(struct i2c_client *client, const struct i2c_device_id *id)
return error;
}
- error = sysfs_create_group(&client->dev.kobj, &mip4_attr_group);
+ error = devm_device_add_group(&client->dev, &mip4_attr_group);
if (error) {
dev_err(&client->dev,
"Failed to create sysfs attribute group: %d\n", error);
return error;
}
- error = devm_add_action(&client->dev, mip4_sysfs_remove, ts);
- if (error) {
- mip4_sysfs_remove(ts);
- dev_err(&client->dev,
- "Failed to install sysfs remoce action: %d\n", error);
- return error;
- }
-
return 0;
}
--
2.14.2
Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
and friends") has added the the managed version for creating
sysfs group files.
Use devm_device_add_group instead of sysfs_create_group.
CC: Nick Dyer <[email protected]>
Signed-off-by: Andi Shyti <[email protected]>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 7659bc48f1db..e5968f136f08 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -3170,7 +3170,7 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
if (error)
return error;
- error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group);
+ error = devm_device_add_group(&client->dev, &mxt_attr_group);
if (error) {
dev_err(&client->dev, "Failure %d creating sysfs group\n",
error);
@@ -3190,7 +3190,6 @@ static int mxt_remove(struct i2c_client *client)
struct mxt_data *data = i2c_get_clientdata(client);
disable_irq(data->irq);
- sysfs_remove_group(&client->dev.kobj, &mxt_attr_group);
mxt_free_input_device(data);
mxt_free_object_table(data);
--
2.14.2
Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
and friends") has added the the managed version for creating
sysfs group files.
Use devm_device_add_group instead of sysfs_create_group and
remove the relative sysfs_remove_group.
Signed-off-by: Andi Shyti <[email protected]>
---
drivers/input/touchscreen/wdt87xx_i2c.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/input/touchscreen/wdt87xx_i2c.c b/drivers/input/touchscreen/wdt87xx_i2c.c
index a9132603ab34..b866cc88d942 100644
--- a/drivers/input/touchscreen/wdt87xx_i2c.c
+++ b/drivers/input/touchscreen/wdt87xx_i2c.c
@@ -1106,7 +1106,7 @@ static int wdt87xx_ts_probe(struct i2c_client *client,
return error;
}
- error = sysfs_create_group(&client->dev.kobj, &wdt87xx_attr_group);
+ error = devm_device_add_group(&client->dev, &wdt87xx_attr_group);
if (error) {
dev_err(&client->dev, "create sysfs failed: %d\n", error);
return error;
@@ -1117,8 +1117,6 @@ static int wdt87xx_ts_probe(struct i2c_client *client,
static int wdt87xx_ts_remove(struct i2c_client *client)
{
- sysfs_remove_group(&client->dev.kobj, &wdt87xx_attr_group);
-
return 0;
}
--
2.14.2
Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
and friends") has added the the managed version for creating
sysfs group files.
Use devm_device_add_group instead of sysfs_create_group and
remove the action that cleans the sysfs file when exiting the
driver.
Signed-off-by: Andi Shyti <[email protected]>
---
drivers/input/touchscreen/raydium_i2c_ts.c | 18 +-----------------
1 file changed, 1 insertion(+), 17 deletions(-)
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c
index 4f1d3fd5d412..100538d64fff 100644
--- a/drivers/input/touchscreen/raydium_i2c_ts.c
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -943,13 +943,6 @@ static const struct attribute_group raydium_i2c_attribute_group = {
.attrs = raydium_i2c_attributes,
};
-static void raydium_i2c_remove_sysfs_group(void *_data)
-{
- struct raydium_data *ts = _data;
-
- sysfs_remove_group(&ts->client->dev.kobj, &raydium_i2c_attribute_group);
-}
-
static int raydium_i2c_power_on(struct raydium_data *ts)
{
int error;
@@ -1120,7 +1113,7 @@ static int raydium_i2c_probe(struct i2c_client *client,
return error;
}
- error = sysfs_create_group(&client->dev.kobj,
+ error = devm_device_add_group(&client->dev,
&raydium_i2c_attribute_group);
if (error) {
dev_err(&client->dev, "failed to create sysfs attributes: %d\n",
@@ -1128,15 +1121,6 @@ static int raydium_i2c_probe(struct i2c_client *client,
return error;
}
- error = devm_add_action(&client->dev,
- raydium_i2c_remove_sysfs_group, ts);
- if (error) {
- raydium_i2c_remove_sysfs_group(ts);
- dev_err(&client->dev,
- "Failed to add sysfs cleanup action: %d\n", error);
- return error;
- }
-
return 0;
}
--
2.14.2
Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
and friends") has added the the managed version for creating
sysfs group files.
Use devm_device_add_group instead of sysfs_create_group and
remove the relative sysfs_remove_group and goto label.
Signed-off-by: Andi Shyti <[email protected]>
---
drivers/input/touchscreen/edt-ft5x06.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 5bf63f76ddda..f879d14f7ffc 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -998,13 +998,13 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
return error;
}
- error = sysfs_create_group(&client->dev.kobj, &edt_ft5x06_attr_group);
+ error = devm_device_add_group(&client->dev, &edt_ft5x06_attr_group);
if (error)
return error;
error = input_register_device(input);
if (error)
- goto err_remove_attrs;
+ return error;
edt_ft5x06_ts_prepare_debugfs(tsdata, dev_driver_string(&client->dev));
device_init_wakeup(&client->dev, 1);
@@ -1016,10 +1016,6 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1);
return 0;
-
-err_remove_attrs:
- sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group);
- return error;
}
static int edt_ft5x06_ts_remove(struct i2c_client *client)
@@ -1027,7 +1023,6 @@ static int edt_ft5x06_ts_remove(struct i2c_client *client)
struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client);
edt_ft5x06_ts_teardown_debugfs(tsdata);
- sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group);
return 0;
}
--
2.14.2
Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
and friends") has added the the managed version for creating
sysfs group files.
Use devm_device_add_group instead of sysfs_create_group and
remove the action that cleans the sysfs file when exiting the
driver.
Signed-off-by: Andi Shyti <[email protected]>
---
drivers/input/touchscreen/elants_i2c.c | 19 +------------------
1 file changed, 1 insertion(+), 18 deletions(-)
diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index 0f4cda7282a2..e102d7764bc2 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -1070,13 +1070,6 @@ static const struct attribute_group elants_attribute_group = {
.attrs = elants_attributes,
};
-static void elants_i2c_remove_sysfs_group(void *_data)
-{
- struct elants_data *ts = _data;
-
- sysfs_remove_group(&ts->client->dev.kobj, &elants_attribute_group);
-}
-
static int elants_i2c_power_on(struct elants_data *ts)
{
int error;
@@ -1289,23 +1282,13 @@ static int elants_i2c_probe(struct i2c_client *client,
if (!client->dev.of_node)
device_init_wakeup(&client->dev, true);
- error = sysfs_create_group(&client->dev.kobj, &elants_attribute_group);
+ error = devm_device_add_group(&client->dev, &elants_attribute_group);
if (error) {
dev_err(&client->dev, "failed to create sysfs attributes: %d\n",
error);
return error;
}
- error = devm_add_action(&client->dev,
- elants_i2c_remove_sysfs_group, ts);
- if (error) {
- elants_i2c_remove_sysfs_group(ts);
- dev_err(&client->dev,
- "Failed to add sysfs cleanup action: %d\n",
- error);
- return error;
- }
-
return 0;
}
--
2.14.2
Hi Andi,
On Sat, Sep 30, 2017 at 05:38:28AM +0900, Andi Shyti wrote:
> Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
> and friends") has added the the managed version for creating
> sysfs group files.
>
> Use devm_device_add_group instead of sysfs_create_group and
> remove the relative sysfs_remove_group and goto label.
>
> CC: Michael Hennerich <[email protected]>
> Signed-off-by: Andi Shyti <[email protected]>
> ---
> drivers/input/touchscreen/ad7877.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c
> index 9c250ae780d9..677ba38b4d1c 100644
> --- a/drivers/input/touchscreen/ad7877.c
> +++ b/drivers/input/touchscreen/ad7877.c
> @@ -783,18 +783,16 @@ static int ad7877_probe(struct spi_device *spi)
> goto err_free_mem;
> }
>
> - err = sysfs_create_group(&spi->dev.kobj, &ad7877_attr_group);
> + err = devm_device_add_group(&spi->dev, &ad7877_attr_group);
This changes order of operations and ultimately may cause use-after-free
as memory for ad7877 structure will be freed before we remove
attributes.
> if (err)
> goto err_free_irq;
>
> err = input_register_device(input_dev);
> if (err)
> - goto err_remove_attr_group;
> + goto err_free_irq;
>
> return 0;
>
> -err_remove_attr_group:
> - sysfs_remove_group(&spi->dev.kobj, &ad7877_attr_group);
> err_free_irq:
> free_irq(spi->irq, ts);
> err_free_mem:
> @@ -807,8 +805,6 @@ static int ad7877_remove(struct spi_device *spi)
> {
> struct ad7877 *ts = spi_get_drvdata(spi);
>
> - sysfs_remove_group(&spi->dev.kobj, &ad7877_attr_group);
> -
> ad7877_disable(ts);
> free_irq(ts->spi->irq, ts);
>
> --
> 2.14.2
>
Thanks.
--
Dmitry
On Sat, Sep 30, 2017 at 05:38:33AM +0900, Andi Shyti wrote:
> Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
> and friends") has added the the managed version for creating
> sysfs group files.
>
> Use devm_device_add_group instead of sysfs_create_group and
> remove the action that cleans the sysfs file when exiting the
> driver.
>
> Signed-off-by: Andi Shyti <[email protected]>
Applied, thank you.
> ---
> drivers/input/touchscreen/elants_i2c.c | 19 +------------------
> 1 file changed, 1 insertion(+), 18 deletions(-)
>
> diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
> index 0f4cda7282a2..e102d7764bc2 100644
> --- a/drivers/input/touchscreen/elants_i2c.c
> +++ b/drivers/input/touchscreen/elants_i2c.c
> @@ -1070,13 +1070,6 @@ static const struct attribute_group elants_attribute_group = {
> .attrs = elants_attributes,
> };
>
> -static void elants_i2c_remove_sysfs_group(void *_data)
> -{
> - struct elants_data *ts = _data;
> -
> - sysfs_remove_group(&ts->client->dev.kobj, &elants_attribute_group);
> -}
> -
> static int elants_i2c_power_on(struct elants_data *ts)
> {
> int error;
> @@ -1289,23 +1282,13 @@ static int elants_i2c_probe(struct i2c_client *client,
> if (!client->dev.of_node)
> device_init_wakeup(&client->dev, true);
>
> - error = sysfs_create_group(&client->dev.kobj, &elants_attribute_group);
> + error = devm_device_add_group(&client->dev, &elants_attribute_group);
> if (error) {
> dev_err(&client->dev, "failed to create sysfs attributes: %d\n",
> error);
> return error;
> }
>
> - error = devm_add_action(&client->dev,
> - elants_i2c_remove_sysfs_group, ts);
> - if (error) {
> - elants_i2c_remove_sysfs_group(ts);
> - dev_err(&client->dev,
> - "Failed to add sysfs cleanup action: %d\n",
> - error);
> - return error;
> - }
> -
> return 0;
> }
>
> --
> 2.14.2
>
--
Dmitry
On Sat, Sep 30, 2017 at 05:38:35AM +0900, Andi Shyti wrote:
> Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
> and friends") has added the the managed version for creating
> sysfs group files.
>
> Use devm_device_add_group instead of sysfs_create_group and
> remove the action that cleans the sysfs file when exiting the
> driver.
>
> CC: Sangwon Jee <[email protected]>
> Signed-off-by: Andi Shyti <[email protected]>
Applied, thank you.
> ---
> drivers/input/touchscreen/melfas_mip4.c | 17 +----------------
> 1 file changed, 1 insertion(+), 16 deletions(-)
>
> diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c
> index 05108c2fea93..6892f0e28918 100644
> --- a/drivers/input/touchscreen/melfas_mip4.c
> +++ b/drivers/input/touchscreen/melfas_mip4.c
> @@ -1433,13 +1433,6 @@ static const struct attribute_group mip4_attr_group = {
> .attrs = mip4_attrs,
> };
>
> -static void mip4_sysfs_remove(void *_data)
> -{
> - struct mip4_ts *ts = _data;
> -
> - sysfs_remove_group(&ts->client->dev.kobj, &mip4_attr_group);
> -}
> -
> static int mip4_probe(struct i2c_client *client, const struct i2c_device_id *id)
> {
> struct mip4_ts *ts;
> @@ -1535,21 +1528,13 @@ static int mip4_probe(struct i2c_client *client, const struct i2c_device_id *id)
> return error;
> }
>
> - error = sysfs_create_group(&client->dev.kobj, &mip4_attr_group);
> + error = devm_device_add_group(&client->dev, &mip4_attr_group);
> if (error) {
> dev_err(&client->dev,
> "Failed to create sysfs attribute group: %d\n", error);
> return error;
> }
>
> - error = devm_add_action(&client->dev, mip4_sysfs_remove, ts);
> - if (error) {
> - mip4_sysfs_remove(ts);
> - dev_err(&client->dev,
> - "Failed to install sysfs remoce action: %d\n", error);
> - return error;
> - }
> -
> return 0;
> }
>
> --
> 2.14.2
>
--
Dmitry
On Sat, Sep 30, 2017 at 05:38:36AM +0900, Andi Shyti wrote:
> Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
> and friends") has added the the managed version for creating
> sysfs group files.
>
> Use devm_device_add_group instead of sysfs_create_group and
> remove the action that cleans the sysfs file when exiting the
> driver.
>
> Signed-off-by: Andi Shyti <[email protected]>
Applied, thank you.
> ---
> drivers/input/touchscreen/raydium_i2c_ts.c | 18 +-----------------
> 1 file changed, 1 insertion(+), 17 deletions(-)
>
> diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c
> index 4f1d3fd5d412..100538d64fff 100644
> --- a/drivers/input/touchscreen/raydium_i2c_ts.c
> +++ b/drivers/input/touchscreen/raydium_i2c_ts.c
> @@ -943,13 +943,6 @@ static const struct attribute_group raydium_i2c_attribute_group = {
> .attrs = raydium_i2c_attributes,
> };
>
> -static void raydium_i2c_remove_sysfs_group(void *_data)
> -{
> - struct raydium_data *ts = _data;
> -
> - sysfs_remove_group(&ts->client->dev.kobj, &raydium_i2c_attribute_group);
> -}
> -
> static int raydium_i2c_power_on(struct raydium_data *ts)
> {
> int error;
> @@ -1120,7 +1113,7 @@ static int raydium_i2c_probe(struct i2c_client *client,
> return error;
> }
>
> - error = sysfs_create_group(&client->dev.kobj,
> + error = devm_device_add_group(&client->dev,
> &raydium_i2c_attribute_group);
> if (error) {
> dev_err(&client->dev, "failed to create sysfs attributes: %d\n",
> @@ -1128,15 +1121,6 @@ static int raydium_i2c_probe(struct i2c_client *client,
> return error;
> }
>
> - error = devm_add_action(&client->dev,
> - raydium_i2c_remove_sysfs_group, ts);
> - if (error) {
> - raydium_i2c_remove_sysfs_group(ts);
> - dev_err(&client->dev,
> - "Failed to add sysfs cleanup action: %d\n", error);
> - return error;
> - }
> -
> return 0;
> }
>
> --
> 2.14.2
>
--
Dmitry
On Sat, Sep 30, 2017 at 05:38:37AM +0900, Andi Shyti wrote:
> Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
> and friends") has added the the managed version for creating
> sysfs group files.
>
> Use devm_device_add_group instead of sysfs_create_group and
> remove the action that cleans the sysfs file when exiting the
> driver.
>
> Signed-off-by: Andi Shyti <[email protected]>
Applied, thank you.
> ---
> drivers/input/touchscreen/rohm_bu21023.c | 17 +----------------
> 1 file changed, 1 insertion(+), 16 deletions(-)
>
> diff --git a/drivers/input/touchscreen/rohm_bu21023.c b/drivers/input/touchscreen/rohm_bu21023.c
> index eeaf6ff03597..bda0500c9b57 100644
> --- a/drivers/input/touchscreen/rohm_bu21023.c
> +++ b/drivers/input/touchscreen/rohm_bu21023.c
> @@ -1103,13 +1103,6 @@ static void rohm_ts_close(struct input_dev *input_dev)
> ts->initialized = false;
> }
>
> -static void rohm_ts_remove_sysfs_group(void *_dev)
> -{
> - struct device *dev = _dev;
> -
> - sysfs_remove_group(&dev->kobj, &rohm_ts_attr_group);
> -}
> -
> static int rohm_bu21023_i2c_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> @@ -1180,20 +1173,12 @@ static int rohm_bu21023_i2c_probe(struct i2c_client *client,
> return error;
> }
>
> - error = sysfs_create_group(&dev->kobj, &rohm_ts_attr_group);
> + error = devm_device_add_group(dev, &rohm_ts_attr_group);
> if (error) {
> dev_err(dev, "failed to create sysfs group: %d\n", error);
> return error;
> }
>
> - error = devm_add_action(dev, rohm_ts_remove_sysfs_group, dev);
> - if (error) {
> - rohm_ts_remove_sysfs_group(dev);
> - dev_err(dev, "Failed to add sysfs cleanup action: %d\n",
> - error);
> - return error;
> - }
> -
> return error;
> }
>
> --
> 2.14.2
>
--
Dmitry
On Sat, Sep 30, 2017 at 05:38:39AM +0900, Andi Shyti wrote:
> Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
> and friends") has added the the managed version for creating
> sysfs group files.
>
> Use devm_device_add_group instead of sysfs_create_group and
> remove the relative sysfs_remove_group.
>
> Signed-off-by: Andi Shyti <[email protected]>
Applied, thank you.
> ---
> drivers/input/touchscreen/wdt87xx_i2c.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/input/touchscreen/wdt87xx_i2c.c b/drivers/input/touchscreen/wdt87xx_i2c.c
> index a9132603ab34..b866cc88d942 100644
> --- a/drivers/input/touchscreen/wdt87xx_i2c.c
> +++ b/drivers/input/touchscreen/wdt87xx_i2c.c
> @@ -1106,7 +1106,7 @@ static int wdt87xx_ts_probe(struct i2c_client *client,
> return error;
> }
>
> - error = sysfs_create_group(&client->dev.kobj, &wdt87xx_attr_group);
> + error = devm_device_add_group(&client->dev, &wdt87xx_attr_group);
> if (error) {
> dev_err(&client->dev, "create sysfs failed: %d\n", error);
> return error;
> @@ -1117,8 +1117,6 @@ static int wdt87xx_ts_probe(struct i2c_client *client,
>
> static int wdt87xx_ts_remove(struct i2c_client *client)
> {
> - sysfs_remove_group(&client->dev.kobj, &wdt87xx_attr_group);
> -
> return 0;
> }
>
> --
> 2.14.2
>
--
Dmitry
On Sat, Sep 30, 2017 at 05:38:32AM +0900, Andi Shyti wrote:
> Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
> and friends") has added the the managed version for creating
> sysfs group files.
>
> Use devm_device_add_group instead of sysfs_create_group and
> remove the relative sysfs_remove_group and goto label.
>
> Signed-off-by: Andi Shyti <[email protected]>
Applied, thank you.
> ---
> drivers/input/touchscreen/edt-ft5x06.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
> index 5bf63f76ddda..f879d14f7ffc 100644
> --- a/drivers/input/touchscreen/edt-ft5x06.c
> +++ b/drivers/input/touchscreen/edt-ft5x06.c
> @@ -998,13 +998,13 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
> return error;
> }
>
> - error = sysfs_create_group(&client->dev.kobj, &edt_ft5x06_attr_group);
> + error = devm_device_add_group(&client->dev, &edt_ft5x06_attr_group);
> if (error)
> return error;
>
> error = input_register_device(input);
> if (error)
> - goto err_remove_attrs;
> + return error;
>
> edt_ft5x06_ts_prepare_debugfs(tsdata, dev_driver_string(&client->dev));
> device_init_wakeup(&client->dev, 1);
> @@ -1016,10 +1016,6 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
> tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1);
>
> return 0;
> -
> -err_remove_attrs:
> - sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group);
> - return error;
> }
>
> static int edt_ft5x06_ts_remove(struct i2c_client *client)
> @@ -1027,7 +1023,6 @@ static int edt_ft5x06_ts_remove(struct i2c_client *client)
> struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client);
>
> edt_ft5x06_ts_teardown_debugfs(tsdata);
> - sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group);
>
> return 0;
> }
> --
> 2.14.2
>
--
Dmitry
On Sat, Sep 30, 2017 at 05:38:38AM +0900, Andi Shyti wrote:
> Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
> and friends") has added the the managed version for creating
> sysfs group files.
>
> Use devm_device_add_group instead of sysfs_create_group and
> remove the relative sysfs_remove_group and goto label.
>
> Signed-off-by: Andi Shyti <[email protected]>
> ---
> drivers/input/touchscreen/tsc200x-core.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c
> index 88ea5e1b72ae..caec24265d78 100644
> --- a/drivers/input/touchscreen/tsc200x-core.c
> +++ b/drivers/input/touchscreen/tsc200x-core.c
> @@ -559,7 +559,7 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
> return error;
>
> dev_set_drvdata(dev, ts);
> - error = sysfs_create_group(&dev->kobj, &tsc200x_attr_group);
> + error = devm_device_add_group(dev, &tsc200x_attr_group);
> if (error) {
> dev_err(dev,
> "Failed to create sysfs attributes, err: %d\n", error);
> @@ -570,14 +570,12 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
> if (error) {
> dev_err(dev,
> "Failed to register input device, err: %d\n", error);
> - goto err_remove_sysfs;
> + goto disable_regulator;
> }
>
> irq_set_irq_wake(irq, 1);
> return 0;
>
> -err_remove_sysfs:
> - sysfs_remove_group(&dev->kobj, &tsc200x_attr_group);
> disable_regulator:
> regulator_disable(ts->vio);
> return error;
> @@ -588,8 +586,6 @@ int tsc200x_remove(struct device *dev)
> {
> struct tsc200x *ts = dev_get_drvdata(dev);
>
> - sysfs_remove_group(&dev->kobj, &tsc200x_attr_group);
> -
Wrong ordering now, you do not want to be accessing the device when it
is powered down.
> regulator_disable(ts->vio);
>
> return 0;
> --
> 2.14.2
>
Thanks.
--
Dmitry
On Sat, Sep 30, 2017 at 05:38:34AM +0900, Andi Shyti wrote:
> Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
> and friends") has added the the managed version for creating
> sysfs group files.
>
> Use devm_device_add_group instead of sysfs_create_group and
> remove the relative sysfs_remove_group and goto label.
>
> Signed-off-by: Andi Shyti <[email protected]>
> ---
> drivers/input/touchscreen/ili210x.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
> index 6f76eeedf465..03a6aca2941f 100644
> --- a/drivers/input/touchscreen/ili210x.c
> +++ b/drivers/input/touchscreen/ili210x.c
> @@ -266,7 +266,7 @@ static int ili210x_i2c_probe(struct i2c_client *client,
> goto err_free_mem;
> }
>
> - error = sysfs_create_group(&dev->kobj, &ili210x_attr_group);
> + error = devm_device_add_group(dev, &ili210x_attr_group);
> if (error) {
> dev_err(dev, "Unable to create sysfs attributes, err: %d\n",
> error);
> @@ -276,7 +276,7 @@ static int ili210x_i2c_probe(struct i2c_client *client,
> error = input_register_device(priv->input);
> if (error) {
> dev_err(dev, "Cannot register input device, err: %d\n", error);
> - goto err_remove_sysfs;
> + goto err_free_irq;
> }
>
> device_init_wakeup(dev, 1);
> @@ -287,8 +287,6 @@ static int ili210x_i2c_probe(struct i2c_client *client,
>
> return 0;
>
> -err_remove_sysfs:
> - sysfs_remove_group(&dev->kobj, &ili210x_attr_group);
> err_free_irq:
> free_irq(client->irq, priv);
> err_free_mem:
> @@ -301,7 +299,6 @@ static int ili210x_i2c_remove(struct i2c_client *client)
> {
> struct ili210x *priv = i2c_get_clientdata(client);
>
> - sysfs_remove_group(&client->dev.kobj, &ili210x_attr_group);
Wrong ordering, the sysfs attributes will be removed only after device
has been town down.
> free_irq(priv->client->irq, priv);
> cancel_delayed_work_sync(&priv->dwork);
> input_unregister_device(priv->input);
> --
> 2.14.2
>
--
Dmitry
On Sat, Sep 30, 2017 at 05:38:31AM +0900, Andi Shyti wrote:
> Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
> and friends") has added the the managed version for creating
> sysfs group files.
>
> Use devm_device_add_group instead of sysfs_create_group.
>
> CC: Nick Dyer <[email protected]>
> Signed-off-by: Andi Shyti <[email protected]>
> ---
> drivers/input/touchscreen/atmel_mxt_ts.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
> index 7659bc48f1db..e5968f136f08 100644
> --- a/drivers/input/touchscreen/atmel_mxt_ts.c
> +++ b/drivers/input/touchscreen/atmel_mxt_ts.c
> @@ -3170,7 +3170,7 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
> if (error)
> return error;
>
> - error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group);
> + error = devm_device_add_group(&client->dev, &mxt_attr_group);
> if (error) {
> dev_err(&client->dev, "Failure %d creating sysfs group\n",
> error);
> @@ -3190,7 +3190,6 @@ static int mxt_remove(struct i2c_client *client)
> struct mxt_data *data = i2c_get_clientdata(client);
>
> disable_irq(data->irq);
> - sysfs_remove_group(&client->dev.kobj, &mxt_attr_group);
Wrong ordering.
> mxt_free_input_device(data);
> mxt_free_object_table(data);
>
> --
> 2.14.2
>
--
Dmitry
On Sat, Sep 30, 2017 at 05:38:30AM +0900, Andi Shyti wrote:
> Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
> and friends") has added the the managed version for creating
> sysfs group files.
>
> Use devm_device_add_group instead of sysfs_create_group and
> remove the relative sysfs_remove_group and goto label.
>
> Signed-off-by: Andi Shyti <[email protected]>
> ---
> drivers/input/touchscreen/ads7846.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
> index a2f45aefce08..597f4a2cca42 100644
> --- a/drivers/input/touchscreen/ads7846.c
> +++ b/drivers/input/touchscreen/ads7846.c
> @@ -1416,13 +1416,13 @@ static int ads7846_probe(struct spi_device *spi)
> else
> (void) ads7846_read12_ser(&spi->dev, READ_12BIT_SER(vaux));
>
> - err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group);
> + err = devm_device_add_group(&spi->dev, &ads784x_attr_group);
> if (err)
> goto err_remove_hwmon;
>
> err = input_register_device(input_dev);
> if (err)
> - goto err_remove_attr_group;
> + goto err_remove_hwmon;
>
> device_init_wakeup(&spi->dev, pdata->wakeup);
>
> @@ -1435,8 +1435,6 @@ static int ads7846_probe(struct spi_device *spi)
>
> return 0;
>
> - err_remove_attr_group:
> - sysfs_remove_group(&spi->dev.kobj, &ads784x_attr_group);
> err_remove_hwmon:
> ads784x_hwmon_unregister(spi, ts);
> err_free_irq:
> @@ -1462,8 +1460,6 @@ static int ads7846_remove(struct spi_device *spi)
> {
> struct ads7846 *ts = spi_get_drvdata(spi);
>
> - sysfs_remove_group(&spi->dev.kobj, &ads784x_attr_group);
> -
Wrong ordering.
> ads7846_disable(ts);
> free_irq(ts->spi->irq, ts);
>
> --
> 2.14.2
>
--
Dmitry
On Sat, Sep 30, 2017 at 05:38:29AM +0900, Andi Shyti wrote:
> Commit 57b8ff070f98 ("driver core: add devm_device_add_group()
> and friends") has added the the managed version for creating
> sysfs group files.
>
> Use devm_device_add_group instead of sysfs_create_group and
> remove the action that cleans the sysfs file when exiting the
> driver.
>
> CC: Michael Hennerich <[email protected]>
> Signed-off-by: Andi Shyti <[email protected]>
Applied, thank you.
> ---
> drivers/input/touchscreen/ad7879.c | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
> index 196028c45210..7d74a0ae2c94 100644
> --- a/drivers/input/touchscreen/ad7879.c
> +++ b/drivers/input/touchscreen/ad7879.c
> @@ -524,13 +524,6 @@ static int ad7879_parse_dt(struct device *dev, struct ad7879 *ts)
> return 0;
> }
>
> -static void ad7879_cleanup_sysfs(void *_ts)
> -{
> - struct ad7879 *ts = _ts;
> -
> - sysfs_remove_group(&ts->dev->kobj, &ad7879_attr_group);
> -}
> -
> int ad7879_probe(struct device *dev, struct regmap *regmap,
> int irq, u16 bustype, u8 devid)
> {
> @@ -658,11 +651,7 @@ int ad7879_probe(struct device *dev, struct regmap *regmap,
>
> __ad7879_disable(ts);
>
> - err = sysfs_create_group(&dev->kobj, &ad7879_attr_group);
> - if (err)
> - return err;
> -
> - err = devm_add_action_or_reset(dev, ad7879_cleanup_sysfs, ts);
> + err = devm_device_add_group(dev, &ad7879_attr_group);
> if (err)
> return err;
>
> --
> 2.14.2
>
--
Dmitry