Exynos Thermal code improvement
Subsystems (3)
v5 cover Exynos Thermal code improvement
Hi All,
This patch series is a rework of my previous patch series [1], where the code changes were not adequately justified.
In this new series, I have improved the commit subject and commit message to better explain the changes.
v5: Drop the guard mutex patch
v4: Tried to address Lukasz review comments.
Tested on Odroid U3 amd XU4 SoC boards.
Build with clang with W=1 enable.
[3] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[1] https://lore.kernel.org/all/[email protected]/
[0] https://lore.kernel.org/lkml/CANAwSgS=08fVsqn95WHzSF71WTTyD2-=K2C6-BEz0tY0t6A1-g@mail.gmail.com/T/#m77e57120d230d57f34c29e1422d7fc5f5587ac30
Thanks
-Anand
Anand Moon (3):
drivers/thermal/exynos: Refactor clk_sec initialization inside
SOC-specific case
drivers/thermal/exymos: Remove redundant IS_ERR() checks for clk_sec
clock
drivers/thermal/exymos: Fixed the efuse min max value for exynos5422
drivers/thermal/samsung/exynos_tmu.c | 62 ++++++++++++++++------------ 1 file changed, 35 insertions(+), 27 deletions(-)
base-commit: 3b07108ada81a8ebcebf1fe61367b4e436c895bd
Signature · 1 line
2.49.0
PATCH v5 1/3 drivers/thermal/exynos: Refactor clk_sec initialization inside SOC-specific case
Refactor the initialization of the clk_sec clock to be inside the SOC_ARCH_EXYNOS5420_TRIMINFO case. It ensures that the clk_sec clock is only initialized for the specified SOC and not for other SOCs, thereby simplifying the code. The clk_sec clock is used by the TMU for GPU on the Exynos 542x platform.
Removed redundant IS_ERR() checks for the clk_sec clock since error handling is already managed internally by clk_unprepare() functions.
---
v5: None
v4: Fix the aligment of code clk for clk_prepare in proper if/else block.
update the commit for clk_sec used.
checked to goto clean up all the clks are proper.
drop IS_ERR() check for clk_sec.
v3: improve the commit message.
--- drivers/thermal/samsung/exynos_tmu.c | 37 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 19 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +18 -19
@@ -1037,29 +1037,30 @@ static int exynos_tmu_probe(struct platform_device *pdev)return ret; data->clk =devm_clk_get (dev,"tmu_apbif" ); -if (IS_ERR (data->clk)) +if (IS_ERR (data->clk)) {return dev_err_probe (dev,PTR_ERR (data->clk),"Failed to get clock\n" ); - - data->clk_sec =devm_clk_get (dev,"tmu_triminfo_apbif" ); -if (IS_ERR (data->clk_sec)) { -if (data->soc ==SOC_ARCH_EXYNOS5420_TRIMINFO ) -return dev_err_probe (dev,PTR_ERR (data->clk_sec), -"Failed to get triminfo clock\n" ); }else { - ret =clk_prepare (data->clk_sec); + ret =clk_prepare (data->clk);if (ret) {dev_err (dev,"Failed to get clock\n" );return ret; } } - ret =clk_prepare (data->clk); -if (ret) { -dev_err (dev,"Failed to get clock\n" ); - goto err_clk_sec; - } -switch (data->soc) { +case SOC_ARCH_EXYNOS5420_TRIMINFO : + data->clk_sec =devm_clk_get (dev,"tmu_triminfo_apbif" ); +if (IS_ERR (data->clk_sec)) { + ret =dev_err_probe (dev,PTR_ERR (data->clk_sec), +"Failed to get clk_sec clock\n" ); + goto err_clk; + } + ret =clk_prepare (data->clk_sec); +if (ret) { +dev_err (dev,"Failed to prepare clk_sec clock\n" ); + goto err_clk_sec; + } +break ;case SOC_ARCH_EXYNOS5433 :case SOC_ARCH_EXYNOS7 : data->sclk =devm_clk_get (dev,"tmu_sclk" );
@@ -1112,11 +1113,10 @@ static int exynos_tmu_probe(struct platform_device *pdev) err_sclk:clk_disable_unprepare (data->sclk); +err_clk_sec: +clk_unprepare (data->clk_sec); err_clk:clk_unprepare (data->clk); -err_clk_sec: -if (!IS_ERR (data->clk_sec)) -clk_unprepare (data->clk_sec);return ret; }
@@ -1128,8 +1128,7 @@ static void exynos_tmu_remove(struct platform_device *pdev)clk_disable_unprepare (data->sclk);clk_unprepare (data->clk); -if (!IS_ERR (data->clk_sec)) -clk_unprepare (data->clk_sec); +clk_unprepare (data->clk_sec); }#ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.49.0
PATCH v5 2/3 drivers/thermal/exymos: Remove redundant IS_ERR() checks for clk_sec clock
In reply to Anand MoonRemove unnecessary IS_ERR() checks for the clk_sec clock, the clk_enable() and clk_disable() functions can handle NULL clock pointers, so the additional checks are redundant and have been removed to simplify the code.
---
v5: None
v4: drop IE_ERR() for clk_unprepare() as its handle in earlier code.
v3: improve the commit message.
--- drivers/thermal/samsung/exynos_tmu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +2 -4
@@ -258,8 +258,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)mutex_lock (&data->lock);clk_enable (data->clk); -if (!IS_ERR (data->clk_sec)) -clk_enable (data->clk_sec); +clk_enable (data->clk_sec); status =readb (data->base +EXYNOS_TMU_REG_STATUS );if (!status) {
@@ -269,8 +268,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev) data->tmu_clear_irqs (data); } -if (!IS_ERR (data->clk_sec)) -clk_disable (data->clk_sec); +clk_disable (data->clk_sec);clk_disable (data->clk);mutex_unlock (&data->lock);
Signature · 1 line
2.49.0
PATCH v5 3/3 drivers/thermal/exymos: Fixed the efuse min max value for exynos5422
In reply to Anand MoonAs per Exynos5422 user manual e-Fuse range min~max range is 16~76. if e-Fuse value is out of this range, then thermal sensor may not sense thermal data properly. Refactors the efuse value initialization logic within exynos_map_dt_data function by replacing the nested if-else statements with a switch statement. Ensures proper initialization of efuse values based on the SOC type.
---
v5: None
v4: None
v3: Improve the logic to convert if/else to switch
--- drivers/thermal/samsung/exynos_tmu.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +15 -4
@@ -899,12 +899,23 @@ static int exynos_map_dt_data(struct platform_device *pdev) data->gain =8 ; data->reference_voltage =16 ; data->efuse_value =55 ; -if (data->soc !=SOC_ARCH_EXYNOS5420 && - data->soc !=SOC_ARCH_EXYNOS5420_TRIMINFO ) + data->max_efuse_value =100 ; +switch (data->soc) { +case SOC_ARCH_EXYNOS3250 : +case SOC_ARCH_EXYNOS4412 : +case SOC_ARCH_EXYNOS5250 : +case SOC_ARCH_EXYNOS5260 : data->min_efuse_value =40 ; -else +break ; +case SOC_ARCH_EXYNOS5420 : +case SOC_ARCH_EXYNOS5420_TRIMINFO : + data->min_efuse_value =16 ; + data->max_efuse_value =76 ; +break ; +default : data->min_efuse_value =0 ; - data->max_efuse_value =100 ; +break ; + }break ;case SOC_ARCH_EXYNOS5433 : data->tmu_set_low_temp = exynos5433_tmu_set_low_temp;
Signature · 1 line
2.49.0
Re: [PATCH v5 3/3] drivers/thermal/exymos: Fixed the efuse min max value for exynos5422
Quoted 38 lines · Anand Moon
As per Exynos5422 user manual e-Fuse range min~max range is 16~76. if e-Fuse value is out of this range, then thermal sensor may not sense thermal data properly. Refactors the efuse value initialization logic within
exynos_map_dt_datafunction by replacing the nested if-else statements with a switch statement. Ensures proper initialization of efuse values based on the SOC type.Signed-off-by Anand Moon <[email protected]>---
v5: None
v4: None
v3: Improve the logic to convert if/else to switch--- drivers/thermal/samsung/exynos_tmu.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)drivers/thermal/samsung/exynos_tmu.c +10
-3@@ -899,12 +899,23 @@ static int exynos_map_dt_data(struct platform_device *pdev) data->gain =8 ; data->reference_voltage =16 ; data->efuse_value =55 ; -if (data->soc !=SOC_ARCH_EXYNOS5420 && - data->soc !=SOC_ARCH_EXYNOS5420_TRIMINFO ) + data->max_efuse_value =100 ; +switch (data->soc) { +case SOC_ARCH_EXYNOS3250 : +case SOC_ARCH_EXYNOS4412 : +case SOC_ARCH_EXYNOS5250 : +case SOC_ARCH_EXYNOS5260 : data->min_efuse_value =40 ; -else +break ; +case SOC_ARCH_EXYNOS5420 : +case SOC_ARCH_EXYNOS5420_TRIMINFO : + data->min_efuse_value =16 ;
drivers/thermal/samsung/exynos_tmu.c static int exynos_map_dt_data(struct platform_device *pdev) · line 921
Quoted 10 lines
drivers/thermal/samsung/exynos_tmu.c +5
-1+ data->max_efuse_value =76 ; +break ; +default : data->min_efuse_value =0 ; - data->max_efuse_value =100 ; +break ; + }break ;case SOC_ARCH_EXYNOS5433 : data->tmu_set_low_temp = exynos5433_tmu_set_low_temp;
I should have added that in earlier version: LGTM,
Re: [PATCH v5 2/3] drivers/thermal/exymos: Remove redundant IS_ERR() checks for clk_sec clock
In reply to Anand MoonQuoted 29 lines · Anand Moon
Remove unnecessary
IS_ERR()checks for theclk_secclock, theclk_enable()andclk_disable()functions can handle NULL clock pointers, so the additional checks are redundant and have been removed to simplify the code.Signed-off-by Anand Moon <[email protected]>---
v5: None
v4: dropIE_ERR()forclk_unprepare()as its handle in earlier code.
v3: improve the commit message.--- drivers/thermal/samsung/exynos_tmu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/thermal/samsung/exynos_tmu.c +1
-2@@ -258,8 +258,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)mutex_lock (&data->lock);clk_enable (data->clk); -if (!IS_ERR (data->clk_sec)) -clk_enable (data->clk_sec); +clk_enable (data->clk_sec); status =readb (data->base +EXYNOS_TMU_REG_STATUS );if (!status) {
drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_initialize(struct platform_device *pdev) · line 274
Quoted 9 lines
drivers/thermal/samsung/exynos_tmu.c +1
-2@@ -269,8 +268,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev) data->tmu_clear_irqs (data); } -if (!IS_ERR (data->clk_sec)) -clk_disable (data->clk_sec); +clk_disable (data->clk_sec);clk_disable (data->clk);mutex_unlock (&data->lock);
Re: [PATCH v5 1/3] drivers/thermal/exynos: Refactor clk_sec initialization inside SOC-specific case
In reply to Anand MoonQuoted 85 lines · Anand Moon
Refactor the initialization of the
clk_secclock to be inside theSOC_ARCH_EXYNOS5420_TRIMINFOcase. It ensures that theclk_secclock is only initialized for the specified SOC and not for other SOCs, thereby simplifying the code. Theclk_secclock is used by the TMU for GPU on the Exynos 542x platform.Removed redundant
IS_ERR()checks for theclk_secclock since error handling is already managed internally byclk_unprepare()functions.Signed-off-by Anand Moon <[email protected]>---
v5: None
v4: Fix the aligment of code clk forclk_preparein proper if/else block.
update the commit forclk_secused.
checked to goto clean up all the clks are proper.
dropIS_ERR()check forclk_sec.
v3: improve the commit message.--- drivers/thermal/samsung/exynos_tmu.c | 37 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 19 deletions(-)drivers/thermal/samsung/exynos_tmu.c +17
-17@@ -1037,29 +1037,30 @@ static int exynos_tmu_probe(struct platform_device *pdev)return ret; data->clk =devm_clk_get (dev,"tmu_apbif" ); -if (IS_ERR (data->clk)) +if (IS_ERR (data->clk)) {return dev_err_probe (dev,PTR_ERR (data->clk),"Failed to get clock\n" ); - - data->clk_sec =devm_clk_get (dev,"tmu_triminfo_apbif" ); -if (IS_ERR (data->clk_sec)) { -if (data->soc ==SOC_ARCH_EXYNOS5420_TRIMINFO ) -return dev_err_probe (dev,PTR_ERR (data->clk_sec), -"Failed to get triminfo clock\n" ); }else { - ret =clk_prepare (data->clk_sec); + ret =clk_prepare (data->clk);if (ret) {dev_err (dev,"Failed to get clock\n" );return ret; } } - ret =clk_prepare (data->clk); -if (ret) { -dev_err (dev,"Failed to get clock\n" ); - goto err_clk_sec; - } -switch (data->soc) { +case SOC_ARCH_EXYNOS5420_TRIMINFO : + data->clk_sec =devm_clk_get (dev,"tmu_triminfo_apbif" ); +if (IS_ERR (data->clk_sec)) { + ret =dev_err_probe (dev,PTR_ERR (data->clk_sec), +"Failed to get clk_sec clock\n" ); + goto err_clk; + } + ret =clk_prepare (data->clk_sec); +if (ret) { +dev_err (dev,"Failed to prepare clk_sec clock\n" ); + goto err_clk_sec; + } +break ;case SOC_ARCH_EXYNOS5433 :case SOC_ARCH_EXYNOS7 : data->sclk =devm_clk_get (dev,"tmu_sclk" );@@ -1112,11 +1113,10 @@ static int exynos_tmu_probe(struct platform_device *pdev) err_sclk:clk_disable_unprepare (data->sclk); +err_clk_sec: +clk_unprepare (data->clk_sec); err_clk:clk_unprepare (data->clk); -err_clk_sec: -if (!IS_ERR (data->clk_sec)) -clk_unprepare (data->clk_sec);return ret; }
drivers/thermal/samsung/exynos_tmu.c static void exynos_tmu_remove(struct platform_device *pdev) · line 1134
Quoted 9 lines
drivers/thermal/samsung/exynos_tmu.c +1
-2@@ -1128,8 +1128,7 @@ static void exynos_tmu_remove(struct platform_device *pdev)clk_disable_unprepare (data->sclk);clk_unprepare (data->clk); -if (!IS_ERR (data->clk_sec)) -clk_unprepare (data->clk_sec); +clk_unprepare (data->clk_sec); }#ifdef CONFIG_PM_SLEEP
It looks good. I've missed the v4 where you addressed my comments.
Re: [PATCH v5 1/3] drivers/thermal/exynos: Refactor clk_sec initialization inside SOC-specific case
In reply to Anand MoonQuoted 26 lines · Anand Moon
Refactor the initialization of the
clk_secclock to be inside theSOC_ARCH_EXYNOS5420_TRIMINFOcase. It ensures that theclk_secclock is only initialized for the specified SOC and not for other SOCs, thereby simplifying the code. Theclk_secclock is used by the TMU for GPU on the Exynos 542x platform.Removed redundant
IS_ERR()checks for theclk_secclock since error handling is already managed internally byclk_unprepare()functions.Signed-off-by Anand Moon <[email protected]>---
v5: None
v4: Fix the aligment of code clk forclk_preparein proper if/else block.
update the commit forclk_secused.
checked to goto clean up all the clks are proper.
dropIS_ERR()check forclk_sec.
v3: improve the commit message.--- drivers/thermal/samsung/exynos_tmu.c | 37 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 19 deletions(-)drivers/thermal/samsung/exynos_tmu.c +0
-0
drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_probe(struct platform_device *pdev) · line 1041
Quoted 6 lines
drivers/thermal/samsung/exynos_tmu.c +1
-1@@ -1037,29 +1037,30 @@ static int exynos_tmu_probe(struct platform_device *pdev)return ret; data->clk =devm_clk_get (dev,"tmu_apbif" ); -if (IS_ERR (data->clk)) +if (IS_ERR (data->clk)) {return dev_err_probe (dev,PTR_ERR (data->clk),"Failed to get clock\n" );
As this branch returns, the else block can be removed.
if (IS_ERR(data->clk))
return dev_err_probe(dev, PTR_ERR(data->clk), "Failed to get clock\n");
ret = clk_prepare(data->clk);
if (ret) {
...
}May be worth to group both calls with devm_clk_get_enabled()
Quoted 20 lines
drivers/thermal/samsung/exynos_tmu.c +1
-12- - data->clk_sec =devm_clk_get (dev,"tmu_triminfo_apbif" ); -if (IS_ERR (data->clk_sec)) { -if (data->soc ==SOC_ARCH_EXYNOS5420_TRIMINFO ) -return dev_err_probe (dev,PTR_ERR (data->clk_sec), -"Failed to get triminfo clock\n" ); }else { - ret =clk_prepare (data->clk_sec); + ret =clk_prepare (data->clk);if (ret) {dev_err (dev,"Failed to get clock\n" );return ret; } } - ret =clk_prepare (data->clk); -if (ret) { -dev_err (dev,"Failed to get clock\n" ); - goto err_clk_sec; - }
drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_probe(struct platform_device *pdev) · line 1058
Quoted 10 lines
drivers/thermal/samsung/exynos_tmu.c +8
-1-switch (data->soc) { +case SOC_ARCH_EXYNOS5420_TRIMINFO : + data->clk_sec =devm_clk_get (dev,"tmu_triminfo_apbif" ); +if (IS_ERR (data->clk_sec)) { + ret =dev_err_probe (dev,PTR_ERR (data->clk_sec), +"Failed to get clk_sec clock\n" ); + goto err_clk; + } + ret =clk_prepare (data->clk_sec);
Same comment, devm_clk_get_enabled()
Quoted 9 lines
drivers/thermal/samsung/exynos_tmu.c +5
-0+if (ret) { +dev_err (dev,"Failed to prepare clk_sec clock\n" ); + goto err_clk_sec; + } +break ;case SOC_ARCH_EXYNOS5433 :case SOC_ARCH_EXYNOS7 : data->sclk =devm_clk_get (dev,"tmu_sclk" );
drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_probe(struct platform_device *pdev) · line 1119
Quoted 10 lines
drivers/thermal/samsung/exynos_tmu.c +2
-3@@ -1112,11 +1113,10 @@ static int exynos_tmu_probe(struct platform_device *pdev) err_sclk:clk_disable_unprepare (data->sclk); +err_clk_sec: +clk_unprepare (data->clk_sec); err_clk:clk_unprepare (data->clk); -err_clk_sec: -if (!IS_ERR (data->clk_sec)) -clk_unprepare (data->clk_sec);
With devm_ variant those labels should go away
Quoted 16 lines
drivers/thermal/samsung/exynos_tmu.c +1
-2return ret; }@@ -1128,8 +1128,7 @@ static void exynos_tmu_remove(struct platform_device *pdev)clk_disable_unprepare (data->sclk);clk_unprepare (data->clk); -if (!IS_ERR (data->clk_sec)) -clk_unprepare (data->clk_sec); +clk_unprepare (data->clk_sec); }#ifdef CONFIG_PM_SLEEP Signature · 1 line
2.49.0
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Re: [PATCH v5 2/3] drivers/thermal/exymos: Remove redundant IS_ERR() checks for clk_sec clock
In reply to Anand MoonQuoted 6 lines · Anand Moon
Remove unnecessary
IS_ERR()checks for theclk_secclock, theclk_enable()andclk_disable()functions can handle NULL clock pointers, so the additional checks are redundant and have been removed to simplify the code.Signed-off-by Anand Moon <[email protected]>
Typo in the subject: s/exymos/exynos/
Quoted 23 lines
---
v5: None
v4: dropIE_ERR()forclk_unprepare()as its handle in earlier code.
v3: improve the commit message.--- drivers/thermal/samsung/exynos_tmu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/thermal/samsung/exynos_tmu.c +1
-2@@ -258,8 +258,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)mutex_lock (&data->lock);clk_enable (data->clk); -if (!IS_ERR (data->clk_sec)) -clk_enable (data->clk_sec); +clk_enable (data->clk_sec); status =readb (data->base +EXYNOS_TMU_REG_STATUS );if (!status) {
drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_initialize(struct platform_device *pdev) · line 273
Quoted 8 lines
drivers/thermal/samsung/exynos_tmu.c +1
-2@@ -269,8 +268,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev) data->tmu_clear_irqs (data); } -if (!IS_ERR (data->clk_sec)) -clk_disable (data->clk_sec); +clk_disable (data->clk_sec);clk_disable (data->clk);mutex_unlock (&data->lock);
To be replaced by devm_clk_get_enabled() ?
Quoted 4 lines
Signature · 2 lines
-- 2.49.0
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Re: [PATCH v5 3/3] drivers/thermal/exymos: Fixed the efuse min max value for exynos5422
In reply to Anand MoonQuoted 8 lines · Anand Moon
As per Exynos5422 user manual e-Fuse range min~max range is 16~76. if e-Fuse value is out of this range, then thermal sensor may not sense thermal data properly. Refactors the efuse value initialization logic within
exynos_map_dt_datafunction by replacing the nested if-else statements with a switch statement. Ensures proper initialization of efuse values based on the SOC type.Signed-off-by Anand Moon <[email protected]>
Same subject typo: s/exymos/exynos/
Quoted 30 lines
---
v5: None
v4: None
v3: Improve the logic to convert if/else to switch--- drivers/thermal/samsung/exynos_tmu.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)drivers/thermal/samsung/exynos_tmu.c +10
-3@@ -899,12 +899,23 @@ static int exynos_map_dt_data(struct platform_device *pdev) data->gain =8 ; data->reference_voltage =16 ; data->efuse_value =55 ; -if (data->soc !=SOC_ARCH_EXYNOS5420 && - data->soc !=SOC_ARCH_EXYNOS5420_TRIMINFO ) + data->max_efuse_value =100 ; +switch (data->soc) { +case SOC_ARCH_EXYNOS3250 : +case SOC_ARCH_EXYNOS4412 : +case SOC_ARCH_EXYNOS5250 : +case SOC_ARCH_EXYNOS5260 : data->min_efuse_value =40 ; -else +break ; +case SOC_ARCH_EXYNOS5420 : +case SOC_ARCH_EXYNOS5420_TRIMINFO : + data->min_efuse_value =16 ;
drivers/thermal/samsung/exynos_tmu.c static int exynos_map_dt_data(struct platform_device *pdev) · line 921
Quoted 10 lines
drivers/thermal/samsung/exynos_tmu.c +5
-1+ data->max_efuse_value =76 ; +break ; +default : data->min_efuse_value =0 ; - data->max_efuse_value =100 ; +break ; + }break ;case SOC_ARCH_EXYNOS5433 : data->tmu_set_low_temp = exynos5433_tmu_set_low_temp;
Thanks for taking care of cleaning up this portion of code. IMO, it would be interesting to go a bit further in the house keeping by replacing this big switch with a set of structures stored as __init sections. The initialization finds the right structure and does a structure copy to 'data'.
It is up to you to do this change or not.
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Re: [PATCH v5 1/3] drivers/thermal/exynos: Refactor clk_sec initialization inside SOC-specific case
In reply to Daniel LezcanoHi Daniel,
Quoted 37 lines · Daniel Lezcano
Quoted 26 lines · Anand Moon
Refactor the initialization of the
clk_secclock to be inside theSOC_ARCH_EXYNOS5420_TRIMINFOcase. It ensures that theclk_secclock is only initialized for the specified SOC and not for other SOCs, thereby simplifying the code. Theclk_secclock is used by the TMU for GPU on the Exynos 542x platform.Removed redundant
IS_ERR()checks for theclk_secclock since error handling is already managed internally byclk_unprepare()functions.Signed-off-by Anand Moon <[email protected]>---
v5: None
v4: Fix the aligment of code clk forclk_preparein proper if/else block.
update the commit forclk_secused.
checked to goto clean up all the clks are proper.
dropIS_ERR()check forclk_sec.
v3: improve the commit message.--- drivers/thermal/samsung/exynos_tmu.c | 37 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 19 deletions(-)drivers/thermal/samsung/exynos_tmu.c +0
-0drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_probe(struct platform_device *pdev) · line 1041
Quoted 6 lines
drivers/thermal/samsung/exynos_tmu.c +1
-1@@ -1037,29 +1037,30 @@ static int exynos_tmu_probe(struct platform_device *pdev)return ret; data->clk =devm_clk_get (dev,"tmu_apbif" ); -if (IS_ERR (data->clk)) +if (IS_ERR (data->clk)) {return dev_err_probe (dev,PTR_ERR (data->clk),"Failed to get clock\n" );As this branch returns, the else block can be removed.
Quoted 8 lines
if (IS_ERR(data->clk))
return dev_err_probe(dev, PTR_ERR(data->clk), "Failed to get clock\n");
ret = clk_prepare(data->clk);
if (ret) {
...
}Earlier I got this review comment on this.
[0] https://patchwork.kernel.org/project/linux-samsung-soc/patch/[email protected]/
I will try to fix this in next vrsion.
Quoted 1 line
May be worth to group both calls with
devm_clk_get_enabled()
Earlier, I attempted to change the clock ABI, but it didn't work.
[1] https://lore.kernel.org/all/[email protected]/
If you're okay with changing this, I'll update it in the next version.
Quoted 24 lines
Quoted 24 lines
drivers/thermal/samsung/exynos_tmu.c +3
-13- - data->clk_sec =devm_clk_get (dev,"tmu_triminfo_apbif" ); -if (IS_ERR (data->clk_sec)) { -if (data->soc ==SOC_ARCH_EXYNOS5420_TRIMINFO ) -return dev_err_probe (dev,PTR_ERR (data->clk_sec), -"Failed to get triminfo clock\n" ); }else { - ret =clk_prepare (data->clk_sec); + ret =clk_prepare (data->clk);if (ret) {dev_err (dev,"Failed to get clock\n" );return ret; } } - ret =clk_prepare (data->clk); -if (ret) { -dev_err (dev,"Failed to get clock\n" ); - goto err_clk_sec; - } -switch (data->soc) { +case SOC_ARCH_EXYNOS5420_TRIMINFO : + data->clk_sec =devm_clk_get (dev,"tmu_triminfo_apbif" );
Quoted 8 lines
drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_probe(struct platform_device *pdev) · line 1058
Quoted 6 lines
drivers/thermal/samsung/exynos_tmu.c +6
-0+if (IS_ERR (data->clk_sec)) { + ret =dev_err_probe (dev,PTR_ERR (data->clk_sec), +"Failed to get clk_sec clock\n" ); + goto err_clk; + } + ret =clk_prepare (data->clk_sec);Same comment,
devm_clk_get_enabled()
If you're okay with changing this, I'll update it in the next version.
Quoted 11 lines
Quoted 11 lines
drivers/thermal/samsung/exynos_tmu.c +5
-0+if (ret) { +dev_err (dev,"Failed to prepare clk_sec clock\n" ); + goto err_clk_sec; + } +break ;case SOC_ARCH_EXYNOS5433 :case SOC_ARCH_EXYNOS7 : data->sclk =devm_clk_get (dev,"tmu_sclk" );@@ -1112,11 +1113,10 @@ static int exynos_tmu_probe(struct platform_device *pdev)
Quoted 11 lines
drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_probe(struct platform_device *pdev) · line 1119
Quoted 9 lines
drivers/thermal/samsung/exynos_tmu.c +2
-3err_sclk:clk_disable_unprepare (data->sclk); +err_clk_sec: +clk_unprepare (data->clk_sec); err_clk:clk_unprepare (data->clk); -err_clk_sec: -if (!IS_ERR (data->clk_sec)) -clk_unprepare (data->clk_sec);With
devm_variant those labels should go away
Correct.
Thanks
-Anand
Quoted 25 lines
Quoted 15 lines
drivers/thermal/samsung/exynos_tmu.c +1
-3return ret; }@@ -1128,8 +1128,7 @@ static void exynos_tmu_remove(struct platform_device *pdev)clk_disable_unprepare (data->sclk);clk_unprepare (data->clk); -if (!IS_ERR (data->clk_sec)) -clk_unprepare (data->clk_sec); +clk_unprepare (data->clk_sec); }#ifdef CONFIG_PM_SLEEP --Quoted 2 lines
2.49.0
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
Re: [PATCH v5 2/3] drivers/thermal/exymos: Remove redundant IS_ERR() checks for clk_sec clock
In reply to Daniel LezcanoHi Daniel,
Quoted 11 lines · Daniel Lezcano
Quoted 6 lines · Anand Moon
Remove unnecessary
IS_ERR()checks for theclk_secclock, theclk_enable()andclk_disable()functions can handle NULL clock pointers, so the additional checks are redundant and have been removed to simplify the code.Signed-off-by Anand Moon <[email protected]>Typo in the subject: s/exymos/exynos/
Thanks for your review comments.
Opps, I will fix this next version it got skipped.
Thanks
-Anand
Re: [PATCH v5 3/3] drivers/thermal/exymos: Fixed the efuse min max value for exynos5422
In reply to Daniel LezcanoHi Daniel,
Quoted 9 lines · Daniel Lezcano
Quoted 7 lines · Anand Moon
As per Exynos5422 user manual e-Fuse range min~max range is 16~76. if e-Fuse value is out of this range, then thermal sensor may not sense thermal data properly. Refactors the efuse value initialization logic within
exynos_map_dt_datafunction by replacing the nested if-else statements with a switch statement. Ensures proper initialization of efuse values based on the SOC type.
Quoted 3 lines
Quoted 1 line
Signed-off-by Anand Moon <[email protected]>Same subject typo: s/exymos/exynos/
Thanks for your review comments.
Opps, I will fix this next version it got skipped.
Quoted 47 lines
Quoted 31 lines
---
v5: None
v4: None
v3: Improve the logic to convert if/else to switch--- drivers/thermal/samsung/exynos_tmu.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)drivers/thermal/samsung/exynos_tmu.c +10
-3@@ -899,12 +899,23 @@ static int exynos_map_dt_data(struct platform_device *pdev) data->gain =8 ; data->reference_voltage =16 ; data->efuse_value =55 ; -if (data->soc !=SOC_ARCH_EXYNOS5420 && - data->soc !=SOC_ARCH_EXYNOS5420_TRIMINFO ) + data->max_efuse_value =100 ; +switch (data->soc) { +case SOC_ARCH_EXYNOS3250 : +case SOC_ARCH_EXYNOS4412 : +case SOC_ARCH_EXYNOS5250 : +case SOC_ARCH_EXYNOS5260 : data->min_efuse_value =40 ; -else +break ; +case SOC_ARCH_EXYNOS5420 : +case SOC_ARCH_EXYNOS5420_TRIMINFO : + data->min_efuse_value =16 ;drivers/thermal/samsung/exynos_tmu.c static int exynos_map_dt_data(struct platform_device *pdev) · line 921
Quoted 10 lines
drivers/thermal/samsung/exynos_tmu.c +5
-1+ data->max_efuse_value =76 ; +break ; +default : data->min_efuse_value =0 ; - data->max_efuse_value =100 ; +break ; + }break ;case SOC_ARCH_EXYNOS5433 : data->tmu_set_low_temp = exynos5433_tmu_set_low_temp;Thanks for taking care of cleaning up this portion of code. IMO, it would be interesting to go a bit further in the house keeping by replacing this big switch with a set of structures stored as
__initsections. The initialization finds the right structure and does a structure copy to 'data'.
Quoted 1 line
It is up to you to do this change or not.
I'll be sure to check this out.
Thanks
-Anand
Quoted 8 lines
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog