HID: intel-thc-hid: intel-thc: make read-only arrays static const
Subsystems (3)
PATCH 1/1 HID: intel-thc-hid: intel-thc: make read-only arrays static const
Don't populate the read-only arrays frequency and frequency_div on the stack at run time, instead make them static const.
--- drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c +2 -2
@@ -1121,7 +1121,7 @@ EXPORT_SYMBOL_NS_GPL(thc_port_select, "INTEL_THC");static u8 thc_get_spi_freq_div_val (struct thc_device *dev,u32 spi_freq_val) { -int frequency[] = { +static const int frequency[] = {THC_SPI_FREQUENCY_7M ,THC_SPI_FREQUENCY_15M ,THC_SPI_FREQUENCY_17M ,
@@ -1130,7 +1130,7 @@ static u8 thc_get_spi_freq_div_val(struct thc_device *dev, u32 spi_freq_val)THC_SPI_FREQUENCY_31M , THC_SPI_FREQUENCY_41M, }; -u8 frequency_div[] = { +static const u8 frequency_div[] = {THC_SPI_FRQ_DIV_2 ,THC_SPI_FRQ_DIV_1 , THC_SPI_FRQ_DIV_7,
Signature · 1 line
2.49.0
Quoted 43 lines
-----Original Message-----
From: Colin Ian King <[email protected]>
Sent: Wednesday, April 2, 2025 7:21 PM
To: Xu, Even <[email protected]>; Sun, Xinpeng <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>; Srinivas Pandruvada <[email protected]>; Mark Pearson <mpearson- [email protected]>; [email protected]
Cc: [email protected]; [email protected]
Subject: [PATCH] HID: intel-thc-hid: intel-thc: make read-only arrays static constDon't populate the read-only arrays frequency and
frequency_divon the stack at run time, instead make them static const.Signed-off-by Colin Ian King <[email protected]>--- drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/hid/intel- renamed from drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c +0
-0
thc-hid/intel-thc/intel-thc-dev.c
index4fc78b5a04b5..c105df7f6c87100644drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c +2
-2@@ -1121,7 +1121,7 @@ EXPORT_SYMBOL_NS_GPL(thc_port_select, "INTEL_THC");static u8 thc_get_spi_freq_div_val (struct thc_device *dev,u32 spi_freq_val) { -int frequency[] = { +static const int frequency[] = {THC_SPI_FREQUENCY_7M ,THC_SPI_FREQUENCY_15M ,THC_SPI_FREQUENCY_17M ,@@ -1130,7 +1130,7 @@ static u8 thc_get_spi_freq_div_val(struct thc_device *dev, u32 spi_freq_val)THC_SPI_FREQUENCY_31M , THC_SPI_FREQUENCY_41M, }; -u8 frequency_div[] = { +static const u8 frequency_div[] = {THC_SPI_FRQ_DIV_2 ,THC_SPI_FRQ_DIV_1 ,
Quoted 1 line
THC_SPI_FRQ_DIV_7,
Thanks for the improvement!
LGTM.
Quoted 2 lines
--
2.49.0
Quoted 22 lines · Colin Ian King
Don't populate the read-only arrays frequency and
frequency_divon the stack at run time, instead make them static const.Signed-off-by Colin Ian King <[email protected]>--- drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c +1
-1@@ -1121,7 +1121,7 @@ EXPORT_SYMBOL_NS_GPL(thc_port_select, "INTEL_THC");static u8 thc_get_spi_freq_div_val (struct thc_device *dev,u32 spi_freq_val) { -int frequency[] = { +static const int frequency[] = {THC_SPI_FREQUENCY_7M ,THC_SPI_FREQUENCY_15M ,THC_SPI_FREQUENCY_17M ,
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c static u8 thc_get_spi_freq_div_val(struct thc_device *dev, u32 spi_freq_val) · line 1136
Quoted 8 lines
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c +1
-1@@ -1130,7 +1130,7 @@ static u8 thc_get_spi_freq_div_val(struct thc_device *dev, u32 spi_freq_val)THC_SPI_FREQUENCY_31M , THC_SPI_FREQUENCY_41M, }; -u8 frequency_div[] = { +static const u8 frequency_div[] = {THC_SPI_FRQ_DIV_2 ,THC_SPI_FRQ_DIV_1 , THC_SPI_FRQ_DIV_7,
Applied, thanks.
Signature · 2 lines
Jiri Kosina SUSE Labs