From nobody Sat Feb 7 23:48:13 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB79427E7EB; Tue, 3 Feb 2026 17:30:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770139819; cv=none; b=XrWTHjiqtWAY6wbuEESKn27dly9pzWI5+lRSkHwFbzaMYIYNfOPq+mF80oHKlZJi0tWJnaQxLZJvy1P7eA9OhURErOhSQZ1GzA/hiIe6b9w+sZheZo7VFFv7QsF45EB0wGIA83U9Osd3oliH/gBmxuBFoBEWMW+jYlHwrqNU56k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770139819; c=relaxed/simple; bh=CTakssbPD5mZa/dpW9T53W/pl1AiG+PjzXOlBCYHqos=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DArta0OJMKkKL4yj0ElwakoXwNNS+AWC4rhvzrnZoZOh78GOWMmFKJ6ATFdqcAKcttqpUBAwqXu8uT6ylPJXMgGLxn/eqb4wlIPz34Mca5HRZURviaIPmEknh80IzUJ6qlIiTFCXSPsn9fkVr4Y8UT9fA5I5CNX0IPTEFLxyxnE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fqMi7Xqw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fqMi7Xqw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3671C19421; Tue, 3 Feb 2026 17:30:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770139818; bh=CTakssbPD5mZa/dpW9T53W/pl1AiG+PjzXOlBCYHqos=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fqMi7XqwPpWMGlrJrdRobcmf2ZFWBV02p0dttrUHipAZyGlKPvEtzQGK3TQ3CBRnk 6Q1K8SH9NrNsDElqNxI2GmTRHV4xR5JlBX8x73hwGK4e4Ya5gdrSq/2UTCAktxxT7S NrktYVh63uRKwSApX4Ef5j8eEix97ccCpxbt391U9yXiRC1hlLSCNwjCnCxPIRmAYC ZaL4/V4hlURfF/XTltPjnI0DjJNcYL7tgxulhgz9JyfXb06Lw9gAIGqmUVlNH7LHNt 1WWVkkKgabfG00QR4BQx0SFkpXHmfsj1GxF/woJV/YpoRPUydllrg939DKq7r3KNZL BD0nivBT2DUDw== From: Conor Dooley To: linusw@kernel.org Cc: conor@kernel.org, Conor Dooley , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [rfc 1/2] pinctrl: pinconf-generic: perform basic checks on pincfg properties Date: Tue, 3 Feb 2026 17:29:42 +0000 Message-ID: <20260203-herald-wrench-990ca2aaed2a@spud> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260203-device-unwashed-ed24f8592d79@spud> References: <20260203-device-unwashed-ed24f8592d79@spud> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4476; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=yMFtCzvyTWIGqd+o1eahXgukEiJT/4dN+e2EwxmDNM8=; b=owGbwMvMwCVWscWwfUFT0iXG02pJDJlNBjO+/bDWzXC/4Oh1pH8FQwc3r9/fm3KxW1Y8f7sl3 O/D2+hfHaUsDGJcDLJiiiyJt/tapNb/cdnh3PMWZg4rE8gQBi5OAZjIWSdGhrbeuwppgkLfOlyy Sias33g37bzD7Rs3Il5lTxdb8PnCmgkMfzh7lMImL5K4sfdIkluYkKfWXNdTB94zs/25dWjRPAn N28wA X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Conor Dooley Some pinconf properties are mutually exclusive, either because they convey the same information in different units or represent incompatible configurations of the same pin. Attempt, in two ways, to prevent these situations. Firstly, for enable/disable properties, produce an error if both are set. Since enable/disable properties share the same enum value, they can be trivially checked via the newly added bitmap. Having both enable and disable for the same config makes no sense at all, so produce an error in this case. For interactions between properties, doing them outside the loop makes more sense as it can be evaluated once. In case there are some edge cases that would be broken by producing an error, only warn for now. Signed-off-by: Conor Dooley --- ngl, this is a bit of a lazy approach, and I just didn't bother checking the more complex things that a simple bitmap scheme could not address. Chief among the more complexes thing that I didn't do anything about is that properties that I don't feel make sense when something is disabled don't complain when they are present but the disabled property also is. That's because enable and disable are the same bit in the bitmap, so more info than just the bitmap would be required to perform that check. Part of me says that that's okay and should be handled by dt tools, since it's mostly harmless and that denying things that are effectively undefined behaviour (well really, they're driver/implementation defined behaviour) is what's actually valuable here. I dunno about the tests being done as a sum, but I dunno if there's a neater way to do that test without creating bitmaps to and with the created one. --- drivers/pinctrl/pinconf-generic.c | 41 ++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-ge= neric.c index 366775841c63..d182ec84e2df 100644 --- a/drivers/pinctrl/pinconf-generic.c +++ b/drivers/pinctrl/pinconf-generic.c @@ -222,7 +222,10 @@ static int parse_dt_cfg(struct device_node *np, unsigned int count, unsigned long *cfg, unsigned int *ncfg) { - int i; + unsigned long *properties; + int i, test; + + properties =3D bitmap_zalloc(count, GFP_KERNEL); =20 for (i =3D 0; i < count; i++) { u32 val; @@ -251,11 +254,45 @@ static int parse_dt_cfg(struct device_node *np, if (ret) val =3D par->default_value; =20 + /* if param is greater than count, these are custom properties */ + if (par->param <=3D count) { + ret =3D test_and_set_bit(par->param, properties); + if (ret) { + pr_err("%s: conflicting setting detected for %s\n", + np->name, par->property); + bitmap_free(properties); + return -EINVAL; + } + } + pr_debug("found %s with value %u\n", par->property, val); cfg[*ncfg] =3D pinconf_to_config_packed(par->param, val); (*ncfg)++; } =20 + if (test_bit(PIN_CONFIG_DRIVE_STRENGTH, properties) && + test_bit(PIN_CONFIG_DRIVE_STRENGTH_UA, properties)) + pr_err("%s: cannot have multiple drive strength properties\n", + np->name); + + test =3D test_bit(PIN_CONFIG_BIAS_BUS_HOLD, properties) + + test_bit(PIN_CONFIG_BIAS_DISABLE, properties) + + test_bit(PIN_CONFIG_BIAS_HIGH_IMPEDANCE, properties) + + test_bit(PIN_CONFIG_BIAS_PULL_UP, properties) + + test_bit(PIN_CONFIG_BIAS_PULL_PIN_DEFAULT, properties) + + test_bit(PIN_CONFIG_BIAS_PULL_DOWN, properties); + if (test > 1) + pr_err("%s: cannot have multiple bias configurations\n", + np->name); + + test =3D test_bit(PIN_CONFIG_DRIVE_OPEN_DRAIN, properties) + + test_bit(PIN_CONFIG_DRIVE_OPEN_SOURCE, properties) + + test_bit(PIN_CONFIG_DRIVE_PUSH_PULL, properties); + if (test > 1) + pr_err("%s: cannot have multiple drive configurations\n", + np->name); + + bitmap_free(properties); return 0; } =20 @@ -352,6 +389,7 @@ int pinconf_generic_parse_dt_config(struct device_node = *np, ret =3D parse_dt_cfg(np, dt_params, ARRAY_SIZE(dt_params), cfg, &ncfg); if (ret) return ret; + if (pctldev && pctldev->desc->num_custom_params && pctldev->desc->custom_params) { ret =3D parse_dt_cfg(np, pctldev->desc->custom_params, @@ -360,6 +398,7 @@ int pinconf_generic_parse_dt_config(struct device_node = *np, return ret; } =20 + /* no configs found at all */ if (ncfg =3D=3D 0) { *configs =3D NULL; --=20 2.51.0 From nobody Sat Feb 7 23:48:13 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 298353644D2; Tue, 3 Feb 2026 17:30:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770139821; cv=none; b=UhKOgGXu61taW5sBg+yR7zzEVFx9elIl71a5PxLao5ijn4mPjwsaCBnrq/E2POgxg0d5YSzL45Dp2OIfsaLUtfg1KCjIxR034bwLCTsF/zOvmKFWw1fvBeVUMAo/yL6YgjyjSSH3OFqiptNVdYPn7VS6tUe9/vdWyaXrNQ2XA+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770139821; c=relaxed/simple; bh=+TJZbuSUrc2aq/cuJGaaBK3cvI5fuXEhX3m/yBP+rCY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NWC4aNPNYaF1LASwsCTaqLSfevgeHrC0n33emAzTiaT63Ee0go6TukFFgS9+a6BnWQTJVlIrJzSMtBmJWWwGXWqSuh+ttEn5H1EBdrvWcF0Y1S1cMATjHDCQ+/aKdtQjC5OtcL8H/LFatvnto3eK5KKY45o4vdNqrq9LJ4AUqys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GRaWRc6b; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GRaWRc6b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8EBAC2BC86; Tue, 3 Feb 2026 17:30:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770139820; bh=+TJZbuSUrc2aq/cuJGaaBK3cvI5fuXEhX3m/yBP+rCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GRaWRc6bEwLpO8hmq0KoNnypzwN76hNAMU4aiLMDrSNyG6V82eV6MklhBYmLy4p1x p8nYreFLKGHkTXC0f5sjC7hT7Ydh4Yjg5P9FQL6umoQpsIorC1ogGgIQV0EKuSXjY6 CstRjgNkYZozYURWnyZTKGT2shl8i4bM+EmhvvhWthUhkxDDpVyAUICboqPPZ/UivJ pASGHcf+8EwdCfT4i36nd329lDTk0BhBuUrYfEo2fQpvYIcVDf+gm1UDr2h5VPQSyt kUtbXq/uzBQW1W1oHQ2ZhgOy9F7md8yNlaeO5HN7lSDDmWeU3SbkMX5X0Fy0u4ROVy f7V1Tcho8m2cg== From: Conor Dooley To: linusw@kernel.org Cc: conor@kernel.org, Conor Dooley , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [rfc 2/2] dt-bindings: pinctrl: pincfg-node: add restrictions on conflicting properties Date: Tue, 3 Feb 2026 17:29:43 +0000 Message-ID: <20260203-gleaming-perky-e12d6a5fe86f@spud> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260203-device-unwashed-ed24f8592d79@spud> References: <20260203-device-unwashed-ed24f8592d79@spud> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3170; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=fHWlkhGu4hcgzz/nLnrdWCDLipWjIryl6nOBxJfO8ZM=; b=owGbwMvMwCVWscWwfUFT0iXG02pJDJlNBjN6zvKLxfLMys0Om/17rpbpRXfR4IDKli8cJ1ec3 b6i5v7KjlIWBjEuBlkxRZbE230tUuv/uOxw7nkLM4eVCWQIAxenAExkkhQjw+7uL7blu7yN61a6 evk7n2qrcHSfyS0dbyFrnnmsZ2rkQkaGPa67+oK9jJK8Q8/MmLzt2bLpjmwh5Uc0ZjkVlGUyHGH mAQA= X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Conor Dooley Many of the possible pincfg properties are not compatible with one another, either because they represent mutually exclusive states for a pin or because they provide the same information in different units. Add some simple restrictions to prevent invalid configurations. Signed-off-by: Conor Dooley --- .../bindings/pinctrl/pincfg-node.yaml | 105 ++++++++++++++++-- 1 file changed, 98 insertions(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/pinctrl/pincfg-node.yaml b/D= ocumentation/devicetree/bindings/pinctrl/pincfg-node.yaml index d1bc389e0a6d..874f0781d2fc 100644 --- a/Documentation/devicetree/bindings/pinctrl/pincfg-node.yaml +++ b/Documentation/devicetree/bindings/pinctrl/pincfg-node.yaml @@ -162,12 +162,103 @@ properties: this affects the expected delay in ps before latching a value to an output pin. =20 -if: - required: - - skew-delay -then: - properties: - skew-delay-input-ps: false - skew-delay-output-ps: false +allOf: + - if: + required: + - skew-delay + then: + properties: + skew-delay-input-ps: false + skew-delay-output-ps: false + + - if: + required: + - input-disable + then: + properties: + input-enable: false + + - if: + required: + - output-disable + then: + properties: + output-enable: false + output-impedance-ohms: false + + - if: + required: + - output-low + then: + properties: + output-high: false + + - if: + required: + - low-power-enable + then: + properties: + low-power-disable: false + + - if: + required: + - input-schmitt-disable + then: + properties: + input-schmitt-enable: false + input-schmitt-microvolt: false + + - if: + required: + - drive-strength + then: + properties: + drive-strength-microamp: false + + - if: + anyOf: + - required: + - drive-open-source + - required: + - drive-open-drain + - required: + - drive-push-pull + then: + oneOf: + - required: + - drive-open-source + - required: + - drive-open-drain + - required: + - drive-push-pull + + - if: + anyOf: + - required: + - bias-disable + - required: + - bias-high-impedance + - required: + - bias-bus-hold + - required: + - bias-pull-up + - required: + - bias-pull-down + - required: + - bias-pull-pin-default + then: + oneOf: + - required: + - bias-disable + - required: + - bias-high-impedance + - required: + - bias-bus-hold + - required: + - bias-pull-up + - required: + - bias-pull-down + - required: + - bias-pull-pin-default =20 additionalProperties: true --=20 2.51.0