Skip to content

Commit aa284d6

Browse files
committed
Merge tag 'gpio-5.0-rc4-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into fixes
GPIO fixes for 5.0-rc4 - fix from Roger Quadros for a warning resulting from reusing the same irqchip for multiple pcf857x instances - fix for missing line event timestamp when using nested interrupts - two fixes for the sprd driver dealing with value reading and the irq chip - fix for the direction_output callback for altera-a10sr
2 parents 49a5785 + 2095a45 commit aa284d6

File tree

4 files changed

+36
-17
lines changed

4 files changed

+36
-17
lines changed

drivers/gpio/gpio-altera-a10sr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ static int altr_a10sr_gpio_direction_input(struct gpio_chip *gc,
6666
static int altr_a10sr_gpio_direction_output(struct gpio_chip *gc,
6767
unsigned int nr, int value)
6868
{
69-
if (nr <= (ALTR_A10SR_OUT_VALID_RANGE_HI - ALTR_A10SR_LED_VALID_SHIFT))
69+
if (nr <= (ALTR_A10SR_OUT_VALID_RANGE_HI - ALTR_A10SR_LED_VALID_SHIFT)) {
70+
altr_a10sr_gpio_set(gc, nr, value);
7071
return 0;
72+
}
7173
return -EINVAL;
7274
}
7375

drivers/gpio/gpio-eic-sprd.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,18 @@ static void sprd_eic_free(struct gpio_chip *chip, unsigned int offset)
180180

181181
static int sprd_eic_get(struct gpio_chip *chip, unsigned int offset)
182182
{
183-
return sprd_eic_read(chip, offset, SPRD_EIC_DBNC_DATA);
183+
struct sprd_eic *sprd_eic = gpiochip_get_data(chip);
184+
185+
switch (sprd_eic->type) {
186+
case SPRD_EIC_DEBOUNCE:
187+
return sprd_eic_read(chip, offset, SPRD_EIC_DBNC_DATA);
188+
case SPRD_EIC_ASYNC:
189+
return sprd_eic_read(chip, offset, SPRD_EIC_ASYNC_DATA);
190+
case SPRD_EIC_SYNC:
191+
return sprd_eic_read(chip, offset, SPRD_EIC_SYNC_DATA);
192+
default:
193+
return -ENOTSUPP;
194+
}
184195
}
185196

186197
static int sprd_eic_direction_input(struct gpio_chip *chip, unsigned int offset)
@@ -368,6 +379,7 @@ static int sprd_eic_irq_set_type(struct irq_data *data, unsigned int flow_type)
368379
irq_set_handler_locked(data, handle_edge_irq);
369380
break;
370381
case IRQ_TYPE_EDGE_BOTH:
382+
sprd_eic_update(chip, offset, SPRD_EIC_ASYNC_INTMODE, 0);
371383
sprd_eic_update(chip, offset, SPRD_EIC_ASYNC_INTBOTH, 1);
372384
irq_set_handler_locked(data, handle_edge_irq);
373385
break;

drivers/gpio/gpio-pcf857x.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ MODULE_DEVICE_TABLE(of, pcf857x_of_table);
8484
*/
8585
struct pcf857x {
8686
struct gpio_chip chip;
87+
struct irq_chip irqchip;
8788
struct i2c_client *client;
8889
struct mutex lock; /* protect 'out' */
8990
unsigned out; /* software latch */
@@ -252,18 +253,6 @@ static void pcf857x_irq_bus_sync_unlock(struct irq_data *data)
252253
mutex_unlock(&gpio->lock);
253254
}
254255

255-
static struct irq_chip pcf857x_irq_chip = {
256-
.name = "pcf857x",
257-
.irq_enable = pcf857x_irq_enable,
258-
.irq_disable = pcf857x_irq_disable,
259-
.irq_ack = noop,
260-
.irq_mask = noop,
261-
.irq_unmask = noop,
262-
.irq_set_wake = pcf857x_irq_set_wake,
263-
.irq_bus_lock = pcf857x_irq_bus_lock,
264-
.irq_bus_sync_unlock = pcf857x_irq_bus_sync_unlock,
265-
};
266-
267256
/*-------------------------------------------------------------------------*/
268257

269258
static int pcf857x_probe(struct i2c_client *client,
@@ -376,8 +365,17 @@ static int pcf857x_probe(struct i2c_client *client,
376365

377366
/* Enable irqchip if we have an interrupt */
378367
if (client->irq) {
368+
gpio->irqchip.name = "pcf857x",
369+
gpio->irqchip.irq_enable = pcf857x_irq_enable,
370+
gpio->irqchip.irq_disable = pcf857x_irq_disable,
371+
gpio->irqchip.irq_ack = noop,
372+
gpio->irqchip.irq_mask = noop,
373+
gpio->irqchip.irq_unmask = noop,
374+
gpio->irqchip.irq_set_wake = pcf857x_irq_set_wake,
375+
gpio->irqchip.irq_bus_lock = pcf857x_irq_bus_lock,
376+
gpio->irqchip.irq_bus_sync_unlock = pcf857x_irq_bus_sync_unlock,
379377
status = gpiochip_irqchip_add_nested(&gpio->chip,
380-
&pcf857x_irq_chip,
378+
&gpio->irqchip,
381379
0, handle_level_irq,
382380
IRQ_TYPE_NONE);
383381
if (status) {
@@ -392,7 +390,7 @@ static int pcf857x_probe(struct i2c_client *client,
392390
if (status)
393391
goto fail;
394392

395-
gpiochip_set_nested_irqchip(&gpio->chip, &pcf857x_irq_chip,
393+
gpiochip_set_nested_irqchip(&gpio->chip, &gpio->irqchip,
396394
client->irq);
397395
gpio->irq_parent = client->irq;
398396
}

drivers/gpio/gpiolib.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,14 @@ static irqreturn_t lineevent_irq_thread(int irq, void *p)
828828
/* Do not leak kernel stack to userspace */
829829
memset(&ge, 0, sizeof(ge));
830830

831-
ge.timestamp = le->timestamp;
831+
/*
832+
* We may be running from a nested threaded interrupt in which case
833+
* we didn't get the timestamp from lineevent_irq_handler().
834+
*/
835+
if (!le->timestamp)
836+
ge.timestamp = ktime_get_real_ns();
837+
else
838+
ge.timestamp = le->timestamp;
832839

833840
if (le->eflags & GPIOEVENT_REQUEST_RISING_EDGE
834841
&& le->eflags & GPIOEVENT_REQUEST_FALLING_EDGE) {

0 commit comments

Comments
 (0)