mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert+renesas@glider.be>
To: Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Kevin Hilman <khilman@kernel.org>,
	Magnus Damm <magnus.damm@gmail.com>,
	Olof Johansson <olof@lixom.net>,
	Simon Horman <horms@verge.net.au>
Cc: linux-renesas-soc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Geert Uytterhoeven <geert+renesas@glider.be>
Subject: [PATCH v2 1/2] base: soc: Let soc_device_match() return no match when called too early
Date: Wed, 29 Mar 2017 21:38:53 +0200	[thread overview]
Message-ID: <1490816334-14568-2-git-send-email-geert+renesas@glider.be> (raw)
In-Reply-To: <1490816334-14568-1-git-send-email-geert+renesas@glider.be>

If soc_device_match() is called before the SoC bus has been registered,
bus_for_each_dev() returns -EINVAL, which is considered a match, as it
is non-zero.

While calling soc_device_match() too early can be considered an
integration mistake, returning a match is counter-intuitive:
soc_device_match() is typically used to handle quirks, i.e. to deviate
from the default path.  Hence add a check to abort checking and return
no match instead.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Arnd Bergmann <arnd@arndb.de>
---
v2:
  - Drop RFC state,
  - Add Acked-by,
  - Add missing "too early" to second paragraph of description.
---
 drivers/base/soc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index dc26e5949a320223..50033081834a9ccd 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -230,6 +230,8 @@ const struct soc_device_attribute *soc_device_match(
 			break;
 		ret = bus_for_each_dev(&soc_bus_type, NULL, (void *)matches,
 				       soc_device_match_one);
+		if (ret < 0)
+			return NULL;
 		if (!ret)
 			matches++;
 		else
-- 
2.7.4

  reply	other threads:[~2017-03-29 19:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29 19:38 [PATCH v2 0/2] base: soc: soc_device_match() improvements Geert Uytterhoeven
2017-03-29 19:38 ` Geert Uytterhoeven [this message]
2017-03-29 19:38 ` [PATCH v2 2/2] base: soc: Allow early registration of a single SoC device Geert Uytterhoeven
2017-03-29 19:48 ` [PATCH v2 0/2] base: soc: soc_device_match() improvements Arnd Bergmann
2017-03-31  8:39   ` Simon Horman

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=1490816334-14568-2-git-send-email-geert+renesas@glider.be \
    --to=geert+renesas@glider.be \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=horms@verge.net.au \
    --cc=khilman@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=olof@lixom.net \
    /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®