hwmon: (applesmc) Fix smc_sane() function
Subsystems (3)
PATCH 1/1 hwmon: (applesmc) Fix smc_sane() function
This test is reversed so the function will return without sending the APPLESMC_READ_CMD or completing the rest of the function.
--- drivers/hwmon/applesmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/applesmc.c +1 -1
@@ -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)
Signature · 1 line
2.29.2
G’day Dan,
Have you tested that change on hardware?
Sent from an annoyingly small mobile device with no keyboard.
Quoted 28 lines · Dan Carpenter
This test is reversed so the function will return without sending the
APPLESMC_READ_CMDor completing the rest of the function.Fixes 4d64bb4ba5ec ("hwmon: (applesmc) Re-work SMC comms")Signed-off-by Dan Carpenter <[email protected]>---
drivers/hwmon/applesmc.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwmon/applesmc.c +1
-1@@ -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)Signature · 1 line
2.29.2
Quoted 2 lines · Dan Carpenter
This test is reversed so the function will return without sending the
APPLESMC_READ_CMDor 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.
Quoted 20 lines
Fixes 4d64bb4ba5ec ("hwmon: (applesmc) Re-work SMC comms")Signed-off-by Dan Carpenter <[email protected]>--- drivers/hwmon/applesmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwmon/applesmc.c +1
-1@@ -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)
Quoted 7 lines · Brad Campbell
Quoted 2 lines · Dan Carpenter
This test is reversed so the function will return without sending the
APPLESMC_READ_CMDor 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