Skip to content

Commit f5ed9c3

Browse files
JuliaLawalljic23
authored andcommitted
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>
1 parent 91b4171 commit f5ed9c3

1 file changed

Lines changed: 8 additions & 17 deletions

File tree

‎drivers/staging/iio/adc/spear_adc.c‎

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -330,36 +330,30 @@ static int __devinit spear_adc_probe(struct platform_device *pdev)
330330
goto errout3;
331331
}
332332

333-
ret = clk_prepare(info->clk);
334-
if (ret) {
335-
dev_err(dev, "failed preparing clock\n");
336-
goto errout4;
337-
}
338-
339-
ret = clk_enable(info->clk);
333+
ret = clk_prepare_enable(info->clk);
340334
if (ret) {
341335
dev_err(dev, "failed enabling clock\n");
342-
goto errout5;
336+
goto errout4;
343337
}
344338

345339
irq = platform_get_irq(pdev, 0);
346340
if ((irq < 0) || (irq >= NR_IRQS)) {
347341
dev_err(dev, "failed getting interrupt resource\n");
348342
ret = -EINVAL;
349-
goto errout6;
343+
goto errout5;
350344
}
351345

352346
ret = devm_request_irq(dev, irq, spear_adc_isr, 0, MOD_NAME, info);
353347
if (ret < 0) {
354348
dev_err(dev, "failed requesting interrupt\n");
355-
goto errout6;
349+
goto errout5;
356350
}
357351

358352
if (of_property_read_u32(np, "sampling-frequency",
359353
&info->sampling_freq)) {
360354
dev_err(dev, "sampling-frequency missing in DT\n");
361355
ret = -EINVAL;
362-
goto errout6;
356+
goto errout5;
363357
}
364358

365359
/*
@@ -389,16 +383,14 @@ static int __devinit spear_adc_probe(struct platform_device *pdev)
389383

390384
ret = iio_device_register(iodev);
391385
if (ret)
392-
goto errout6;
386+
goto errout5;
393387

394388
dev_info(dev, "SPEAR ADC driver loaded, IRQ %d\n", irq);
395389

396390
return 0;
397391

398-
errout6:
399-
clk_disable(info->clk);
400392
errout5:
401-
clk_unprepare(info->clk);
393+
clk_disable_unprepare(info->clk);
402394
errout4:
403395
clk_put(info->clk);
404396
errout3:
@@ -416,8 +408,7 @@ static int __devexit spear_adc_remove(struct platform_device *pdev)
416408

417409
iio_device_unregister(iodev);
418410
platform_set_drvdata(pdev, NULL);
419-
clk_disable(info->clk);
420-
clk_unprepare(info->clk);
411+
clk_disable_unprepare(info->clk);
421412
clk_put(info->clk);
422413
iounmap(info->adc_base_spear6xx);
423414
iio_device_free(iodev);

0 commit comments

Comments
 (0)