Skip to content

Commit 9b3b94e

Browse files
svenpeter42linusw
authored andcommitted
pinctrl: apple: Always return valid type in apple_gpio_irq_type
apple_gpio_irq_type can possibly return -EINVAL which triggers the following compile error with gcc 9 because the type no longer fits into the mask. drivers/pinctrl/pinctrl-apple-gpio.c: In function 'apple_gpio_irq_set_type': ././include/linux/compiler_types.h:335:38: error: call to '__compiletime_assert_289' declared with attribute error: FIELD_PREP: value too large for the field 335 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^ [...] drivers/pinctrl/pinctrl-apple-gpio.c:294:7: note: in expansion of macro 'FIELD_PREP' 294 | FIELD_PREP(REG_GPIOx_MODE, irqtype)); | ^~~~~~~~~~ Fix this by making the return value always valid and instead checking for REG_GPIOx_IN_IRQ_OFF in apple_gpio_irq_set_type and return -EINVAL from there. Fixes: a0f160f ("pinctrl: add pinctrl/GPIO driver for Apple SoCs") Signed-off-by: Sven Peter <[email protected]> Reviewed-by: Joey Gouly <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent a5b9703 commit 9b3b94e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/pinctrl/pinctrl-apple-gpio.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ static void apple_gpio_irq_ack(struct irq_data *data)
258258
pctl->base + REG_IRQ(irqgrp, data->hwirq));
259259
}
260260

261-
static int apple_gpio_irq_type(unsigned int type)
261+
static unsigned int apple_gpio_irq_type(unsigned int type)
262262
{
263263
switch (type & IRQ_TYPE_SENSE_MASK) {
264264
case IRQ_TYPE_EDGE_RISING:
@@ -272,7 +272,7 @@ static int apple_gpio_irq_type(unsigned int type)
272272
case IRQ_TYPE_LEVEL_LOW:
273273
return REG_GPIOx_IN_IRQ_LO;
274274
default:
275-
return -EINVAL;
275+
return REG_GPIOx_IN_IRQ_OFF;
276276
}
277277
}
278278

@@ -288,7 +288,7 @@ static void apple_gpio_irq_unmask(struct irq_data *data)
288288
{
289289
struct apple_gpio_pinctrl *pctl =
290290
gpiochip_get_data(irq_data_get_irq_chip_data(data));
291-
int irqtype = apple_gpio_irq_type(irqd_get_trigger_type(data));
291+
unsigned int irqtype = apple_gpio_irq_type(irqd_get_trigger_type(data));
292292

293293
apple_gpio_set_reg(pctl, data->hwirq, REG_GPIOx_MODE,
294294
FIELD_PREP(REG_GPIOx_MODE, irqtype));
@@ -313,10 +313,10 @@ static int apple_gpio_irq_set_type(struct irq_data *data,
313313
{
314314
struct apple_gpio_pinctrl *pctl =
315315
gpiochip_get_data(irq_data_get_irq_chip_data(data));
316-
int irqtype = apple_gpio_irq_type(type);
316+
unsigned int irqtype = apple_gpio_irq_type(type);
317317

318-
if (irqtype < 0)
319-
return irqtype;
318+
if (irqtype == REG_GPIOx_IN_IRQ_OFF)
319+
return -EINVAL;
320320

321321
apple_gpio_set_reg(pctl, data->hwirq, REG_GPIOx_MODE,
322322
FIELD_PREP(REG_GPIOx_MODE, irqtype));

0 commit comments

Comments
 (0)