public inbox for linux-hwmon@vger.kernel.org
 help / color / mirror / Atom feed
From: Tabrez Ahmed <tabreztalks@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
	shuah@kernel.org, me@brighamcampbell.com
Subject: Re: [PATCH 1/2] hwmon: (ads7871) Add mutex to serialize SPI transactions
Date: Sun, 29 Mar 2026 10:30:36 +0530	[thread overview]
Message-ID: <9c7b873d-8797-4fa1-ab44-2599b2b02f4e@gmail.com> (raw)
In-Reply-To: <f158d290-69b5-46bb-a49d-a6162d39e2a1@roeck-us.net>

On 3/29/26 08:46, Guenter Roeck wrote:
> When using the with_info API to register the hwmon device, the subsystem 
> already
> serializes sysfs accesses. The next patch converts the driver to use the
> with_info API. Pleas explain why the extra protection is necessary.

Ah yes. I originally wrote the mutex patch to fix the race condition in 
the legacy sysfs code, but totally missed that migrating to with_info 
handles the serialization for us natively.

> Sashiko has the same feedback:
> 
> https://sashiko.dev/#/patchset/20260328182015.220298-1- 
> tabreztalks%40gmail.com

Separately, Sashiko flagged a pre-existing bug where 
ads7871_write_reg8() passes a stack-allocated array (u8 tmp[2]) to 
spi_write(), breaking DMA.

To fix this properly, I need to move the buffer into the device's 
private data structure. However, doing so requires serialization to 
prevent concurrent reads from corrupting the shared buffer. Since moving 
to with_info provides that serialization, my plan for the v2 series is:

- Patch 1: Convert to hwmon_device_register_with_info (which natively 
serializes the driver).
- Patch 2: Fix the SPI DMA bug by introducing a shared tx_buf (now 
safely protected by the hwmon core).

I will drop the custom mutex entirely and send out v2 with this structure.

Thanks,
Tabrez



  reply	other threads:[~2026-03-29  5:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-28 18:20 [PATCH 0/2] hwmon: (ads7871) Fix concurrency and modernize API Tabrez Ahmed
2026-03-28 18:20 ` [PATCH 1/2] hwmon: (ads7871) Add mutex to serialize SPI transactions Tabrez Ahmed
2026-03-29  3:16   ` Guenter Roeck
2026-03-29  5:00     ` Tabrez Ahmed [this message]
2026-03-28 18:20 ` [PATCH 2/2] hwmon: (ads7871) Convert to hwmon_device_register_with_info Tabrez Ahmed

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=9c7b873d-8797-4fa1-ab44-2599b2b02f4e@gmail.com \
    --to=tabreztalks@gmail.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=me@brighamcampbell.com \
    --cc=shuah@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