openwrt/target/linux/bcm27xx/patches-6.6/950-0827-pinctrl-bcm2712-Fix-for-sparse-GPIOs.patch
Álvaro Fernández Rojas 8c405cdccc bcm27xx: add 6.6 kernel patches
The patches were generated from the RPi repo with the following command:
git format-patch v6.6.34..rpi-6.1.y

Some patches needed rebasing and, as usual, the applied and reverted, wireless
drivers, Github workflows, READMEs and defconfigs patches were removed.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2024-06-18 18:52:49 +02:00

32 lines
1.1 KiB
Diff

From 1b63d3a80c412d16198bcb6a71c07786f6ffa36c Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Wed, 15 Nov 2023 14:49:55 +0000
Subject: [PATCH 0827/1085] pinctrl: bcm2712: Fix for sparse GPIOs
BCM2712D0's sparse GPIO map revealed that it is not safe to treat
group_selector as the GPIO number - it is an index into the array of
pinctrl_pin_descs, and the "number" member says which GPIO it refers to.
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
drivers/pinctrl/bcm/pinctrl-bcm2712.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
--- a/drivers/pinctrl/bcm/pinctrl-bcm2712.c
+++ b/drivers/pinctrl/bcm/pinctrl-bcm2712.c
@@ -906,8 +906,13 @@ static int bcm2712_pmx_set(struct pinctr
unsigned group_selector)
{
struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
+ const struct pinctrl_desc *pctldesc = &pc->pctl_desc;
+ const struct pinctrl_pin_desc *pindesc;
- bcm2712_pinctrl_fsel_set(pc, group_selector, func_selector);
+ if (group_selector >= pctldesc->npins)
+ return -EINVAL;
+ pindesc = &pctldesc->pins[group_selector];
+ bcm2712_pinctrl_fsel_set(pc, pindesc->number, func_selector);
return 0;
}