diff options
author | Fabio Estevam <fabio.estevam@freescale.com> | 2012-10-03 23:15:04 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-11-20 06:21:10 -0500 |
commit | ffe20b6854db455a0c40e5fe1f9db2cfc9a62c6a (patch) | |
tree | 3d0c670bdb93327618e2dda4c47717e010d697a5 | |
parent | 17143e38afd60128332067ff91af080ddc764780 (diff) |
mfd: da9052-core: Use regmap_irq_get_virq() and fix the probe
On a mx53qsb dt-kernel the da9052-core driver fails to probe as follows:
da9052 1-0048: DA9052 ADC IRQ failed ret=-22
The reason for the error was due to passing only the offset as the interrupt
number in request_threaded_irq() without da9052->irq_base.
The recommended approach though is to use regmap_get_virq() to acquire the
interrupt number and this allows to get rid of da9052->irq_base.
Fix it and allow the driver to probe successfully.
Also provide a few more error logs and change the irq string to "adc-irq", so
that it appears as a single word in 'cat /proc/interrupts'
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Reviwed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r-- | drivers/mfd/da9052-core.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/mfd/da9052-core.c b/drivers/mfd/da9052-core.c index a0a62b24621b..c96cdbc0daff 100644 --- a/drivers/mfd/da9052-core.c +++ b/drivers/mfd/da9052-core.c | |||
@@ -769,10 +769,15 @@ struct regmap_config da9052_regmap_config = { | |||
769 | }; | 769 | }; |
770 | EXPORT_SYMBOL_GPL(da9052_regmap_config); | 770 | EXPORT_SYMBOL_GPL(da9052_regmap_config); |
771 | 771 | ||
772 | static int da9052_map_irq(struct da9052 *da9052, int irq) | ||
773 | { | ||
774 | return regmap_irq_get_virq(da9052->irq_data, irq); | ||
775 | } | ||
776 | |||
772 | int __devinit da9052_device_init(struct da9052 *da9052, u8 chip_id) | 777 | int __devinit da9052_device_init(struct da9052 *da9052, u8 chip_id) |
773 | { | 778 | { |
774 | struct da9052_pdata *pdata = da9052->dev->platform_data; | 779 | struct da9052_pdata *pdata = da9052->dev->platform_data; |
775 | int ret; | 780 | int ret, i; |
776 | 781 | ||
777 | mutex_init(&da9052->auxadc_lock); | 782 | mutex_init(&da9052->auxadc_lock); |
778 | init_completion(&da9052->done); | 783 | init_completion(&da9052->done); |
@@ -782,35 +787,34 @@ int __devinit da9052_device_init(struct da9052 *da9052, u8 chip_id) | |||
782 | 787 | ||
783 | da9052->chip_id = chip_id; | 788 | da9052->chip_id = chip_id; |
784 | 789 | ||
785 | if (!pdata || !pdata->irq_base) | ||
786 | da9052->irq_base = -1; | ||
787 | else | ||
788 | da9052->irq_base = pdata->irq_base; | ||
789 | |||
790 | ret = regmap_add_irq_chip(da9052->regmap, da9052->chip_irq, | 790 | ret = regmap_add_irq_chip(da9052->regmap, da9052->chip_irq, |
791 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | 791 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, |
792 | da9052->irq_base, &da9052_regmap_irq_chip, | 792 | -1, &da9052_regmap_irq_chip, |
793 | &da9052->irq_data); | 793 | &da9052->irq_data); |
794 | if (ret < 0) | 794 | if (ret < 0) { |
795 | dev_err(da9052->dev, "regmap_add_irq_chip failed: %d\n", ret); | ||
795 | goto regmap_err; | 796 | goto regmap_err; |
797 | } | ||
796 | 798 | ||
797 | da9052->irq_base = regmap_irq_chip_get_base(da9052->irq_data); | 799 | i = da9052_map_irq(da9052, DA9052_IRQ_ADC_EOM); |
798 | 800 | ret = request_threaded_irq(i, NULL, da9052_auxadc_irq, | |
799 | ret = request_threaded_irq(DA9052_IRQ_ADC_EOM, NULL, da9052_auxadc_irq, | ||
800 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | 801 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, |
801 | "adc irq", da9052); | 802 | "adc-irq", da9052); |
802 | if (ret != 0) | 803 | if (ret != 0) |
803 | dev_err(da9052->dev, "DA9052 ADC IRQ failed ret=%d\n", ret); | 804 | dev_err(da9052->dev, "DA9052 ADC IRQ failed ret=%d\n", ret); |
804 | 805 | ||
805 | ret = mfd_add_devices(da9052->dev, -1, da9052_subdev_info, | 806 | ret = mfd_add_devices(da9052->dev, -1, da9052_subdev_info, |
806 | ARRAY_SIZE(da9052_subdev_info), NULL, 0, NULL); | 807 | ARRAY_SIZE(da9052_subdev_info), NULL, 0, NULL); |
807 | if (ret) | 808 | if (ret) { |
809 | dev_err(da9052->dev, "mfd_add_devices failed: %d\n", ret); | ||
808 | goto err; | 810 | goto err; |
811 | } | ||
809 | 812 | ||
810 | return 0; | 813 | return 0; |
811 | 814 | ||
812 | err: | 815 | err: |
813 | free_irq(DA9052_IRQ_ADC_EOM, da9052); | 816 | free_irq(da9052_map_irq(da9052, DA9052_IRQ_ADC_EOM), da9052); |
817 | regmap_del_irq_chip(da9052->chip_irq, da9052->irq_data); | ||
814 | mfd_remove_devices(da9052->dev); | 818 | mfd_remove_devices(da9052->dev); |
815 | regmap_err: | 819 | regmap_err: |
816 | return ret; | 820 | return ret; |
@@ -818,7 +822,7 @@ regmap_err: | |||
818 | 822 | ||
819 | void da9052_device_exit(struct da9052 *da9052) | 823 | void da9052_device_exit(struct da9052 *da9052) |
820 | { | 824 | { |
821 | free_irq(DA9052_IRQ_ADC_EOM, da9052); | 825 | free_irq(da9052_map_irq(da9052, DA9052_IRQ_ADC_EOM), da9052); |
822 | regmap_del_irq_chip(da9052->chip_irq, da9052->irq_data); | 826 | regmap_del_irq_chip(da9052->chip_irq, da9052->irq_data); |
823 | mfd_remove_devices(da9052->dev); | 827 | mfd_remove_devices(da9052->dev); |
824 | } | 828 | } |