kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: (applesmc) Fix smc_sane() function
@ 2020-11-17  7:24 Dan Carpenter
  2020-11-17  9:25 ` Brad Campbell
  2020-11-17  9:58 ` Brad Campbell
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2020-11-17  7:24 UTC (permalink / raw)
  To: Henrik Rydberg
  Cc: Jean Delvare, Guenter Roeck, Brad Campbell, linux-hwmon,
	kernel-janitors

This test is reversed so the function will return without sending
the APPLESMC_READ_CMD or completing the rest of the function.

Fixes: 4d64bb4ba5ec ("hwmon: (applesmc) Re-work SMC comms")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/hwmon/applesmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 79b498f816fe..289b39537683 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -227,7 +227,7 @@ static int smc_sane(void)
 	int ret;
 
 	ret = wait_status(0, SMC_STATUS_BUSY);
-	if (!ret)
+	if (ret)
 		return ret;
 	ret = send_command(APPLESMC_READ_CMD);
 	if (ret)
-- 
2.29.2

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

* Re: [PATCH] hwmon: (applesmc) Fix smc_sane() function
  2020-11-17  7:24 [PATCH] hwmon: (applesmc) Fix smc_sane() function Dan Carpenter
@ 2020-11-17  9:25 ` Brad Campbell
  2020-11-17  9:58 ` Brad Campbell
  1 sibling, 0 replies; 4+ messages in thread
From: Brad Campbell @ 2020-11-17  9:25 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Henrik Rydberg, Jean Delvare, Guenter Roeck, linux-hwmon,
	kernel-janitors

G’day Dan,

Have you tested that change on hardware?

Sent from an annoyingly small mobile device with no keyboard.

> On 17 Nov 2020, at 7:52 pm, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
> This test is reversed so the function will return without sending
> the APPLESMC_READ_CMD or completing the rest of the function.
> 
> Fixes: 4d64bb4ba5ec ("hwmon: (applesmc) Re-work SMC comms")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/hwmon/applesmc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
> index 79b498f816fe..289b39537683 100644
> --- a/drivers/hwmon/applesmc.c
> +++ b/drivers/hwmon/applesmc.c
> @@ -227,7 +227,7 @@ static int smc_sane(void)
>    int ret;
> 
>    ret = wait_status(0, SMC_STATUS_BUSY);
> -    if (!ret)
> +    if (ret)
>        return ret;
>    ret = send_command(APPLESMC_READ_CMD);
>    if (ret)
> -- 
> 2.29.2
> 
> 

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

* Re: [PATCH] hwmon: (applesmc) Fix smc_sane() function
  2020-11-17  7:24 [PATCH] hwmon: (applesmc) Fix smc_sane() function Dan Carpenter
  2020-11-17  9:25 ` Brad Campbell
@ 2020-11-17  9:58 ` Brad Campbell
  2020-11-17 14:02   ` Dan Carpenter
  1 sibling, 1 reply; 4+ messages in thread
From: Brad Campbell @ 2020-11-17  9:58 UTC (permalink / raw)
  To: Dan Carpenter, Henrik Rydberg
  Cc: Jean Delvare, Guenter Roeck, linux-hwmon, kernel-janitors

On 17/11/20 6:24 pm, Dan Carpenter wrote:
> This test is reversed so the function will return without sending
> the APPLESMC_READ_CMD or completing the rest of the function.

That is as designed. The routine looks at the busy line and if it's already in the right state then it simply ends. If not then it tries to "re-align" the state machine by sending a new command.

> Fixes: 4d64bb4ba5ec ("hwmon: (applesmc) Re-work SMC comms")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/hwmon/applesmc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
> index 79b498f816fe..289b39537683 100644
> --- a/drivers/hwmon/applesmc.c
> +++ b/drivers/hwmon/applesmc.c
> @@ -227,7 +227,7 @@ static int smc_sane(void)
>  	int ret;
>  
>  	ret = wait_status(0, SMC_STATUS_BUSY);
> -	if (!ret)
> +	if (ret)
>  		return ret;
>  	ret = send_command(APPLESMC_READ_CMD);
>  	if (ret)
> 

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

* Re: [PATCH] hwmon: (applesmc) Fix smc_sane() function
  2020-11-17  9:58 ` Brad Campbell
@ 2020-11-17 14:02   ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2020-11-17 14:02 UTC (permalink / raw)
  To: Brad Campbell
  Cc: Henrik Rydberg, Jean Delvare, Guenter Roeck, linux-hwmon,
	kernel-janitors

On Tue, Nov 17, 2020 at 08:58:47PM +1100, Brad Campbell wrote:
> On 17/11/20 6:24 pm, Dan Carpenter wrote:
> > This test is reversed so the function will return without sending
> > the APPLESMC_READ_CMD or completing the rest of the function.
> 
> That is as designed. The routine looks at the busy line and if it's
> already in the right state then it simply ends. If not then it tries
> to "re-align" the state machine by sending a new command.

Ah.  Ok.  It looked like a typo.  These "if (!ret) return ret;" typos
are surprisingly common so I review them every time they are added.
It's a static analysis warning, that I haven't published.  I kind of
feel like it would be more clearly intentional if it were written like
so:

	ret = wait_status(0, SMC_STATUS_BUSY);
	if (!ret)
		return 0;

But I try not to get too bogged down with style so let's leave it.

regards,
dan carpenter

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

end of thread, other threads:[~2020-11-17 14:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-17  7:24 [PATCH] hwmon: (applesmc) Fix smc_sane() function Dan Carpenter
2020-11-17  9:25 ` Brad Campbell
2020-11-17  9:58 ` Brad Campbell
2020-11-17 14:02   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).