diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2012-08-26 12:00:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2012-09-03 15:26:41 -0400 |
commit | f5ed9c35bd2af6d9d171290d3dc45004f4f79bcf (patch) | |
tree | 58bb6d3362bbdc981ad9dcc917247d8eaf6c2f2e /drivers | |
parent | 91b4171f4e7e2d49aee54259b50e703e09bcff20 (diff) |
drivers/staging/iio/adc/spear_adc.c: use clk_prepare_enable and clk_disable_unprepare
Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare. They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.
A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
expression e;
@@
- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);
@@
expression e;
@@
- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/iio/adc/spear_adc.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index 675c427c02ad..0b83e2e1f410 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c | |||
@@ -330,36 +330,30 @@ static int __devinit spear_adc_probe(struct platform_device *pdev) | |||
330 | goto errout3; | 330 | goto errout3; |
331 | } | 331 | } |
332 | 332 | ||
333 | ret = clk_prepare(info->clk); | 333 | ret = clk_prepare_enable(info->clk); |
334 | if (ret) { | ||
335 | dev_err(dev, "failed preparing clock\n"); | ||
336 | goto errout4; | ||
337 | } | ||
338 | |||
339 | ret = clk_enable(info->clk); | ||
340 | if (ret) { | 334 | if (ret) { |
341 | dev_err(dev, "failed enabling clock\n"); | 335 | dev_err(dev, "failed enabling clock\n"); |
342 | goto errout5; | 336 | goto errout4; |
343 | } | 337 | } |
344 | 338 | ||
345 | irq = platform_get_irq(pdev, 0); | 339 | irq = platform_get_irq(pdev, 0); |
346 | if ((irq < 0) || (irq >= NR_IRQS)) { | 340 | if ((irq < 0) || (irq >= NR_IRQS)) { |
347 | dev_err(dev, "failed getting interrupt resource\n"); | 341 | dev_err(dev, "failed getting interrupt resource\n"); |
348 | ret = -EINVAL; | 342 | ret = -EINVAL; |
349 | goto errout6; | 343 | goto errout5; |
350 | } | 344 | } |
351 | 345 | ||
352 | ret = devm_request_irq(dev, irq, spear_adc_isr, 0, MOD_NAME, info); | 346 | ret = devm_request_irq(dev, irq, spear_adc_isr, 0, MOD_NAME, info); |
353 | if (ret < 0) { | 347 | if (ret < 0) { |
354 | dev_err(dev, "failed requesting interrupt\n"); | 348 | dev_err(dev, "failed requesting interrupt\n"); |
355 | goto errout6; | 349 | goto errout5; |
356 | } | 350 | } |
357 | 351 | ||
358 | if (of_property_read_u32(np, "sampling-frequency", | 352 | if (of_property_read_u32(np, "sampling-frequency", |
359 | &info->sampling_freq)) { | 353 | &info->sampling_freq)) { |
360 | dev_err(dev, "sampling-frequency missing in DT\n"); | 354 | dev_err(dev, "sampling-frequency missing in DT\n"); |
361 | ret = -EINVAL; | 355 | ret = -EINVAL; |
362 | goto errout6; | 356 | goto errout5; |
363 | } | 357 | } |
364 | 358 | ||
365 | /* | 359 | /* |
@@ -389,16 +383,14 @@ static int __devinit spear_adc_probe(struct platform_device *pdev) | |||
389 | 383 | ||
390 | ret = iio_device_register(iodev); | 384 | ret = iio_device_register(iodev); |
391 | if (ret) | 385 | if (ret) |
392 | goto errout6; | 386 | goto errout5; |
393 | 387 | ||
394 | dev_info(dev, "SPEAR ADC driver loaded, IRQ %d\n", irq); | 388 | dev_info(dev, "SPEAR ADC driver loaded, IRQ %d\n", irq); |
395 | 389 | ||
396 | return 0; | 390 | return 0; |
397 | 391 | ||
398 | errout6: | ||
399 | clk_disable(info->clk); | ||
400 | errout5: | 392 | errout5: |
401 | clk_unprepare(info->clk); | 393 | clk_disable_unprepare(info->clk); |
402 | errout4: | 394 | errout4: |
403 | clk_put(info->clk); | 395 | clk_put(info->clk); |
404 | errout3: | 396 | errout3: |
@@ -416,8 +408,7 @@ static int __devexit spear_adc_remove(struct platform_device *pdev) | |||
416 | 408 | ||
417 | iio_device_unregister(iodev); | 409 | iio_device_unregister(iodev); |
418 | platform_set_drvdata(pdev, NULL); | 410 | platform_set_drvdata(pdev, NULL); |
419 | clk_disable(info->clk); | 411 | clk_disable_unprepare(info->clk); |
420 | clk_unprepare(info->clk); | ||
421 | clk_put(info->clk); | 412 | clk_put(info->clk); |
422 | iounmap(info->adc_base_spear6xx); | 413 | iounmap(info->adc_base_spear6xx); |
423 | iio_device_free(iodev); | 414 | iio_device_free(iodev); |