hwmon: Switch to using the new API kobj_to_dev()
diff mbox series

Message ID 1614071667-5665-1-git-send-email-yang.lee@linux.alibaba.com
State Accepted
Commit 77d76768d0984510b2be1987a3c410df598a9ea2
Headers show
Series
  • hwmon: Switch to using the new API kobj_to_dev()
Related show

Commit Message

Yang Li Feb. 23, 2021, 9:14 a.m. UTC
fixed the following coccicheck:
./drivers/hwmon/hwmon.c:82:60-61: WARNING opportunity for kobj_to_dev()

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
---
 drivers/hwmon/hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Guenter Roeck March 11, 2021, 9:38 p.m. UTC | #1
On Tue, Feb 23, 2021 at 05:14:27PM +0800, Yang Li wrote:
> fixed the following coccicheck:
> ./drivers/hwmon/hwmon.c:82:60-61: WARNING opportunity for kobj_to_dev()
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/hwmon.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
> index 6c68405..fd47ab4 100644
> --- a/drivers/hwmon/hwmon.c
> +++ b/drivers/hwmon/hwmon.c
> @@ -79,7 +79,7 @@ struct hwmon_thermal_data {
>  static umode_t hwmon_dev_name_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);
>  
>  	if (to_hwmon_device(dev)->name == NULL)
>  		return 0;

Patch
diff mbox series

diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index 6c68405..fd47ab4 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -79,7 +79,7 @@  struct hwmon_thermal_data {
 static umode_t hwmon_dev_name_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);
 
 	if (to_hwmon_device(dev)->name == NULL)
 		return 0;