public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Sergey Suloev <sergey.suloev@gmail.com>
To: ulf.hansson@linaro.org
Cc: catalin.popescu@leica-geosystems.com, linux-mmc@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Sergey Suloev <sergey.suloev@gmail.com>
Subject: [PATCH] mmc: pwrseq_simple: fix probe failure when CONFIG_RESET_GPIO is enabled
Date: Fri, 20 Feb 2026 22:47:25 +0300	[thread overview]
Message-ID: <20260220194725.1341281-1-sergey.suloev@gmail.com> (raw)

The driver uses a heuristic — checking if exactly one entry exists in
'reset-gpios' — to decide whether to attempt reset controller API usage
via devm_reset_control_get_optional_shared(). This is semantically
incorrect and causes a permanent probe failure when CONFIG_RESET_GPIO
is enabled.

When CONFIG_RESET_GPIO=y, __of_reset_control_get() intercepts the
'reset-gpios' DT property and attempts to register the GPIO as a reset
controller via __reset_add_reset_gpio_device(). If the GPIO controller
is not yet fully initialized at probe time, this returns -ENOENT instead
of -EPROBE_DEFER, and the error path does not respect the 'optional'
flag, causing pwrseq_simple to fail permanently rather than defer.
This prevents mmc1 from probing on boards that use 'reset-gpios' for
WiFi power sequencing, such as BananaPi M2 Magic with AP6212/BCM43430
on Allwinner R16.

The correct indicator of reset controller intent is the explicit presence
of a 'resets' property in the device tree node, not the count of
'reset-gpios' entries. A single 'reset-gpios' entry is just as likely
to be a plain GPIO as multiple entries.

Replace the ngpio == 1 heuristic with an explicit check for the 'resets'
DT property, making the behavior unambiguous and immune to
CONFIG_RESET_GPIO interference.

Fixes: 73bf4b7381f7 ("mmc: pwrseq_simple: add support for one reset control")
Signed-off-by: Sergey Suloev <sergey.suloev@gmail.com>
---
 drivers/mmc/core/pwrseq_simple.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mmc/core/pwrseq_simple.c b/drivers/mmc/core/pwrseq_simple.c
index 4b47e6c3b04b..780c8818a273 100644
--- a/drivers/mmc/core/pwrseq_simple.c
+++ b/drivers/mmc/core/pwrseq_simple.c
@@ -124,7 +124,6 @@ static int mmc_pwrseq_simple_probe(struct platform_device *pdev)
 {
 	struct mmc_pwrseq_simple *pwrseq;
 	struct device *dev = &pdev->dev;
-	int ngpio;
 
 	pwrseq = devm_kzalloc(dev, sizeof(*pwrseq), GFP_KERNEL);
 	if (!pwrseq)
@@ -134,8 +133,7 @@ static int mmc_pwrseq_simple_probe(struct platform_device *pdev)
 	if (IS_ERR(pwrseq->ext_clk) && PTR_ERR(pwrseq->ext_clk) != -ENOENT)
 		return dev_err_probe(dev, PTR_ERR(pwrseq->ext_clk), "external clock not ready\n");
 
-	ngpio = of_count_phandle_with_args(dev->of_node, "reset-gpios", "#gpio-cells");
-	if (ngpio == 1) {
+	if (device_property_present(dev, "resets")) {
 		pwrseq->reset_ctrl = devm_reset_control_get_optional_shared(dev, NULL);
 		if (IS_ERR(pwrseq->reset_ctrl))
 			return dev_err_probe(dev, PTR_ERR(pwrseq->reset_ctrl),
-- 
2.43.0


             reply	other threads:[~2026-02-20 19:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-20 19:47 Sergey Suloev [this message]
2026-03-04 16:03 ` [PATCH] mmc: pwrseq_simple: fix probe failure when CONFIG_RESET_GPIO is enabled Ulf Hansson
2026-03-04 16:41 ` Bartosz Golaszewski
2026-03-05  9:43   ` Philipp Zabel
2026-03-05 10:04     ` Bartosz Golaszewski
2026-03-05 10:46       ` Krzysztof Kozlowski
2026-03-09  9:36         ` Bartosz Golaszewski

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=20260220194725.1341281-1-sergey.suloev@gmail.com \
    --to=sergey.suloev@gmail.com \
    --cc=catalin.popescu@leica-geosystems.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.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