2020-06-12 07:09:25

by 王擎

[permalink] [raw]
Subject: [PATCH] drivers\power\supply: use kobj_to_dev

Use kobj_to_dev() API instead of container_of().

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

diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index bc79560..af0cad2
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -343,7 +343,7 @@ static umode_t power_supply_attr_is_visible(struct kobject *kobj,
struct attribute *attr,
int attrno)
{
- struct device *dev = container_of(kobj, struct device, kobj);
+ struct device *dev = kobj_to_dev(kobj);
struct power_supply *psy = dev_get_drvdata(dev);
umode_t mode = S_IRUSR | S_IRGRP | S_IROTH;
int i;
--
2.7.4


2020-06-19 15:00:33

by Sebastian Reichel

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

Hi,

On Fri, Jun 12, 2020 at 02:55:54PM +0800, Wang Qing wrote:
> Use kobj_to_dev() API instead of container_of().
>
> Signed-off-by: Wang Qing <[email protected]>
> ---

Thanks, queued.

-- Sebastian

> drivers/power/supply/power_supply_sysfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> mode change 100644 => 100755 drivers/power/supply/power_supply_sysfs.c
>
> diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
> index bc79560..af0cad2
> --- a/drivers/power/supply/power_supply_sysfs.c
> +++ b/drivers/power/supply/power_supply_sysfs.c
> @@ -343,7 +343,7 @@ static umode_t power_supply_attr_is_visible(struct kobject *kobj,
> struct attribute *attr,
> int attrno)
> {
> - struct device *dev = container_of(kobj, struct device, kobj);
> + struct device *dev = kobj_to_dev(kobj);
> struct power_supply *psy = dev_get_drvdata(dev);
> umode_t mode = S_IRUSR | S_IRGRP | S_IROTH;
> int i;
> --
> 2.7.4
>


Attachments:
(No filename) (1.00 kB)
signature.asc (849.00 B)
Download all attachments