mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <ahmad@a3f.at>
Subject: [PATCH 5/7] driver: be explicit about supported #feature-cells
Date: Mon, 24 Apr 2023 14:18:03 +0200	[thread overview]
Message-ID: <20230424121805.150434-5-ahmad@a3f.at> (raw)
In-Reply-To: <20230424121805.150434-1-ahmad@a3f.at>

A feature controller may control the activation of multiple devices.
This is represented by a single index argument in the API. Thus any
value higher than #feature-cells = <1>; is unsupported, so let's be
explicit about that. #feature-cells = <0>; specs will just be
interpreted as if the argument was a 0.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 drivers/base/featctrl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/base/featctrl.c b/drivers/base/featctrl.c
index abe21698ede7..f40b1f04bc1f 100644
--- a/drivers/base/featctrl.c
+++ b/drivers/base/featctrl.c
@@ -53,10 +53,13 @@ static struct feature_controller *featctrl_get_from_provider(struct of_phandle_a
 	if (ret < 0)
 		return ERR_PTR(ret);
 
+	if (spec->args_count > 1)
+		return ERR_PTR(-EINVAL);
+
 	/* Check if we have such a controller in our array */
 	list_for_each_entry(featctrl, &of_feature_controllers, list) {
 		if (dev_of_node(featctrl->dev) == spec->np) {
-			*gateid = spec->args[0];
+			*gateid = spec->args_count ? spec->args[0] : 0;
 			return featctrl;
 		}
 	}
-- 
2.38.4




  parent reply	other threads:[~2023-04-24 12:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24 12:17 [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully Ahmad Fatoum
2023-04-24 12:18 ` [PATCH 2/7] sandbox: power: " Ahmad Fatoum
2023-04-24 12:18 ` [PATCH 3/7] sandbox: hostfile: don't warn on failed hostfile fixup Ahmad Fatoum
2023-04-24 12:18 ` [PATCH 4/7] treewide: drop trailing space Ahmad Fatoum
2023-04-24 12:18 ` Ahmad Fatoum [this message]
2023-04-24 12:18 ` [PATCH 6/7] featctrl: drop useless NULL check Ahmad Fatoum
2023-04-24 12:18 ` [PATCH 7/7] sandbox: hostfile: add feature controller support Ahmad Fatoum
2023-05-02  9:34 ` [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully Sascha Hauer

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=20230424121805.150434-5-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --cc=barebox@lists.infradead.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