Re: [PATCH] HID: intel-thc-hid: intel-thc: make read-only arrays static const

From: Jiri Kosina
Date: Thu Apr 24 2025 - 06:15:06 EST


On Wed, 2 Apr 2025, Colin Ian King wrote:

> Don't populate the read-only arrays frequency and frequency_div on
> the stack at run time, instead make them static const.
>
> Signed-off-by: Colin Ian King <colin.i.king@xxxxxxxxx>
> ---
> drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c
> index 4fc78b5a04b5..c105df7f6c87 100644
> --- a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c
> +++ b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c
> @@ -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,

Applied, thanks.

--
Jiri Kosina
SUSE Labs