mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH][next] thermal: lvts: make some read-only arrays static const
@ 2023-10-17 17:16 Colin Ian King
  2023-10-17 17:54 ` Daniel Lezcano
  0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2023-10-17 17:16 UTC (permalink / raw)
  To: Rafael J . Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
	Matthias Brugger, AngeloGioacchino Del Regno, linux-pm,
	linux-arm-kernel, linux-mediatek
  Cc: kernel-janitors, linux-kernel

Don't populate the read-only arrays on the stack, instead make them
static const. Make lvts_write_config parameters cmds and nr_cmds
const too.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 drivers/thermal/mediatek/lvts_thermal.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 877a0e5ac3fd..b20e69cb466f 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -308,7 +308,7 @@ static int lvts_get_temp(struct thermal_zone_device *tz, int *temp)
 
 static void lvts_update_irq_mask(struct lvts_ctrl *lvts_ctrl)
 {
-	u32 masks[] = {
+	static const u32 masks[] = {
 		LVTS_MONINT_OFFSET_SENSOR0,
 		LVTS_MONINT_OFFSET_SENSOR1,
 		LVTS_MONINT_OFFSET_SENSOR2,
@@ -400,7 +400,7 @@ static irqreturn_t lvts_ctrl_irq_handler(struct lvts_ctrl *lvts_ctrl)
 {
 	irqreturn_t iret = IRQ_NONE;
 	u32 value;
-	u32 masks[] = {
+	static const u32 masks[] = {
 		LVTS_INT_SENSOR0,
 		LVTS_INT_SENSOR1,
 		LVTS_INT_SENSOR2,
@@ -781,7 +781,7 @@ static int lvts_ctrl_init(struct device *dev, struct lvts_domain *lvts_td,
  * each write in the configuration register must be separated by a
  * delay of 2 us.
  */
-static void lvts_write_config(struct lvts_ctrl *lvts_ctrl, u32 *cmds, int nr_cmds)
+static void lvts_write_config(struct lvts_ctrl *lvts_ctrl, const u32 *cmds, const int nr_cmds)
 {
 	int i;
 
@@ -865,7 +865,8 @@ static int lvts_ctrl_set_enable(struct lvts_ctrl *lvts_ctrl, int enable)
 
 static int lvts_ctrl_connect(struct device *dev, struct lvts_ctrl *lvts_ctrl)
 {
-	u32 id, cmds[] = { 0xC103FFFF, 0xC502FF55 };
+	u32 id;
+	static const u32 cmds[] = { 0xC103FFFF, 0xC502FF55 };
 
 	lvts_write_config(lvts_ctrl, cmds, ARRAY_SIZE(cmds));
 
@@ -889,7 +890,7 @@ static int lvts_ctrl_initialize(struct device *dev, struct lvts_ctrl *lvts_ctrl)
 	/*
 	 * Write device mask: 0xC1030000
 	 */
-	u32 cmds[] = {
+	static const u32 cmds[] = {
 		0xC1030E01, 0xC1030CFC, 0xC1030A8C, 0xC103098D, 0xC10308F1,
 		0xC10307A6, 0xC10306B8, 0xC1030500, 0xC1030420, 0xC1030300,
 		0xC1030030, 0xC10300F6, 0xC1030050, 0xC1030060, 0xC10300AC,
-- 
2.39.2


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

* Re: [PATCH][next] thermal: lvts: make some read-only arrays static const
  2023-10-17 17:16 [PATCH][next] thermal: lvts: make some read-only arrays static const Colin Ian King
@ 2023-10-17 17:54 ` Daniel Lezcano
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Lezcano @ 2023-10-17 17:54 UTC (permalink / raw)
  To: Colin Ian King, Rafael J . Wysocki, Zhang Rui, Lukasz Luba,
	Matthias Brugger, AngeloGioacchino Del Regno, linux-pm,
	linux-arm-kernel, linux-mediatek
  Cc: kernel-janitors, linux-kernel


Hi Colin,

On 17/10/2023 19:16, Colin Ian King wrote:
> Don't populate the read-only arrays on the stack, instead make them
> static const. 

Why ?

> Make lvts_write_config parameters cmds and nr_cmds
> const too.
> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>   drivers/thermal/mediatek/lvts_thermal.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
> index 877a0e5ac3fd..b20e69cb466f 100644
> --- a/drivers/thermal/mediatek/lvts_thermal.c
> +++ b/drivers/thermal/mediatek/lvts_thermal.c
> @@ -308,7 +308,7 @@ static int lvts_get_temp(struct thermal_zone_device *tz, int *temp)
>   
>   static void lvts_update_irq_mask(struct lvts_ctrl *lvts_ctrl)
>   {
> -	u32 masks[] = {
> +	static const u32 masks[] = {
>   		LVTS_MONINT_OFFSET_SENSOR0,
>   		LVTS_MONINT_OFFSET_SENSOR1,
>   		LVTS_MONINT_OFFSET_SENSOR2,
> @@ -400,7 +400,7 @@ static irqreturn_t lvts_ctrl_irq_handler(struct lvts_ctrl *lvts_ctrl)
>   {
>   	irqreturn_t iret = IRQ_NONE;
>   	u32 value;
> -	u32 masks[] = {
> +	static const u32 masks[] = {
>   		LVTS_INT_SENSOR0,
>   		LVTS_INT_SENSOR1,
>   		LVTS_INT_SENSOR2,
> @@ -781,7 +781,7 @@ static int lvts_ctrl_init(struct device *dev, struct lvts_domain *lvts_td,
>    * each write in the configuration register must be separated by a
>    * delay of 2 us.
>    */
> -static void lvts_write_config(struct lvts_ctrl *lvts_ctrl, u32 *cmds, int nr_cmds)
> +static void lvts_write_config(struct lvts_ctrl *lvts_ctrl, const u32 *cmds, const int nr_cmds)
>   {
>   	int i;
>   
> @@ -865,7 +865,8 @@ static int lvts_ctrl_set_enable(struct lvts_ctrl *lvts_ctrl, int enable)
>   
>   static int lvts_ctrl_connect(struct device *dev, struct lvts_ctrl *lvts_ctrl)
>   {
> -	u32 id, cmds[] = { 0xC103FFFF, 0xC502FF55 };
> +	u32 id;
> +	static const u32 cmds[] = { 0xC103FFFF, 0xC502FF55 };
>   
>   	lvts_write_config(lvts_ctrl, cmds, ARRAY_SIZE(cmds));
>   
> @@ -889,7 +890,7 @@ static int lvts_ctrl_initialize(struct device *dev, struct lvts_ctrl *lvts_ctrl)
>   	/*
>   	 * Write device mask: 0xC1030000
>   	 */
> -	u32 cmds[] = {
> +	static const u32 cmds[] = {
>   		0xC1030E01, 0xC1030CFC, 0xC1030A8C, 0xC103098D, 0xC10308F1,
>   		0xC10307A6, 0xC10306B8, 0xC1030500, 0xC1030420, 0xC1030300,
>   		0xC1030030, 0xC10300F6, 0xC1030050, 0xC1030060, 0xC10300AC,

-- 
<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


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

end of thread, other threads:[~2023-10-17 17:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-17 17:16 [PATCH][next] thermal: lvts: make some read-only arrays static const Colin Ian King
2023-10-17 17:54 ` Daniel Lezcano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®