Commit 13441457 authored by William Breathitt Gray's avatar William Breathitt Gray Committed by Linus Walleij

gpio: sch311x: Use devm_request_region

By the time request_region is called in the SMSC SCH311x GPIO driver, a
corresponding device structure has already been allocated. The
devm_request_region function should be used to help simplify the cleanup
code and reduce the possible points of failure.
Signed-off-by: default avatarWilliam Breathitt Gray <vilhelm.gray@gmail.com>
Reviewed-by: default avatarAlexandre Courbot <acourbot@nvidia.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 8a06b08e
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
* (at your option) any later version. * (at your option) any later version.
*/ */
#include <linux/ioport.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -228,7 +229,8 @@ static int sch311x_gpio_probe(struct platform_device *pdev) ...@@ -228,7 +229,8 @@ static int sch311x_gpio_probe(struct platform_device *pdev)
int err, i; int err, i;
/* we can register all GPIO data registers at once */ /* we can register all GPIO data registers at once */
if (!request_region(pdata->runtime_reg + GP1, 6, DRV_NAME)) { if (!devm_request_region(&pdev->dev, pdata->runtime_reg + GP1, 6,
DRV_NAME)) {
dev_err(&pdev->dev, "Failed to request region 0x%04x-0x%04x.\n", dev_err(&pdev->dev, "Failed to request region 0x%04x-0x%04x.\n",
pdata->runtime_reg + GP1, pdata->runtime_reg + GP1 + 5); pdata->runtime_reg + GP1, pdata->runtime_reg + GP1 + 5);
return -EBUSY; return -EBUSY;
...@@ -273,7 +275,6 @@ static int sch311x_gpio_probe(struct platform_device *pdev) ...@@ -273,7 +275,6 @@ static int sch311x_gpio_probe(struct platform_device *pdev)
return 0; return 0;
exit_err: exit_err:
release_region(pdata->runtime_reg + GP1, 6);
/* release already registered chips */ /* release already registered chips */
for (--i; i >= 0; i--) for (--i; i >= 0; i--)
gpiochip_remove(&priv->blocks[i].chip); gpiochip_remove(&priv->blocks[i].chip);
...@@ -282,12 +283,9 @@ static int sch311x_gpio_probe(struct platform_device *pdev) ...@@ -282,12 +283,9 @@ static int sch311x_gpio_probe(struct platform_device *pdev)
static int sch311x_gpio_remove(struct platform_device *pdev) static int sch311x_gpio_remove(struct platform_device *pdev)
{ {
struct sch311x_pdev_data *pdata = dev_get_platdata(&pdev->dev);
struct sch311x_gpio_priv *priv = platform_get_drvdata(pdev); struct sch311x_gpio_priv *priv = platform_get_drvdata(pdev);
int i; int i;
release_region(pdata->runtime_reg + GP1, 6);
for (i = 0; i < ARRAY_SIZE(priv->blocks); i++) { for (i = 0; i < ARRAY_SIZE(priv->blocks); i++) {
gpiochip_remove(&priv->blocks[i].chip); gpiochip_remove(&priv->blocks[i].chip);
dev_info(&pdev->dev, dev_info(&pdev->dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment