aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-ep93xx.c
diff options
context:
space:
mode:
authorabdoulaye berthe <berthe.ab@gmail.com>2014-05-13 18:36:54 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-05-16 11:52:38 -0400
commit1aeede0b3c055665fb722a012d3cd834146fc112 (patch)
tree049fce600fd89284e6bc4ca558edd58d1f75a029 /drivers/gpio/gpio-ep93xx.c
parentae28193e01c8467f448e77234a074bae05b7a66f (diff)
gpio: gpioep93xx: use devm functions
This uses devm functions for mem allocation Signed-off-by: abdoulaye berthe <berthe.ab@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-ep93xx.c')
-rw-r--r--drivers/gpio/gpio-ep93xx.c34
1 files changed, 7 insertions, 27 deletions
diff --git a/drivers/gpio/gpio-ep93xx.c b/drivers/gpio/gpio-ep93xx.c
index 80829f3c6543..dd39f27f3cb2 100644
--- a/drivers/gpio/gpio-ep93xx.c
+++ b/drivers/gpio/gpio-ep93xx.c
@@ -344,37 +344,24 @@ static int ep93xx_gpio_probe(struct platform_device *pdev)
344{ 344{
345 struct ep93xx_gpio *ep93xx_gpio; 345 struct ep93xx_gpio *ep93xx_gpio;
346 struct resource *res; 346 struct resource *res;
347 void __iomem *mmio;
348 int i; 347 int i;
349 int ret; 348 struct device *dev = &pdev->dev;
350 349
351 ep93xx_gpio = kzalloc(sizeof(*ep93xx_gpio), GFP_KERNEL); 350 ep93xx_gpio = devm_kzalloc(dev, sizeof(struct ep93xx_gpio), GFP_KERNEL);
352 if (!ep93xx_gpio) 351 if (!ep93xx_gpio)
353 return -ENOMEM; 352 return -ENOMEM;
354 353
355 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 354 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
356 if (!res) { 355 ep93xx_gpio->mmio_base = devm_request_and_ioremap(dev, res);
357 ret = -ENXIO; 356 if (IS_ERR(ep93xx_gpio->mmio_base))
358 goto exit_free; 357 return PTR_ERR(ep93xx_gpio->mmio_base);
359 }
360
361 if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
362 ret = -EBUSY;
363 goto exit_free;
364 }
365
366 mmio = ioremap(res->start, resource_size(res));
367 if (!mmio) {
368 ret = -ENXIO;
369 goto exit_release;
370 }
371 ep93xx_gpio->mmio_base = mmio;
372 358
373 for (i = 0; i < ARRAY_SIZE(ep93xx_gpio_banks); i++) { 359 for (i = 0; i < ARRAY_SIZE(ep93xx_gpio_banks); i++) {
374 struct bgpio_chip *bgc = &ep93xx_gpio->bgc[i]; 360 struct bgpio_chip *bgc = &ep93xx_gpio->bgc[i];
375 struct ep93xx_gpio_bank *bank = &ep93xx_gpio_banks[i]; 361 struct ep93xx_gpio_bank *bank = &ep93xx_gpio_banks[i];
376 362
377 if (ep93xx_gpio_add_bank(bgc, &pdev->dev, mmio, bank)) 363 if (ep93xx_gpio_add_bank(bgc, &pdev->dev,
364 ep93xx_gpio->mmio_base, bank))
378 dev_warn(&pdev->dev, "Unable to add gpio bank %s\n", 365 dev_warn(&pdev->dev, "Unable to add gpio bank %s\n",
379 bank->label); 366 bank->label);
380 } 367 }
@@ -382,13 +369,6 @@ static int ep93xx_gpio_probe(struct platform_device *pdev)
382 ep93xx_gpio_init_irq(); 369 ep93xx_gpio_init_irq();
383 370
384 return 0; 371 return 0;
385
386exit_release:
387 release_mem_region(res->start, resource_size(res));
388exit_free:
389 kfree(ep93xx_gpio);
390 dev_info(&pdev->dev, "%s failed with errno %d\n", __func__, ret);
391 return ret;
392} 372}
393 373
394static struct platform_driver ep93xx_gpio_driver = { 374static struct platform_driver ep93xx_gpio_driver = {