mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fixup! pinctrl: Rockchip: Update from Linux
@ 2021-06-09 17:49 Ahmad Fatoum
  2021-06-11 11:52 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2021-06-09 17:49 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The original code uses regmap for the base address and reg for the
offset to add onto it. The barebox port combines both into one pointer
named reg. In rockchip_pinctrl_set_func(), two different offsets are
used with the same base address. The code erroneously uses
reg (base + offset) in place of base, leading to memory writes into
the wrong registers. Fix this.

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

diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index c3d89938943c..df702fbb6164 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -715,19 +715,19 @@ static int rockchip_pinctrl_set_func(struct rockchip_pin_bank *bank, int pin,
 				     int mux)
 {
 	struct rockchip_pinctrl *info = bank->drvdata;
-	void __iomem *reg;
+	void __iomem *base, *reg;
 	u8 bit;
 	u32 data, route_location, route_reg, route_val;
 	int iomux_num = (pin / 8);
 	int mux_type;
 	int mask;
 
-	reg = (bank->iomux[iomux_num].type & IOMUX_SOURCE_PMU)
+	base = (bank->iomux[iomux_num].type & IOMUX_SOURCE_PMU)
 				? info->reg_pmu : info->reg_base;
 
 	/* get basic quadrupel of mux registers and the correct reg inside */
 	mux_type = bank->iomux[iomux_num].type;
-	reg += bank->iomux[iomux_num].offset;
+	reg = base + bank->iomux[iomux_num].offset;
 
 	dev_dbg(info->pctl_dev.dev, "setting func of GPIO%d-%d to %d\n",
 		 bank->bank_num, pin, mux);
@@ -750,7 +750,7 @@ static int rockchip_pinctrl_set_func(struct rockchip_pin_bank *bank, int pin,
 	if (bank->route_mask & BIT(pin)) {
 		if (rockchip_get_mux_route(bank, pin, mux, &route_location,
 					   &route_reg, &route_val)) {
-			void __iomem  *route = reg;
+			void __iomem  *route = base;
 
 			/* handle special locations */
 			switch (route_location) {
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* Re: [PATCH] fixup! pinctrl: Rockchip: Update from Linux
  2021-06-09 17:49 [PATCH] fixup! pinctrl: Rockchip: Update from Linux Ahmad Fatoum
@ 2021-06-11 11:52 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2021-06-11 11:52 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Wed, Jun 09, 2021 at 07:49:13PM +0200, Ahmad Fatoum wrote:
> The original code uses regmap for the base address and reg for the
> offset to add onto it. The barebox port combines both into one pointer
> named reg. In rockchip_pinctrl_set_func(), two different offsets are
> used with the same base address. The code erroneously uses
> reg (base + offset) in place of base, leading to memory writes into
> the wrong registers. Fix this.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/pinctrl/pinctrl-rockchip.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

end of thread, other threads:[~2021-06-11 11:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 17:49 [PATCH] fixup! pinctrl: Rockchip: Update from Linux Ahmad Fatoum
2021-06-11 11:52 ` Sascha Hauer

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