Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: adp5588: Use irqchip template

This makes the driver use the irqchip template to assign
properties to the gpio_irq_chip instead of using the
explicit calls to gpiochip_irqchip_add_nested() and
gpiochip_set_nested_irqchip(). The irqchip is instead
added while adding the gpiochip.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Cc: Nikolaus Voss <nv@vosn.de>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Link: https://lore.kernel.org/r/20200716150502.195821-1-linus.walleij@linaro.org

+24 -15
+24 -15
drivers/gpio/gpio-adp5588.c
··· 272 272 return IRQ_HANDLED; 273 273 } 274 274 275 + 276 + static int adp5588_irq_init_hw(struct gpio_chip *gc) 277 + { 278 + struct adp5588_gpio *dev = gpiochip_get_data(gc); 279 + /* Enable IRQs after registering chip */ 280 + adp5588_gpio_write(dev->client, CFG, 281 + ADP5588_AUTO_INC | ADP5588_INT_CFG | ADP5588_KE_IEN); 282 + 283 + return 0; 284 + } 285 + 275 286 static int adp5588_irq_setup(struct adp5588_gpio *dev) 276 287 { 277 288 struct i2c_client *client = dev->client; 278 289 int ret; 279 290 struct adp5588_gpio_platform_data *pdata = 280 291 dev_get_platdata(&client->dev); 281 - int irq_base = pdata ? pdata->irq_base : 0; 292 + struct gpio_irq_chip *girq; 282 293 283 294 adp5588_gpio_write(client, CFG, ADP5588_AUTO_INC); 284 295 adp5588_gpio_write(client, INT_STAT, -1); /* status is W1C */ ··· 305 294 client->irq); 306 295 return ret; 307 296 } 308 - ret = gpiochip_irqchip_add_nested(&dev->gpio_chip, 309 - &adp5588_irq_chip, irq_base, 310 - handle_simple_irq, 311 - IRQ_TYPE_NONE); 312 - if (ret) { 313 - dev_err(&client->dev, 314 - "could not connect irqchip to gpiochip\n"); 315 - return ret; 316 - } 317 - gpiochip_set_nested_irqchip(&dev->gpio_chip, 318 - &adp5588_irq_chip, 319 - client->irq); 320 297 321 - adp5588_gpio_write(client, CFG, 322 - ADP5588_AUTO_INC | ADP5588_INT_CFG | ADP5588_KE_IEN); 298 + /* This will be registered in the call to devm_gpiochip_add_data() */ 299 + girq = &dev->gpio_chip.irq; 300 + girq->chip = &adp5588_irq_chip; 301 + /* This will let us handle the parent IRQ in the driver */ 302 + girq->parent_handler = NULL; 303 + girq->num_parents = 0; 304 + girq->parents = NULL; 305 + girq->first = pdata ? pdata->irq_base : 0; 306 + girq->default_type = IRQ_TYPE_NONE; 307 + girq->handler = handle_simple_irq; 308 + girq->init_hw = adp5588_irq_init_hw; 309 + girq->threaded = true; 323 310 324 311 return 0; 325 312 }