diff options
author | Linus Walleij <linus.walleij@stericsson.com> | 2012-07-03 17:05:14 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-07-04 05:05:05 -0400 |
commit | 5e754f330d189d9082017525668220e458757e5b (patch) | |
tree | d572b9fa23b0b45085febe0909c2f72618a64ee2 /drivers/pinctrl | |
parent | fcd217edc056e505e9ab4d0ca602069acc0e1ff4 (diff) |
pinctrl/nomadik: use devm_* allocators for gpio probe
The GPIO portions of the Nomadik pinctrl driver was not using
the managed devm_* interfaces, lets' use them consequently and
cut down the error path and special case handling.
Acked-by: Patrice Chotard <patrice.chotard@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r-- | drivers/pinctrl/pinctrl-nomadik.c | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c index 3e7e47d6b38..095bbc6450c 100644 --- a/drivers/pinctrl/pinctrl-nomadik.c +++ b/drivers/pinctrl/pinctrl-nomadik.c | |||
@@ -1194,7 +1194,7 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) | |||
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | if (np) { | 1196 | if (np) { |
1197 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); | 1197 | pdata = devm_kzalloc(&dev->dev, sizeof(*pdata), GFP_KERNEL); |
1198 | if (!pdata) | 1198 | if (!pdata) |
1199 | return -ENOMEM; | 1199 | return -ENOMEM; |
1200 | 1200 | ||
@@ -1229,29 +1229,23 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) | |||
1229 | goto out; | 1229 | goto out; |
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | if (request_mem_region(res->start, resource_size(res), | 1232 | base = devm_request_and_ioremap(&dev->dev, res); |
1233 | dev_name(&dev->dev)) == NULL) { | ||
1234 | ret = -EBUSY; | ||
1235 | goto out; | ||
1236 | } | ||
1237 | |||
1238 | base = ioremap(res->start, resource_size(res)); | ||
1239 | if (!base) { | 1233 | if (!base) { |
1240 | ret = -ENOMEM; | 1234 | ret = -ENOMEM; |
1241 | goto out_release; | 1235 | goto out; |
1242 | } | 1236 | } |
1243 | 1237 | ||
1244 | clk = clk_get(&dev->dev, NULL); | 1238 | clk = devm_clk_get(&dev->dev, NULL); |
1245 | if (IS_ERR(clk)) { | 1239 | if (IS_ERR(clk)) { |
1246 | ret = PTR_ERR(clk); | 1240 | ret = PTR_ERR(clk); |
1247 | goto out_unmap; | 1241 | goto out; |
1248 | } | 1242 | } |
1249 | clk_prepare(clk); | 1243 | clk_prepare(clk); |
1250 | 1244 | ||
1251 | nmk_chip = kzalloc(sizeof(*nmk_chip), GFP_KERNEL); | 1245 | nmk_chip = devm_kzalloc(&dev->dev, sizeof(*nmk_chip), GFP_KERNEL); |
1252 | if (!nmk_chip) { | 1246 | if (!nmk_chip) { |
1253 | ret = -ENOMEM; | 1247 | ret = -ENOMEM; |
1254 | goto out_clk; | 1248 | goto out; |
1255 | } | 1249 | } |
1256 | 1250 | ||
1257 | /* | 1251 | /* |
@@ -1286,7 +1280,7 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) | |||
1286 | 1280 | ||
1287 | ret = gpiochip_add(&nmk_chip->chip); | 1281 | ret = gpiochip_add(&nmk_chip->chip); |
1288 | if (ret) | 1282 | if (ret) |
1289 | goto out_free; | 1283 | goto out; |
1290 | 1284 | ||
1291 | BUG_ON(nmk_chip->bank >= ARRAY_SIZE(nmk_gpio_chips)); | 1285 | BUG_ON(nmk_chip->bank >= ARRAY_SIZE(nmk_gpio_chips)); |
1292 | 1286 | ||
@@ -1300,7 +1294,7 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) | |||
1300 | if (!nmk_chip->domain) { | 1294 | if (!nmk_chip->domain) { |
1301 | pr_err("%s: Failed to create irqdomain\n", np->full_name); | 1295 | pr_err("%s: Failed to create irqdomain\n", np->full_name); |
1302 | ret = -ENOSYS; | 1296 | ret = -ENOSYS; |
1303 | goto out_free; | 1297 | goto out; |
1304 | } | 1298 | } |
1305 | 1299 | ||
1306 | nmk_gpio_init_irq(nmk_chip); | 1300 | nmk_gpio_init_irq(nmk_chip); |
@@ -1309,20 +1303,9 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) | |||
1309 | 1303 | ||
1310 | return 0; | 1304 | return 0; |
1311 | 1305 | ||
1312 | out_free: | ||
1313 | kfree(nmk_chip); | ||
1314 | out_clk: | ||
1315 | clk_disable(clk); | ||
1316 | clk_put(clk); | ||
1317 | out_unmap: | ||
1318 | iounmap(base); | ||
1319 | out_release: | ||
1320 | release_mem_region(res->start, resource_size(res)); | ||
1321 | out: | 1306 | out: |
1322 | dev_err(&dev->dev, "Failure %i for GPIO %i-%i\n", ret, | 1307 | dev_err(&dev->dev, "Failure %i for GPIO %i-%i\n", ret, |
1323 | pdata->first_gpio, pdata->first_gpio+31); | 1308 | pdata->first_gpio, pdata->first_gpio+31); |
1324 | if (np) | ||
1325 | kfree(pdata); | ||
1326 | 1309 | ||
1327 | return ret; | 1310 | return ret; |
1328 | } | 1311 | } |