Merge branch 'devm-gpiochip-add-data' into devel

This commit is contained in:
Linus Walleij 2016-03-08 14:41:41 +07:00
commit 016bf20829
63 changed files with 229 additions and 470 deletions

View File

@ -252,6 +252,11 @@ GPIO
devm_gpiod_get_index_optional()
devm_gpiod_get_optional()
devm_gpiod_put()
devm_gpiochip_add_data()
devm_gpiochip_remove()
devm_gpio_request()
devm_gpio_request_one()
devm_gpio_free()
IIO
devm_iio_device_alloc()

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# linux-upstream
This is for sharing upstreaming activities.

View File

@ -140,15 +140,7 @@ static int mmio_74xx_gpio_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, priv);
return gpiochip_add_data(&priv->gc, priv);
}
static int mmio_74xx_gpio_remove(struct platform_device *pdev)
{
struct mmio_74xx_gpio_priv *priv = platform_get_drvdata(pdev);
gpiochip_remove(&priv->gc);
return 0;
return devm_gpiochip_add_data(&pdev->dev, &priv->gc, priv);
}
static struct platform_driver mmio_74xx_gpio_driver = {
@ -157,7 +149,6 @@ static struct platform_driver mmio_74xx_gpio_driver = {
.of_match_table = mmio_74xx_gpio_ids,
},
.probe = mmio_74xx_gpio_probe,
.remove = mmio_74xx_gpio_remove,
};
module_platform_driver(mmio_74xx_gpio_driver);

View File

@ -265,7 +265,7 @@ static int adnp_gpio_setup(struct adnp *adnp, unsigned int num_gpios)
chip->of_node = chip->parent->of_node;
chip->owner = THIS_MODULE;
err = gpiochip_add_data(chip, adnp);
err = devm_gpiochip_add_data(&adnp->client->dev, chip, adnp);
if (err)
return err;
@ -520,14 +520,6 @@ static int adnp_i2c_probe(struct i2c_client *client,
return 0;
}
static int adnp_i2c_remove(struct i2c_client *client)
{
struct adnp *adnp = i2c_get_clientdata(client);
gpiochip_remove(&adnp->gpio);
return 0;
}
static const struct i2c_device_id adnp_i2c_id[] = {
{ "gpio-adnp" },
{ },
@ -546,7 +538,6 @@ static struct i2c_driver adnp_i2c_driver = {
.of_match_table = adnp_of_match,
},
.probe = adnp_i2c_probe,
.remove = adnp_i2c_remove,
.id_table = adnp_i2c_id,
};
module_i2c_driver(adnp_i2c_driver);

View File

@ -153,7 +153,7 @@ static int adp5520_gpio_probe(struct platform_device *pdev)
goto err;
}
ret = gpiochip_add_data(&dev->gpio_chip, dev);
ret = devm_gpiochip_add_data(&pdev->dev, &dev->gpio_chip, dev);
if (ret)
goto err;
@ -164,22 +164,11 @@ err:
return ret;
}
static int adp5520_gpio_remove(struct platform_device *pdev)
{
struct adp5520_gpio *dev;
dev = platform_get_drvdata(pdev);
gpiochip_remove(&dev->gpio_chip);
return 0;
}
static struct platform_driver adp5520_gpio_driver = {
.driver = {
.name = "adp5520-gpio",
},
.probe = adp5520_gpio_probe,
.remove = adp5520_gpio_remove,
};
module_platform_driver(adp5520_gpio_driver);

View File

@ -414,7 +414,7 @@ static int adp5588_gpio_probe(struct i2c_client *client,
}
}
ret = gpiochip_add_data(&dev->gpio_chip, dev);
ret = devm_gpiochip_add_data(&client->dev, &dev->gpio_chip, dev);
if (ret)
goto err_irq;
@ -457,8 +457,6 @@ static int adp5588_gpio_remove(struct i2c_client *client)
if (dev->irq_base)
free_irq(dev->client->irq, dev);
gpiochip_remove(&dev->gpio_chip);
return 0;
}

View File

@ -312,8 +312,8 @@ static int altera_gpio_probe(struct platform_device *pdev)
handle_simple_irq, IRQ_TYPE_NONE);
if (ret) {
dev_info(&pdev->dev, "could not add irqchip\n");
return ret;
dev_err(&pdev->dev, "could not add irqchip\n");
goto teardown;
}
gpiochip_set_chained_irqchip(&altera_gc->mmchip.gc,
@ -326,6 +326,7 @@ static int altera_gpio_probe(struct platform_device *pdev)
skip_irq:
return 0;
teardown:
of_mm_gpiochip_remove(&altera_gc->mmchip);
pr_err("%s: registration failed with status %d\n",
node->full_name, ret);

View File

@ -132,7 +132,8 @@ static int arizona_gpio_probe(struct platform_device *pdev)
else
arizona_gpio->gpio_chip.base = -1;
ret = gpiochip_add_data(&arizona_gpio->gpio_chip, arizona_gpio);
ret = devm_gpiochip_add_data(&pdev->dev, &arizona_gpio->gpio_chip,
arizona_gpio);
if (ret < 0) {
dev_err(&pdev->dev, "Could not register gpiochip, %d\n",
ret);
@ -147,18 +148,9 @@ err:
return ret;
}
static int arizona_gpio_remove(struct platform_device *pdev)
{
struct arizona_gpio *arizona_gpio = platform_get_drvdata(pdev);
gpiochip_remove(&arizona_gpio->gpio_chip);
return 0;
}
static struct platform_driver arizona_gpio_driver = {
.driver.name = "arizona-gpio",
.probe = arizona_gpio_probe,
.remove = arizona_gpio_remove,
};
module_platform_driver(arizona_gpio_driver);

View File

@ -630,7 +630,7 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev)
bcm_kona_gpio_reset(kona_gpio);
ret = gpiochip_add_data(chip, kona_gpio);
ret = devm_gpiochip_add_data(dev, chip, kona_gpio);
if (ret < 0) {
dev_err(dev, "Couldn't add GPIO chip -- %d\n", ret);
goto err_irq_domain;

View File

@ -67,15 +67,7 @@ static int clps711x_gpio_probe(struct platform_device *pdev)
gc->owner = THIS_MODULE;
platform_set_drvdata(pdev, gc);
return gpiochip_add_data(gc, NULL);
}
static int clps711x_gpio_remove(struct platform_device *pdev)
{
struct gpio_chip *gc = platform_get_drvdata(pdev);
gpiochip_remove(gc);
return 0;
return devm_gpiochip_add_data(&pdev->dev, gc, NULL);
}
static const struct of_device_id __maybe_unused clps711x_gpio_ids[] = {
@ -90,7 +82,6 @@ static struct platform_driver clps711x_gpio_driver = {
.of_match_table = of_match_ptr(clps711x_gpio_ids),
},
.probe = clps711x_gpio_probe,
.remove = clps711x_gpio_remove,
};
module_platform_driver(clps711x_gpio_driver);

View File

@ -345,7 +345,7 @@ static int crystalcove_gpio_probe(struct platform_device *pdev)
cg->chip.dbg_show = crystalcove_gpio_dbg_show;
cg->regmap = pmic->regmap;
retval = gpiochip_add_data(&cg->chip, cg);
retval = devm_gpiochip_add_data(&pdev->dev, &cg->chip, cg);
if (retval) {
dev_warn(&pdev->dev, "add gpio chip error: %d\n", retval);
return retval;
@ -359,14 +359,10 @@ static int crystalcove_gpio_probe(struct platform_device *pdev)
if (retval) {
dev_warn(&pdev->dev, "request irq failed: %d\n", retval);
goto out_remove_gpio;
return retval;
}
return 0;
out_remove_gpio:
gpiochip_remove(&cg->chip);
return retval;
}
static int crystalcove_gpio_remove(struct platform_device *pdev)
@ -374,7 +370,6 @@ static int crystalcove_gpio_remove(struct platform_device *pdev)
struct crystalcove_gpio *cg = platform_get_drvdata(pdev);
int irq = platform_get_irq(pdev, 0);
gpiochip_remove(&cg->chip);
if (irq >= 0)
free_irq(irq, cg);
return 0;

View File

@ -320,13 +320,13 @@ static int cs5535_gpio_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
if (!res) {
dev_err(&pdev->dev, "can't fetch device resource info\n");
goto done;
return err;
}
if (!devm_request_region(&pdev->dev, res->start, resource_size(res),
pdev->name)) {
dev_err(&pdev->dev, "can't request region\n");
goto done;
return err;
}
/* set up the driver-specific struct */
@ -348,19 +348,10 @@ static int cs5535_gpio_probe(struct platform_device *pdev)
mask_orig, mask);
/* finally, register with the generic GPIO API */
err = gpiochip_add_data(&cs5535_gpio_chip.chip, &cs5535_gpio_chip);
err = devm_gpiochip_add_data(&pdev->dev, &cs5535_gpio_chip.chip,
&cs5535_gpio_chip);
if (err)
goto done;
return 0;
done:
return err;
}
static int cs5535_gpio_remove(struct platform_device *pdev)
{
gpiochip_remove(&cs5535_gpio_chip.chip);
return 0;
}
@ -370,7 +361,6 @@ static struct platform_driver cs5535_gpio_driver = {
.name = DRV_NAME,
},
.probe = cs5535_gpio_probe,
.remove = cs5535_gpio_remove,
};
module_platform_driver(cs5535_gpio_driver);

View File

@ -214,7 +214,7 @@ static int da9052_gpio_probe(struct platform_device *pdev)
if (pdata && pdata->gpio_base)
gpio->gp.base = pdata->gpio_base;
ret = gpiochip_add_data(&gpio->gp, gpio);
ret = devm_gpiochip_add_data(&pdev->dev, &gpio->gp, gpio);
if (ret < 0) {
dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
return ret;
@ -225,17 +225,8 @@ static int da9052_gpio_probe(struct platform_device *pdev)
return 0;
}
static int da9052_gpio_remove(struct platform_device *pdev)
{
struct da9052_gpio *gpio = platform_get_drvdata(pdev);
gpiochip_remove(&gpio->gp);
return 0;
}
static struct platform_driver da9052_gpio_driver = {
.probe = da9052_gpio_probe,
.remove = da9052_gpio_remove,
.driver = {
.name = "da9052-gpio",
},

View File

@ -151,31 +151,19 @@ static int da9055_gpio_probe(struct platform_device *pdev)
if (pdata && pdata->gpio_base)
gpio->gp.base = pdata->gpio_base;
ret = gpiochip_add_data(&gpio->gp, gpio);
ret = devm_gpiochip_add_data(&pdev->dev, &gpio->gp, gpio);
if (ret < 0) {
dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
goto err_mem;
return ret;
}
platform_set_drvdata(pdev, gpio);
return 0;
err_mem:
return ret;
}
static int da9055_gpio_remove(struct platform_device *pdev)
{
struct da9055_gpio *gpio = platform_get_drvdata(pdev);
gpiochip_remove(&gpio->gp);
return 0;
}
static struct platform_driver da9055_gpio_driver = {
.probe = da9055_gpio_probe,
.remove = da9055_gpio_remove,
.driver = {
.name = "da9055-gpio",
},

View File

@ -195,7 +195,7 @@ static int davinci_gpio_of_xlate(struct gpio_chip *gc,
static int davinci_gpio_probe(struct platform_device *pdev)
{
int i, base;
unsigned ngpio;
unsigned ngpio, nbank;
struct davinci_gpio_controller *chips;
struct davinci_gpio_platform_data *pdata;
struct davinci_gpio_regs __iomem *regs;
@ -224,8 +224,9 @@ static int davinci_gpio_probe(struct platform_device *pdev)
if (WARN_ON(ARCH_NR_GPIOS < ngpio))
ngpio = ARCH_NR_GPIOS;
nbank = DIV_ROUND_UP(ngpio, 32);
chips = devm_kzalloc(dev,
ngpio * sizeof(struct davinci_gpio_controller),
nbank * sizeof(struct davinci_gpio_controller),
GFP_KERNEL);
if (!chips)
return -ENOMEM;
@ -512,7 +513,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
return irq;
}
irq_domain = irq_domain_add_legacy(NULL, ngpio, irq, 0,
irq_domain = irq_domain_add_legacy(dev->of_node, ngpio, irq, 0,
&davinci_gpio_irq_ops,
chips);
if (!irq_domain) {

View File

@ -479,40 +479,32 @@ static int dln2_gpio_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dln2);
ret = gpiochip_add_data(&dln2->gpio, dln2);
ret = devm_gpiochip_add_data(dev, &dln2->gpio, dln2);
if (ret < 0) {
dev_err(dev, "failed to add gpio chip: %d\n", ret);
goto out;
return ret;
}
ret = gpiochip_irqchip_add(&dln2->gpio, &dln2_gpio_irqchip, 0,
handle_simple_irq, IRQ_TYPE_NONE);
if (ret < 0) {
dev_err(dev, "failed to add irq chip: %d\n", ret);
goto out_gpiochip_remove;
return ret;
}
ret = dln2_register_event_cb(pdev, DLN2_GPIO_CONDITION_MET_EV,
dln2_gpio_event);
if (ret) {
dev_err(dev, "failed to register event cb: %d\n", ret);
goto out_gpiochip_remove;
return ret;
}
return 0;
out_gpiochip_remove:
gpiochip_remove(&dln2->gpio);
out:
return ret;
}
static int dln2_gpio_remove(struct platform_device *pdev)
{
struct dln2_gpio *dln2 = platform_get_drvdata(pdev);
dln2_unregister_event_cb(pdev, DLN2_GPIO_CONDITION_MET_EV);
gpiochip_remove(&dln2->gpio);
return 0;
}

View File

@ -339,7 +339,7 @@ static int ep93xx_gpio_add_bank(struct gpio_chip *gc, struct device *dev,
gc->to_irq = ep93xx_gpio_to_irq;
}
return gpiochip_add_data(gc, NULL);
return devm_gpiochip_add_data(dev, gc, NULL);
}
static int ep93xx_gpio_probe(struct platform_device *pdev)

View File

@ -350,34 +350,13 @@ static int f7188x_gpio_probe(struct platform_device *pdev)
bank->chip.parent = &pdev->dev;
bank->data = data;
err = gpiochip_add_data(&bank->chip, bank);
err = devm_gpiochip_add_data(&pdev->dev, &bank->chip, bank);
if (err) {
dev_err(&pdev->dev,
"Failed to register gpiochip %d: %d\n",
i, err);
goto err_gpiochip;
}
}
return 0;
err_gpiochip:
for (i = i - 1; i >= 0; i--) {
struct f7188x_gpio_bank *bank = &data->bank[i];
gpiochip_remove(&bank->chip);
}
return err;
}
static int f7188x_gpio_remove(struct platform_device *pdev)
{
int i;
struct f7188x_gpio_data *data = platform_get_drvdata(pdev);
for (i = 0; i < data->nr_bank; i++) {
struct f7188x_gpio_bank *bank = &data->bank[i];
gpiochip_remove(&bank->chip);
}
return 0;
@ -476,7 +455,6 @@ static struct platform_driver f7188x_gpio_driver = {
.name = DRVNAME,
},
.probe = f7188x_gpio_probe,
.remove = f7188x_gpio_remove,
};
static int __init f7188x_gpio_init(void)

View File

@ -89,7 +89,7 @@ static int __init gef_gpio_probe(struct platform_device *pdev)
gc->of_node = pdev->dev.of_node;
/* This function adds a memory mapped GPIO chip */
ret = gpiochip_add_data(gc, NULL);
ret = devm_gpiochip_add_data(&pdev->dev, gc, NULL);
if (ret)
goto err0;

View File

@ -628,15 +628,7 @@ static int bgpio_pdev_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, gc);
return gpiochip_add_data(gc, NULL);
}
static int bgpio_pdev_remove(struct platform_device *pdev)
{
struct gpio_chip *gc = platform_get_drvdata(pdev);
gpiochip_remove(gc);
return 0;
return devm_gpiochip_add_data(&pdev->dev, gc, NULL);
}
static const struct platform_device_id bgpio_id_table[] = {
@ -657,7 +649,6 @@ static struct platform_driver bgpio_driver = {
},
.id_table = bgpio_id_table,
.probe = bgpio_pdev_probe,
.remove = bgpio_pdev_remove,
};
module_platform_driver(bgpio_driver);

View File

@ -114,7 +114,7 @@ static int iop3xx_gpio_probe(struct platform_device *pdev)
if (IS_ERR(base))
return PTR_ERR(base);
return gpiochip_add_data(&iop3xx_chip, NULL);
return devm_gpiochip_add_data(&pdev->dev, &iop3xx_chip, NULL);
}
static struct platform_driver iop3xx_gpio_driver = {

View File

@ -182,7 +182,7 @@ static int ttl_probe(struct platform_device *pdev)
gpio->base = -1;
gpio->ngpio = 20;
ret = gpiochip_add_data(gpio, NULL);
ret = devm_gpiochip_add_data(dev, gpio, NULL);
if (ret) {
dev_err(dev, "unable to add GPIO chip\n");
return ret;
@ -191,21 +191,11 @@ static int ttl_probe(struct platform_device *pdev)
return 0;
}
static int ttl_remove(struct platform_device *pdev)
{
struct ttl_module *mod = platform_get_drvdata(pdev);
gpiochip_remove(&mod->gpio);
return 0;
}
static struct platform_driver ttl_driver = {
.driver = {
.name = DRV_NAME,
},
.probe = ttl_probe,
.remove = ttl_remove,
};
module_platform_driver(ttl_driver);

View File

@ -178,7 +178,7 @@ static int kempld_gpio_probe(struct platform_device *pdev)
return -ENODEV;
}
ret = gpiochip_add_data(chip, gpio);
ret = devm_gpiochip_add_data(dev, chip, gpio);
if (ret) {
dev_err(dev, "Could not register GPIO chip\n");
return ret;
@ -190,20 +190,11 @@ static int kempld_gpio_probe(struct platform_device *pdev)
return 0;
}
static int kempld_gpio_remove(struct platform_device *pdev)
{
struct kempld_gpio_data *gpio = platform_get_drvdata(pdev);
gpiochip_remove(&gpio->chip);
return 0;
}
static struct platform_driver kempld_gpio_driver = {
.driver = {
.name = "kempld-gpio",
},
.probe = kempld_gpio_probe,
.remove = kempld_gpio_remove,
};
module_platform_driver(kempld_gpio_driver);

View File

@ -204,15 +204,8 @@ static int lp3943_gpio_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, lp3943_gpio);
return gpiochip_add_data(&lp3943_gpio->chip, lp3943_gpio);
}
static int lp3943_gpio_remove(struct platform_device *pdev)
{
struct lp3943_gpio *lp3943_gpio = platform_get_drvdata(pdev);
gpiochip_remove(&lp3943_gpio->chip);
return 0;
return devm_gpiochip_add_data(&pdev->dev, &lp3943_gpio->chip,
lp3943_gpio);
}
static const struct of_device_id lp3943_gpio_of_match[] = {
@ -223,7 +216,6 @@ MODULE_DEVICE_TABLE(of, lp3943_gpio_of_match);
static struct platform_driver lp3943_gpio_driver = {
.probe = lp3943_gpio_probe,
.remove = lp3943_gpio_remove,
.driver = {
.name = "lp3943-gpio",
.of_match_table = lp3943_gpio_of_match,

View File

@ -547,7 +547,7 @@ static int lpc32xx_gpio_probe(struct platform_device *pdev)
lpc32xx_gpiochip[i].chip.of_gpio_n_cells = 3;
lpc32xx_gpiochip[i].chip.of_node = pdev->dev.of_node;
}
gpiochip_add_data(&lpc32xx_gpiochip[i].chip,
devm_gpiochip_add_data(&pdev->dev, &lpc32xx_gpiochip[i].chip,
&lpc32xx_gpiochip[i]);
}

View File

@ -370,7 +370,7 @@ static int lp_gpio_probe(struct platform_device *pdev)
gc->can_sleep = false;
gc->parent = dev;
ret = gpiochip_add_data(gc, lg);
ret = devm_gpiochip_add_data(dev, gc, lg);
if (ret) {
dev_err(dev, "failed adding lp-gpio chip\n");
return ret;
@ -439,9 +439,7 @@ MODULE_DEVICE_TABLE(acpi, lynxpoint_gpio_acpi_match);
static int lp_gpio_remove(struct platform_device *pdev)
{
struct lp_gpio *lg = platform_get_drvdata(pdev);
pm_runtime_disable(&pdev->dev);
gpiochip_remove(&lg->chip);
return 0;
}

View File

@ -103,17 +103,7 @@ static int mc9s08dz60_probe(struct i2c_client *client,
mc9s->client = client;
i2c_set_clientdata(client, mc9s);
return gpiochip_add_data(&mc9s->chip, mc9s);
}
static int mc9s08dz60_remove(struct i2c_client *client)
{
struct mc9s08dz60 *mc9s;
mc9s = i2c_get_clientdata(client);
gpiochip_remove(&mc9s->chip);
return 0;
return devm_gpiochip_add_data(&client->dev, &mc9s->chip, mc9s);
}
static const struct i2c_device_id mc9s08dz60_id[] = {
@ -128,7 +118,6 @@ static struct i2c_driver mc9s08dz60_i2c_driver = {
.name = "mc9s08dz60",
},
.probe = mc9s08dz60_probe,
.remove = mc9s08dz60_remove,
.id_table = mc9s08dz60_id,
};

View File

@ -60,7 +60,7 @@ static int moxart_gpio_probe(struct platform_device *pdev)
gc->base = 0;
gc->owner = THIS_MODULE;
ret = gpiochip_add_data(gc, NULL);
ret = devm_gpiochip_add_data(dev, gc, NULL);
if (ret) {
dev_err(dev, "%s: gpiochip_add failed\n",
dev->of_node->full_name);

View File

@ -756,7 +756,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
BUG();
}
gpiochip_add_data(&mvchip->chip, mvchip);
devm_gpiochip_add_data(&pdev->dev, &mvchip->chip, mvchip);
/* Some gpio controllers do not provide irq support */
if (!of_irq_count(np))
@ -777,16 +777,14 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
mvchip->irqbase = irq_alloc_descs(-1, 0, ngpios, -1);
if (mvchip->irqbase < 0) {
dev_err(&pdev->dev, "no irqs\n");
err = mvchip->irqbase;
goto err_gpiochip_add;
return mvchip->irqbase;
}
gc = irq_alloc_generic_chip("mvebu_gpio_irq", 2, mvchip->irqbase,
mvchip->membase, handle_level_irq);
if (!gc) {
dev_err(&pdev->dev, "Cannot allocate generic irq_chip\n");
err = -ENOMEM;
goto err_gpiochip_add;
return -ENOMEM;
}
gc->private = mvchip;
@ -828,9 +826,6 @@ err_generic_chip:
IRQ_LEVEL | IRQ_NOPROBE);
kfree(gc);
err_gpiochip_add:
gpiochip_remove(&mvchip->chip);
return err;
}

View File

@ -462,14 +462,14 @@ static int mxc_gpio_probe(struct platform_device *pdev)
port->gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 :
pdev->id * 32;
err = gpiochip_add_data(&port->gc, port);
err = devm_gpiochip_add_data(&pdev->dev, &port->gc, port);
if (err)
goto out_bgio;
irq_base = irq_alloc_descs(-1, 0, 32, numa_node_id());
if (irq_base < 0) {
err = irq_base;
goto out_gpiochip_remove;
goto out_bgio;
}
port->domain = irq_domain_add_legacy(np, 32, irq_base, 0,
@ -492,8 +492,6 @@ out_irqdomain_remove:
irq_domain_remove(port->domain);
out_irqdesc_free:
irq_free_descs(irq_base, 32);
out_gpiochip_remove:
gpiochip_remove(&port->gc);
out_bgio:
dev_info(&pdev->dev, "%s failed with errno %d\n", __func__, err);
return err;

View File

@ -117,7 +117,7 @@ static int octeon_gpio_probe(struct platform_device *pdev)
chip->get = octeon_gpio_get;
chip->direction_output = octeon_gpio_dir_out;
chip->set = octeon_gpio_set;
err = gpiochip_add_data(chip, gpio);
err = devm_gpiochip_add_data(&pdev->dev, chip, gpio);
if (err)
goto out;
@ -126,13 +126,6 @@ out:
return err;
}
static int octeon_gpio_remove(struct platform_device *pdev)
{
struct gpio_chip *chip = dev_get_platdata(&pdev->dev);
gpiochip_remove(chip);
return 0;
}
static struct of_device_id octeon_gpio_match[] = {
{
.compatible = "cavium,octeon-3860-gpio",
@ -147,7 +140,6 @@ static struct platform_driver octeon_gpio_driver = {
.of_match_table = octeon_gpio_match,
},
.probe = octeon_gpio_probe,
.remove = octeon_gpio_remove,
};
module_platform_driver(octeon_gpio_driver);

View File

@ -195,7 +195,8 @@ static int palmas_gpio_probe(struct platform_device *pdev)
else
palmas_gpio->gpio_chip.base = -1;
ret = gpiochip_add_data(&palmas_gpio->gpio_chip, palmas_gpio);
ret = devm_gpiochip_add_data(&pdev->dev, &palmas_gpio->gpio_chip,
palmas_gpio);
if (ret < 0) {
dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
return ret;
@ -205,20 +206,11 @@ static int palmas_gpio_probe(struct platform_device *pdev)
return ret;
}
static int palmas_gpio_remove(struct platform_device *pdev)
{
struct palmas_gpio *palmas_gpio = platform_get_drvdata(pdev);
gpiochip_remove(&palmas_gpio->gpio_chip);
return 0;
}
static struct platform_driver palmas_gpio_driver = {
.driver.name = "palmas-gpio",
.driver.owner = THIS_MODULE,
.driver.of_match_table = of_palmas_gpio_match,
.probe = palmas_gpio_probe,
.remove = palmas_gpio_remove,
};
static int __init palmas_gpio_init(void)

View File

@ -754,7 +754,7 @@ static int pca953x_probe(struct i2c_client *client,
if (ret)
return ret;
ret = gpiochip_add_data(&chip->gpio_chip, chip);
ret = devm_gpiochip_add_data(&client->dev, &chip->gpio_chip, chip);
if (ret)
return ret;
@ -789,8 +789,6 @@ static int pca953x_remove(struct i2c_client *client)
}
}
gpiochip_remove(&chip->gpio_chip);
return 0;
}

View File

@ -372,7 +372,7 @@ static int pcf857x_probe(struct i2c_client *client,
gpio->out = ~n_latch;
gpio->status = gpio->out;
status = gpiochip_add_data(&gpio->chip, gpio);
status = devm_gpiochip_add_data(&client->dev, &gpio->chip, gpio);
if (status < 0)
goto fail;
@ -383,7 +383,7 @@ static int pcf857x_probe(struct i2c_client *client,
IRQ_TYPE_NONE);
if (status) {
dev_err(&client->dev, "cannot add irqchip\n");
goto fail_irq;
goto fail;
}
status = devm_request_threaded_irq(&client->dev, client->irq,
@ -391,7 +391,7 @@ static int pcf857x_probe(struct i2c_client *client,
IRQF_TRIGGER_FALLING | IRQF_SHARED,
dev_name(&client->dev), gpio);
if (status)
goto fail_irq;
goto fail;
gpiochip_set_chained_irqchip(&gpio->chip, &pcf857x_irq_chip,
client->irq, NULL);
@ -413,9 +413,6 @@ static int pcf857x_probe(struct i2c_client *client,
return 0;
fail_irq:
gpiochip_remove(&gpio->chip);
fail:
dev_dbg(&client->dev, "probe error %d for '%s'\n", status,
client->name);
@ -440,7 +437,6 @@ static int pcf857x_remove(struct i2c_client *client)
}
}
gpiochip_remove(&gpio->chip);
return status;
}

View File

@ -136,15 +136,8 @@ static int rc5t583_gpio_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, rc5t583_gpio);
return gpiochip_add_data(&rc5t583_gpio->gpio_chip, rc5t583_gpio);
}
static int rc5t583_gpio_remove(struct platform_device *pdev)
{
struct rc5t583_gpio *rc5t583_gpio = platform_get_drvdata(pdev);
gpiochip_remove(&rc5t583_gpio->gpio_chip);
return 0;
return devm_gpiochip_add_data(&pdev->dev, &rc5t583_gpio->gpio_chip,
rc5t583_gpio);
}
static struct platform_driver rc5t583_gpio_driver = {
@ -152,7 +145,6 @@ static struct platform_driver rc5t583_gpio_driver = {
.name = "rc5t583-gpio",
},
.probe = rc5t583_gpio_probe,
.remove = rc5t583_gpio_remove,
};
static int __init rc5t583_gpio_init(void)

View File

@ -196,6 +196,44 @@ static int gpio_rcar_irq_set_wake(struct irq_data *d, unsigned int on)
return 0;
}
static void gpio_rcar_irq_bus_lock(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct gpio_rcar_priv *p = gpiochip_get_data(gc);
pm_runtime_get_sync(&p->pdev->dev);
}
static void gpio_rcar_irq_bus_sync_unlock(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct gpio_rcar_priv *p = gpiochip_get_data(gc);
pm_runtime_put(&p->pdev->dev);
}
static int gpio_rcar_irq_request_resources(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct gpio_rcar_priv *p = gpiochip_get_data(gc);
int error;
error = pm_runtime_get_sync(&p->pdev->dev);
if (error < 0)
return error;
return 0;
}
static void gpio_rcar_irq_release_resources(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct gpio_rcar_priv *p = gpiochip_get_data(gc);
pm_runtime_put(&p->pdev->dev);
}
static irqreturn_t gpio_rcar_irq_handler(int irq, void *dev_id)
{
struct gpio_rcar_priv *p = dev_id;
@ -450,6 +488,10 @@ static int gpio_rcar_probe(struct platform_device *pdev)
irq_chip->irq_unmask = gpio_rcar_irq_enable;
irq_chip->irq_set_type = gpio_rcar_irq_set_type;
irq_chip->irq_set_wake = gpio_rcar_irq_set_wake;
irq_chip->irq_bus_lock = gpio_rcar_irq_bus_lock;
irq_chip->irq_bus_sync_unlock = gpio_rcar_irq_bus_sync_unlock;
irq_chip->irq_request_resources = gpio_rcar_irq_request_resources;
irq_chip->irq_release_resources = gpio_rcar_irq_release_resources;
irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND;
ret = gpiochip_add_data(gpio_chip, p);

View File

@ -194,23 +194,14 @@ static int rdc321x_gpio_probe(struct platform_device *pdev)
dev_info(&pdev->dev, "registering %d GPIOs\n",
rdc321x_gpio_dev->chip.ngpio);
return gpiochip_add_data(&rdc321x_gpio_dev->chip, rdc321x_gpio_dev);
}
static int rdc321x_gpio_remove(struct platform_device *pdev)
{
struct rdc321x_gpio *rdc321x_gpio_dev = platform_get_drvdata(pdev);
gpiochip_remove(&rdc321x_gpio_dev->chip);
return 0;
return devm_gpiochip_add_data(&pdev->dev, &rdc321x_gpio_dev->chip,
rdc321x_gpio_dev);
}
static struct platform_driver rdc321x_gpio_driver = {
.driver.name = "rdc321x-gpio",
.driver.owner = THIS_MODULE,
.probe = rdc321x_gpio_probe,
.remove = rdc321x_gpio_remove,
};
module_platform_driver(rdc321x_gpio_driver);

View File

@ -215,15 +215,7 @@ static int sch_gpio_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, sch);
return gpiochip_add_data(&sch->chip, sch);
}
static int sch_gpio_remove(struct platform_device *pdev)
{
struct sch_gpio *sch = platform_get_drvdata(pdev);
gpiochip_remove(&sch->chip);
return 0;
return devm_gpiochip_add_data(&pdev->dev, &sch->chip, sch);
}
static struct platform_driver sch_gpio_driver = {
@ -231,7 +223,6 @@ static struct platform_driver sch_gpio_driver = {
.name = "sch_gpio",
},
.probe = sch_gpio_probe,
.remove = sch_gpio_remove,
};
module_platform_driver(sch_gpio_driver);

View File

@ -165,7 +165,7 @@ static int spics_gpio_probe(struct platform_device *pdev)
spics->chip.owner = THIS_MODULE;
spics->last_off = -1;
ret = gpiochip_add_data(&spics->chip, spics);
ret = devm_gpiochip_add_data(&pdev->dev, &spics->chip, spics);
if (ret) {
dev_err(&pdev->dev, "unable to add gpio chip\n");
return ret;

View File

@ -409,7 +409,7 @@ static int gsta_probe(struct platform_device *dev)
goto err_free_descs;
}
err = gpiochip_add_data(&chip->gpio, chip);
err = devm_gpiochip_add_data(&dev->dev, &chip->gpio, chip);
if (err < 0) {
dev_err(&dev->dev, "sta2x11 gpio: Can't register (%i)\n",
-err);

View File

@ -258,7 +258,7 @@ static int xway_stp_probe(struct platform_device *pdev)
ret = xway_stp_hw_init(chip);
if (!ret)
ret = gpiochip_add_data(&chip->gc, chip);
ret = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip);
if (!ret)
dev_info(&pdev->dev, "Init done\n");

View File

@ -687,7 +687,7 @@ static int sx150x_probe(struct i2c_client *client,
if (rc < 0)
return rc;
rc = gpiochip_add_data(&chip->gpio_chip, chip);
rc = devm_gpiochip_add_data(&client->dev, &chip->gpio_chip, chip);
if (rc)
return rc;
@ -696,23 +696,10 @@ static int sx150x_probe(struct i2c_client *client,
pdata->irq_summary,
pdata->irq_base);
if (rc < 0)
goto probe_fail_post_gpiochip_add;
}
i2c_set_clientdata(client, chip);
return 0;
probe_fail_post_gpiochip_add:
gpiochip_remove(&chip->gpio_chip);
return rc;
}
static int sx150x_remove(struct i2c_client *client)
{
struct sx150x_chip *chip;
chip = i2c_get_clientdata(client);
gpiochip_remove(&chip->gpio_chip);
i2c_set_clientdata(client, chip);
return 0;
}
@ -723,7 +710,6 @@ static struct i2c_driver sx150x_driver = {
.of_match_table = of_match_ptr(sx150x_of_match),
},
.probe = sx150x_probe,
.remove = sx150x_remove,
.id_table = sx150x_id,
};

View File

@ -238,15 +238,7 @@ static int syscon_gpio_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, priv);
return gpiochip_add_data(&priv->chip, priv);
}
static int syscon_gpio_remove(struct platform_device *pdev)
{
struct syscon_gpio_priv *priv = platform_get_drvdata(pdev);
gpiochip_remove(&priv->chip);
return 0;
return devm_gpiochip_add_data(&pdev->dev, &priv->chip, priv);
}
static struct platform_driver syscon_gpio_driver = {
@ -255,7 +247,6 @@ static struct platform_driver syscon_gpio_driver = {
.of_match_table = syscon_gpio_ids,
},
.probe = syscon_gpio_probe,
.remove = syscon_gpio_remove,
};
module_platform_driver(syscon_gpio_driver);

View File

@ -205,10 +205,10 @@ static int tb10x_gpio_probe(struct platform_device *pdev)
tb10x_gpio->gc.can_sleep = false;
ret = gpiochip_add_data(&tb10x_gpio->gc, tb10x_gpio);
ret = devm_gpiochip_add_data(&pdev->dev, &tb10x_gpio->gc, tb10x_gpio);
if (ret < 0) {
dev_err(&pdev->dev, "Could not add gpiochip.\n");
goto fail_gpiochip_registration;
return ret;
}
platform_set_drvdata(pdev, tb10x_gpio);
@ -219,7 +219,7 @@ static int tb10x_gpio_probe(struct platform_device *pdev)
ret = platform_get_irq(pdev, 0);
if (ret < 0) {
dev_err(&pdev->dev, "No interrupt specified.\n");
goto fail_get_irq;
return ret;
}
tb10x_gpio->gc.to_irq = tb10x_gpio_to_irq;
@ -229,14 +229,13 @@ static int tb10x_gpio_probe(struct platform_device *pdev)
IRQF_TRIGGER_NONE | IRQF_SHARED,
dev_name(&pdev->dev), tb10x_gpio);
if (ret != 0)
goto fail_request_irq;
return ret;
tb10x_gpio->domain = irq_domain_add_linear(dn,
tb10x_gpio->gc.ngpio,
&irq_generic_chip_ops, NULL);
if (!tb10x_gpio->domain) {
ret = -ENOMEM;
goto fail_irq_domain;
return -ENOMEM;
}
ret = irq_alloc_domain_generic_chips(tb10x_gpio->domain,
@ -244,7 +243,7 @@ static int tb10x_gpio_probe(struct platform_device *pdev)
handle_edge_irq, IRQ_NOREQUEST, IRQ_NOPROBE,
IRQ_GC_INIT_MASK_CACHE);
if (ret)
goto fail_irq_domain;
return ret;
gc = tb10x_gpio->domain->gc->gc[0];
gc->reg_base = tb10x_gpio->base;
@ -258,14 +257,6 @@ static int tb10x_gpio_probe(struct platform_device *pdev)
}
return 0;
fail_irq_domain:
fail_request_irq:
fail_get_irq:
gpiochip_remove(&tb10x_gpio->gc);
fail_gpiochip_registration:
fail_ioremap:
return ret;
}
static int tb10x_gpio_remove(struct platform_device *pdev)
@ -278,7 +269,6 @@ static int tb10x_gpio_remove(struct platform_device *pdev)
kfree(tb10x_gpio->domain->gc);
irq_domain_remove(tb10x_gpio->domain);
}
gpiochip_remove(&tb10x_gpio->gc);
return 0;
}

View File

@ -272,7 +272,8 @@ static int tc3589x_gpio_probe(struct platform_device *pdev)
return ret;
}
ret = gpiochip_add_data(&tc3589x_gpio->chip, tc3589x_gpio);
ret = devm_gpiochip_add_data(&pdev->dev, &tc3589x_gpio->chip,
tc3589x_gpio);
if (ret) {
dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret);
return ret;
@ -299,20 +300,10 @@ static int tc3589x_gpio_probe(struct platform_device *pdev)
return 0;
}
static int tc3589x_gpio_remove(struct platform_device *pdev)
{
struct tc3589x_gpio *tc3589x_gpio = platform_get_drvdata(pdev);
gpiochip_remove(&tc3589x_gpio->chip);
return 0;
}
static struct platform_driver tc3589x_gpio_driver = {
.driver.name = "tc3589x-gpio",
.driver.owner = THIS_MODULE,
.probe = tc3589x_gpio_probe,
.remove = tc3589x_gpio_remove,
};
static int __init tc3589x_gpio_init(void)

View File

@ -545,7 +545,7 @@ static int tegra_gpio_probe(struct platform_device *pdev)
tegra_gpio_chip.of_node = pdev->dev.of_node;
ret = gpiochip_add_data(&tegra_gpio_chip, NULL);
ret = devm_gpiochip_add_data(&pdev->dev, &tegra_gpio_chip, NULL);
if (ret < 0) {
irq_domain_remove(irq_domain);
return ret;

View File

@ -279,7 +279,7 @@ static int timbgpio_probe(struct platform_device *pdev)
gc->ngpio = pdata->nr_pins;
gc->can_sleep = false;
err = gpiochip_add_data(gc, tgpio);
err = devm_gpiochip_add_data(&pdev->dev, gc, tgpio);
if (err)
return err;
@ -320,8 +320,6 @@ static int timbgpio_remove(struct platform_device *pdev)
irq_set_handler_data(irq, NULL);
}
gpiochip_remove(&tgpio->gpio);
return 0;
}

View File

@ -117,7 +117,8 @@ static int tps6586x_gpio_probe(struct platform_device *pdev)
else
tps6586x_gpio->gpio_chip.base = -1;
ret = gpiochip_add_data(&tps6586x_gpio->gpio_chip, tps6586x_gpio);
ret = devm_gpiochip_add_data(&pdev->dev, &tps6586x_gpio->gpio_chip,
tps6586x_gpio);
if (ret < 0) {
dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
return ret;
@ -128,19 +129,10 @@ static int tps6586x_gpio_probe(struct platform_device *pdev)
return ret;
}
static int tps6586x_gpio_remove(struct platform_device *pdev)
{
struct tps6586x_gpio *tps6586x_gpio = platform_get_drvdata(pdev);
gpiochip_remove(&tps6586x_gpio->gpio_chip);
return 0;
}
static struct platform_driver tps6586x_gpio_driver = {
.driver.name = "tps6586x-gpio",
.driver.owner = THIS_MODULE,
.probe = tps6586x_gpio_probe,
.remove = tps6586x_gpio_remove,
};
static int __init tps6586x_gpio_init(void)

View File

@ -170,7 +170,8 @@ static int tps65910_gpio_probe(struct platform_device *pdev)
}
skip_init:
ret = gpiochip_add_data(&tps65910_gpio->gpio_chip, tps65910_gpio);
ret = devm_gpiochip_add_data(&pdev->dev, &tps65910_gpio->gpio_chip,
tps65910_gpio);
if (ret < 0) {
dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
return ret;
@ -181,19 +182,10 @@ skip_init:
return ret;
}
static int tps65910_gpio_remove(struct platform_device *pdev)
{
struct tps65910_gpio *tps65910_gpio = platform_get_drvdata(pdev);
gpiochip_remove(&tps65910_gpio->gpio_chip);
return 0;
}
static struct platform_driver tps65910_gpio_driver = {
.driver.name = "tps65910-gpio",
.driver.owner = THIS_MODULE,
.probe = tps65910_gpio_probe,
.remove = tps65910_gpio_remove,
};
static int __init tps65910_gpio_init(void)

View File

@ -106,7 +106,8 @@ static int tps65912_gpio_probe(struct platform_device *pdev)
if (pdata && pdata->gpio_base)
tps65912_gpio->gpio_chip.base = pdata->gpio_base;
ret = gpiochip_add_data(&tps65912_gpio->gpio_chip, tps65912_gpio);
ret = devm_gpiochip_add_data(&pdev->dev, &tps65912_gpio->gpio_chip,
tps65912_gpio);
if (ret < 0) {
dev_err(&pdev->dev, "Failed to register gpiochip, %d\n", ret);
return ret;
@ -117,20 +118,11 @@ static int tps65912_gpio_probe(struct platform_device *pdev)
return ret;
}
static int tps65912_gpio_remove(struct platform_device *pdev)
{
struct tps65912_gpio_data *tps65912_gpio = platform_get_drvdata(pdev);
gpiochip_remove(&tps65912_gpio->gpio_chip);
return 0;
}
static struct platform_driver tps65912_gpio_driver = {
.driver = {
.name = "tps65912-gpio",
},
.probe = tps65912_gpio_probe,
.remove = tps65912_gpio_remove,
};
static int __init tps65912_gpio_init(void)

View File

@ -58,16 +58,7 @@ static int ts4800_gpio_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, chip);
return gpiochip_add_data(chip, NULL);
}
static int ts4800_gpio_remove(struct platform_device *pdev)
{
struct gpio_chip *chip = platform_get_drvdata(pdev);
gpiochip_remove(chip);
return 0;
return devm_gpiochip_add_data(&pdev->dev, chip, NULL);
}
static const struct of_device_id ts4800_gpio_of_match[] = {
@ -81,7 +72,6 @@ static struct platform_driver ts4800_gpio_driver = {
.of_match_table = ts4800_gpio_of_match,
},
.probe = ts4800_gpio_probe,
.remove = ts4800_gpio_remove,
};
module_platform_driver_probe(ts4800_gpio_driver, ts4800_gpio_probe);

View File

@ -409,7 +409,7 @@ static int ts5500_dio_probe(struct platform_device *pdev)
break;
}
ret = gpiochip_add_data(&priv->gpio_chip, priv);
ret = devm_gpiochip_add_data(dev, &priv->gpio_chip, priv);
if (ret) {
dev_err(dev, "failed to register the gpio chip\n");
return ret;
@ -418,13 +418,10 @@ static int ts5500_dio_probe(struct platform_device *pdev)
ret = ts5500_enable_irq(priv);
if (ret) {
dev_err(dev, "invalid interrupt %d\n", priv->hwirq);
goto cleanup;
return ret;
}
return 0;
cleanup:
gpiochip_remove(&priv->gpio_chip);
return ret;
}
static int ts5500_dio_remove(struct platform_device *pdev)
@ -432,7 +429,7 @@ static int ts5500_dio_remove(struct platform_device *pdev)
struct ts5500_priv *priv = platform_get_drvdata(pdev);
ts5500_disable_irq(priv);
gpiochip_remove(&priv->gpio_chip);
return 0;
}

View File

@ -100,7 +100,7 @@ static int gpo_twl6040_probe(struct platform_device *pdev)
twl6040gpo_chip.of_node = twl6040_core_dev->of_node;
#endif
ret = gpiochip_add_data(&twl6040gpo_chip, NULL);
ret = devm_gpiochip_add_data(&pdev->dev, &twl6040gpo_chip, NULL);
if (ret < 0) {
dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret);
twl6040gpo_chip.ngpio = 0;
@ -109,12 +109,6 @@ static int gpo_twl6040_probe(struct platform_device *pdev)
return ret;
}
static int gpo_twl6040_remove(struct platform_device *pdev)
{
gpiochip_remove(&twl6040gpo_chip);
return 0;
}
/* Note: this hardware lives inside an I2C-based multi-function device. */
MODULE_ALIAS("platform:twl6040-gpo");
@ -123,7 +117,6 @@ static struct platform_driver gpo_twl6040_driver = {
.name = "twl6040-gpo",
},
.probe = gpo_twl6040_probe,
.remove = gpo_twl6040_remove,
};
module_platform_driver(gpo_twl6040_driver);

View File

@ -67,7 +67,7 @@ static int ucb1400_gpio_probe(struct platform_device *dev)
ucb->gc.set = ucb1400_gpio_set;
ucb->gc.can_sleep = true;
err = gpiochip_add_data(&ucb->gc, ucb);
err = devm_gpiochip_add_data(&dev->dev, &ucb->gc, ucb);
if (err)
goto err;
@ -90,7 +90,6 @@ static int ucb1400_gpio_remove(struct platform_device *dev)
return err;
}
gpiochip_remove(&ucb->gc);
return err;
}

View File

@ -410,10 +410,10 @@ static int vprbrd_gpio_probe(struct platform_device *pdev)
vb_gpio->gpioa.get = vprbrd_gpioa_get;
vb_gpio->gpioa.direction_input = vprbrd_gpioa_direction_input;
vb_gpio->gpioa.direction_output = vprbrd_gpioa_direction_output;
ret = gpiochip_add_data(&vb_gpio->gpioa, vb_gpio);
ret = devm_gpiochip_add_data(&pdev->dev, &vb_gpio->gpioa, vb_gpio);
if (ret < 0) {
dev_err(vb_gpio->gpioa.parent, "could not add gpio a");
goto err_gpioa;
return ret;
}
/* registering gpio b */
@ -427,37 +427,21 @@ static int vprbrd_gpio_probe(struct platform_device *pdev)
vb_gpio->gpiob.get = vprbrd_gpiob_get;
vb_gpio->gpiob.direction_input = vprbrd_gpiob_direction_input;
vb_gpio->gpiob.direction_output = vprbrd_gpiob_direction_output;
ret = gpiochip_add_data(&vb_gpio->gpiob, vb_gpio);
ret = devm_gpiochip_add_data(&pdev->dev, &vb_gpio->gpiob, vb_gpio);
if (ret < 0) {
dev_err(vb_gpio->gpiob.parent, "could not add gpio b");
goto err_gpiob;
return ret;
}
platform_set_drvdata(pdev, vb_gpio);
return ret;
err_gpiob:
gpiochip_remove(&vb_gpio->gpioa);
err_gpioa:
return ret;
}
static int vprbrd_gpio_remove(struct platform_device *pdev)
{
struct vprbrd_gpio *vb_gpio = platform_get_drvdata(pdev);
gpiochip_remove(&vb_gpio->gpiob);
return 0;
}
static struct platform_driver vprbrd_gpio_driver = {
.driver.name = "viperboard-gpio",
.driver.owner = THIS_MODULE,
.probe = vprbrd_gpio_probe,
.remove = vprbrd_gpio_remove,
};
static int __init vprbrd_gpio_init(void)

View File

@ -259,16 +259,7 @@ static int vx855gpio_probe(struct platform_device *pdev)
vx855gpio_gpio_setup(vg);
return gpiochip_add_data(&vg->gpio, vg);
}
static int vx855gpio_remove(struct platform_device *pdev)
{
struct vx855_gpio *vg = platform_get_drvdata(pdev);
gpiochip_remove(&vg->gpio);
return 0;
return devm_gpiochip_add_data(&pdev->dev, &vg->gpio, vg);
}
static struct platform_driver vx855gpio_driver = {
@ -276,7 +267,6 @@ static struct platform_driver vx855gpio_driver = {
.name = MODULE_NAME,
},
.probe = vx855gpio_probe,
.remove = vx855gpio_remove,
};
module_platform_driver(vx855gpio_driver);

View File

@ -259,7 +259,8 @@ static int wm831x_gpio_probe(struct platform_device *pdev)
else
wm831x_gpio->gpio_chip.base = -1;
ret = gpiochip_add_data(&wm831x_gpio->gpio_chip, wm831x_gpio);
ret = devm_gpiochip_add_data(&pdev->dev, &wm831x_gpio->gpio_chip,
wm831x_gpio);
if (ret < 0) {
dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
return ret;
@ -270,19 +271,10 @@ static int wm831x_gpio_probe(struct platform_device *pdev)
return ret;
}
static int wm831x_gpio_remove(struct platform_device *pdev)
{
struct wm831x_gpio *wm831x_gpio = platform_get_drvdata(pdev);
gpiochip_remove(&wm831x_gpio->gpio_chip);
return 0;
}
static struct platform_driver wm831x_gpio_driver = {
.driver.name = "wm831x-gpio",
.driver.owner = THIS_MODULE,
.probe = wm831x_gpio_probe,
.remove = wm831x_gpio_remove,
};
static int __init wm831x_gpio_init(void)

View File

@ -125,7 +125,8 @@ static int wm8350_gpio_probe(struct platform_device *pdev)
else
wm8350_gpio->gpio_chip.base = -1;
ret = gpiochip_add_data(&wm8350_gpio->gpio_chip, wm8350_gpio);
ret = devm_gpiochip_add_data(&pdev->dev, &wm8350_gpio->gpio_chip,
wm8350_gpio);
if (ret < 0) {
dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
return ret;
@ -136,19 +137,10 @@ static int wm8350_gpio_probe(struct platform_device *pdev)
return ret;
}
static int wm8350_gpio_remove(struct platform_device *pdev)
{
struct wm8350_gpio_data *wm8350_gpio = platform_get_drvdata(pdev);
gpiochip_remove(&wm8350_gpio->gpio_chip);
return 0;
}
static struct platform_driver wm8350_gpio_driver = {
.driver.name = "wm8350-gpio",
.driver.owner = THIS_MODULE,
.probe = wm8350_gpio_probe,
.remove = wm8350_gpio_remove,
};
static int __init wm8350_gpio_init(void)

View File

@ -261,34 +261,23 @@ static int wm8994_gpio_probe(struct platform_device *pdev)
else
wm8994_gpio->gpio_chip.base = -1;
ret = gpiochip_add_data(&wm8994_gpio->gpio_chip, wm8994_gpio);
ret = devm_gpiochip_add_data(&pdev->dev, &wm8994_gpio->gpio_chip,
wm8994_gpio);
if (ret < 0) {
dev_err(&pdev->dev, "Could not register gpiochip, %d\n",
ret);
goto err;
return ret;
}
platform_set_drvdata(pdev, wm8994_gpio);
return ret;
err:
return ret;
}
static int wm8994_gpio_remove(struct platform_device *pdev)
{
struct wm8994_gpio *wm8994_gpio = platform_get_drvdata(pdev);
gpiochip_remove(&wm8994_gpio->gpio_chip);
return 0;
}
static struct platform_driver wm8994_gpio_driver = {
.driver.name = "wm8994-gpio",
.driver.owner = THIS_MODULE,
.probe = wm8994_gpio_probe,
.remove = wm8994_gpio_remove,
};
static int __init wm8994_gpio_init(void)

View File

@ -311,7 +311,7 @@ static int xgene_gpio_sb_probe(struct platform_device *pdev)
priv->gc.irqdomain = priv->irq_domain;
ret = gpiochip_add_data(&priv->gc, priv);
ret = devm_gpiochip_add_data(&pdev->dev, &priv->gc, priv);
if (ret) {
dev_err(&pdev->dev,
"failed to register X-Gene GPIO Standby driver\n");
@ -339,7 +339,6 @@ static int xgene_gpio_sb_remove(struct platform_device *pdev)
irq_domain_remove(priv->irq_domain);
gpiochip_remove(&priv->gc);
return 0;
}

View File

@ -193,7 +193,7 @@ static int xgene_gpio_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, gpio);
err = gpiochip_add_data(&gpio->chip, gpio);
err = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio);
if (err) {
dev_err(&pdev->dev,
"failed to register gpiochip.\n");
@ -207,14 +207,6 @@ err:
return err;
}
static int xgene_gpio_remove(struct platform_device *pdev)
{
struct xgene_gpio *gpio = platform_get_drvdata(pdev);
gpiochip_remove(&gpio->chip);
return 0;
}
static const struct of_device_id xgene_gpio_of_match[] = {
{ .compatible = "apm,xgene-gpio", },
{},
@ -228,7 +220,6 @@ static struct platform_driver xgene_gpio_driver = {
.pm = XGENE_GPIO_PM_OPS,
},
.probe = xgene_gpio_probe,
.remove = xgene_gpio_remove,
};
module_platform_driver(xgene_gpio_driver);

View File

@ -708,6 +708,80 @@ void gpiochip_remove(struct gpio_chip *chip)
}
EXPORT_SYMBOL_GPL(gpiochip_remove);
static void devm_gpio_chip_release(struct device *dev, void *res)
{
struct gpio_chip *chip = *(struct gpio_chip **)res;
gpiochip_remove(chip);
}
static int devm_gpio_chip_match(struct device *dev, void *res, void *data)
{
struct gpio_chip **r = res;
if (!r || !*r) {
WARN_ON(!r || !*r);
return 0;
}
return *r == data;
}
/**
* devm_gpiochip_add_data() - Resource manager piochip_add_data()
* @dev: the device pointer on which irq_chip belongs to.
* @chip: the chip to register, with chip->base initialized
* Context: potentially before irqs will work
*
* Returns a negative errno if the chip can't be registered, such as
* because the chip->base is invalid or already associated with a
* different chip. Otherwise it returns zero as a success code.
*
* The gpio chip automatically be released when the device is unbound.
*/
int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *chip,
void *data)
{
struct gpio_chip **ptr;
int ret;
ptr = devres_alloc(devm_gpio_chip_release, sizeof(*ptr),
GFP_KERNEL);
if (!ptr)
return -ENOMEM;
ret = gpiochip_add_data(chip, data);
if (ret < 0) {
devres_free(ptr);
return ret;
}
*ptr = chip;
devres_add(dev, ptr);
return 0;
}
EXPORT_SYMBOL_GPL(devm_gpiochip_add_data);
/**
* devm_gpiochip_remove() - Resource manager of gpiochip_remove()
* @dev: device for which which resource was allocated
* @chip: the chip to remove
*
* A gpio_chip with any GPIOs still requested may not be removed.
*/
void devm_gpiochip_remove(struct device *dev, struct gpio_chip *chip)
{
int ret;
ret = devres_release(dev, devm_gpio_chip_release,
devm_gpio_chip_match, chip);
if (!ret)
WARN_ON(ret);
}
EXPORT_SYMBOL_GPL(devm_gpiochip_remove);
/**
* gpiochip_find() - iterator for locating a specific gpio_chip
* @data: data to pass to match function

View File

@ -192,6 +192,10 @@ static inline int gpiochip_add(struct gpio_chip *chip)
return gpiochip_add_data(chip, NULL);
}
extern void gpiochip_remove(struct gpio_chip *chip);
extern int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *chip,
void *data);
extern void devm_gpiochip_remove(struct device *dev, struct gpio_chip *chip);
extern struct gpio_chip *gpiochip_find(void *data,
int (*match)(struct gpio_chip *chip, void *data));