diff options
author | Eunki Kim <eunki_kim@samsung.com> | 2012-11-20 06:50:54 -0500 |
---|---|---|
committer | Kukjin Kim <kgene.kim@samsung.com> | 2012-11-20 06:50:54 -0500 |
commit | 2ee8e6f0e375c68d420c47ddab70485d8e587d95 (patch) | |
tree | 508fd2420d5b56f371686867cea169bf6ad5832e /arch/arm/plat-samsung | |
parent | 559a67dba204793b278f660606624e5a67a9fd3d (diff) |
ARM: SAMSUNG: use devm_ functions for ADC driver
This patch uses devm_* functions for probe function in ADC driver.
It reduces code size and simplifies the code.
Signed-off-by: Eunki Kim <eunki_kim@samsung.com>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
Diffstat (limited to 'arch/arm/plat-samsung')
-rw-r--r-- | arch/arm/plat-samsung/adc.c | 48 |
1 files changed, 13 insertions, 35 deletions
diff --git a/arch/arm/plat-samsung/adc.c b/arch/arm/plat-samsung/adc.c index b1e05ccff3ac..37542c2689a2 100644 --- a/arch/arm/plat-samsung/adc.c +++ b/arch/arm/plat-samsung/adc.c | |||
@@ -344,7 +344,7 @@ static int s3c_adc_probe(struct platform_device *pdev) | |||
344 | int ret; | 344 | int ret; |
345 | unsigned tmp; | 345 | unsigned tmp; |
346 | 346 | ||
347 | adc = kzalloc(sizeof(struct adc_device), GFP_KERNEL); | 347 | adc = devm_kzalloc(dev, sizeof(struct adc_device), GFP_KERNEL); |
348 | if (adc == NULL) { | 348 | if (adc == NULL) { |
349 | dev_err(dev, "failed to allocate adc_device\n"); | 349 | dev_err(dev, "failed to allocate adc_device\n"); |
350 | return -ENOMEM; | 350 | return -ENOMEM; |
@@ -355,50 +355,46 @@ static int s3c_adc_probe(struct platform_device *pdev) | |||
355 | adc->pdev = pdev; | 355 | adc->pdev = pdev; |
356 | adc->prescale = S3C2410_ADCCON_PRSCVL(49); | 356 | adc->prescale = S3C2410_ADCCON_PRSCVL(49); |
357 | 357 | ||
358 | adc->vdd = regulator_get(dev, "vdd"); | 358 | adc->vdd = devm_regulator_get(dev, "vdd"); |
359 | if (IS_ERR(adc->vdd)) { | 359 | if (IS_ERR(adc->vdd)) { |
360 | dev_err(dev, "operating without regulator \"vdd\" .\n"); | 360 | dev_err(dev, "operating without regulator \"vdd\" .\n"); |
361 | ret = PTR_ERR(adc->vdd); | 361 | return PTR_ERR(adc->vdd); |
362 | goto err_alloc; | ||
363 | } | 362 | } |
364 | 363 | ||
365 | adc->irq = platform_get_irq(pdev, 1); | 364 | adc->irq = platform_get_irq(pdev, 1); |
366 | if (adc->irq <= 0) { | 365 | if (adc->irq <= 0) { |
367 | dev_err(dev, "failed to get adc irq\n"); | 366 | dev_err(dev, "failed to get adc irq\n"); |
368 | ret = -ENOENT; | 367 | return -ENOENT; |
369 | goto err_reg; | ||
370 | } | 368 | } |
371 | 369 | ||
372 | ret = request_irq(adc->irq, s3c_adc_irq, 0, dev_name(dev), adc); | 370 | ret = devm_request_irq(dev, adc->irq, s3c_adc_irq, 0, dev_name(dev), |
371 | adc); | ||
373 | if (ret < 0) { | 372 | if (ret < 0) { |
374 | dev_err(dev, "failed to attach adc irq\n"); | 373 | dev_err(dev, "failed to attach adc irq\n"); |
375 | goto err_reg; | 374 | return ret; |
376 | } | 375 | } |
377 | 376 | ||
378 | adc->clk = clk_get(dev, "adc"); | 377 | adc->clk = devm_clk_get(dev, "adc"); |
379 | if (IS_ERR(adc->clk)) { | 378 | if (IS_ERR(adc->clk)) { |
380 | dev_err(dev, "failed to get adc clock\n"); | 379 | dev_err(dev, "failed to get adc clock\n"); |
381 | ret = PTR_ERR(adc->clk); | 380 | return PTR_ERR(adc->clk); |
382 | goto err_irq; | ||
383 | } | 381 | } |
384 | 382 | ||
385 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 383 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
386 | if (!regs) { | 384 | if (!regs) { |
387 | dev_err(dev, "failed to find registers\n"); | 385 | dev_err(dev, "failed to find registers\n"); |
388 | ret = -ENXIO; | 386 | return -ENXIO; |
389 | goto err_clk; | ||
390 | } | 387 | } |
391 | 388 | ||
392 | adc->regs = ioremap(regs->start, resource_size(regs)); | 389 | adc->regs = devm_request_and_ioremap(dev, regs); |
393 | if (!adc->regs) { | 390 | if (!adc->regs) { |
394 | dev_err(dev, "failed to map registers\n"); | 391 | dev_err(dev, "failed to map registers\n"); |
395 | ret = -ENXIO; | 392 | return -ENXIO; |
396 | goto err_clk; | ||
397 | } | 393 | } |
398 | 394 | ||
399 | ret = regulator_enable(adc->vdd); | 395 | ret = regulator_enable(adc->vdd); |
400 | if (ret) | 396 | if (ret) |
401 | goto err_ioremap; | 397 | return ret; |
402 | 398 | ||
403 | clk_enable(adc->clk); | 399 | clk_enable(adc->clk); |
404 | 400 | ||
@@ -418,32 +414,14 @@ static int s3c_adc_probe(struct platform_device *pdev) | |||
418 | adc_dev = adc; | 414 | adc_dev = adc; |
419 | 415 | ||
420 | return 0; | 416 | return 0; |
421 | |||
422 | err_ioremap: | ||
423 | iounmap(adc->regs); | ||
424 | err_clk: | ||
425 | clk_put(adc->clk); | ||
426 | |||
427 | err_irq: | ||
428 | free_irq(adc->irq, adc); | ||
429 | err_reg: | ||
430 | regulator_put(adc->vdd); | ||
431 | err_alloc: | ||
432 | kfree(adc); | ||
433 | return ret; | ||
434 | } | 417 | } |
435 | 418 | ||
436 | static int __devexit s3c_adc_remove(struct platform_device *pdev) | 419 | static int __devexit s3c_adc_remove(struct platform_device *pdev) |
437 | { | 420 | { |
438 | struct adc_device *adc = platform_get_drvdata(pdev); | 421 | struct adc_device *adc = platform_get_drvdata(pdev); |
439 | 422 | ||
440 | iounmap(adc->regs); | ||
441 | free_irq(adc->irq, adc); | ||
442 | clk_disable(adc->clk); | 423 | clk_disable(adc->clk); |
443 | regulator_disable(adc->vdd); | 424 | regulator_disable(adc->vdd); |
444 | regulator_put(adc->vdd); | ||
445 | clk_put(adc->clk); | ||
446 | kfree(adc); | ||
447 | 425 | ||
448 | return 0; | 426 | return 0; |
449 | } | 427 | } |