[PATCH] pinctrl: rockchip: check for invalid pull settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux