aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/ezx-pcap.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mfd/ezx-pcap.c')
-rw-r--r--drivers/mfd/ezx-pcap.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/mfd/ezx-pcap.c b/drivers/mfd/ezx-pcap.c
index b7a61f0f27a4..5502106ad515 100644
--- a/drivers/mfd/ezx-pcap.c
+++ b/drivers/mfd/ezx-pcap.c
@@ -393,7 +393,7 @@ static int pcap_add_subdev(struct pcap_chip *pcap,
393 393
394static int ezx_pcap_remove(struct spi_device *spi) 394static int ezx_pcap_remove(struct spi_device *spi)
395{ 395{
396 struct pcap_chip *pcap = dev_get_drvdata(&spi->dev); 396 struct pcap_chip *pcap = spi_get_drvdata(spi);
397 struct pcap_platform_data *pdata = spi->dev.platform_data; 397 struct pcap_platform_data *pdata = spi->dev.platform_data;
398 int i, adc_irq; 398 int i, adc_irq;
399 399
@@ -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;
@@ -441,14 +439,14 @@ static int ezx_pcap_probe(struct spi_device *spi)
441 mutex_init(&pcap->adc_mutex); 439 mutex_init(&pcap->adc_mutex);
442 INIT_WORK(&pcap->isr_work, pcap_isr_work); 440 INIT_WORK(&pcap->isr_work, pcap_isr_work);
443 INIT_WORK(&pcap->msr_work, pcap_msr_work); 441 INIT_WORK(&pcap->msr_work, pcap_msr_work);
444 dev_set_drvdata(&spi->dev, pcap); 442 spi_set_drvdata(spi, pcap);
445 443
446 /* setup spi */ 444 /* setup spi */
447 spi->bits_per_word = 32; 445 spi->bits_per_word = 32;
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}