linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Charles Keepax <ckeepax@opensource.cirrus.com>
Cc: broonie@kernel.org, linus.walleij@linaro.org, brgl@bgdev.pl,
	linux-gpio@vger.kernel.org, linux-spi@vger.kernel.org,
	patches@opensource.cirrus.com
Subject: Re: [PATCH 1/3] gpio: swnode: Add ability to specify native chip selects for SPI
Date: Tue, 10 Dec 2024 16:15:18 -0800	[thread overview]
Message-ID: <Z1jZliSoXziuLt1u@google.com> (raw)
In-Reply-To: <20240326141108.1079993-2-ckeepax@opensource.cirrus.com>

On Tue, Mar 26, 2024 at 02:11:06PM +0000, Charles Keepax wrote:
> SPI devices can specify a cs-gpios property to enumerate their
> chip selects. Under device tree, a zero entry in this property can
> be used to specify that a particular chip select is using the SPI
> controllers native chip select, for example:
> 
>         cs-gpios = <&gpio1 0 0>, <0>;
> 
> Here the second chip select is native. However, when using swnodes
> there is currently no way to specify a native chip select. The
> proposal here is to register a swnode_gpio_undefined software node,
> that can be specified to allow the indication of a native chip
> select. For example:
> 
> static const struct software_node_ref_args device_cs_refs[] = {
> 	{
> 		.node  = &device_gpiochip_swnode,
> 		.nargs = 2,
> 		.args  = { 0, GPIO_ACTIVE_LOW },
> 	},
> 	{
> 		.node  = &swnode_gpio_undefined,
> 		.nargs = 0,
> 	},
> };

I am sorry, I am very late to the party, but wouldn't it all work by
simply setting ".node" to NULL? As far as I can see we have in
software_node_get_reference_args():

	...

	if (index * sizeof(*ref) >= prop->length)
		return -ENOENT;

	ref_array = prop->pointer;
	ref = &ref_array[index];

	refnode = software_node_fwnode(ref->node);
	if (!refnode)
		return -ENOENT;

if ref->node is NULL then software_node_fwnode(ref->node) will return
NULL and we'll get -ENOENT which will bubble up to
gpiod_get_index_optional() in SPI core.

Thanks.

-- 
Dmitry

  parent reply	other threads:[~2024-12-11  0:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-26 14:11 [PATCH 0/3] Add bridged amplifiers to cs42l43 Charles Keepax
2024-03-26 14:11 ` [PATCH 1/3] gpio: swnode: Add ability to specify native chip selects for SPI Charles Keepax
2024-04-04  8:16   ` Linus Walleij
2024-04-08 13:21     ` Charles Keepax
2024-04-09  7:12       ` Linus Walleij
2024-04-09  8:44         ` Charles Keepax
2024-12-11  0:15   ` Dmitry Torokhov [this message]
2024-12-12 10:45     ` Charles Keepax
2024-03-26 14:11 ` [PATCH 2/3] spi: Add a mechanism to use the fwnode name for the SPI device Charles Keepax
2024-03-26 14:11 ` [PATCH 3/3] spi: cs42l43: Add bridged cs35l56 amplifiers Charles Keepax
2024-03-27 18:34   ` kernel test robot
2024-03-28 13:15   ` kernel test robot

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=Z1jZliSoXziuLt1u@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=patches@opensource.cirrus.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;
as well as URLs for NNTP newsgroup(s).