[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221020220447.GE4035307@roeck-us.net>
Date: Thu, 20 Oct 2022 15:04:47 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Martin Blumenstingl <martin.blumenstingl@...glemail.com>
Cc: linux-hwmon@...r.kernel.org, jdelvare@...e.com,
linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH v2 2/4] hwmon: (jc42) Convert to regmap's built-in
caching
On Thu, Oct 20, 2022 at 11:03:18PM +0200, Martin Blumenstingl wrote:
> Move over to regmap's built-in caching instead of adding a custom
> caching implementation. This works for JC42_REG_TEMP_UPPER,
> JC42_REG_TEMP_LOWER and JC42_REG_TEMP_CRITICAL as these values never
> change except when explicitly written. For JC42_REG_TEMP a cache
> variable is still kept as regmap cannot cache this register (because
> it's volatile, meaning it can change at any time).
>
Just drop that one as well, together with jc42_update_device(),
and read the temperature directly where needed. In practice
caching of 'hot' registers isn't really worth the trouble.
Thanks,
Guenter
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@...glemail.com>
> ---
> drivers/hwmon/jc42.c | 97 ++++++++++++++++++++++++--------------------
> 1 file changed, 54 insertions(+), 43 deletions(-)
>
> diff --git a/drivers/hwmon/jc42.c b/drivers/hwmon/jc42.c
> index 329a80264556..3f524ab5451c 100644
> --- a/drivers/hwmon/jc42.c
> +++ b/drivers/hwmon/jc42.c
> @@ -200,21 +200,6 @@ static struct jc42_chips jc42_chips[] = {
> { STM_MANID, STTS3000_DEVID, STTS3000_DEVID_MASK },
> };
>
> -enum temp_index {
> - t_input = 0,
> - t_crit,
> - t_min,
> - t_max,
> - t_num_temp
> -};
> -
> -static const u8 temp_regs[t_num_temp] = {
> - [t_input] = JC42_REG_TEMP,
> - [t_crit] = JC42_REG_TEMP_CRITICAL,
> - [t_min] = JC42_REG_TEMP_LOWER,
> - [t_max] = JC42_REG_TEMP_UPPER,
> -};
> -
> /* Each client has this additional data */
> struct jc42_data {
> struct regmap *regmap;
> @@ -224,7 +209,7 @@ struct jc42_data {
> unsigned long last_updated; /* In jiffies */
> u16 orig_config; /* original configuration */
> u16 config; /* current configuration */
> - u16 temp[t_num_temp];/* Temperatures */
> + u16 temp; /* Cached temperature register value */
Powered by blists - more mailing lists