thermal/drivers/qoriq: Use dev_err_probe() simplify the code
Frank Li
maintainerPATCH 1/2 thermal/drivers/qoriq: Use dev_err_probe() simplify the code
Use dev_err_probe() and devm_clk_get_optional_enabled() to simplify the code.
--- drivers/thermal/qoriq_thermal.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-)
drivers/thermal/qoriq_thermal.c +10 -23
@@ -296,38 +296,27 @@ static int qoriq_tmu_probe(struct platform_device *pdev) base =devm_platform_ioremap_resource (pdev,0 ); ret =PTR_ERR_OR_ZERO (base); -if (ret) { -dev_err (dev,"Failed to get memory region\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Failed to get memory region\n" ); data->regmap =devm_regmap_init_mmio (dev, base, ®map_config); ret =PTR_ERR_OR_ZERO (data->regmap); -if (ret) { -dev_err (dev,"Failed to init regmap (%d)\n" , ret); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Failed to init regmap\n" ); - data->clk =devm_clk_get_optional (dev,NULL ); + data->clk =devm_clk_get_optional_enabled (dev,NULL );if (IS_ERR (data->clk))return PTR_ERR (data->clk); - ret =clk_prepare_enable (data->clk); -if (ret) { -dev_err (dev,"Failed to enable clock\n" ); -return ret; - } - ret =devm_add_action_or_reset (dev, qoriq_tmu_action, data);if (ret)return ret;/* version register offset at: 0xbf8 on both v1 and v2 */ ret =regmap_read (data->regmap,REGS_IPBRR (0 ), &ver); -if (ret) { -dev_err (&pdev->dev,"Failed to read IP block version\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Failed to read IP block version\n" ); + data->ver = (ver >>8 ) &0xff ;qoriq_tmu_init_device (data);/* TMU initialization */
@@ -337,10 +326,8 @@ static int qoriq_tmu_probe(struct platform_device *pdev)return ret; ret =qoriq_tmu_register_tmu_zone (dev, data); -if (ret <0 ) { -dev_err (dev,"Failed to register sensors\n" ); -return ret; - } +if (ret <0 ) +return dev_err_probe (dev, ret,"Failed to register sensors\n" );platform_set_drvdata (pdev, data);
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH 2/2 thermal/drivers/qoriq: Power down TMU on system suspend
From: Alice Guo <[email protected]>
Enable power-down of TMU (Thermal Management Unit) for TMU version 2 during system suspend to save power. Save approximately 4.3mW on VDD_ANA_1P8 on i.MX93 platforms.
--- drivers/thermal/qoriq_thermal.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/thermal/qoriq_thermal.c +13 -0
@@ -18,6 +18,7 @@#define SITES_MAX 16#define TMR_DISABLE 0x0#define TMR_ME 0x80000000 +#define TMR_CMD BIT(29)#define TMR_ALPF 0x0c000000#define TMR_ALPF_V2 0x03000000#define TMTMIR_DEFAULT 0x0000000f
@@ -343,6 +344,12 @@ static int qoriq_tmu_suspend(struct device *dev)if (ret)return ret; +if (data->ver >TMU_VER1 ) { + ret =regmap_set_bits (data->regmap,REGS_TMR ,TMR_CMD ); +if (ret) +return ret; + } +clk_disable_unprepare (data->clk);return 0 ;
@@ -357,6 +364,12 @@ static int qoriq_tmu_resume(struct device *dev)if (ret)return ret; +if (data->ver >TMU_VER1 ) { + ret =regmap_clear_bits (data->regmap,REGS_TMR ,TMR_CMD ); +if (ret) +return ret; + } +/* Enable monitoring */ return regmap_update_bits (data->regmap,REGS_TMR ,TMR_ME ,TMR_ME ); }
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH v6 1/2 iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code
In reply to Frank LiUse devm_* and dev_err_probe() simplify probe function and remove vf610_adc_remove().
---
Change from v5 to v6
- none
Change from v4 to v5
- Remove vref check in remove action callback
Change from v3 to v4
- keep vref_uv as u32
- keep original regulator part and only add devm_add_action_or_reset(&pdev->dev, vf610_adc_remove, info)
Change from v2 to v3
- change vref_uv to int from u32 to fix below warning
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
smatch warnings:drivers/iio/adc/vf610_adc.c:857 vf610_adc_probe() warn: unsigned 'info->vref_uv' is never less than zero.
vim +857 drivers/iio/adc/vf610_adc.c
Change from v1 to v2
- add Haibo's review tag
--- drivers/iio/adc/vf610_adc.c | 78 ++++++++++++------------------------- 1 file changed, 25 insertions(+), 53 deletions(-)
drivers/iio/adc/vf610_adc.c +25 -53
@@ -814,6 +814,13 @@ static const struct of_device_id vf610_adc_match[] = { };MODULE_DEVICE_TABLE (of, vf610_adc_match); +static void vf610_adc_action_remove (void *d) +{ +struct vf610_adc *info = d; + +regulator_disable (info->vref); +} +static int vf610_adc_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -823,10 +830,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,17 +847,12 @@ 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 ) +return 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\n" ); info->vref =devm_regulator_get (&pdev->dev,"vref" );if (IS_ERR (info->vref))
@@ -862,6 +862,10 @@ static int vf610_adc_probe(struct platform_device *pdev)if (ret)return ret; + ret =devm_add_action_or_reset (&pdev->dev, vf610_adc_action_remove, info); +if (ret) +return ret; + info->vref_uv =regulator_get_voltage (info->vref);device_property_read_u32_array (dev,"fsl,adck-max-frequency" , info->max_adck_rate,3 );
@@ -879,52 +883,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 +945,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,
Signature · 1 line
2.34.1
Frank Li
maintainerRe: [PATCH v6 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code
Quoted 2 lines · Frank Li
Use devm_* and
dev_err_probe()simplify probe function and removevf610_adc_remove().
This patch already in linux-next, send out accidently. please forget it. sorry for that.
Frank
Quoted 166 lines
Reviewed-by Haibo Chen <[email protected]>Signed-off-by Frank Li <[email protected]>---
Change from v5 to v6
- noneChange from v4 to v5
- Remove vref check in remove action callbackChange from v3 to v4
- keepvref_uvas u32
- keep original regulator part and only adddevm_add_action_or_reset(&pdev->dev, vf610_adc_remove, info)Change from v2 to v3
- changevref_uvto int from u32 to fix below warning
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
smatch warnings:drivers/iio/adc/vf610_adc.c:857vf610_adc_probe()warn: unsigned 'info->vref_uv' is never less than zero.vim +857
drivers/iio/adc/vf610_adc.cChange from v1 to v2
- add Haibo's review tag--- drivers/iio/adc/vf610_adc.c | 78 ++++++++++++------------------------- 1 file changed, 25 insertions(+), 53 deletions(-)drivers/iio/adc/vf610_adc.c +25
-54@@ -814,6 +814,13 @@ static const struct of_device_id vf610_adc_match[] = { };MODULE_DEVICE_TABLE (of, vf610_adc_match); +static void vf610_adc_action_remove (void *d) +{ +struct vf610_adc *info = d; + +regulator_disable (info->vref); +} +static int vf610_adc_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;@@ -823,10 +830,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,17 +847,12 @@ 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 ) +return 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\n" ); info->vref =devm_regulator_get (&pdev->dev,"vref" );if (IS_ERR (info->vref))@@ -862,6 +862,10 @@ static int vf610_adc_probe(struct platform_device *pdev)if (ret)return ret; + ret =devm_add_action_or_reset (&pdev->dev, vf610_adc_action_remove, info); +if (ret) +return ret; + info->vref_uv =regulator_get_voltage (info->vref);device_property_read_u32_array (dev,"fsl,adck-max-frequency" , info->max_adck_rate,3 );@@ -879,52 +883,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 +945,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
Frank Li
maintainerPATCH v6 2/2 iio: adc: vf610_adc: limit i.MX6SX's channel number to 4
In reply to Frank Lii.MX6SX only has 4 ADC channels, so limit channel numbers to 4 for compatible string 'fsl,imx6sx-adc'.
---
compatible string 'fsl,imx6sx-adc' already document in Documentation/devicetree/bindings/iio/adc/fsl,vf610-adc.yaml Change from v5 to v6
- remove return value check of device_get_match_data() and move it to declare place.
Change from v4 to v5
- none
Change from v3 to v4
- Add struct vf610_chip_info to avoid cast int to void*
Change from v2 to v3
- none
Change from v1 to v2
- Add Haibo Chen <[email protected]>
- change cast to uintptr_t to fix below warning
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
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);
|
---
drivers/iio/adc/vf610_adc.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)drivers/iio/adc/vf610_adc.c +16 -2
@@ -177,6 +177,10 @@ struct vf610_adc { } scan; }; +struct vf610_chip_info { +u8 num_channels; +}; +static const u32 vf610_hw_avgs[] = {1 ,4 ,8 ,16 ,32 };static const u32 vf610_lst_adder[] = {3 ,5 ,7 ,9 ,13 ,17 ,21 ,25 };
@@ -808,8 +812,17 @@ static const struct iio_info vf610_adc_iio_info = { .attrs = &vf610_attribute_group, }; +static const struct vf610_chip_info vf610_chip_info = { + .num_channels =ARRAY_SIZE (vf610_adc_iio_channels), +}; + +static const struct vf610_chip_info imx6sx_chip_info = { + .num_channels =4 , +}; +static const struct of_device_id vf610_adc_match[] = { - { .compatible ="fsl,vf610-adc" , }, + { .compatible ="fsl,imx6sx-adc" , .data = &imx6sx_chip_info}, + { .compatible ="fsl,vf610-adc" , .data = &vf610_chip_info}, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, vf610_adc_match);
@@ -824,6 +837,7 @@ static void vf610_adc_action_remove(void *d)static int vf610_adc_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; +const struct vf610_chip_info *chip_info =device_get_match_data (dev);struct vf610_adc *info;struct iio_dev *indio_dev;int irq;
@@ -881,7 +895,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 = chip_info->num_channels;vf610_adc_cfg_init (info);vf610_adc_hw_init (info);
Signature · 1 line
2.34.1
Frank Li
maintainerRe: [PATCH v6 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4
Quoted 2 lines · Frank Li
i.MX6SX only has 4 ADC channels, so limit channel numbers to 4 for compatible string 'fsl,imx6sx-adc'.
This patch already in linux-next, send out accidently. please forget it. sorry for that.
Frank
Quoted 95 lines
Reviewed-by Haibo Chen <[email protected]>Signed-off-by Frank Li <[email protected]>---
compatible string 'fsl,imx6sx-adc' already document inDocumentation/devicetree/bindings/iio/adc/fsl,vf610-adc.yamlChange from v5 to v6
- remove return value check ofdevice_get_match_data()and move it to declare place.Change from v4 to v5
- noneChange from v3 to v4
- Add structvf610_chip_infoto avoid cast int to void*Change from v2 to v3
- noneChange from v1 to v2
- Add Haibo Chen <[email protected]>
- change cast touintptr_tto fix below warning| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):In file included from
drivers/iio/adc/vf610_adc.c:20: In file included frominclude/linux/regulator/consumer.h:35:
In file included frominclude/linux/suspend.h:5:
In file included frominclude/linux/swap.h:9:
In file included frominclude/linux/memcontrol.h:21:
In file included frominclude/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); | --- drivers/iio/adc/vf610_adc.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)drivers/iio/adc/vf610_adc.c +16
-3@@ -177,6 +177,10 @@ struct vf610_adc { } scan; }; +struct vf610_chip_info { +u8 num_channels; +}; +static const u32 vf610_hw_avgs[] = {1 ,4 ,8 ,16 ,32 };static const u32 vf610_lst_adder[] = {3 ,5 ,7 ,9 ,13 ,17 ,21 ,25 };@@ -808,8 +812,17 @@ static const struct iio_info vf610_adc_iio_info = { .attrs = &vf610_attribute_group, }; +static const struct vf610_chip_info vf610_chip_info = { + .num_channels =ARRAY_SIZE (vf610_adc_iio_channels), +}; + +static const struct vf610_chip_info imx6sx_chip_info = { + .num_channels =4 , +}; +static const struct of_device_id vf610_adc_match[] = { - { .compatible ="fsl,vf610-adc" , }, + { .compatible ="fsl,imx6sx-adc" , .data = &imx6sx_chip_info}, + { .compatible ="fsl,vf610-adc" , .data = &vf610_chip_info}, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, vf610_adc_match);@@ -824,6 +837,7 @@ static void vf610_adc_action_remove(void *d)static int vf610_adc_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; +const struct vf610_chip_info *chip_info =device_get_match_data (dev);struct vf610_adc *info;struct iio_dev *indio_dev;int irq;@@ -881,7 +895,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 = chip_info->num_channels;vf610_adc_cfg_init (info);vf610_adc_hw_init (info); --2.34.1
Le 06/12/2024 à 23:56, Frank Li a écrit :
Quoted 34 lines
Use
dev_err_probe()anddevm_clk_get_optional_enabled()to simplify the code.Signed-off-by Frank Li <[email protected]>--- drivers/thermal/qoriq_thermal.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-)drivers/thermal/qoriq_thermal.c +5
-9@@ -296,38 +296,27 @@ static int qoriq_tmu_probe(struct platform_device *pdev) base =devm_platform_ioremap_resource (pdev,0 ); ret =PTR_ERR_OR_ZERO (base); -if (ret) { -dev_err (dev,"Failed to get memory region\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Failed to get memory region\n" ); data->regmap =devm_regmap_init_mmio (dev, base, ®map_config); ret =PTR_ERR_OR_ZERO (data->regmap); -if (ret) { -dev_err (dev,"Failed to init regmap (%d)\n" , ret); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Failed to init regmap\n" ); - data->clk =devm_clk_get_optional (dev,NULL ); + data->clk =devm_clk_get_optional_enabled (dev,NULL );
drivers/thermal/qoriq_thermal.c static int qoriq_tmu_probe(struct platform_device *pdev) · line 311
Quoted 10 lines
drivers/thermal/qoriq_thermal.c +0
-6if (IS_ERR (data->clk))return PTR_ERR (data->clk); - ret =clk_prepare_enable (data->clk); -if (ret) { -dev_err (dev,"Failed to enable clock\n" ); -return ret; - } - ret =devm_add_action_or_reset (dev, qoriq_tmu_action, data);
clk_disable_unprepare() in qoriq_tmu_action() should be removed as-well.
Quoted 28 lines
drivers/thermal/qoriq_thermal.c +5
-8if (ret)return ret;/* version register offset at: 0xbf8 on both v1 and v2 */ ret =regmap_read (data->regmap,REGS_IPBRR (0 ), &ver); -if (ret) { -dev_err (&pdev->dev,"Failed to read IP block version\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Failed to read IP block version\n" ); + data->ver = (ver >>8 ) &0xff ;qoriq_tmu_init_device (data);/* TMU initialization */ @@ -337,10 +326,8 @@ static int qoriq_tmu_probe(struct platform_device *pdev)return ret; ret =qoriq_tmu_register_tmu_zone (dev, data); -if (ret <0 ) { -dev_err (dev,"Failed to register sensors\n" ); -return ret; - } +if (ret <0 ) +return dev_err_probe (dev, ret,"Failed to register sensors\n" );platform_set_drvdata (pdev, data);