mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] pinctrl: rockchip: check for invalid pull settings
@ 2024-04-15  7:21 Ahmad Fatoum
  2024-04-16 10:02 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-04-15  7:21 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Commit e877582e9875 ("pinctrl: rockchip: fix bias settings") reinstated
the translation done to pull settings via the bank->pull_type array,
like the original Linux driver does. What it didn't do is actually check
that the translation succeeded. Add this check to make sure we don't
somehow end up packing a negative value into the bitset we write into
the hardware.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/pinctrl/pinctrl-rockchip.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index c1e937ea2cb1..ca9939c9e91d 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -2172,8 +2172,13 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank,
 			if (ret == RK_BIAS_PULL_UP)
 				ret = 3;
 		}
 
+		if (ret < 0) {
+			dev_err(dev, "unsupported pull setting %d\n", pull);
+			return ret;
+		}
+
 		/* enable the write to the equivalent lower bits */
 		data = ((1 << RK3188_PULL_BITS_PER_PIN) - 1) << (bit + 16);
 		rmask = data | (data >> 16);
 		data |= (ret << bit);
-- 
2.39.2




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-16 10:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-15  7:21 [PATCH] pinctrl: rockchip: check for invalid pull settings Ahmad Fatoum
2024-04-16 10:02 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox