* [PATCH] USB: typec: ucsi_ccg: convert i2c driver to use dev_groups
@ 2019-08-05 19:36 Greg Kroah-Hartman
2019-08-06 12:59 ` Heikki Krogerus
0 siblings, 1 reply; 2+ messages in thread
From: Greg Kroah-Hartman @ 2019-08-05 19:36 UTC (permalink / raw)
To: linux-usb
Cc: Greg Kroah-Hartman, Heikki Krogerus, Ajay Gupta, Wolfram Sang,
Wei Yongjun
The driver core now supports the option to automatically create and
remove any needed sysfs attribute files for a driver when the device is
bound/removed from it. Convert the uscsi_ccg code to use that instead
of trying to create sysfs files "by hand".
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Ajay Gupta <ajayg@nvidia.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/typec/ucsi/ucsi_ccg.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c
index f7a79a23ebed..e283a42e4f06 100644
--- a/drivers/usb/typec/ucsi/ucsi_ccg.c
+++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
@@ -1104,14 +1104,11 @@ static ssize_t do_flash_store(struct device *dev,
static DEVICE_ATTR_WO(do_flash);
-static struct attribute *ucsi_ccg_sysfs_attrs[] = {
+static struct attribute *ucsi_ccg_attrs[] = {
&dev_attr_do_flash.attr,
NULL,
};
-
-static struct attribute_group ucsi_ccg_attr_group = {
- .attrs = ucsi_ccg_sysfs_attrs,
-};
+ATTRIBUTE_GROUPS(ucsi_ccg);
static int ucsi_ccg_probe(struct i2c_client *client,
const struct i2c_device_id *id)
@@ -1189,10 +1186,6 @@ static int ucsi_ccg_probe(struct i2c_client *client,
i2c_set_clientdata(client, uc);
- status = sysfs_create_group(&uc->dev->kobj, &ucsi_ccg_attr_group);
- if (status)
- dev_err(uc->dev, "cannot create sysfs group: %d\n", status);
-
pm_runtime_set_active(uc->dev);
pm_runtime_enable(uc->dev);
pm_runtime_idle(uc->dev);
@@ -1209,7 +1202,6 @@ static int ucsi_ccg_remove(struct i2c_client *client)
ucsi_unregister_ppm(uc->ucsi);
pm_runtime_disable(uc->dev);
free_irq(uc->irq, uc);
- sysfs_remove_group(&uc->dev->kobj, &ucsi_ccg_attr_group);
return 0;
}
@@ -1270,6 +1262,7 @@ static struct i2c_driver ucsi_ccg_driver = {
.driver = {
.name = "ucsi_ccg",
.pm = &ucsi_ccg_pm,
+ .dev_groups = ucsi_ccg_groups,
},
.probe = ucsi_ccg_probe,
.remove = ucsi_ccg_remove,
--
2.22.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] USB: typec: ucsi_ccg: convert i2c driver to use dev_groups
2019-08-05 19:36 [PATCH] USB: typec: ucsi_ccg: convert i2c driver to use dev_groups Greg Kroah-Hartman
@ 2019-08-06 12:59 ` Heikki Krogerus
0 siblings, 0 replies; 2+ messages in thread
From: Heikki Krogerus @ 2019-08-06 12:59 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-usb, Ajay Gupta, Wolfram Sang, Wei Yongjun
On Mon, Aug 05, 2019 at 09:36:36PM +0200, Greg Kroah-Hartman wrote:
> The driver core now supports the option to automatically create and
> remove any needed sysfs attribute files for a driver when the device is
> bound/removed from it. Convert the uscsi_ccg code to use that instead
> of trying to create sysfs files "by hand".
>
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Cc: Ajay Gupta <ajayg@nvidia.com>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: Wei Yongjun <weiyongjun1@huawei.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/ucsi/ucsi_ccg.c | 13 +++----------
> 1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c
> index f7a79a23ebed..e283a42e4f06 100644
> --- a/drivers/usb/typec/ucsi/ucsi_ccg.c
> +++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
> @@ -1104,14 +1104,11 @@ static ssize_t do_flash_store(struct device *dev,
>
> static DEVICE_ATTR_WO(do_flash);
>
> -static struct attribute *ucsi_ccg_sysfs_attrs[] = {
> +static struct attribute *ucsi_ccg_attrs[] = {
> &dev_attr_do_flash.attr,
> NULL,
> };
> -
> -static struct attribute_group ucsi_ccg_attr_group = {
> - .attrs = ucsi_ccg_sysfs_attrs,
> -};
> +ATTRIBUTE_GROUPS(ucsi_ccg);
>
> static int ucsi_ccg_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> @@ -1189,10 +1186,6 @@ static int ucsi_ccg_probe(struct i2c_client *client,
>
> i2c_set_clientdata(client, uc);
>
> - status = sysfs_create_group(&uc->dev->kobj, &ucsi_ccg_attr_group);
> - if (status)
> - dev_err(uc->dev, "cannot create sysfs group: %d\n", status);
> -
> pm_runtime_set_active(uc->dev);
> pm_runtime_enable(uc->dev);
> pm_runtime_idle(uc->dev);
> @@ -1209,7 +1202,6 @@ static int ucsi_ccg_remove(struct i2c_client *client)
> ucsi_unregister_ppm(uc->ucsi);
> pm_runtime_disable(uc->dev);
> free_irq(uc->irq, uc);
> - sysfs_remove_group(&uc->dev->kobj, &ucsi_ccg_attr_group);
>
> return 0;
> }
> @@ -1270,6 +1262,7 @@ static struct i2c_driver ucsi_ccg_driver = {
> .driver = {
> .name = "ucsi_ccg",
> .pm = &ucsi_ccg_pm,
> + .dev_groups = ucsi_ccg_groups,
> },
> .probe = ucsi_ccg_probe,
> .remove = ucsi_ccg_remove,
> --
> 2.22.0
thanks,
--
heikki
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-06 12:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-05 19:36 [PATCH] USB: typec: ucsi_ccg: convert i2c driver to use dev_groups Greg Kroah-Hartman
2019-08-06 12:59 ` Heikki Krogerus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).