2020-06-12 08:08:36

by 王擎

[permalink] [raw]
Subject: [PATCH] drivers\gpio: use kobj_to_dev

Use kobj_to_dev() API instead of container_of().

Signed-off-by: Wang Qing <[email protected]>
---
drivers/gpio/gpiolib-sysfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
mode change 100644 => 100755 drivers/gpio/gpiolib-sysfs.c

diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index 23e3d33..82371fe
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -365,7 +365,7 @@ static DEVICE_ATTR_RW(active_low);
static umode_t gpio_is_visible(struct kobject *kobj, struct attribute *attr,
int n)
{
- struct device *dev = container_of(kobj, struct device, kobj);
+ struct device *dev = kobj_to_dev(kobj);
struct gpiod_data *data = dev_get_drvdata(dev);
struct gpio_desc *desc = data->desc;
umode_t mode = attr->mode;
--
2.7.4


2020-06-15 08:11:22

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH] drivers\gpio: use kobj_to_dev

pt., 12 cze 2020 o 10:05 Wang Qing <[email protected]> napisał(a):
>
> Use kobj_to_dev() API instead of container_of().
>
> Signed-off-by: Wang Qing <[email protected]>
> ---
> drivers/gpio/gpiolib-sysfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> mode change 100644 => 100755 drivers/gpio/gpiolib-sysfs.c
>
> diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
> index 23e3d33..82371fe
> --- a/drivers/gpio/gpiolib-sysfs.c
> +++ b/drivers/gpio/gpiolib-sysfs.c
> @@ -365,7 +365,7 @@ static DEVICE_ATTR_RW(active_low);
> static umode_t gpio_is_visible(struct kobject *kobj, struct attribute *attr,
> int n)
> {
> - struct device *dev = container_of(kobj, struct device, kobj);
> + struct device *dev = kobj_to_dev(kobj);
> struct gpiod_data *data = dev_get_drvdata(dev);
> struct gpio_desc *desc = data->desc;
> umode_t mode = attr->mode;
> --
> 2.7.4
>

Patch applied, thanks!

Bartosz