Skip to content

Commit b8a837b

Browse files
kadamskialexhorner
authored andcommitted
pinctrl-blfb: fix EDGE_FAILLING
The bflb_gpio_irq_type() would return a BFLB_IRQ_MODE_SYNC_EDGE_FALLING value in case none of the supported types were matched. It happens that this define is represented by the value 0. The bflb_gpio_irq_set_type() would reject the value 0 returned by that function and return -EINVAL. Problem is, that same thing would happen when the EDGE_FALLING (which is valid) mode was requested making it impossible to select this mode. This patch fixes the problem by returning an -EINVAL from the bflb_gpio_irq_type() in case of an error instead of value 0 so we can now easily differentiate those two cases and requesting EDGE_FALLING interrupt is now possible. Signed-off-by: Krzysztof Adamski <[email protected]>
1 parent 24dbff5 commit b8a837b

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

drivers/pinctrl/pinctrl-bflb.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static void bflb_gpio_irq_ack(struct irq_data *data)
348348

349349
//AH: Find the correct value for the type of interrupts we want to receive
350350
//for a GPIO
351-
static unsigned int bflb_gpio_irq_type(unsigned int type)
351+
static int bflb_gpio_irq_type(unsigned int type)
352352
{
353353
unsigned int selected;
354354

@@ -374,10 +374,8 @@ static unsigned int bflb_gpio_irq_type(unsigned int type)
374374
selected = BFLB_IRQ_MODE_SYNC_LEVEL_LOW;
375375
break;
376376

377-
//No "off" available on BL808, set to default IRQ_TYPE_EDGE_FALLING and
378-
//then we'll need to mask
379377
default:
380-
selected = BFLB_IRQ_MODE_SYNC_EDGE_FALLING;
378+
selected = -EINVAL;
381379
break;
382380
}
383381

@@ -404,7 +402,14 @@ static void bflb_gpio_irq_unmask(struct irq_data *data)
404402
{
405403
struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
406404
struct bflb_gpio_pinctrl *pctl = gpiochip_get_data(gc);
407-
unsigned int irqtype = bflb_gpio_irq_type(irqd_get_trigger_type(data));
405+
int irqtype = bflb_gpio_irq_type(irqd_get_trigger_type(data));
406+
407+
if (irqtype < 0) {
408+
// this should never happen as this would be prevented by
409+
// bflb_gpio_irq_set_type()
410+
dev_err(pctl->dev, "irqtype of %lu negative!", data->hwirq);
411+
return;
412+
}
408413

409414
gpiochip_enable_irq(gc, data->hwirq);
410415
set_bit(data->hwirq, pctl->irqsunmasked);
@@ -441,10 +446,10 @@ static int bflb_gpio_irq_set_type(struct irq_data *data, unsigned int type)
441446
struct bflb_gpio_pinctrl *pctl =
442447
gpiochip_get_data(irq_data_get_irq_chip_data(data));
443448

444-
unsigned int irqtype = bflb_gpio_irq_type(type);
449+
int irqtype = bflb_gpio_irq_type(type);
445450

446-
if (irqtype == 0)
447-
return -EINVAL;
451+
if (irqtype < 0)
452+
return irqtype;
448453

449454
bflb_gpio_set_reg(pctl, data->hwirq, REG_GPIOx_INT_MODE_SET,
450455
FIELD_PREP(REG_GPIOx_INT_MODE_SET, irqtype));

0 commit comments

Comments
 (0)