Skip to content

Commit 3022bf3

Browse files
committed
Merge tag 'gpio-fixes-for-v6.9-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio fixes from Bartosz Golaszewski: - fix a regression in pin access control in gpio-tegra186 - make data pointer dereference robust in Intel Tangier driver * tag 'gpio-fixes-for-v6.9-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: gpio: tegra186: Fix tegra186_gpio_is_accessible() check gpio: tangier: Use correct type for the IRQ chip data
2 parents 5b43efa + c714fcd commit 3022bf3

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

drivers/gpio/gpio-tangier.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ static int tng_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
195195

196196
static void tng_irq_ack(struct irq_data *d)
197197
{
198-
struct tng_gpio *priv = irq_data_get_irq_chip_data(d);
198+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
199+
struct tng_gpio *priv = gpiochip_get_data(gc);
199200
irq_hw_number_t gpio = irqd_to_hwirq(d);
200201
void __iomem *gisr;
201202
u8 shift;
@@ -227,7 +228,8 @@ static void tng_irq_unmask_mask(struct tng_gpio *priv, u32 gpio, bool unmask)
227228

228229
static void tng_irq_mask(struct irq_data *d)
229230
{
230-
struct tng_gpio *priv = irq_data_get_irq_chip_data(d);
231+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
232+
struct tng_gpio *priv = gpiochip_get_data(gc);
231233
irq_hw_number_t gpio = irqd_to_hwirq(d);
232234

233235
tng_irq_unmask_mask(priv, gpio, false);
@@ -236,7 +238,8 @@ static void tng_irq_mask(struct irq_data *d)
236238

237239
static void tng_irq_unmask(struct irq_data *d)
238240
{
239-
struct tng_gpio *priv = irq_data_get_irq_chip_data(d);
241+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
242+
struct tng_gpio *priv = gpiochip_get_data(gc);
240243
irq_hw_number_t gpio = irqd_to_hwirq(d);
241244

242245
gpiochip_enable_irq(&priv->chip, gpio);

drivers/gpio/gpio-tegra186.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@
3636
#define TEGRA186_GPIO_SCR_SEC_REN BIT(27)
3737
#define TEGRA186_GPIO_SCR_SEC_G1W BIT(9)
3838
#define TEGRA186_GPIO_SCR_SEC_G1R BIT(1)
39-
#define TEGRA186_GPIO_FULL_ACCESS (TEGRA186_GPIO_SCR_SEC_WEN | \
40-
TEGRA186_GPIO_SCR_SEC_REN | \
41-
TEGRA186_GPIO_SCR_SEC_G1R | \
42-
TEGRA186_GPIO_SCR_SEC_G1W)
43-
#define TEGRA186_GPIO_SCR_SEC_ENABLE (TEGRA186_GPIO_SCR_SEC_WEN | \
44-
TEGRA186_GPIO_SCR_SEC_REN)
4539

4640
/* control registers */
4741
#define TEGRA186_GPIO_ENABLE_CONFIG 0x00
@@ -177,10 +171,18 @@ static inline bool tegra186_gpio_is_accessible(struct tegra_gpio *gpio, unsigned
177171

178172
value = __raw_readl(secure + TEGRA186_GPIO_SCR);
179173

180-
if ((value & TEGRA186_GPIO_SCR_SEC_ENABLE) == 0)
181-
return true;
174+
/*
175+
* When SCR_SEC_[R|W]EN is unset, then we have full read/write access to all the
176+
* registers for given GPIO pin.
177+
* When SCR_SEC[R|W]EN is set, then there is need to further check the accompanying
178+
* SCR_SEC_G1[R|W] bit to determine read/write access to all the registers for given
179+
* GPIO pin.
180+
*/
182181

183-
if ((value & TEGRA186_GPIO_FULL_ACCESS) == TEGRA186_GPIO_FULL_ACCESS)
182+
if (((value & TEGRA186_GPIO_SCR_SEC_REN) == 0 ||
183+
((value & TEGRA186_GPIO_SCR_SEC_REN) && (value & TEGRA186_GPIO_SCR_SEC_G1R))) &&
184+
((value & TEGRA186_GPIO_SCR_SEC_WEN) == 0 ||
185+
((value & TEGRA186_GPIO_SCR_SEC_WEN) && (value & TEGRA186_GPIO_SCR_SEC_G1W))))
184186
return true;
185187

186188
return false;

0 commit comments

Comments
 (0)