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>
This commit is contained in:
parent
d15b717963
commit
644c8df2fb
1 changed files with 7 additions and 11 deletions
|
@ -548,7 +548,8 @@ static int sx150x_install_irq_chip(struct sx150x_chip *chip,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
err = request_threaded_irq(irq_summary,
|
err = devm_request_threaded_irq(&chip->client->dev,
|
||||||
|
irq_summary,
|
||||||
NULL,
|
NULL,
|
||||||
sx150x_irq_thread_fn,
|
sx150x_irq_thread_fn,
|
||||||
IRQF_SHARED | IRQF_TRIGGER_FALLING,
|
IRQF_SHARED | IRQF_TRIGGER_FALLING,
|
||||||
|
@ -567,8 +568,6 @@ static void sx150x_remove_irq_chip(struct sx150x_chip *chip)
|
||||||
unsigned n;
|
unsigned n;
|
||||||
unsigned irq;
|
unsigned irq;
|
||||||
|
|
||||||
free_irq(chip->irq_summary, chip);
|
|
||||||
|
|
||||||
for (n = 0; n < chip->dev_cfg->ngpios; ++n) {
|
for (n = 0; n < chip->dev_cfg->ngpios; ++n) {
|
||||||
irq = chip->irq_base + n;
|
irq = chip->irq_base + n;
|
||||||
irq_set_chip_and_handler(irq, NULL, NULL);
|
irq_set_chip_and_handler(irq, NULL, NULL);
|
||||||
|
@ -591,18 +590,19 @@ static int sx150x_probe(struct i2c_client *client,
|
||||||
if (!i2c_check_functionality(client->adapter, i2c_funcs))
|
if (!i2c_check_functionality(client->adapter, i2c_funcs))
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
|
|
||||||
chip = kzalloc(sizeof(struct sx150x_chip), GFP_KERNEL);
|
chip = devm_kzalloc(&client->dev,
|
||||||
|
sizeof(struct sx150x_chip), GFP_KERNEL);
|
||||||
if (!chip)
|
if (!chip)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
sx150x_init_chip(chip, client, id->driver_data, pdata);
|
sx150x_init_chip(chip, client, id->driver_data, pdata);
|
||||||
rc = sx150x_init_hw(chip, pdata);
|
rc = sx150x_init_hw(chip, pdata);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto probe_fail_pre_gpiochip_add;
|
return rc;
|
||||||
|
|
||||||
rc = gpiochip_add(&chip->gpio_chip);
|
rc = gpiochip_add(&chip->gpio_chip);
|
||||||
if (rc < 0)
|
if (rc)
|
||||||
goto probe_fail_pre_gpiochip_add;
|
return rc;
|
||||||
|
|
||||||
if (pdata->irq_summary >= 0) {
|
if (pdata->irq_summary >= 0) {
|
||||||
rc = sx150x_install_irq_chip(chip,
|
rc = sx150x_install_irq_chip(chip,
|
||||||
|
@ -617,8 +617,6 @@ static int sx150x_probe(struct i2c_client *client,
|
||||||
return 0;
|
return 0;
|
||||||
probe_fail_post_gpiochip_add:
|
probe_fail_post_gpiochip_add:
|
||||||
WARN_ON(gpiochip_remove(&chip->gpio_chip) < 0);
|
WARN_ON(gpiochip_remove(&chip->gpio_chip) < 0);
|
||||||
probe_fail_pre_gpiochip_add:
|
|
||||||
kfree(chip);
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,8 +633,6 @@ static int sx150x_remove(struct i2c_client *client)
|
||||||
if (chip->irq_summary >= 0)
|
if (chip->irq_summary >= 0)
|
||||||
sx150x_remove_irq_chip(chip);
|
sx150x_remove_irq_chip(chip);
|
||||||
|
|
||||||
kfree(chip);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue