diff mbox series

[2/6] hwmon: (lm90) Re-enable interrupts after alert clears

Message ID 20220111165116.1298459-3-linux@roeck-us.net (mailing list archive)
State Accepted
Headers show
Series hwmon: Fixes for lm90 driver | expand

Commit Message

Guenter Roeck Jan. 11, 2022, 4:51 p.m. UTC
If alert handling is broken, interrupts are disabled after an alert and
re-enabled after the alert clears. However, if there is an interrupt
handler, this does not apply if alerts were originally disabled and enabled
when the driver was loaded. In that case, interrupts will stay disabled
after an alert was handled though the alert handler even after the alert
condition clears. Address the situation by always re-enabling interrupts
after the alert condition clears if there is an interrupt handler.

Fixes: 2abdc357c55d9 ("hwmon: (lm90) Unmask hardware interrupt")
Cc: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/lm90.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dmitry Osipenko Jan. 15, 2022, 8:09 p.m. UTC | #1
11.01.2022 19:51, Guenter Roeck пишет:
> If alert handling is broken, interrupts are disabled after an alert and
> re-enabled after the alert clears. However, if there is an interrupt
> handler, this does not apply if alerts were originally disabled and enabled
> when the driver was loaded. In that case, interrupts will stay disabled
> after an alert was handled though the alert handler even after the alert
> condition clears. Address the situation by always re-enabling interrupts
> after the alert condition clears if there is an interrupt handler.
> 
> Fixes: 2abdc357c55d9 ("hwmon: (lm90) Unmask hardware interrupt")
> Cc: Dmitry Osipenko <digetx@gmail.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  drivers/hwmon/lm90.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
> index cc5e48fe304b..e4ecf3440d7c 100644
> --- a/drivers/hwmon/lm90.c
> +++ b/drivers/hwmon/lm90.c
> @@ -848,7 +848,7 @@ static int lm90_update_device(struct device *dev)
>  		 * Re-enable ALERT# output if it was originally enabled and
>  		 * relevant alarms are all clear
>  		 */
> -		if (!(data->config_orig & 0x80) &&
> +		if ((client->irq || !(data->config_orig & 0x80)) &&
>  		    !(data->alarms & data->alert_alarms)) {
>  			if (data->config & 0x80) {
>  				dev_dbg(&client->dev, "Re-enabling ALERT#\n");
> 

Good catch!
diff mbox series

Patch

diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index cc5e48fe304b..e4ecf3440d7c 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -848,7 +848,7 @@  static int lm90_update_device(struct device *dev)
 		 * Re-enable ALERT# output if it was originally enabled and
 		 * relevant alarms are all clear
 		 */
-		if (!(data->config_orig & 0x80) &&
+		if ((client->irq || !(data->config_orig & 0x80)) &&
 		    !(data->alarms & data->alert_alarms)) {
 			if (data->config & 0x80) {
 				dev_dbg(&client->dev, "Re-enabling ALERT#\n");