2021-06-07 12:28:06

by Yue Haibing

[permalink] [raw]
Subject: [PATCH -next] Input: cros_ec_keyb - Fix kobj_to_dev.cocci warnings

Use kobj_to_dev() instead of container_of()

Generated by: scripts/coccinelle/api/kobj_to_dev.cocci

Signed-off-by: YueHaibing <[email protected]>
---
drivers/input/keyboard/cros_ec_keyb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
index 38457d9641bd..fc02c540636e 100644
--- a/drivers/input/keyboard/cros_ec_keyb.c
+++ b/drivers/input/keyboard/cros_ec_keyb.c
@@ -644,7 +644,7 @@ static umode_t cros_ec_keyb_attr_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 cros_ec_keyb *ckdev = dev_get_drvdata(dev);

if (attr == &dev_attr_function_row_physmap.attr &&
--
2.17.1


2021-06-20 05:28:00

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH -next] Input: cros_ec_keyb - Fix kobj_to_dev.cocci warnings

On Mon, Jun 07, 2021 at 08:26:16PM +0800, YueHaibing wrote:
> Use kobj_to_dev() instead of container_of()
>
> Generated by: scripts/coccinelle/api/kobj_to_dev.cocci

Ended up picking another incarnation of this same patch, sorry.

>
> Signed-off-by: YueHaibing <[email protected]>
> ---
> drivers/input/keyboard/cros_ec_keyb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
> index 38457d9641bd..fc02c540636e 100644
> --- a/drivers/input/keyboard/cros_ec_keyb.c
> +++ b/drivers/input/keyboard/cros_ec_keyb.c
> @@ -644,7 +644,7 @@ static umode_t cros_ec_keyb_attr_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 cros_ec_keyb *ckdev = dev_get_drvdata(dev);
>
> if (attr == &dev_attr_function_row_physmap.attr &&
> --
> 2.17.1
>

--
Dmitry