* [PATCH 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code
@ 2024-11-04 23:11 Frank Li
2024-11-04 23:12 ` [PATCH 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4 Frank Li
2024-11-05 2:07 ` [PATCH 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code Bough Chen
0 siblings, 2 replies; 6+ messages in thread
From: Frank Li @ 2024-11-04 23:11 UTC (permalink / raw)
To: Haibo Chen, Jonathan Cameron, Lars-Peter Clausen,
open list:NXP i.MX 7D/6SX/6UL/93 AND VF610 ADC DRIVER,
open list:NXP i.MX 7D/6SX/6UL/93 AND VF610 ADC DRIVER, open list
Use devm_* and dev_err_probe() simplify probe function and remove
vf610_adc_remove().
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
drivers/iio/adc/vf610_adc.c | 77 +++++++++----------------------------
1 file changed, 19 insertions(+), 58 deletions(-)
diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
index 4d83c12975c53..4e737b193c012 100644
--- a/drivers/iio/adc/vf610_adc.c
+++ b/drivers/iio/adc/vf610_adc.c
@@ -823,10 +823,8 @@ static int vf610_adc_probe(struct platform_device *pdev)
int ret;
indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct vf610_adc));
- if (!indio_dev) {
- dev_err(&pdev->dev, "Failed allocating iio device\n");
- return -ENOMEM;
- }
+ if (!indio_dev)
+ return dev_err_probe(&pdev->dev, -ENOMEM, "Failed allocating iio device\n");
info = iio_priv(indio_dev);
info->dev = &pdev->dev;
@@ -842,27 +840,22 @@ static int vf610_adc_probe(struct platform_device *pdev)
ret = devm_request_irq(info->dev, irq,
vf610_adc_isr, 0,
dev_name(&pdev->dev), indio_dev);
- if (ret < 0) {
- dev_err(&pdev->dev, "failed requesting irq, irq = %d\n", irq);
- return ret;
- }
+ if (ret < 0)
+ dev_err_probe(&pdev->dev, ret, "failed requesting irq, irq = %d\n", irq);
- info->clk = devm_clk_get(&pdev->dev, "adc");
- if (IS_ERR(info->clk)) {
- dev_err(&pdev->dev, "failed getting clock, err = %ld\n",
- PTR_ERR(info->clk));
- return PTR_ERR(info->clk);
- }
+ info->clk = devm_clk_get_enabled(&pdev->dev, "adc");
+ if (IS_ERR(info->clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(info->clk),
+ "failed getting clock, err = %ld\n",
+ PTR_ERR(info->clk));
info->vref = devm_regulator_get(&pdev->dev, "vref");
if (IS_ERR(info->vref))
return PTR_ERR(info->vref);
- ret = regulator_enable(info->vref);
- if (ret)
- return ret;
-
- info->vref_uv = regulator_get_voltage(info->vref);
+ info->vref_uv = devm_regulator_get_enable_read_voltage(&pdev->dev, "vref");
+ if (info->vref_uv < 0)
+ return info->vref_uv;
device_property_read_u32_array(dev, "fsl,adck-max-frequency", info->max_adck_rate, 3);
@@ -879,52 +872,21 @@ static int vf610_adc_probe(struct platform_device *pdev)
indio_dev->channels = vf610_adc_iio_channels;
indio_dev->num_channels = ARRAY_SIZE(vf610_adc_iio_channels);
- ret = clk_prepare_enable(info->clk);
- if (ret) {
- dev_err(&pdev->dev,
- "Could not prepare or enable the clock.\n");
- goto error_adc_clk_enable;
- }
-
vf610_adc_cfg_init(info);
vf610_adc_hw_init(info);
- ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
- NULL, &iio_triggered_buffer_setup_ops);
- if (ret < 0) {
- dev_err(&pdev->dev, "Couldn't initialise the buffer\n");
- goto error_iio_device_register;
- }
+ ret = devm_iio_triggered_buffer_setup(&pdev->dev, indio_dev, &iio_pollfunc_store_time,
+ NULL, &iio_triggered_buffer_setup_ops);
+ if (ret < 0)
+ return dev_err_probe(&pdev->dev, ret, "Couldn't initialise the buffer\n");
mutex_init(&info->lock);
- ret = iio_device_register(indio_dev);
- if (ret) {
- dev_err(&pdev->dev, "Couldn't register the device.\n");
- goto error_adc_buffer_init;
- }
+ ret = devm_iio_device_register(&pdev->dev, indio_dev);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret, "Couldn't register the device.\n");
return 0;
-
-error_adc_buffer_init:
- iio_triggered_buffer_cleanup(indio_dev);
-error_iio_device_register:
- clk_disable_unprepare(info->clk);
-error_adc_clk_enable:
- regulator_disable(info->vref);
-
- return ret;
-}
-
-static void vf610_adc_remove(struct platform_device *pdev)
-{
- struct iio_dev *indio_dev = platform_get_drvdata(pdev);
- struct vf610_adc *info = iio_priv(indio_dev);
-
- iio_device_unregister(indio_dev);
- iio_triggered_buffer_cleanup(indio_dev);
- regulator_disable(info->vref);
- clk_disable_unprepare(info->clk);
}
static int vf610_adc_suspend(struct device *dev)
@@ -972,7 +934,6 @@ static DEFINE_SIMPLE_DEV_PM_OPS(vf610_adc_pm_ops, vf610_adc_suspend,
static struct platform_driver vf610_adc_driver = {
.probe = vf610_adc_probe,
- .remove = vf610_adc_remove,
.driver = {
.name = DRIVER_NAME,
.of_match_table = vf610_adc_match,
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4
2024-11-04 23:11 [PATCH 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code Frank Li
@ 2024-11-04 23:12 ` Frank Li
2024-11-05 2:09 ` Bough Chen
` (2 more replies)
2024-11-05 2:07 ` [PATCH 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code Bough Chen
1 sibling, 3 replies; 6+ messages in thread
From: Frank Li @ 2024-11-04 23:12 UTC (permalink / raw)
To: Haibo Chen, Jonathan Cameron, Lars-Peter Clausen,
open list:NXP i.MX 7D/6SX/6UL/93 AND VF610 ADC DRIVER,
open list:NXP i.MX 7D/6SX/6UL/93 AND VF610 ADC DRIVER, open list
i.MX6SX only has 4 ADC channels, so limit channel numbers to 4 for
compatible string 'fsl,imx6sx-adc'.
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
compatible string 'fsl,imx6sx-adc' already document in
Documentation/devicetree/bindings/iio/adc/fsl,vf610-adc.yaml
---
drivers/iio/adc/vf610_adc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
index 4e737b193c012..84573cdfce5da 100644
--- a/drivers/iio/adc/vf610_adc.c
+++ b/drivers/iio/adc/vf610_adc.c
@@ -809,7 +809,8 @@ static const struct iio_info vf610_adc_iio_info = {
};
static const struct of_device_id vf610_adc_match[] = {
- { .compatible = "fsl,vf610-adc", },
+ { .compatible = "fsl,imx6sx-adc", .data = (void *)4},
+ { .compatible = "fsl,vf610-adc", .data = (void *)ARRAY_SIZE(vf610_adc_iio_channels)},
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, vf610_adc_match);
@@ -870,7 +871,7 @@ static int vf610_adc_probe(struct platform_device *pdev)
indio_dev->info = &vf610_adc_iio_info;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = vf610_adc_iio_channels;
- indio_dev->num_channels = ARRAY_SIZE(vf610_adc_iio_channels);
+ indio_dev->num_channels = (u32)device_get_match_data(dev);
vf610_adc_cfg_init(info);
vf610_adc_hw_init(info);
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* RE: [PATCH 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4
2024-11-04 23:12 ` [PATCH 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4 Frank Li
@ 2024-11-05 2:09 ` Bough Chen
2024-11-05 13:53 ` kernel test robot
2024-11-05 15:47 ` kernel test robot
2 siblings, 0 replies; 6+ messages in thread
From: Bough Chen @ 2024-11-05 2:09 UTC (permalink / raw)
To: Frank Li, Jonathan Cameron, Lars-Peter Clausen,
open list:NXP i.MX 7D/6SX/6UL/93 AND VF610 ADC DRIVER,
open list:NXP i.MX 7D/6SX/6UL/93 AND VF610 ADC DRIVER, open list
> -----Original Message-----
> From: Frank Li <frank.li@nxp.com>
> Sent: 2024年11月5日 7:12
> To: Bough Chen <haibo.chen@nxp.com>; Jonathan Cameron
> <jic23@kernel.org>; Lars-Peter Clausen <lars@metafoo.de>; open list:NXP i.MX
> 7D/6SX/6UL/93 AND VF610 ADC DRIVER <linux-iio@vger.kernel.org>; open
> list:NXP i.MX 7D/6SX/6UL/93 AND VF610 ADC DRIVER <imx@lists.linux.dev>;
> open list <linux-kernel@vger.kernel.org>
> Subject: [PATCH 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4
>
> i.MX6SX only has 4 ADC channels, so limit channel numbers to 4 for compatible
> string 'fsl,imx6sx-adc'.
Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
Best Regards
Haibo Chen
>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
> compatible string 'fsl,imx6sx-adc' already document in
> Documentation/devicetree/bindings/iio/adc/fsl,vf610-adc.yaml
> ---
> drivers/iio/adc/vf610_adc.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index
> 4e737b193c012..84573cdfce5da 100644
> --- a/drivers/iio/adc/vf610_adc.c
> +++ b/drivers/iio/adc/vf610_adc.c
> @@ -809,7 +809,8 @@ static const struct iio_info vf610_adc_iio_info = { };
>
> static const struct of_device_id vf610_adc_match[] = {
> - { .compatible = "fsl,vf610-adc", },
> + { .compatible = "fsl,imx6sx-adc", .data = (void *)4},
> + { .compatible = "fsl,vf610-adc", .data = (void
> +*)ARRAY_SIZE(vf610_adc_iio_channels)},
> { /* sentinel */ }
> };
> MODULE_DEVICE_TABLE(of, vf610_adc_match); @@ -870,7 +871,7 @@
> static int vf610_adc_probe(struct platform_device *pdev)
> indio_dev->info = &vf610_adc_iio_info;
> indio_dev->modes = INDIO_DIRECT_MODE;
> indio_dev->channels = vf610_adc_iio_channels;
> - indio_dev->num_channels = ARRAY_SIZE(vf610_adc_iio_channels);
> + indio_dev->num_channels = (u32)device_get_match_data(dev);
>
> vf610_adc_cfg_init(info);
> vf610_adc_hw_init(info);
> --
> 2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4
2024-11-04 23:12 ` [PATCH 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4 Frank Li
2024-11-05 2:09 ` Bough Chen
@ 2024-11-05 13:53 ` kernel test robot
2024-11-05 15:47 ` kernel test robot
2 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2024-11-05 13:53 UTC (permalink / raw)
To: Frank Li, Haibo Chen, Jonathan Cameron, Lars-Peter Clausen,
open list:NXP i.MX 7D/6SX/6UL/93 AND VF610 ADC DRIVER, open list
Cc: oe-kbuild-all
Hi Frank,
kernel test robot noticed the following build warnings:
[auto build test WARNING on jic23-iio/togreg]
[also build test WARNING on next-20241105]
[cannot apply to linus/master v6.12-rc6]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Frank-Li/iio-adc-vf610_adc-limit-i-MX6SX-s-channel-number-to-4/20241105-071339
base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
patch link: https://lore.kernel.org/r/20241104231200.2745342-2-Frank.Li%40nxp.com
patch subject: [PATCH 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4
config: alpha-randconfig-r072-20241105 (https://download.01.org/0day-ci/archive/20241105/202411052136.jstxD0iJ-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 13.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241105/202411052136.jstxD0iJ-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411052136.jstxD0iJ-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/iio/adc/vf610_adc.c: In function 'vf610_adc_probe':
>> drivers/iio/adc/vf610_adc.c:874:35: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
874 | indio_dev->num_channels = (u32)device_get_match_data(dev);
| ^
vim +874 drivers/iio/adc/vf610_adc.c
817
818 static int vf610_adc_probe(struct platform_device *pdev)
819 {
820 struct device *dev = &pdev->dev;
821 struct vf610_adc *info;
822 struct iio_dev *indio_dev;
823 int irq;
824 int ret;
825
826 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct vf610_adc));
827 if (!indio_dev)
828 return dev_err_probe(&pdev->dev, -ENOMEM, "Failed allocating iio device\n");
829
830 info = iio_priv(indio_dev);
831 info->dev = &pdev->dev;
832
833 info->regs = devm_platform_ioremap_resource(pdev, 0);
834 if (IS_ERR(info->regs))
835 return PTR_ERR(info->regs);
836
837 irq = platform_get_irq(pdev, 0);
838 if (irq < 0)
839 return irq;
840
841 ret = devm_request_irq(info->dev, irq,
842 vf610_adc_isr, 0,
843 dev_name(&pdev->dev), indio_dev);
844 if (ret < 0)
845 dev_err_probe(&pdev->dev, ret, "failed requesting irq, irq = %d\n", irq);
846
847 info->clk = devm_clk_get_enabled(&pdev->dev, "adc");
848 if (IS_ERR(info->clk))
849 return dev_err_probe(&pdev->dev, PTR_ERR(info->clk),
850 "failed getting clock, err = %ld\n",
851 PTR_ERR(info->clk));
852
853 info->vref = devm_regulator_get(&pdev->dev, "vref");
854 if (IS_ERR(info->vref))
855 return PTR_ERR(info->vref);
856
857 info->vref_uv = devm_regulator_get_enable_read_voltage(&pdev->dev, "vref");
858 if (info->vref_uv < 0)
859 return info->vref_uv;
860
861 device_property_read_u32_array(dev, "fsl,adck-max-frequency", info->max_adck_rate, 3);
862
863 info->adc_feature.default_sample_time = DEFAULT_SAMPLE_TIME;
864 device_property_read_u32(dev, "min-sample-time", &info->adc_feature.default_sample_time);
865
866 platform_set_drvdata(pdev, indio_dev);
867
868 init_completion(&info->completion);
869
870 indio_dev->name = dev_name(&pdev->dev);
871 indio_dev->info = &vf610_adc_iio_info;
872 indio_dev->modes = INDIO_DIRECT_MODE;
873 indio_dev->channels = vf610_adc_iio_channels;
> 874 indio_dev->num_channels = (u32)device_get_match_data(dev);
875
876 vf610_adc_cfg_init(info);
877 vf610_adc_hw_init(info);
878
879 ret = devm_iio_triggered_buffer_setup(&pdev->dev, indio_dev, &iio_pollfunc_store_time,
880 NULL, &iio_triggered_buffer_setup_ops);
881 if (ret < 0)
882 return dev_err_probe(&pdev->dev, ret, "Couldn't initialise the buffer\n");
883
884 mutex_init(&info->lock);
885
886 ret = devm_iio_device_register(&pdev->dev, indio_dev);
887 if (ret)
888 return dev_err_probe(&pdev->dev, ret, "Couldn't register the device.\n");
889
890 return 0;
891 }
892
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4
2024-11-04 23:12 ` [PATCH 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4 Frank Li
2024-11-05 2:09 ` Bough Chen
2024-11-05 13:53 ` kernel test robot
@ 2024-11-05 15:47 ` kernel test robot
2 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2024-11-05 15:47 UTC (permalink / raw)
To: Frank Li, Haibo Chen, Jonathan Cameron, Lars-Peter Clausen,
open list:NXP i.MX 7D/6SX/6UL/93 AND VF610 ADC DRIVER, open list
Cc: llvm, oe-kbuild-all
Hi Frank,
kernel test robot noticed the following build warnings:
[auto build test WARNING on jic23-iio/togreg]
[also build test WARNING on next-20241105]
[cannot apply to linus/master v6.12-rc6]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Frank-Li/iio-adc-vf610_adc-limit-i-MX6SX-s-channel-number-to-4/20241105-071339
base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
patch link: https://lore.kernel.org/r/20241104231200.2745342-2-Frank.Li%40nxp.com
patch subject: [PATCH 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4
config: x86_64-buildonly-randconfig-005-20241105 (https://download.01.org/0day-ci/archive/20241105/202411052345.gyJaM3h4-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241105/202411052345.gyJaM3h4-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411052345.gyJaM3h4-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from drivers/iio/adc/vf610_adc.c:20:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:21:
In file included from include/linux/mm.h:2213:
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
>> drivers/iio/adc/vf610_adc.c:874:28: warning: cast to smaller integer type 'u32' (aka 'unsigned int') from 'const void *' [-Wvoid-pointer-to-int-cast]
874 | indio_dev->num_channels = (u32)device_get_match_data(dev);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
vim +874 drivers/iio/adc/vf610_adc.c
817
818 static int vf610_adc_probe(struct platform_device *pdev)
819 {
820 struct device *dev = &pdev->dev;
821 struct vf610_adc *info;
822 struct iio_dev *indio_dev;
823 int irq;
824 int ret;
825
826 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct vf610_adc));
827 if (!indio_dev)
828 return dev_err_probe(&pdev->dev, -ENOMEM, "Failed allocating iio device\n");
829
830 info = iio_priv(indio_dev);
831 info->dev = &pdev->dev;
832
833 info->regs = devm_platform_ioremap_resource(pdev, 0);
834 if (IS_ERR(info->regs))
835 return PTR_ERR(info->regs);
836
837 irq = platform_get_irq(pdev, 0);
838 if (irq < 0)
839 return irq;
840
841 ret = devm_request_irq(info->dev, irq,
842 vf610_adc_isr, 0,
843 dev_name(&pdev->dev), indio_dev);
844 if (ret < 0)
845 dev_err_probe(&pdev->dev, ret, "failed requesting irq, irq = %d\n", irq);
846
847 info->clk = devm_clk_get_enabled(&pdev->dev, "adc");
848 if (IS_ERR(info->clk))
849 return dev_err_probe(&pdev->dev, PTR_ERR(info->clk),
850 "failed getting clock, err = %ld\n",
851 PTR_ERR(info->clk));
852
853 info->vref = devm_regulator_get(&pdev->dev, "vref");
854 if (IS_ERR(info->vref))
855 return PTR_ERR(info->vref);
856
857 info->vref_uv = devm_regulator_get_enable_read_voltage(&pdev->dev, "vref");
858 if (info->vref_uv < 0)
859 return info->vref_uv;
860
861 device_property_read_u32_array(dev, "fsl,adck-max-frequency", info->max_adck_rate, 3);
862
863 info->adc_feature.default_sample_time = DEFAULT_SAMPLE_TIME;
864 device_property_read_u32(dev, "min-sample-time", &info->adc_feature.default_sample_time);
865
866 platform_set_drvdata(pdev, indio_dev);
867
868 init_completion(&info->completion);
869
870 indio_dev->name = dev_name(&pdev->dev);
871 indio_dev->info = &vf610_adc_iio_info;
872 indio_dev->modes = INDIO_DIRECT_MODE;
873 indio_dev->channels = vf610_adc_iio_channels;
> 874 indio_dev->num_channels = (u32)device_get_match_data(dev);
875
876 vf610_adc_cfg_init(info);
877 vf610_adc_hw_init(info);
878
879 ret = devm_iio_triggered_buffer_setup(&pdev->dev, indio_dev, &iio_pollfunc_store_time,
880 NULL, &iio_triggered_buffer_setup_ops);
881 if (ret < 0)
882 return dev_err_probe(&pdev->dev, ret, "Couldn't initialise the buffer\n");
883
884 mutex_init(&info->lock);
885
886 ret = devm_iio_device_register(&pdev->dev, indio_dev);
887 if (ret)
888 return dev_err_probe(&pdev->dev, ret, "Couldn't register the device.\n");
889
890 return 0;
891 }
892
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code
2024-11-04 23:11 [PATCH 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code Frank Li
2024-11-04 23:12 ` [PATCH 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4 Frank Li
@ 2024-11-05 2:07 ` Bough Chen
1 sibling, 0 replies; 6+ messages in thread
From: Bough Chen @ 2024-11-05 2:07 UTC (permalink / raw)
To: Frank Li, Jonathan Cameron, Lars-Peter Clausen,
open list:NXP i.MX 7D/6SX/6UL/93 AND VF610 ADC DRIVER,
open list:NXP i.MX 7D/6SX/6UL/93 AND VF610 ADC DRIVER, open list
> -----Original Message-----
> From: Frank Li <frank.li@nxp.com>
> Sent: 2024年11月5日 7:12
> To: Bough Chen <haibo.chen@nxp.com>; Jonathan Cameron
> <jic23@kernel.org>; Lars-Peter Clausen <lars@metafoo.de>; open list:NXP i.MX
> 7D/6SX/6UL/93 AND VF610 ADC DRIVER <linux-iio@vger.kernel.org>; open
> list:NXP i.MX 7D/6SX/6UL/93 AND VF610 ADC DRIVER <imx@lists.linux.dev>;
> open list <linux-kernel@vger.kernel.org>
> Subject: [PATCH 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to
> simple code
>
> Use devm_* and dev_err_probe() simplify probe function and remove
> vf610_adc_remove().
Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
Best Regards
Haibo Chen
>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/iio/adc/vf610_adc.c | 77 +++++++++----------------------------
> 1 file changed, 19 insertions(+), 58 deletions(-)
>
> diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index
> 4d83c12975c53..4e737b193c012 100644
> --- a/drivers/iio/adc/vf610_adc.c
> +++ b/drivers/iio/adc/vf610_adc.c
> @@ -823,10 +823,8 @@ static int vf610_adc_probe(struct platform_device
> *pdev)
> int ret;
>
> indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct vf610_adc));
> - if (!indio_dev) {
> - dev_err(&pdev->dev, "Failed allocating iio device\n");
> - return -ENOMEM;
> - }
> + if (!indio_dev)
> + return dev_err_probe(&pdev->dev, -ENOMEM, "Failed allocating iio
> +device\n");
>
> info = iio_priv(indio_dev);
> info->dev = &pdev->dev;
> @@ -842,27 +840,22 @@ static int vf610_adc_probe(struct platform_device
> *pdev)
> ret = devm_request_irq(info->dev, irq,
> vf610_adc_isr, 0,
> dev_name(&pdev->dev), indio_dev);
> - if (ret < 0) {
> - dev_err(&pdev->dev, "failed requesting irq, irq = %d\n", irq);
> - return ret;
> - }
> + if (ret < 0)
> + dev_err_probe(&pdev->dev, ret, "failed requesting irq, irq = %d\n",
> +irq);
>
> - info->clk = devm_clk_get(&pdev->dev, "adc");
> - if (IS_ERR(info->clk)) {
> - dev_err(&pdev->dev, "failed getting clock, err = %ld\n",
> - PTR_ERR(info->clk));
> - return PTR_ERR(info->clk);
> - }
> + info->clk = devm_clk_get_enabled(&pdev->dev, "adc");
> + if (IS_ERR(info->clk))
> + return dev_err_probe(&pdev->dev, PTR_ERR(info->clk),
> + "failed getting clock, err = %ld\n",
> + PTR_ERR(info->clk));
>
> info->vref = devm_regulator_get(&pdev->dev, "vref");
> if (IS_ERR(info->vref))
> return PTR_ERR(info->vref);
>
> - ret = regulator_enable(info->vref);
> - if (ret)
> - return ret;
> -
> - info->vref_uv = regulator_get_voltage(info->vref);
> + info->vref_uv = devm_regulator_get_enable_read_voltage(&pdev->dev,
> "vref");
> + if (info->vref_uv < 0)
> + return info->vref_uv;
>
> device_property_read_u32_array(dev, "fsl,adck-max-frequency",
> info->max_adck_rate, 3);
>
> @@ -879,52 +872,21 @@ static int vf610_adc_probe(struct platform_device
> *pdev)
> indio_dev->channels = vf610_adc_iio_channels;
> indio_dev->num_channels = ARRAY_SIZE(vf610_adc_iio_channels);
>
> - ret = clk_prepare_enable(info->clk);
> - if (ret) {
> - dev_err(&pdev->dev,
> - "Could not prepare or enable the clock.\n");
> - goto error_adc_clk_enable;
> - }
> -
> vf610_adc_cfg_init(info);
> vf610_adc_hw_init(info);
>
> - ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
> - NULL, &iio_triggered_buffer_setup_ops);
> - if (ret < 0) {
> - dev_err(&pdev->dev, "Couldn't initialise the buffer\n");
> - goto error_iio_device_register;
> - }
> + ret = devm_iio_triggered_buffer_setup(&pdev->dev, indio_dev,
> &iio_pollfunc_store_time,
> + NULL, &iio_triggered_buffer_setup_ops);
> + if (ret < 0)
> + return dev_err_probe(&pdev->dev, ret, "Couldn't initialise the
> +buffer\n");
>
> mutex_init(&info->lock);
>
> - ret = iio_device_register(indio_dev);
> - if (ret) {
> - dev_err(&pdev->dev, "Couldn't register the device.\n");
> - goto error_adc_buffer_init;
> - }
> + ret = devm_iio_device_register(&pdev->dev, indio_dev);
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret, "Couldn't register the
> +device.\n");
>
> return 0;
> -
> -error_adc_buffer_init:
> - iio_triggered_buffer_cleanup(indio_dev);
> -error_iio_device_register:
> - clk_disable_unprepare(info->clk);
> -error_adc_clk_enable:
> - regulator_disable(info->vref);
> -
> - return ret;
> -}
> -
> -static void vf610_adc_remove(struct platform_device *pdev) -{
> - struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> - struct vf610_adc *info = iio_priv(indio_dev);
> -
> - iio_device_unregister(indio_dev);
> - iio_triggered_buffer_cleanup(indio_dev);
> - regulator_disable(info->vref);
> - clk_disable_unprepare(info->clk);
> }
>
> static int vf610_adc_suspend(struct device *dev) @@ -972,7 +934,6 @@
> static DEFINE_SIMPLE_DEV_PM_OPS(vf610_adc_pm_ops, vf610_adc_suspend,
>
> static struct platform_driver vf610_adc_driver = {
> .probe = vf610_adc_probe,
> - .remove = vf610_adc_remove,
> .driver = {
> .name = DRIVER_NAME,
> .of_match_table = vf610_adc_match,
> --
> 2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-05 15:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-04 23:11 [PATCH 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code Frank Li
2024-11-04 23:12 ` [PATCH 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4 Frank Li
2024-11-05 2:09 ` Bough Chen
2024-11-05 13:53 ` kernel test robot
2024-11-05 15:47 ` kernel test robot
2024-11-05 2:07 ` [PATCH 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code Bough Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox