Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CAD5EC46467 for ; Wed, 18 Jan 2023 12:12:41 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 52F3485617; Wed, 18 Jan 2023 13:12:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=walle.cc Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=walle.cc header.i=@walle.cc header.b="xXYioxEC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B248A85602; Wed, 18 Jan 2023 13:12:35 +0100 (CET) Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5099D85605 for ; Wed, 18 Jan 2023 13:12:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=walle.cc Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michael@walle.cc Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id D48801645; Wed, 18 Jan 2023 13:12:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1674043949; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=65MVswXMU29NqeaKLkzBM9jcRHTShl6oqgjlFNv/48Q=; b=xXYioxECessB99zWXHv22qj5K7RG84t0gf9LVPyeGBltDayEl3vTr+vL2eqFl52uV8YybH 1Jtt0jL54MDMkYO5qgoLAv/5d4vDLTRPu1YlsfgdAZSxje0ODOZiD5Op+3GOwOE5JzXWJd dJdKVD+psGPEO0gjhGknXk1+k0DaHm1ZYWpntRQOoh4aX8/K85AFjIPonKwBTpDh8p9MC2 1Nogq3VNNdJrPqs7SEpHw0w9e2UzAvUxKEPVss9KUbN+2AfwGgkGVJGp4WhlY9gstU5Bq8 cURfBIsDoo4r0bhQ9/I0qbQbxiw2Zz4bBH5PYSoCH7PLsPoCcXLRwZRJsNXXYg== From: Michael Walle To: u-boot@lists.denx.de Cc: Marek Vasut , Michael Walle Subject: [PATCH 1/3] pinctrl: don't fall back to pinctrl_select_state_simple() Date: Wed, 18 Jan 2023 13:12:22 +0100 Message-Id: <20230118121224.253241-1-michael@walle.cc> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean If CONFIG_PINCTRL_FULL is enabled, never fall back to the simple implementation. pinctrl_select_state() is called for each device and it is expected to fail. A fallback to the simple imeplementation doesn't make much sense. To keep the return code consistent, we need to change the -EINVAL (which was ignored before) to -ENOSYS. Signed-off-by: Michael Walle --- The real underlying problem is that the pinctrl_select_state_simple() doesn't really work before relocation. This implementation calls uclass_get_device() which will try to probe the pinctrl, but that device might not be ready yet, i.e. in my case, it is an MFD and it needs its parent. For each device in the devicetree, there will be a device_probe(pinctrl) attempt and if that device has some kind of private or platform data, it will eat away the early memory, because there is no free. I'm not really sure how that could be fixed. But still, if there is a full implementation, it shouldn't fall back to the simple one. --- drivers/pinctrl/pinctrl-uclass.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c index ce2d5ddf6d..419ef5f52f 100644 --- a/drivers/pinctrl/pinctrl-uclass.c +++ b/drivers/pinctrl/pinctrl-uclass.c @@ -71,13 +71,13 @@ static int pinctrl_select_state_full(struct udevice *dev, const char *statename) */ state = dectoul(statename, &end); if (*end) - return -EINVAL; + return -ENOSYS; } snprintf(propname, sizeof(propname), "pinctrl-%d", state); list = dev_read_prop(dev, propname, &size); if (!list) - return -EINVAL; + return -ENOSYS; size /= sizeof(*list); for (i = 0; i < size; i++) { @@ -162,11 +162,6 @@ U_BOOT_DRIVER(pinconfig_generic) = { }; #else -static int pinctrl_select_state_full(struct udevice *dev, const char *statename) -{ - return -ENODEV; -} - static int pinconfig_post_bind(struct udevice *dev) { return 0; @@ -317,10 +312,10 @@ int pinctrl_select_state(struct udevice *dev, const char *statename) * Try full-implemented pinctrl first. * If it fails or is not implemented, try simple one. */ - if (pinctrl_select_state_full(dev, statename)) - return pinctrl_select_state_simple(dev); + if (CONFIG_IS_ENABLED(PINCTRL_FULL)) + return pinctrl_select_state_full(dev, statename); - return 0; + return pinctrl_select_state_simple(dev); } int pinctrl_request(struct udevice *dev, int func, int flags) -- 2.30.2