All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Lars Povlsen <lars.povlsen@microchip.com>
Cc: Jean Delvare <jdelvare@suse.com>,
	Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>,
	linux-hwmon@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hwmon: sparx5: Fix initial reading of temperature
Date: Thu, 3 Sep 2020 06:52:09 -0700	[thread overview]
Message-ID: <8ca270c9-5561-3176-61cf-7a9fbee10d1f@roeck-us.net> (raw)
In-Reply-To: <20200903134704.8949-1-lars.povlsen@microchip.com>

On 9/3/20 6:47 AM, Lars Povlsen wrote:
> If the temperature is read before the internal calibration is
> completed, the driver returns -EIO. Instead it should return -EAGAIN
> to encourage repeating the operation.
> 
> Signed-off-by: Lars Povlsen <lars.povlsen@microchip.com>
> ---
>  drivers/hwmon/sparx5-temp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/sparx5-temp.c b/drivers/hwmon/sparx5-temp.c
> index 1a2b1026b026..98be48e3a22a 100644
> --- a/drivers/hwmon/sparx5-temp.c
> +++ b/drivers/hwmon/sparx5-temp.c
> @@ -56,7 +56,7 @@ static int s5_read(struct device *dev, enum hwmon_sensor_types type,
>  	case hwmon_temp_input:
>  		stat = readl_relaxed(hwmon->base + TEMP_STAT);
>  		if (!(stat & TEMP_STAT_VALID))
> -			return -EIO;
> +			return -EAGAIN;

The problem is that this may result in a hard loop and effectively hang the system,
or at least the calling process. It may be better to return -ENODATA in this situation.

Guenter

>  		value = stat & TEMP_STAT_TEMP;
>  		/*
>  		 * From register documentation:
> --
> 2.27.0
> 

WARNING: multiple messages have this Message-ID (diff)
From: Guenter Roeck <linux@roeck-us.net>
To: Lars Povlsen <lars.povlsen@microchip.com>
Cc: linux-hwmon@vger.kernel.org, Jean Delvare <jdelvare@suse.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>
Subject: Re: [PATCH] hwmon: sparx5: Fix initial reading of temperature
Date: Thu, 3 Sep 2020 06:52:09 -0700	[thread overview]
Message-ID: <8ca270c9-5561-3176-61cf-7a9fbee10d1f@roeck-us.net> (raw)
In-Reply-To: <20200903134704.8949-1-lars.povlsen@microchip.com>

On 9/3/20 6:47 AM, Lars Povlsen wrote:
> If the temperature is read before the internal calibration is
> completed, the driver returns -EIO. Instead it should return -EAGAIN
> to encourage repeating the operation.
> 
> Signed-off-by: Lars Povlsen <lars.povlsen@microchip.com>
> ---
>  drivers/hwmon/sparx5-temp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/sparx5-temp.c b/drivers/hwmon/sparx5-temp.c
> index 1a2b1026b026..98be48e3a22a 100644
> --- a/drivers/hwmon/sparx5-temp.c
> +++ b/drivers/hwmon/sparx5-temp.c
> @@ -56,7 +56,7 @@ static int s5_read(struct device *dev, enum hwmon_sensor_types type,
>  	case hwmon_temp_input:
>  		stat = readl_relaxed(hwmon->base + TEMP_STAT);
>  		if (!(stat & TEMP_STAT_VALID))
> -			return -EIO;
> +			return -EAGAIN;

The problem is that this may result in a hard loop and effectively hang the system,
or at least the calling process. It may be better to return -ENODATA in this situation.

Guenter

>  		value = stat & TEMP_STAT_TEMP;
>  		/*
>  		 * From register documentation:
> --
> 2.27.0
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-09-03 14:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03 13:47 [PATCH] hwmon: sparx5: Fix initial reading of temperature Lars Povlsen
2020-09-03 13:47 ` Lars Povlsen
2020-09-03 13:52 ` Guenter Roeck [this message]
2020-09-03 13:52   ` Guenter Roeck
2020-09-04  8:33   ` Lars Povlsen
2020-09-04  8:33     ` Lars Povlsen
2020-09-04 14:08     ` Guenter Roeck
2020-09-04 14:08       ` Guenter Roeck
2020-09-04 16:40 ` Guenter Roeck
2020-09-04 16:40   ` Guenter Roeck

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=8ca270c9-5561-3176-61cf-7a9fbee10d1f@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=jdelvare@suse.com \
    --cc=lars.povlsen@microchip.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.