From: Dimitri Fedrau <dima.fedrau@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: dimitri.fedrau@liebherr.com,
"Uwe Kleine-König" <ukleinek@kernel.org>,
"Jean Delvare" <jdelvare@suse.com>,
linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hwmon@vger.kernel.org
Subject: Re: [PATCH] pwm: mc33xs2410: add support for temperature sensors
Date: Mon, 12 May 2025 15:31:14 +0200 [thread overview]
Message-ID: <20250512133114.GA6440@legfed1> (raw)
In-Reply-To: <1bd48694-9760-4e6b-9138-4651d42ff032@roeck-us.net>
Hi Guenter,
Am Mon, May 12, 2025 at 06:04:33AM -0700 schrieb Guenter Roeck:
> On 5/12/25 04:26, Dimitri Fedrau via B4 Relay wrote:
> > From: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
> >
> > The MC33XS2410 provides temperature sensors for the central die temperature
> > and the four outputs. Additionally a common temperature warning threshold
> > can be configured for the outputs. Add hwmon support for the sensors.
> >
> > Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
> > ---
>
> > +
> > +static int mc33xs2410_hwmon_read_out_status(struct spi_device *spi,
> > + int channel, u16 *val)
> > +{
> > + int ret;
> > +
> > + ret = mc33xs2410_read_reg_diag(spi, MC33XS2410_OUT_STA(channel), val);
> > + if (ret < 0)
> > + return ret;
> > +
> > + /* Bits latches high */
> > + return mc33xs2410_read_reg_diag(spi, MC33XS2410_OUT_STA(channel), val);
>
> Is that double read of the same register needed ? If so, you'll probably
> need a lock to prevent it from being executed from multiple threads at the
> same time.
>
> The comment "Bit latches high" doesn't really mean anything to me and doesn't
> explain why the register needs to be read twice.
>
>
All bits of the output status registers are latched high. In case there
was overtemperature detected, the bit stays set until read once and cleared
afterwards. So I need a second read to get the "realtime" status.
Otherwise I might end up returning an false positive overtemperature
warning. I don't think a lock is really necessary, since I'm only
interested in the "realtime" status but not if there was a warning in
the past. What do you think ?
Will improve the comment.
Best regards
Dimitri Fedrau
next prev parent reply other threads:[~2025-05-12 13:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-12 11:26 [PATCH] pwm: mc33xs2410: add support for temperature sensors Dimitri Fedrau via B4 Relay
2025-05-12 13:04 ` Guenter Roeck
2025-05-12 13:31 ` Dimitri Fedrau [this message]
2025-05-12 13:53 ` Guenter Roeck
2025-05-12 16:52 ` Dimitri Fedrau
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=20250512133114.GA6440@legfed1 \
--to=dima.fedrau@gmail.com \
--cc=dimitri.fedrau@liebherr.com \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=ukleinek@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;
as well as URLs for NNTP newsgroup(s).