# Re: \[PATCH 09/12\] Input: raydium\_i2c\_ts - use managed devm\_device\_add\_group

- From: Dmitry Torokhov \<dmitry.torokhov@gmail.com\>
- Date: 2017-09-29 23:39:20 
- List: linux-input
- Page: https://ratatoskr.run/linux-input/2017/09/5098347
- Thread: https://ratatoskr.run/linux-input/2017/09/5098291/t.md

```text
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 <redacted>

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
```
