Linux-Hwmon Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] driver/hwmon/nct6775: Use kobj_to_dev() API
@ 2020-05-11  3:43 zhouchuangao
  0 siblings, 0 replies; 2+ messages in thread
From: zhouchuangao @ 2020-05-11  3:43 UTC (permalink / raw)
  To: linux; +Cc: jdelvare, linux-hwmon, linux-kernel, zhouchuangao

Use kobj_to_dev() API instead of container_of().

Signed-off-by: zhouchuangao <zhouchuangao@xiaomi.com>
---
 drivers/hwmon/nct6775.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index 7efa6bf..e7e1ddc 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -2047,7 +2047,7 @@ store_temp_beep(struct device *dev, struct device_attribute *attr,
 static umode_t nct6775_in_is_visible(struct kobject *kobj,
 				     struct attribute *attr, int index)
 {
-	struct device *dev = container_of(kobj, struct device, kobj);
+	struct device *dev = kobj_to_dev(kobj);
 	struct nct6775_data *data = dev_get_drvdata(dev);
 	int in = index / 5;	/* voltage index */
 
@@ -2253,7 +2253,7 @@ store_fan_pulses(struct device *dev, struct device_attribute *attr,
 static umode_t nct6775_fan_is_visible(struct kobject *kobj,
 				      struct attribute *attr, int index)
 {
-	struct device *dev = container_of(kobj, struct device, kobj);
+	struct device *dev = kobj_to_dev(kobj);
 	struct nct6775_data *data = dev_get_drvdata(dev);
 	int fan = index / 6;	/* fan index */
 	int nr = index % 6;	/* attribute index */
@@ -2440,7 +2440,7 @@ store_temp_type(struct device *dev, struct device_attribute *attr,
 static umode_t nct6775_temp_is_visible(struct kobject *kobj,
 				       struct attribute *attr, int index)
 {
-	struct device *dev = container_of(kobj, struct device, kobj);
+	struct device *dev = kobj_to_dev(kobj);
 	struct nct6775_data *data = dev_get_drvdata(dev);
 	int temp = index / 10;	/* temp index */
 	int nr = index % 10;	/* attribute index */
@@ -3257,7 +3257,7 @@ store_auto_temp(struct device *dev, struct device_attribute *attr,
 static umode_t nct6775_pwm_is_visible(struct kobject *kobj,
 				      struct attribute *attr, int index)
 {
-	struct device *dev = container_of(kobj, struct device, kobj);
+	struct device *dev = kobj_to_dev(kobj);
 	struct nct6775_data *data = dev_get_drvdata(dev);
 	int pwm = index / 36;	/* pwm index */
 	int nr = index % 36;	/* attribute index */
@@ -3459,7 +3459,7 @@ static SENSOR_DEVICE_ATTR(beep_enable, S_IWUSR | S_IRUGO, show_beep,
 static umode_t nct6775_other_is_visible(struct kobject *kobj,
 					struct attribute *attr, int index)
 {
-	struct device *dev = container_of(kobj, struct device, kobj);
+	struct device *dev = kobj_to_dev(kobj);
 	struct nct6775_data *data = dev_get_drvdata(dev);
 
 	if (index == 0 && !data->have_vid)
-- 
2.7.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] driver/hwmon/nct6775: Use kobj_to_dev() API
@ 2020-05-11 16:47 Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2020-05-11 16:47 UTC (permalink / raw)
  To: zhouchuangao; +Cc: jdelvare, linux-hwmon, linux-kernel, zhouchuangao

On Mon, May 11, 2020 at 11:43:06AM +0800, zhouchuangao wrote:
> Use kobj_to_dev() API instead of container_of().
> 
> Signed-off-by: zhouchuangao <zhouchuangao@xiaomi.com>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/nct6775.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
> index 7efa6bf..e7e1ddc 100644
> --- a/drivers/hwmon/nct6775.c
> +++ b/drivers/hwmon/nct6775.c
> @@ -2047,7 +2047,7 @@ store_temp_beep(struct device *dev, struct device_attribute *attr,
>  static umode_t nct6775_in_is_visible(struct kobject *kobj,
>  				     struct attribute *attr, int index)
>  {
> -	struct device *dev = container_of(kobj, struct device, kobj);
> +	struct device *dev = kobj_to_dev(kobj);
>  	struct nct6775_data *data = dev_get_drvdata(dev);
>  	int in = index / 5;	/* voltage index */
>  
> @@ -2253,7 +2253,7 @@ store_fan_pulses(struct device *dev, struct device_attribute *attr,
>  static umode_t nct6775_fan_is_visible(struct kobject *kobj,
>  				      struct attribute *attr, int index)
>  {
> -	struct device *dev = container_of(kobj, struct device, kobj);
> +	struct device *dev = kobj_to_dev(kobj);
>  	struct nct6775_data *data = dev_get_drvdata(dev);
>  	int fan = index / 6;	/* fan index */
>  	int nr = index % 6;	/* attribute index */
> @@ -2440,7 +2440,7 @@ store_temp_type(struct device *dev, struct device_attribute *attr,
>  static umode_t nct6775_temp_is_visible(struct kobject *kobj,
>  				       struct attribute *attr, int index)
>  {
> -	struct device *dev = container_of(kobj, struct device, kobj);
> +	struct device *dev = kobj_to_dev(kobj);
>  	struct nct6775_data *data = dev_get_drvdata(dev);
>  	int temp = index / 10;	/* temp index */
>  	int nr = index % 10;	/* attribute index */
> @@ -3257,7 +3257,7 @@ store_auto_temp(struct device *dev, struct device_attribute *attr,
>  static umode_t nct6775_pwm_is_visible(struct kobject *kobj,
>  				      struct attribute *attr, int index)
>  {
> -	struct device *dev = container_of(kobj, struct device, kobj);
> +	struct device *dev = kobj_to_dev(kobj);
>  	struct nct6775_data *data = dev_get_drvdata(dev);
>  	int pwm = index / 36;	/* pwm index */
>  	int nr = index % 36;	/* attribute index */
> @@ -3459,7 +3459,7 @@ static SENSOR_DEVICE_ATTR(beep_enable, S_IWUSR | S_IRUGO, show_beep,
>  static umode_t nct6775_other_is_visible(struct kobject *kobj,
>  					struct attribute *attr, int index)
>  {
> -	struct device *dev = container_of(kobj, struct device, kobj);
> +	struct device *dev = kobj_to_dev(kobj);
>  	struct nct6775_data *data = dev_get_drvdata(dev);
>  
>  	if (index == 0 && !data->have_vid)
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-11  3:43 [PATCH] driver/hwmon/nct6775: Use kobj_to_dev() API zhouchuangao
2020-05-11 16:47 Guenter Roeck

Linux-Hwmon Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-hwmon/0 linux-hwmon/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-hwmon linux-hwmon/ https://lore.kernel.org/linux-hwmon \
		linux-hwmon@vger.kernel.org
	public-inbox-index linux-hwmon

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-hwmon


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git