aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2013-02-20 04:30:55 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2013-04-08 11:25:27 -0400
commit1ba895e0487810ee44eb08585e6810ad66159988 (patch)
tree611a59481224aef5897892c45f2e7ea377d65309 /drivers/mfd
parent990810b035b6f151085595c7dadf55fe23e65bbf (diff)
mfd: ezx-pcap: Use devm_*() functions
Use devm_*() functions to make cleanup paths more simple. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/ezx-pcap.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/mfd/ezx-pcap.c b/drivers/mfd/ezx-pcap.c
index b7a61f0f27a4..f83cc3da9308 100644
--- a/drivers/mfd/ezx-pcap.c
+++ b/drivers/mfd/ezx-pcap.c
@@ -403,7 +403,7 @@ static int ezx_pcap_remove(struct spi_device *spi)
403 /* cleanup ADC */ 403 /* cleanup ADC */
404 adc_irq = pcap_to_irq(pcap, (pdata->config & PCAP_SECOND_PORT) ? 404 adc_irq = pcap_to_irq(pcap, (pdata->config & PCAP_SECOND_PORT) ?
405 PCAP_IRQ_ADCDONE2 : PCAP_IRQ_ADCDONE); 405 PCAP_IRQ_ADCDONE2 : PCAP_IRQ_ADCDONE);
406 free_irq(adc_irq, pcap); 406 devm_free_irq(&spi->dev, adc_irq, pcap);
407 mutex_lock(&pcap->adc_mutex); 407 mutex_lock(&pcap->adc_mutex);
408 for (i = 0; i < PCAP_ADC_MAXQ; i++) 408 for (i = 0; i < PCAP_ADC_MAXQ; i++)
409 kfree(pcap->adc_queue[i]); 409 kfree(pcap->adc_queue[i]);
@@ -415,8 +415,6 @@ static int ezx_pcap_remove(struct spi_device *spi)
415 415
416 destroy_workqueue(pcap->workqueue); 416 destroy_workqueue(pcap->workqueue);
417 417
418 kfree(pcap);
419
420 return 0; 418 return 0;
421} 419}
422 420
@@ -431,7 +429,7 @@ static int ezx_pcap_probe(struct spi_device *spi)
431 if (!pdata) 429 if (!pdata)
432 goto ret; 430 goto ret;
433 431
434 pcap = kzalloc(sizeof(*pcap), GFP_KERNEL); 432 pcap = devm_kzalloc(&spi->dev, sizeof(*pcap), GFP_KERNEL);
435 if (!pcap) { 433 if (!pcap) {
436 ret = -ENOMEM; 434 ret = -ENOMEM;
437 goto ret; 435 goto ret;
@@ -448,7 +446,7 @@ static int ezx_pcap_probe(struct spi_device *spi)
448 spi->mode = SPI_MODE_0 | (pdata->config & PCAP_CS_AH ? SPI_CS_HIGH : 0); 446 spi->mode = SPI_MODE_0 | (pdata->config & PCAP_CS_AH ? SPI_CS_HIGH : 0);
449 ret = spi_setup(spi); 447 ret = spi_setup(spi);
450 if (ret) 448 if (ret)
451 goto free_pcap; 449 goto ret;
452 450
453 pcap->spi = spi; 451 pcap->spi = spi;
454 452
@@ -458,7 +456,7 @@ static int ezx_pcap_probe(struct spi_device *spi)
458 if (!pcap->workqueue) { 456 if (!pcap->workqueue) {
459 ret = -ENOMEM; 457 ret = -ENOMEM;
460 dev_err(&spi->dev, "can't create pcap thread\n"); 458 dev_err(&spi->dev, "can't create pcap thread\n");
461 goto free_pcap; 459 goto ret;
462 } 460 }
463 461
464 /* redirect interrupts to AP, except adcdone2 */ 462 /* redirect interrupts to AP, except adcdone2 */
@@ -491,7 +489,8 @@ static int ezx_pcap_probe(struct spi_device *spi)
491 adc_irq = pcap_to_irq(pcap, (pdata->config & PCAP_SECOND_PORT) ? 489 adc_irq = pcap_to_irq(pcap, (pdata->config & PCAP_SECOND_PORT) ?
492 PCAP_IRQ_ADCDONE2 : PCAP_IRQ_ADCDONE); 490 PCAP_IRQ_ADCDONE2 : PCAP_IRQ_ADCDONE);
493 491
494 ret = request_irq(adc_irq, pcap_adc_irq, 0, "ADC", pcap); 492 ret = devm_request_irq(&spi->dev, adc_irq, pcap_adc_irq, 0, "ADC",
493 pcap);
495 if (ret) 494 if (ret)
496 goto free_irqchip; 495 goto free_irqchip;
497 496
@@ -511,14 +510,12 @@ static int ezx_pcap_probe(struct spi_device *spi)
511remove_subdevs: 510remove_subdevs:
512 device_for_each_child(&spi->dev, NULL, pcap_remove_subdev); 511 device_for_each_child(&spi->dev, NULL, pcap_remove_subdev);
513/* free_adc: */ 512/* free_adc: */
514 free_irq(adc_irq, pcap); 513 devm_free_irq(&spi->dev, adc_irq, pcap);
515free_irqchip: 514free_irqchip:
516 for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) 515 for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++)
517 irq_set_chip_and_handler(i, NULL, NULL); 516 irq_set_chip_and_handler(i, NULL, NULL);
518/* destroy_workqueue: */ 517/* destroy_workqueue: */
519 destroy_workqueue(pcap->workqueue); 518 destroy_workqueue(pcap->workqueue);
520free_pcap:
521 kfree(pcap);
522ret: 519ret:
523 return ret; 520 return ret;
524} 521}