* [PATCH v2] pinctrl: stm32: .pin_config_dbg_show fixes
@ 2016-05-24 11:57 patrice.chotard
2016-05-24 11:57 ` [PATCH v2] pinctrl: stm32: factorize stm32_pconf_input/output_get() patrice.chotard
0 siblings, 1 reply; 4+ messages in thread
From: patrice.chotard @ 2016-05-24 11:57 UTC (permalink / raw)
To: linux-kernel, Linus Walleij, linux-gpio, linux-arm-kernel,
Maxime Coquelin
Cc: patrice.chotard
From: Patrice Chotard <patrice.chotard@st.com>
v1 -> v2
_ rebase on top of Linus Torsvald tree.
_ remove "[PATCH 1/2]: pinctrl: stm32: fix warning", already fixed by Linus Torvalds
Patrice Chotard (1):
pinctrl: stm32: factorize stm32_pconf_input/output_get()
drivers/pinctrl/stm32/pinctrl-stm32.c | 31 ++++++++++---------------------
1 file changed, 10 insertions(+), 21 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] pinctrl: stm32: factorize stm32_pconf_input/output_get()
2016-05-24 11:57 [PATCH v2] pinctrl: stm32: .pin_config_dbg_show fixes patrice.chotard
@ 2016-05-24 11:57 ` patrice.chotard
2016-05-24 12:04 ` Maxime Coquelin
2016-05-31 8:06 ` Linus Walleij
0 siblings, 2 replies; 4+ messages in thread
From: patrice.chotard @ 2016-05-24 11:57 UTC (permalink / raw)
To: linux-kernel, Linus Walleij, linux-gpio, linux-arm-kernel,
Maxime Coquelin
Cc: patrice.chotard
From: Patrice Chotard <patrice.chotard@st.com>
As these 2 functions code are 95% similar, factorize them.
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---
drivers/pinctrl/stm32/pinctrl-stm32.c | 31 ++++++++++---------------------
1 file changed, 10 insertions(+), 21 deletions(-)
diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index ae9fab8..4ae596b 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -638,8 +638,8 @@ static u32 stm32_pconf_get_bias(struct stm32_gpio_bank *bank,
return (val >> (offset * 2));
}
-static bool stm32_pconf_input_get(struct stm32_gpio_bank *bank,
- unsigned int offset)
+static bool stm32_pconf_get(struct stm32_gpio_bank *bank,
+ unsigned int offset, bool dir)
{
unsigned long flags;
u32 val;
@@ -647,23 +647,12 @@ static bool stm32_pconf_input_get(struct stm32_gpio_bank *bank,
clk_enable(bank->clk);
spin_lock_irqsave(&bank->lock, flags);
- val = !!(readl_relaxed(bank->base + STM32_GPIO_IDR) & BIT(offset));
-
- spin_unlock_irqrestore(&bank->lock, flags);
- clk_disable(bank->clk);
-
- return val;
-}
-
-static bool stm32_pconf_output_get(struct stm32_gpio_bank *bank,
- unsigned int offset)
-{
- unsigned long flags;
- u32 val;
-
- clk_enable(bank->clk);
- spin_lock_irqsave(&bank->lock, flags);
- val = !!(readl_relaxed(bank->base + STM32_GPIO_ODR) & BIT(offset));
+ if (dir)
+ val = !!(readl_relaxed(bank->base + STM32_GPIO_IDR) &
+ BIT(offset));
+ else
+ val = !!(readl_relaxed(bank->base + STM32_GPIO_ODR) &
+ BIT(offset));
spin_unlock_irqrestore(&bank->lock, flags);
clk_disable(bank->clk);
@@ -772,7 +761,7 @@ static void stm32_pconf_dbg_show(struct pinctrl_dev *pctldev,
switch (mode) {
/* input */
case 0:
- val = stm32_pconf_input_get(bank, offset);
+ val = stm32_pconf_get(bank, offset, true);
seq_printf(s, "- %s - %s",
val ? "high" : "low",
biasing[bias]);
@@ -782,7 +771,7 @@ static void stm32_pconf_dbg_show(struct pinctrl_dev *pctldev,
case 1:
drive = stm32_pconf_get_driving(bank, offset);
speed = stm32_pconf_get_speed(bank, offset);
- val = stm32_pconf_output_get(bank, offset);
+ val = stm32_pconf_get(bank, offset, false);
seq_printf(s, "- %s - %s - %s - %s %s",
val ? "high" : "low",
drive ? "open drain" : "push pull",
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] pinctrl: stm32: factorize stm32_pconf_input/output_get()
2016-05-24 11:57 ` [PATCH v2] pinctrl: stm32: factorize stm32_pconf_input/output_get() patrice.chotard
@ 2016-05-24 12:04 ` Maxime Coquelin
2016-05-31 8:06 ` Linus Walleij
1 sibling, 0 replies; 4+ messages in thread
From: Maxime Coquelin @ 2016-05-24 12:04 UTC (permalink / raw)
To: patrice.chotard, linux-kernel, Linus Walleij, linux-gpio,
linux-arm-kernel, Maxime Coquelin
On 05/24/2016 01:57 PM, patrice.chotard@st.com wrote:
> From: Patrice Chotard<patrice.chotard@st.com>
>
> As these 2 functions code are 95% similar, factorize them.
>
> Signed-off-by: Patrice Chotard<patrice.chotard@st.com>
> ---
> drivers/pinctrl/stm32/pinctrl-stm32.c | 31 ++++++++++---------------------
> 1 file changed, 10 insertions(+), 21 deletions(-)
Acked-by: Maxime Coquelin <maxime.coquelin@st.com>
Thanks!
Maxime
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] pinctrl: stm32: factorize stm32_pconf_input/output_get()
2016-05-24 11:57 ` [PATCH v2] pinctrl: stm32: factorize stm32_pconf_input/output_get() patrice.chotard
2016-05-24 12:04 ` Maxime Coquelin
@ 2016-05-31 8:06 ` Linus Walleij
1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2016-05-31 8:06 UTC (permalink / raw)
To: Patrice CHOTARD
Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, Maxime Coquelin
On Tue, May 24, 2016 at 1:57 PM, <patrice.chotard@st.com> wrote:
> From: Patrice Chotard <patrice.chotard@st.com>
>
> As these 2 functions code are 95% similar, factorize them.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Patch applied with Maxime's ACK.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-05-31 8:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-24 11:57 [PATCH v2] pinctrl: stm32: .pin_config_dbg_show fixes patrice.chotard
2016-05-24 11:57 ` [PATCH v2] pinctrl: stm32: factorize stm32_pconf_input/output_get() patrice.chotard
2016-05-24 12:04 ` Maxime Coquelin
2016-05-31 8:06 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).