linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: rcar_gen3_thermal: Do not shadow thcode variable
@ 2020-05-15 13:56 Niklas Söderlund
  2020-05-15 14:00 ` Geert Uytterhoeven
  0 siblings, 1 reply; 2+ messages in thread
From: Niklas Söderlund @ 2020-05-15 13:56 UTC (permalink / raw)
  To: linux-pm; +Cc: linux-renesas-soc, Niklas Söderlund

The function rcar_gen3_thermal_calc_coefs() takes an argument called
'thcode' which shadows the static global 'thcode' variable. This is not
harmful but bad for readability and is harmful for planed changes to the
driver. The THCODE values should be read from hardware fuses if they are
available and only fallback to the global 'thcode' variable if they are
not fused.

Rename the global 'thcode' variable to 'thcodes' to avoid shadowing the
symbol in functions that takes it as an argument.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/thermal/rcar_gen3_thermal.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c
index 58fe7c1ef00b1270..bb4f5b42beb943e3 100644
--- a/drivers/thermal/rcar_gen3_thermal.c
+++ b/drivers/thermal/rcar_gen3_thermal.c
@@ -63,7 +63,7 @@
 #define TSC_MAX_NUM	3
 
 /* default THCODE values if FUSEs are missing */
-static const int thcode[TSC_MAX_NUM][3] = {
+static const int thcodes[TSC_MAX_NUM][3] = {
 	{ 3397, 2800, 2221 },
 	{ 3393, 2795, 2216 },
 	{ 3389, 2805, 2237 },
@@ -172,7 +172,7 @@ static int rcar_gen3_thermal_get_temp(void *devdata, int *temp)
 	/* Read register and convert to mili Celsius */
 	reg = rcar_gen3_thermal_read(tsc, REG_GEN3_TEMP) & CTEMP_MASK;
 
-	if (reg <= thcode[tsc->id][1])
+	if (reg <= thcodes[tsc->id][1])
 		val = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b1,
 				tsc->coef.a1);
 	else
@@ -430,7 +430,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
 		priv->tscs[i] = tsc;
 
 		priv->thermal_init(tsc);
-		rcar_gen3_thermal_calc_coefs(tsc, ptat, thcode[i],
+		rcar_gen3_thermal_calc_coefs(tsc, ptat, thcodes[i],
 					     *rcar_gen3_ths_tj_1);
 
 		zone = devm_thermal_zone_of_sensor_register(dev, i, tsc,
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] thermal: rcar_gen3_thermal: Do not shadow thcode variable
  2020-05-15 13:56 [PATCH] thermal: rcar_gen3_thermal: Do not shadow thcode variable Niklas Söderlund
@ 2020-05-15 14:00 ` Geert Uytterhoeven
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2020-05-15 14:00 UTC (permalink / raw)
  To: Niklas Söderlund; +Cc: Linux PM list, Linux-Renesas

Hi Niklas,

Thanks for your patch!

On Fri, May 15, 2020 at 3:56 PM Niklas Söderlund
<niklas.soderlund+renesas@ragnatech.se> wrote:
> The function rcar_gen3_thermal_calc_coefs() takes an argument called
> 'thcode' which shadows the static global 'thcode' variable. This is not
> harmful but bad for readability and is harmful for planed changes to the

planned

> driver. The THCODE values should be read from hardware fuses if they are
> available and only fallback to the global 'thcode' variable if they are
> not fused.
>
> Rename the global 'thcode' variable to 'thcodes' to avoid shadowing the
> symbol in functions that takes it as an argument.

take

>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-15 14:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-15 13:56 [PATCH] thermal: rcar_gen3_thermal: Do not shadow thcode variable Niklas Söderlund
2020-05-15 14:00 ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).