From: Mark Brown <broonie@kernel.org>
To: Chao Huang <958028483@qq.com>
Cc: linux-spi <linux-spi@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Chao Huang <huangchao@kylinos.cn>
Subject: Re: [PATCH] spi: Add spi_for_each_controller() helper
Date: Mon, 18 May 2026 09:22:39 +0100 [thread overview]
Message-ID: <01917d8a-4b0f-4047-a065-cfebaec9b211@sirena.org.uk> (raw)
In-Reply-To: <tencent_74D72238CFEAA838A967727CA08D92C23005@qq.com>
[-- Attachment #1: Type: text/plain, Size: 1547 bytes --]
On Mon, May 18, 2026 at 03:10:26PM +0800, Chao Huang wrote:
> > Do you have an actual user for this or is this just purely theoretical
> > at this point? It'd make a lot more sense to add this along with a
> > user.
> Yes, I do have an actual user for this helper in my project.
> The goal is to provide a new SPI controller API that allows users to
> access SPI controllers by bus number and chip select (CS). The
> `spi_for_each_controller()` helper is used to iterate over all registered
> controllers, find the target controller by bus number, and then operate
> on it.
OK, I would hold off on this patch and sumbit it along with the user -
it's not really something that's clearly useful without that user.
> > When unregistering controllers we do start the teardown process before
> > we pull the device off the controller list, and drop the lock while
> > doing so. That's probably fine for a lot of uses.
> >
> Regarding the controller unregistration case you mentioned — do you mean
> the `spi_unregister_controller()` function?
Yes.
> In my `fn` callback, I call `spi_controller_get()` to safely grab a
> reference to the controller, and later call `spi_controller_put()` at an
> appropriate time (e.g., after the operation is done). This should
> prevent the controller from being freed while it is still in use, even
> if unregistration happens concurrently.
The controller itself will be there but we do things like stopping the
queue before we destroy the controller.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2026-05-18 8:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 8:45 ChaoHuang
2026-05-16 6:48 ` Mark Brown
[not found] ` <tencent_74D72238CFEAA838A967727CA08D92C23005@qq.com>
2026-05-18 8:22 ` Mark Brown [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-05-14 6:13 958028483
2026-05-14 7:08 ` Mark Brown
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=01917d8a-4b0f-4047-a065-cfebaec9b211@sirena.org.uk \
--to=broonie@kernel.org \
--cc=958028483@qq.com \
--cc=huangchao@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.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®