aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-sx150x.c
diff options
context:
space:
mode:
authorNikolay Balandin <nbalandin@dev.rtsoft.ru>2013-05-28 18:02:50 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-05-30 16:18:36 -0400
commit644c8df2fb276e6cdfab18d60e9e0bf7a5b65b9a (patch)
tree555d908ae4e0450c9c71ef9d28c5944f8cae781a /drivers/gpio/gpio-sx150x.c
parentd15b71796316100b31729c8305ac11f03a189670 (diff)
gpio: sx150x: convert to use devm_* functions
Use devm_* functions to make cleanup paths simpler. Signed-off-by: Nikolay Balandin <nbalandin@dev.rtsoft.ru> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-sx150x.c')
-rw-r--r--drivers/gpio/gpio-sx150x.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/drivers/gpio/gpio-sx150x.c b/drivers/gpio/gpio-sx150x.c
index 796b6c42fa70..f371732591d2 100644
--- a/drivers/gpio/gpio-sx150x.c
+++ b/drivers/gpio/gpio-sx150x.c
@@ -548,7 +548,8 @@ static int sx150x_install_irq_chip(struct sx150x_chip *chip,
548#endif 548#endif
549 } 549 }
550 550
551 err = request_threaded_irq(irq_summary, 551 err = devm_request_threaded_irq(&chip->client->dev,
552 irq_summary,
552 NULL, 553 NULL,
553 sx150x_irq_thread_fn, 554 sx150x_irq_thread_fn,
554 IRQF_SHARED | IRQF_TRIGGER_FALLING, 555 IRQF_SHARED | IRQF_TRIGGER_FALLING,
@@ -567,8 +568,6 @@ static void sx150x_remove_irq_chip(struct sx150x_chip *chip)
567 unsigned n; 568 unsigned n;
568 unsigned irq; 569 unsigned irq;
569 570
570 free_irq(chip->irq_summary, chip);
571
572 for (n = 0; n < chip->dev_cfg->ngpios; ++n) { 571 for (n = 0; n < chip->dev_cfg->ngpios; ++n) {
573 irq = chip->irq_base + n; 572 irq = chip->irq_base + n;
574 irq_set_chip_and_handler(irq, NULL, NULL); 573 irq_set_chip_and_handler(irq, NULL, NULL);
@@ -591,18 +590,19 @@ static int sx150x_probe(struct i2c_client *client,
591 if (!i2c_check_functionality(client->adapter, i2c_funcs)) 590 if (!i2c_check_functionality(client->adapter, i2c_funcs))
592 return -ENOSYS; 591 return -ENOSYS;
593 592
594 chip = kzalloc(sizeof(struct sx150x_chip), GFP_KERNEL); 593 chip = devm_kzalloc(&client->dev,
594 sizeof(struct sx150x_chip), GFP_KERNEL);
595 if (!chip) 595 if (!chip)
596 return -ENOMEM; 596 return -ENOMEM;
597 597
598 sx150x_init_chip(chip, client, id->driver_data, pdata); 598 sx150x_init_chip(chip, client, id->driver_data, pdata);
599 rc = sx150x_init_hw(chip, pdata); 599 rc = sx150x_init_hw(chip, pdata);
600 if (rc < 0) 600 if (rc < 0)
601 goto probe_fail_pre_gpiochip_add; 601 return rc;
602 602
603 rc = gpiochip_add(&chip->gpio_chip); 603 rc = gpiochip_add(&chip->gpio_chip);
604 if (rc < 0) 604 if (rc)
605 goto probe_fail_pre_gpiochip_add; 605 return rc;
606 606
607 if (pdata->irq_summary >= 0) { 607 if (pdata->irq_summary >= 0) {
608 rc = sx150x_install_irq_chip(chip, 608 rc = sx150x_install_irq_chip(chip,
@@ -617,8 +617,6 @@ static int sx150x_probe(struct i2c_client *client,
617 return 0; 617 return 0;
618probe_fail_post_gpiochip_add: 618probe_fail_post_gpiochip_add:
619 WARN_ON(gpiochip_remove(&chip->gpio_chip) < 0); 619 WARN_ON(gpiochip_remove(&chip->gpio_chip) < 0);
620probe_fail_pre_gpiochip_add:
621 kfree(chip);
622 return rc; 620 return rc;
623} 621}
624 622
@@ -635,8 +633,6 @@ static int sx150x_remove(struct i2c_client *client)
635 if (chip->irq_summary >= 0) 633 if (chip->irq_summary >= 0)
636 sx150x_remove_irq_chip(chip); 634 sx150x_remove_irq_chip(chip);
637 635
638 kfree(chip);
639
640 return 0; 636 return 0;
641} 637}
642 638