Skip to content

Commit 016bf20

Browse files
committed
Merge branch 'devm-gpiochip-add-data' into devel
2 parents a961f9b + 725e3b7 commit 016bf20

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+229
-470
lines changed

Documentation/driver-model/devres.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@ GPIO
252252
devm_gpiod_get_index_optional()
253253
devm_gpiod_get_optional()
254254
devm_gpiod_put()
255+
devm_gpiochip_add_data()
256+
devm_gpiochip_remove()
257+
devm_gpio_request()
258+
devm_gpio_request_one()
259+
devm_gpio_free()
255260

256261
IIO
257262
devm_iio_device_alloc()

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# linux-upstream
2+
This is for sharing upstreaming activities.

drivers/gpio/gpio-74xx-mmio.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,7 @@ static int mmio_74xx_gpio_probe(struct platform_device *pdev)
140140

141141
platform_set_drvdata(pdev, priv);
142142

143-
return gpiochip_add_data(&priv->gc, priv);
144-
}
145-
146-
static int mmio_74xx_gpio_remove(struct platform_device *pdev)
147-
{
148-
struct mmio_74xx_gpio_priv *priv = platform_get_drvdata(pdev);
149-
150-
gpiochip_remove(&priv->gc);
151-
return 0;
143+
return devm_gpiochip_add_data(&pdev->dev, &priv->gc, priv);
152144
}
153145

154146
static struct platform_driver mmio_74xx_gpio_driver = {
@@ -157,7 +149,6 @@ static struct platform_driver mmio_74xx_gpio_driver = {
157149
.of_match_table = mmio_74xx_gpio_ids,
158150
},
159151
.probe = mmio_74xx_gpio_probe,
160-
.remove = mmio_74xx_gpio_remove,
161152
};
162153
module_platform_driver(mmio_74xx_gpio_driver);
163154

drivers/gpio/gpio-adnp.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ static int adnp_gpio_setup(struct adnp *adnp, unsigned int num_gpios)
265265
chip->of_node = chip->parent->of_node;
266266
chip->owner = THIS_MODULE;
267267

268-
err = gpiochip_add_data(chip, adnp);
268+
err = devm_gpiochip_add_data(&adnp->client->dev, chip, adnp);
269269
if (err)
270270
return err;
271271

@@ -520,14 +520,6 @@ static int adnp_i2c_probe(struct i2c_client *client,
520520
return 0;
521521
}
522522

523-
static int adnp_i2c_remove(struct i2c_client *client)
524-
{
525-
struct adnp *adnp = i2c_get_clientdata(client);
526-
527-
gpiochip_remove(&adnp->gpio);
528-
return 0;
529-
}
530-
531523
static const struct i2c_device_id adnp_i2c_id[] = {
532524
{ "gpio-adnp" },
533525
{ },
@@ -546,7 +538,6 @@ static struct i2c_driver adnp_i2c_driver = {
546538
.of_match_table = adnp_of_match,
547539
},
548540
.probe = adnp_i2c_probe,
549-
.remove = adnp_i2c_remove,
550541
.id_table = adnp_i2c_id,
551542
};
552543
module_i2c_driver(adnp_i2c_driver);

drivers/gpio/gpio-adp5520.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static int adp5520_gpio_probe(struct platform_device *pdev)
153153
goto err;
154154
}
155155

156-
ret = gpiochip_add_data(&dev->gpio_chip, dev);
156+
ret = devm_gpiochip_add_data(&pdev->dev, &dev->gpio_chip, dev);
157157
if (ret)
158158
goto err;
159159

@@ -164,22 +164,11 @@ static int adp5520_gpio_probe(struct platform_device *pdev)
164164
return ret;
165165
}
166166

167-
static int adp5520_gpio_remove(struct platform_device *pdev)
168-
{
169-
struct adp5520_gpio *dev;
170-
171-
dev = platform_get_drvdata(pdev);
172-
gpiochip_remove(&dev->gpio_chip);
173-
174-
return 0;
175-
}
176-
177167
static struct platform_driver adp5520_gpio_driver = {
178168
.driver = {
179169
.name = "adp5520-gpio",
180170
},
181171
.probe = adp5520_gpio_probe,
182-
.remove = adp5520_gpio_remove,
183172
};
184173

185174
module_platform_driver(adp5520_gpio_driver);

drivers/gpio/gpio-adp5588.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ static int adp5588_gpio_probe(struct i2c_client *client,
414414
}
415415
}
416416

417-
ret = gpiochip_add_data(&dev->gpio_chip, dev);
417+
ret = devm_gpiochip_add_data(&client->dev, &dev->gpio_chip, dev);
418418
if (ret)
419419
goto err_irq;
420420

@@ -457,8 +457,6 @@ static int adp5588_gpio_remove(struct i2c_client *client)
457457
if (dev->irq_base)
458458
free_irq(dev->client->irq, dev);
459459

460-
gpiochip_remove(&dev->gpio_chip);
461-
462460
return 0;
463461
}
464462

drivers/gpio/gpio-altera.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ static int altera_gpio_probe(struct platform_device *pdev)
312312
handle_simple_irq, IRQ_TYPE_NONE);
313313

314314
if (ret) {
315-
dev_info(&pdev->dev, "could not add irqchip\n");
316-
return ret;
315+
dev_err(&pdev->dev, "could not add irqchip\n");
316+
goto teardown;
317317
}
318318

319319
gpiochip_set_chained_irqchip(&altera_gc->mmchip.gc,
@@ -326,6 +326,7 @@ static int altera_gpio_probe(struct platform_device *pdev)
326326
skip_irq:
327327
return 0;
328328
teardown:
329+
of_mm_gpiochip_remove(&altera_gc->mmchip);
329330
pr_err("%s: registration failed with status %d\n",
330331
node->full_name, ret);
331332

drivers/gpio/gpio-arizona.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ static int arizona_gpio_probe(struct platform_device *pdev)
132132
else
133133
arizona_gpio->gpio_chip.base = -1;
134134

135-
ret = gpiochip_add_data(&arizona_gpio->gpio_chip, arizona_gpio);
135+
ret = devm_gpiochip_add_data(&pdev->dev, &arizona_gpio->gpio_chip,
136+
arizona_gpio);
136137
if (ret < 0) {
137138
dev_err(&pdev->dev, "Could not register gpiochip, %d\n",
138139
ret);
@@ -147,18 +148,9 @@ static int arizona_gpio_probe(struct platform_device *pdev)
147148
return ret;
148149
}
149150

150-
static int arizona_gpio_remove(struct platform_device *pdev)
151-
{
152-
struct arizona_gpio *arizona_gpio = platform_get_drvdata(pdev);
153-
154-
gpiochip_remove(&arizona_gpio->gpio_chip);
155-
return 0;
156-
}
157-
158151
static struct platform_driver arizona_gpio_driver = {
159152
.driver.name = "arizona-gpio",
160153
.probe = arizona_gpio_probe,
161-
.remove = arizona_gpio_remove,
162154
};
163155

164156
module_platform_driver(arizona_gpio_driver);

drivers/gpio/gpio-bcm-kona.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev)
630630

631631
bcm_kona_gpio_reset(kona_gpio);
632632

633-
ret = gpiochip_add_data(chip, kona_gpio);
633+
ret = devm_gpiochip_add_data(dev, chip, kona_gpio);
634634
if (ret < 0) {
635635
dev_err(dev, "Couldn't add GPIO chip -- %d\n", ret);
636636
goto err_irq_domain;

drivers/gpio/gpio-clps711x.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,7 @@ static int clps711x_gpio_probe(struct platform_device *pdev)
6767
gc->owner = THIS_MODULE;
6868
platform_set_drvdata(pdev, gc);
6969

70-
return gpiochip_add_data(gc, NULL);
71-
}
72-
73-
static int clps711x_gpio_remove(struct platform_device *pdev)
74-
{
75-
struct gpio_chip *gc = platform_get_drvdata(pdev);
76-
77-
gpiochip_remove(gc);
78-
return 0;
70+
return devm_gpiochip_add_data(&pdev->dev, gc, NULL);
7971
}
8072

8173
static const struct of_device_id __maybe_unused clps711x_gpio_ids[] = {
@@ -90,7 +82,6 @@ static struct platform_driver clps711x_gpio_driver = {
9082
.of_match_table = of_match_ptr(clps711x_gpio_ids),
9183
},
9284
.probe = clps711x_gpio_probe,
93-
.remove = clps711x_gpio_remove,
9485
};
9586
module_platform_driver(clps711x_gpio_driver);
9687

drivers/gpio/gpio-crystalcove.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ static int crystalcove_gpio_probe(struct platform_device *pdev)
345345
cg->chip.dbg_show = crystalcove_gpio_dbg_show;
346346
cg->regmap = pmic->regmap;
347347

348-
retval = gpiochip_add_data(&cg->chip, cg);
348+
retval = devm_gpiochip_add_data(&pdev->dev, &cg->chip, cg);
349349
if (retval) {
350350
dev_warn(&pdev->dev, "add gpio chip error: %d\n", retval);
351351
return retval;
@@ -359,22 +359,17 @@ static int crystalcove_gpio_probe(struct platform_device *pdev)
359359

360360
if (retval) {
361361
dev_warn(&pdev->dev, "request irq failed: %d\n", retval);
362-
goto out_remove_gpio;
362+
return retval;
363363
}
364364

365365
return 0;
366-
367-
out_remove_gpio:
368-
gpiochip_remove(&cg->chip);
369-
return retval;
370366
}
371367

372368
static int crystalcove_gpio_remove(struct platform_device *pdev)
373369
{
374370
struct crystalcove_gpio *cg = platform_get_drvdata(pdev);
375371
int irq = platform_get_irq(pdev, 0);
376372

377-
gpiochip_remove(&cg->chip);
378373
if (irq >= 0)
379374
free_irq(irq, cg);
380375
return 0;

drivers/gpio/gpio-cs5535.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,13 @@ static int cs5535_gpio_probe(struct platform_device *pdev)
320320
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
321321
if (!res) {
322322
dev_err(&pdev->dev, "can't fetch device resource info\n");
323-
goto done;
323+
return err;
324324
}
325325

326326
if (!devm_request_region(&pdev->dev, res->start, resource_size(res),
327327
pdev->name)) {
328328
dev_err(&pdev->dev, "can't request region\n");
329-
goto done;
329+
return err;
330330
}
331331

332332
/* set up the driver-specific struct */
@@ -348,19 +348,10 @@ static int cs5535_gpio_probe(struct platform_device *pdev)
348348
mask_orig, mask);
349349

350350
/* finally, register with the generic GPIO API */
351-
err = gpiochip_add_data(&cs5535_gpio_chip.chip, &cs5535_gpio_chip);
351+
err = devm_gpiochip_add_data(&pdev->dev, &cs5535_gpio_chip.chip,
352+
&cs5535_gpio_chip);
352353
if (err)
353-
goto done;
354-
355-
return 0;
356-
357-
done:
358-
return err;
359-
}
360-
361-
static int cs5535_gpio_remove(struct platform_device *pdev)
362-
{
363-
gpiochip_remove(&cs5535_gpio_chip.chip);
354+
return err;
364355

365356
return 0;
366357
}
@@ -370,7 +361,6 @@ static struct platform_driver cs5535_gpio_driver = {
370361
.name = DRV_NAME,
371362
},
372363
.probe = cs5535_gpio_probe,
373-
.remove = cs5535_gpio_remove,
374364
};
375365

376366
module_platform_driver(cs5535_gpio_driver);

drivers/gpio/gpio-da9052.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static int da9052_gpio_probe(struct platform_device *pdev)
214214
if (pdata && pdata->gpio_base)
215215
gpio->gp.base = pdata->gpio_base;
216216

217-
ret = gpiochip_add_data(&gpio->gp, gpio);
217+
ret = devm_gpiochip_add_data(&pdev->dev, &gpio->gp, gpio);
218218
if (ret < 0) {
219219
dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
220220
return ret;
@@ -225,17 +225,8 @@ static int da9052_gpio_probe(struct platform_device *pdev)
225225
return 0;
226226
}
227227

228-
static int da9052_gpio_remove(struct platform_device *pdev)
229-
{
230-
struct da9052_gpio *gpio = platform_get_drvdata(pdev);
231-
232-
gpiochip_remove(&gpio->gp);
233-
return 0;
234-
}
235-
236228
static struct platform_driver da9052_gpio_driver = {
237229
.probe = da9052_gpio_probe,
238-
.remove = da9052_gpio_remove,
239230
.driver = {
240231
.name = "da9052-gpio",
241232
},

drivers/gpio/gpio-da9055.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,31 +151,19 @@ static int da9055_gpio_probe(struct platform_device *pdev)
151151
if (pdata && pdata->gpio_base)
152152
gpio->gp.base = pdata->gpio_base;
153153

154-
ret = gpiochip_add_data(&gpio->gp, gpio);
154+
ret = devm_gpiochip_add_data(&pdev->dev, &gpio->gp, gpio);
155155
if (ret < 0) {
156156
dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
157-
goto err_mem;
157+
return ret;
158158
}
159159

160160
platform_set_drvdata(pdev, gpio);
161161

162162
return 0;
163-
164-
err_mem:
165-
return ret;
166-
}
167-
168-
static int da9055_gpio_remove(struct platform_device *pdev)
169-
{
170-
struct da9055_gpio *gpio = platform_get_drvdata(pdev);
171-
172-
gpiochip_remove(&gpio->gp);
173-
return 0;
174163
}
175164

176165
static struct platform_driver da9055_gpio_driver = {
177166
.probe = da9055_gpio_probe,
178-
.remove = da9055_gpio_remove,
179167
.driver = {
180168
.name = "da9055-gpio",
181169
},

drivers/gpio/gpio-davinci.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static int davinci_gpio_of_xlate(struct gpio_chip *gc,
195195
static int davinci_gpio_probe(struct platform_device *pdev)
196196
{
197197
int i, base;
198-
unsigned ngpio;
198+
unsigned ngpio, nbank;
199199
struct davinci_gpio_controller *chips;
200200
struct davinci_gpio_platform_data *pdata;
201201
struct davinci_gpio_regs __iomem *regs;
@@ -224,8 +224,9 @@ static int davinci_gpio_probe(struct platform_device *pdev)
224224
if (WARN_ON(ARCH_NR_GPIOS < ngpio))
225225
ngpio = ARCH_NR_GPIOS;
226226

227+
nbank = DIV_ROUND_UP(ngpio, 32);
227228
chips = devm_kzalloc(dev,
228-
ngpio * sizeof(struct davinci_gpio_controller),
229+
nbank * sizeof(struct davinci_gpio_controller),
229230
GFP_KERNEL);
230231
if (!chips)
231232
return -ENOMEM;
@@ -512,7 +513,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
512513
return irq;
513514
}
514515

515-
irq_domain = irq_domain_add_legacy(NULL, ngpio, irq, 0,
516+
irq_domain = irq_domain_add_legacy(dev->of_node, ngpio, irq, 0,
516517
&davinci_gpio_irq_ops,
517518
chips);
518519
if (!irq_domain) {

0 commit comments

Comments
 (0)