Skip to content

Commit

Permalink
Merge branch 'devm-gpiochip-add-data' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
Linus Walleij committed Mar 8, 2016
2 parents a961f9b + 725e3b7 commit 016bf20
Show file tree
Hide file tree
Showing 63 changed files with 229 additions and 470 deletions.
5 changes: 5 additions & 0 deletions Documentation/driver-model/devres.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# linux-upstream
This is for sharing upstreaming activities.
11 changes: 1 addition & 10 deletions drivers/gpio/gpio-74xx-mmio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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);

Expand Down
11 changes: 1 addition & 10 deletions drivers/gpio/gpio-adnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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" },
{ },
Expand All @@ -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);
Expand Down
13 changes: 1 addition & 12 deletions drivers/gpio/gpio-adp5520.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -164,22 +164,11 @@ static int adp5520_gpio_probe(struct platform_device *pdev)
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);
Expand Down
4 changes: 1 addition & 3 deletions drivers/gpio/gpio-adp5588.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions drivers/gpio/gpio-altera.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);

Expand Down
12 changes: 2 additions & 10 deletions drivers/gpio/gpio-arizona.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -147,18 +148,9 @@ static int arizona_gpio_probe(struct platform_device *pdev)
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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-bcm-kona.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 1 addition & 10 deletions drivers/gpio/gpio-clps711x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand All @@ -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);

Expand Down
9 changes: 2 additions & 7 deletions drivers/gpio/gpio-crystalcove.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -359,22 +359,17 @@ 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)
{
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;
Expand Down
20 changes: 5 additions & 15 deletions drivers/gpio/gpio-cs5535.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 err;

return 0;
}
Expand All @@ -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);
Expand Down
11 changes: 1 addition & 10 deletions drivers/gpio/gpio-da9052.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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",
},
Expand Down
16 changes: 2 additions & 14 deletions drivers/gpio/gpio-da9055.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
7 changes: 4 additions & 3 deletions drivers/gpio/gpio-davinci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit 016bf20

Please sign in to comment.