diff options
author | Frans Klaver <frans.klaver@xsens.com> | 2015-01-14 03:15:37 -0500 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2015-01-20 07:58:28 -0500 |
commit | 62113b31174a9dba99eda8a4222417dd526c7c79 (patch) | |
tree | c6310287b71da6549adafebf59391d15d80c7aba /drivers/power | |
parent | f66472df697ed6341e2317d5c825f2d6916ae47f (diff) |
power: reset: ltc2952: prefer devm_gpiod_get over gpiod_get
This reduces cleanup code and chance of errors.
Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/reset/ltc2952-poweroff.c | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/drivers/power/reset/ltc2952-poweroff.c b/drivers/power/reset/ltc2952-poweroff.c index accadfc01270..4caa9d285026 100644 --- a/drivers/power/reset/ltc2952-poweroff.c +++ b/drivers/power/reset/ltc2952-poweroff.c | |||
@@ -207,44 +207,34 @@ static int ltc2952_poweroff_init(struct platform_device *pdev) | |||
207 | data = ltc2952_data; | 207 | data = ltc2952_data; |
208 | ltc2952_poweroff_default(ltc2952_data); | 208 | ltc2952_poweroff_default(ltc2952_data); |
209 | 209 | ||
210 | ltc2952_data->gpio_watchdog = gpiod_get(&pdev->dev, "watchdog"); | 210 | ltc2952_data->gpio_watchdog = devm_gpiod_get(&pdev->dev, "watchdog", |
211 | GPIOD_OUT_LOW); | ||
211 | if (IS_ERR(ltc2952_data->gpio_watchdog)) { | 212 | if (IS_ERR(ltc2952_data->gpio_watchdog)) { |
212 | ret = PTR_ERR(ltc2952_data->gpio_watchdog); | 213 | ret = PTR_ERR(ltc2952_data->gpio_watchdog); |
213 | dev_err(&pdev->dev, "unable to claim gpio \"watchdog\"\n"); | 214 | dev_err(&pdev->dev, "unable to claim gpio \"watchdog\"\n"); |
214 | return ret; | 215 | return ret; |
215 | } | 216 | } |
216 | 217 | ||
217 | ltc2952_data->gpio_kill = gpiod_get(&pdev->dev, "kill"); | 218 | ltc2952_data->gpio_kill = devm_gpiod_get(&pdev->dev, "kill", |
219 | GPIOD_OUT_LOW); | ||
218 | if (IS_ERR(ltc2952_data->gpio_kill)) { | 220 | if (IS_ERR(ltc2952_data->gpio_kill)) { |
219 | ret = PTR_ERR(ltc2952_data->gpio_kill); | 221 | ret = PTR_ERR(ltc2952_data->gpio_kill); |
220 | dev_err(&pdev->dev, "unable to claim gpio \"kill\"\n"); | 222 | dev_err(&pdev->dev, "unable to claim gpio \"kill\"\n"); |
221 | goto err_kill; | 223 | return ret; |
222 | } | 224 | } |
223 | 225 | ||
224 | ltc2952_data->gpio_trigger = gpiod_get(&pdev->dev, "trigger"); | 226 | ltc2952_data->gpio_trigger = devm_gpiod_get(&pdev->dev, "trigger", |
227 | GPIOD_IN); | ||
225 | if (IS_ERR(ltc2952_data->gpio_trigger)) { | 228 | if (IS_ERR(ltc2952_data->gpio_trigger)) { |
226 | ret = PTR_ERR(ltc2952_data->gpio_trigger); | 229 | ret = PTR_ERR(ltc2952_data->gpio_trigger); |
227 | dev_err(&pdev->dev, "unable to claim gpio \"trigger\"\n"); | 230 | dev_err(&pdev->dev, "unable to claim gpio \"trigger\"\n"); |
228 | goto err_trigger; | 231 | return ret; |
229 | } | ||
230 | |||
231 | ret = gpiod_direction_output( | ||
232 | ltc2952_data->gpio_watchdog, 0); | ||
233 | if (ret) { | ||
234 | dev_err(&pdev->dev, "unable to use watchdog-gpio as output\n"); | ||
235 | goto err_io; | ||
236 | } | ||
237 | |||
238 | ret = gpiod_direction_output(ltc2952_data->gpio_kill, 0); | ||
239 | if (ret) { | ||
240 | dev_err(&pdev->dev, "unable to use kill-gpio as output\n"); | ||
241 | goto err_io; | ||
242 | } | 232 | } |
243 | 233 | ||
244 | virq = gpiod_to_irq(ltc2952_data->gpio_trigger); | 234 | virq = gpiod_to_irq(ltc2952_data->gpio_trigger); |
245 | if (virq < 0) { | 235 | if (virq < 0) { |
246 | dev_err(&pdev->dev, "cannot map GPIO as interrupt"); | 236 | dev_err(&pdev->dev, "cannot map GPIO as interrupt"); |
247 | goto err_io; | 237 | return ret; |
248 | } | 238 | } |
249 | 239 | ||
250 | ret = devm_request_irq(&pdev->dev, virq, | 240 | ret = devm_request_irq(&pdev->dev, virq, |
@@ -255,19 +245,10 @@ static int ltc2952_poweroff_init(struct platform_device *pdev) | |||
255 | 245 | ||
256 | if (ret) { | 246 | if (ret) { |
257 | dev_err(&pdev->dev, "cannot configure an interrupt handler\n"); | 247 | dev_err(&pdev->dev, "cannot configure an interrupt handler\n"); |
258 | goto err_io; | 248 | return ret; |
259 | } | 249 | } |
260 | 250 | ||
261 | return 0; | 251 | return 0; |
262 | |||
263 | err_io: | ||
264 | gpiod_put(ltc2952_data->gpio_trigger); | ||
265 | err_trigger: | ||
266 | gpiod_put(ltc2952_data->gpio_kill); | ||
267 | err_kill: | ||
268 | gpiod_put(ltc2952_data->gpio_watchdog); | ||
269 | |||
270 | return ret; | ||
271 | } | 252 | } |
272 | 253 | ||
273 | static int ltc2952_poweroff_probe(struct platform_device *pdev) | 254 | static int ltc2952_poweroff_probe(struct platform_device *pdev) |
@@ -301,11 +282,6 @@ static int ltc2952_poweroff_remove(struct platform_device *pdev) | |||
301 | { | 282 | { |
302 | pm_power_off = NULL; | 283 | pm_power_off = NULL; |
303 | 284 | ||
304 | if (ltc2952_data) { | ||
305 | gpiod_put(ltc2952_data->gpio_trigger); | ||
306 | gpiod_put(ltc2952_data->gpio_watchdog); | ||
307 | gpiod_put(ltc2952_data->gpio_kill); | ||
308 | } | ||
309 | return 0; | 285 | return 0; |
310 | } | 286 | } |
311 | 287 | ||