mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: "Álvaro Fernández Rojas" <noltari@gmail.com>
Cc: Krzysztof Kozlowski <krzk@kernel.org>,
	jdelvare@suse.com, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, corbet@lwn.net, linux-hwmon@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org
Subject: Re: [PATCH] drivers: hwmon: add EMC2101 driver
Date: Fri, 4 Jul 2025 06:00:33 -0700	[thread overview]
Message-ID: <c70c3d26-c2c7-4e5b-b415-8d8c20f922f1@roeck-us.net> (raw)
In-Reply-To: <CAKR-sGcLkihNKAQpPR6y3u2aCA6xmTd0mp2Ko15e3QZWrc4Dgg@mail.gmail.com>

On Fri, Jul 04, 2025 at 09:26:16AM +0200, Álvaro Fernández Rojas wrote:
> Hi Guenter,
> 
> El vie, 4 jul 2025 a las 2:25, Guenter Roeck (<linux@roeck-us.net>) escribió:
> >
> > On Thu, Jul 03, 2025 at 09:23:41AM +0200, Álvaro Fernández Rojas wrote:
> > > >
> > > > Add a comment describing what you are protecting here. It looks so far
> > > > like you could just use regmap and drop the mutex, but I didn't check
> > > > thoroughly.
> > >
> > > The EMC2101 datasheet is explicit about the Look Up Table registers
> > > (REG_FAN_LUT_TEMP and REG_FAN_LUT_SPEED) being RO if FAN_LUT_DISABLE
> > > isn't set, so I believe that we need the mutex even if we switch to
> > > regmap.
> > > I will add an explanation with that in the next version.
> > > Should I still switch the implementation to regmap considering that we
> > > need a mutex?
> > >
> > What does r/w vs. r/o register access have to do with locking ?
> 
> FAN_LUT_DISABLE bit can be set or cleared when pwm_enable is modified,
> but we need it to be set in order to be able to modify
> REG_FAN_LUT_TEMP and REG_FAN_LUT_SPEED registers.
> If FAN_LUT_DISABLE bit isn't set, any attempt to modify
> REG_FAN_LUT_TEMP and REG_FAN_LUT_SPEED registers won't work because
> they would be RO.
> Therefore, we need a lock to ensure that FAN_LUT_DISABLE is kept while
> modifying those registers.
> Please, take a look at emc2101_pwm_enable_write() and
> __pwm_auto_point_temp_store().
> 
Thanks for the clarification. Please add that as comment into the code.

Regmap is still valuable even if local locking is needed. It provides
caching for non-volatile registers, and it provides various useful API
functions (for example for bit value changes) which you otherwise have
to implement by hand.

Guenter

      reply	other threads:[~2025-07-04 13:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-01 18:12 [PATCH v2 0/3] hwmon: add Microchip " Álvaro Fernández Rojas
2025-07-01 18:12 ` [PATCH v2 1/3] docs: hwmon: add emc2101.rst to docs Álvaro Fernández Rojas
2025-07-01 18:12 ` [PATCH v2 2/3] dt-bindings: hwmon: Add Microchip EMC2101 support Álvaro Fernández Rojas
2025-07-01 19:33   ` Rob Herring (Arm)
2025-07-02  7:16   ` Krzysztof Kozlowski
2025-07-01 18:12 ` [PATCH] drivers: hwmon: add EMC2101 driver Álvaro Fernández Rojas
2025-07-02  8:35   ` Krzysztof Kozlowski
2025-07-03  7:23     ` Álvaro Fernández Rojas
2025-07-04  0:25       ` Guenter Roeck
2025-07-04  7:26         ` Álvaro Fernández Rojas
2025-07-04 13:00           ` 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=c70c3d26-c2c7-4e5b-b415-8d8c20f922f1@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=jdelvare@suse.com \
    --cc=krzk+dt@kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=noltari@gmail.com \
    --cc=robh@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 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®