Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1599683 > unrolled thread
| Started by | John Keeping <john@metanate.com> |
|---|---|
| First post | 2017-03-13 19:40 +0100 |
| Last post | 2017-03-15 17:40 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[RFC PATCH 3/4] pinctrl: rockchip: split out verification of mux settings John Keeping <john@metanate.com> - 2017-03-13 19:40 +0100
Re: [RFC PATCH 3/4] pinctrl: rockchip: split out verification of mux settings Heiko Stuebner <heiko@sntech.de> - 2017-03-15 17:40 +0100
| From | John Keeping <john@metanate.com> |
|---|---|
| Date | 2017-03-13 19:40 +0100 |
| Subject | [RFC PATCH 3/4] pinctrl: rockchip: split out verification of mux settings |
| Message-ID | <tkD2W-4vZ-25@gated-at.bofh.it> |
We need to avoid calling regmap functions from irq handlers, so the next
commit is going to move the call to rockchip_set_mux() into an
irq_bus_sync_unlock handler. But we can't return an error from there so
we still need to check the settings from rockchip_irq_set_type() and we
will use this new rockchip_verify_mux() function from there.
Signed-off-by: John Keeping <john@metanate.com>
---
drivers/pinctrl/pinctrl-rockchip.c | 46 +++++++++++++++++++++++++-------------
1 file changed, 30 insertions(+), 16 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 2f963aea64b2..52e70c4aef7c 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -629,6 +629,31 @@ static int rockchip_get_mux(struct rockchip_pin_bank *bank, int pin)
return ((val >> bit) & mask);
}
+static int rockchip_verify_mux(struct rockchip_pin_bank *bank,
+ int pin, int mux)
+{
+ struct rockchip_pinctrl *info = bank->drvdata;
+ int iomux_num = (pin / 8);
+
+ if (iomux_num > 3)
+ return -EINVAL;
+
+ if (bank->iomux[iomux_num].type & IOMUX_UNROUTED) {
+ dev_err(info->dev, "pin %d is unrouted\n", pin);
+ return -EINVAL;
+ }
+
+ if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY) {
+ if (mux != RK_FUNC_GPIO) {
+ dev_err(info->dev,
+ "pin %d only supports a gpio mux\n", pin);
+ return -ENOTSUPP;
+ }
+ }
+
+ return 0;
+}
+
/*
* Set a new mux function for a pin.
*
@@ -652,23 +677,12 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux)
u8 bit;
u32 data, rmask;
- if (iomux_num > 3)
- return -EINVAL;
-
- if (bank->iomux[iomux_num].type & IOMUX_UNROUTED) {
- dev_err(info->dev, "pin %d is unrouted\n", pin);
- return -EINVAL;
- }
+ ret = rockchip_verify_mux(bank, pin, mux);
+ if (ret < 0)
+ return ret;
- if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY) {
- if (mux != RK_FUNC_GPIO) {
- dev_err(info->dev,
- "pin %d only supports a gpio mux\n", pin);
- return -ENOTSUPP;
- } else {
- return 0;
- }
- }
+ if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY)
+ return 0;
dev_dbg(info->dev, "setting mux of GPIO%d-%d to %d\n",
bank->bank_num, pin, mux);
--
2.12.0.377.gf910686b23.dirty
[toc] | [next] | [standalone]
| From | Heiko Stuebner <heiko@sntech.de> |
|---|---|
| Date | 2017-03-15 17:40 +0100 |
| Message-ID | <tlk7T-1MF-1@gated-at.bofh.it> |
| In reply to | #1599683 |
Am Montag, 13. März 2017, 18:38:12 CET schrieb John Keeping: > We need to avoid calling regmap functions from irq handlers, so the next > commit is going to move the call to rockchip_set_mux() into an > irq_bus_sync_unlock handler. But we can't return an error from there so > we still need to check the settings from rockchip_irq_set_type() and we > will use this new rockchip_verify_mux() function from there. > > Signed-off-by: John Keeping <john@metanate.com> straightforward separation of the verification code Reviewed-by: Heiko Stuebner <heiko@sntech.de>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web