Skip to content

Commit 61550be

Browse files
geertubrgl
authored andcommitted
gpio: pcf857x: Make the irqchip immutable
Commit 6c846d0 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips. Following this change the following warning is now observed for the pcf857x driver: gpio gpiochip1: (pcf8575): not an immutable chip, please consider fixing it! Fix this by making the irqchip in the pcf857x driver immutable. Signed-off-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent ac2f6f9 commit 61550be

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

drivers/gpio/gpio-pcf857x.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ MODULE_DEVICE_TABLE(of, pcf857x_of_table);
7171
*/
7272
struct pcf857x {
7373
struct gpio_chip chip;
74-
struct irq_chip irqchip;
7574
struct i2c_client *client;
7675
struct mutex lock; /* protect 'out' */
7776
unsigned out; /* software latch */
@@ -203,15 +202,19 @@ static int pcf857x_irq_set_wake(struct irq_data *data, unsigned int on)
203202
static void pcf857x_irq_enable(struct irq_data *data)
204203
{
205204
struct pcf857x *gpio = irq_data_get_irq_chip_data(data);
205+
irq_hw_number_t hwirq = irqd_to_hwirq(data);
206206

207-
gpio->irq_enabled |= (1 << data->hwirq);
207+
gpiochip_enable_irq(&gpio->chip, hwirq);
208+
gpio->irq_enabled |= (1 << hwirq);
208209
}
209210

210211
static void pcf857x_irq_disable(struct irq_data *data)
211212
{
212213
struct pcf857x *gpio = irq_data_get_irq_chip_data(data);
214+
irq_hw_number_t hwirq = irqd_to_hwirq(data);
213215

214-
gpio->irq_enabled &= ~(1 << data->hwirq);
216+
gpio->irq_enabled &= ~(1 << hwirq);
217+
gpiochip_disable_irq(&gpio->chip, hwirq);
215218
}
216219

217220
static void pcf857x_irq_bus_lock(struct irq_data *data)
@@ -228,6 +231,20 @@ static void pcf857x_irq_bus_sync_unlock(struct irq_data *data)
228231
mutex_unlock(&gpio->lock);
229232
}
230233

234+
static const struct irq_chip pcf857x_irq_chip = {
235+
.name = "pcf857x",
236+
.irq_enable = pcf857x_irq_enable,
237+
.irq_disable = pcf857x_irq_disable,
238+
.irq_ack = noop,
239+
.irq_mask = noop,
240+
.irq_unmask = noop,
241+
.irq_set_wake = pcf857x_irq_set_wake,
242+
.irq_bus_lock = pcf857x_irq_bus_lock,
243+
.irq_bus_sync_unlock = pcf857x_irq_bus_sync_unlock,
244+
.flags = IRQCHIP_IMMUTABLE,
245+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
246+
};
247+
231248
/*-------------------------------------------------------------------------*/
232249

233250
static int pcf857x_probe(struct i2c_client *client,
@@ -338,16 +355,6 @@ static int pcf857x_probe(struct i2c_client *client,
338355
if (client->irq) {
339356
struct gpio_irq_chip *girq;
340357

341-
gpio->irqchip.name = "pcf857x";
342-
gpio->irqchip.irq_enable = pcf857x_irq_enable;
343-
gpio->irqchip.irq_disable = pcf857x_irq_disable;
344-
gpio->irqchip.irq_ack = noop;
345-
gpio->irqchip.irq_mask = noop;
346-
gpio->irqchip.irq_unmask = noop;
347-
gpio->irqchip.irq_set_wake = pcf857x_irq_set_wake;
348-
gpio->irqchip.irq_bus_lock = pcf857x_irq_bus_lock;
349-
gpio->irqchip.irq_bus_sync_unlock = pcf857x_irq_bus_sync_unlock;
350-
351358
status = devm_request_threaded_irq(&client->dev, client->irq,
352359
NULL, pcf857x_irq, IRQF_ONESHOT |
353360
IRQF_TRIGGER_FALLING | IRQF_SHARED,
@@ -356,7 +363,7 @@ static int pcf857x_probe(struct i2c_client *client,
356363
goto fail;
357364

358365
girq = &gpio->chip.irq;
359-
girq->chip = &gpio->irqchip;
366+
gpio_irq_chip_set_chip(girq, &pcf857x_irq_chip);
360367
/* This will let us handle the parent IRQ in the driver */
361368
girq->parent_handler = NULL;
362369
girq->num_parents = 0;

0 commit comments

Comments
 (0)