From: Guenter Roeck <linux@roeck-us.net>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: linux-hwmon@vger.kernel.org, jdelvare@suse.com,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v2 2/4] hwmon: (jc42) Convert to regmap's built-in caching
Date: Thu, 20 Oct 2022 15:04:47 -0700 [thread overview]
Message-ID: <20221020220447.GE4035307@roeck-us.net> (raw)
In-Reply-To: <20221020210320.1624617-3-martin.blumenstingl@googlemail.com>
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@googlemail.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 */
next prev parent reply other threads:[~2022-10-20 22:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-20 21:03 [RFC PATCH v2 0/4] hwmon: (jc42) regmap conversion and resume fix Martin Blumenstingl
2022-10-20 21:03 ` [RFC PATCH v2 1/4] hwmon: (jc42) Convert register access to use an I2C regmap Martin Blumenstingl
2022-10-20 22:07 ` Guenter Roeck
2022-10-20 21:03 ` [RFC PATCH v2 2/4] hwmon: (jc42) Convert to regmap's built-in caching Martin Blumenstingl
2022-10-20 22:04 ` Guenter Roeck [this message]
2022-10-20 21:03 ` [RFC PATCH v2 3/4] hwmon: (jc42) Restore the min/max/critical temperatures on resume Martin Blumenstingl
2022-10-20 21:03 ` [RFC PATCH v2 4/4] hwmon: (jc42) Don't cache the temperature register Martin Blumenstingl
2022-10-20 22:14 ` Guenter Roeck
2022-10-20 22:22 ` Martin Blumenstingl
2022-10-20 22:37 ` Guenter Roeck
2022-10-20 22:16 ` [RFC PATCH v2 0/4] hwmon: (jc42) regmap conversion and resume fix 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=20221020220447.GE4035307@roeck-us.net \
--to=linux@roeck-us.net \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox