mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Vishwas M <vishwas.reddy.vr@gmail.com>
Cc: Steve Glendinning <steve.glendinning@shawell.net>,
	Jean Delvare <jdelvare@suse.com>,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hwmon: (emc2103) fix unable to change fan pwm1_enable attribute
Date: Tue, 7 Jul 2020 07:56:24 -0700	[thread overview]
Message-ID: <ba55b290-2035-5a03-4029-9e7ac4f6d89c@roeck-us.net> (raw)
In-Reply-To: <20200707142747.118414-1-vishwas.reddy.vr@gmail.com>

On 7/7/20 7:27 AM, Vishwas M wrote:
> This patch fixes a bug which does not let FAN mode to be changed from
> sysfs(pwm1_enable). i.e pwm1_enable can not be set to 3, it will always
> remain at 0.
> 
> This is caused because the device driver handles the result of
> "read_u8_from_i2c(client, REG_FAN_CONF1, &conf_reg)" incorrectly. The
> driver thinks an error has occurred if the (result != 0). This has been
> fixed by changing the condition to (result < 0).
> 
> Signed-off-by: Vishwas M <vishwas.reddy.vr@gmail.com>
> ---
>  drivers/hwmon/emc2103.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
> index 491a570e8e50..924c02c1631d 100644
> --- a/drivers/hwmon/emc2103.c
> +++ b/drivers/hwmon/emc2103.c
> @@ -443,7 +443,7 @@ static ssize_t pwm1_enable_store(struct device *dev,
>  	}
>  
>  	result = read_u8_from_i2c(client, REG_FAN_CONF1, &conf_reg);
> -	if (result) {
> +	if (result < 0) {
>  		count = result;
>  		goto err;
>  	}
> 

The underlying problem is really that read_u8_from_i2c()
returns the value twice - once as return code, and once
written into the passed pointer. This unnecessarily complex
and messy. But, still, valid bug and fix. Applied.

Thanks,
Guenter

      reply	other threads:[~2020-07-07 14:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 14:27 Vishwas M
2020-07-07 14:56 ` Guenter Roeck [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba55b290-2035-5a03-4029-9e7ac4f6d89c@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=steve.glendinning@shawell.net \
    --cc=vishwas.reddy.vr@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®