mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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: [PATCH] hwmon: (jc42) Restore the min/max/critical temperatures on resume
Date: Wed, 19 Oct 2022 15:50:24 -0700	[thread overview]
Message-ID: <2d22d0ac-ecc8-1c05-fb63-b0bd0569036c@roeck-us.net> (raw)
In-Reply-To: <CAFBinCAutvvNzSD7HXfMzLOg-NZ3ubifjtHzC9yURe=BZJQEiA@mail.gmail.com>

On 10/19/22 15:03, Martin Blumenstingl wrote:
> Hi Guenter,
> 
> Thank you for the quick feedback!
> 
> On Wed, Oct 19, 2022 at 11:51 PM Guenter Roeck <linux@roeck-us.net> wrote:
> [...]
>>> +     if (data->valid || data->temp[t_min])
>>
>> This contradicts "with applying the previous values by only configuring
>> them if they are known valid". It explicitly applies the values if they
>> are marked as not valid, and it also applies the values if they are 0
>> (I don't really see the value of doing that).
>>
>> Sorry, I don't understand the logic. Did you mean to use "&&" instead
>> of "||" ?
> My understanding is that that:
> 1) data->valid = true is only set in jc42_update_device() (which is
> only called when reading back the values from the registers)
> 2) jc42_write() can write values without setting data->value = true
> In other words: if jc42_read() is never called but jc42_write() is
> then we still have some setting to apply while data->valid is false.
> Whether that's possible in reality is something that I'm not sure
> about.
> 

The above only means that the code is not optimized for the problem
you are trying to solve.

- Calling jc42_update_device() would solve the valid problem.
- Calling jc42_update_device() from the write function would
   solve it as well.

Relying on a previous call to the write function is most definitely
wrong.

Also, for optimization, jc42_update_device() should really read the limit
registers only once. The best solution would probably be to convert the
driver to use regmap and let regmap handle the caching.

Guenter

> If your suggestion is to simplify this to use data->valid only then I
> can do that.
> It would be great if you could also comment on whether
> jc42_update_device() should be called from jc42_suspend() to give the
> driver the chance to at least read the data once (and set data->valid)
> if this has not happened before.
> 
> 
> Best regards,
> Martin


      reply	other threads:[~2022-10-19 22:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19 21:41 Martin Blumenstingl
2022-10-19 21:51 ` Guenter Roeck
2022-10-19 22:03   ` Martin Blumenstingl
2022-10-19 22:50     ` Guenter Roeck [this message]

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=2d22d0ac-ecc8-1c05-fb63-b0bd0569036c@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

all inboxes | Powered by JetHome®