From 0c0d49229db9ef68a5ea9267296e900ac7274da8 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Mon, 5 Apr 2021 13:02:45 +0200 Subject: [PATCH] soc/intel: Replace open-coded buffer length calculation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use `sizeof(value)` instead of manually calculating the buffer size. Change-Id: Ibe49e40b1c4f2c0b661d94e59059a95bdb204197 Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/coreboot/+/52107 Tested-by: build bot (Jenkins) Reviewed-by: Felix Singer Reviewed-by: Michael Niewöhner --- src/soc/intel/alderlake/chip.c | 6 ++---- src/soc/intel/cannonlake/gpio_common.c | 6 ++---- src/soc/intel/elkhartlake/chip.c | 6 ++---- src/soc/intel/icelake/chip.c | 6 ++---- src/soc/intel/jasperlake/chip.c | 6 ++---- src/soc/intel/tigerlake/chip.c | 6 ++---- 6 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/soc/intel/alderlake/chip.c b/src/soc/intel/alderlake/chip.c index dc5484560067..f4d02412eb29 100644 --- a/src/soc/intel/alderlake/chip.c +++ b/src/soc/intel/alderlake/chip.c @@ -116,11 +116,9 @@ static void soc_fill_gpio_pm_configuration(void) const config_t *config = config_of_soc(); if (config->gpio_override_pm) - memcpy(value, config->gpio_pm, sizeof(uint8_t) * - TOTAL_GPIO_COMM); + memcpy(value, config->gpio_pm, sizeof(value)); else - memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(uint8_t) * - TOTAL_GPIO_COMM); + memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(value)); gpio_pm_configure(value, TOTAL_GPIO_COMM); } diff --git a/src/soc/intel/cannonlake/gpio_common.c b/src/soc/intel/cannonlake/gpio_common.c index 2c2dcdbabd28..4307260cd1f3 100644 --- a/src/soc/intel/cannonlake/gpio_common.c +++ b/src/soc/intel/cannonlake/gpio_common.c @@ -14,11 +14,9 @@ void soc_gpio_pm_configuration(void) const config_t *config = config_of_soc(); if (config->gpio_override_pm) - memcpy(value, config->gpio_pm, sizeof(uint8_t) * - TOTAL_GPIO_COMM); + memcpy(value, config->gpio_pm, sizeof(value)); else - memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(uint8_t) * - TOTAL_GPIO_COMM); + memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(value)); gpio_pm_configure(value, TOTAL_GPIO_COMM); } diff --git a/src/soc/intel/elkhartlake/chip.c b/src/soc/intel/elkhartlake/chip.c index 3917ea0af8d1..ad634819f283 100644 --- a/src/soc/intel/elkhartlake/chip.c +++ b/src/soc/intel/elkhartlake/chip.c @@ -105,11 +105,9 @@ static void soc_fill_gpio_pm_configuration(void) const config_t *config = config_of_soc(); if (config->gpio_override_pm) - memcpy(value, config->gpio_pm, sizeof(uint8_t) * - TOTAL_GPIO_COMM); + memcpy(value, config->gpio_pm, sizeof(value)); else - memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(uint8_t) * - TOTAL_GPIO_COMM); + memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(value)); gpio_pm_configure(value, TOTAL_GPIO_COMM); } diff --git a/src/soc/intel/icelake/chip.c b/src/soc/intel/icelake/chip.c index 32b183009634..05f42b4e7a86 100644 --- a/src/soc/intel/icelake/chip.c +++ b/src/soc/intel/icelake/chip.c @@ -95,11 +95,9 @@ static void soc_fill_gpio_pm_configuration(void) const config_t *config = config_of_soc(); if (config->gpio_override_pm) - memcpy(value, config->gpio_pm, sizeof(uint8_t) * - TOTAL_GPIO_COMM); + memcpy(value, config->gpio_pm, sizeof(value)); else - memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(uint8_t) * - TOTAL_GPIO_COMM); + memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(value)); gpio_pm_configure(value, TOTAL_GPIO_COMM); } diff --git a/src/soc/intel/jasperlake/chip.c b/src/soc/intel/jasperlake/chip.c index ea29fd8b43e6..a8e3c8812822 100644 --- a/src/soc/intel/jasperlake/chip.c +++ b/src/soc/intel/jasperlake/chip.c @@ -111,11 +111,9 @@ static void soc_fill_gpio_pm_configuration(void) const config_t *config = config_of_soc(); if (config->gpio_override_pm) - memcpy(value, config->gpio_pm, sizeof(uint8_t) * - TOTAL_GPIO_COMM); + memcpy(value, config->gpio_pm, sizeof(value)); else - memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(uint8_t) * - TOTAL_GPIO_COMM); + memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(value)); gpio_pm_configure(value, TOTAL_GPIO_COMM); } diff --git a/src/soc/intel/tigerlake/chip.c b/src/soc/intel/tigerlake/chip.c index 1affcce07896..eefc408bc2e5 100644 --- a/src/soc/intel/tigerlake/chip.c +++ b/src/soc/intel/tigerlake/chip.c @@ -116,11 +116,9 @@ static void soc_fill_gpio_pm_configuration(void) const config_t *config = config_of_soc(); if (config->gpio_override_pm) - memcpy(value, config->gpio_pm, sizeof(uint8_t) * - TOTAL_GPIO_COMM); + memcpy(value, config->gpio_pm, sizeof(value)); else - memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(uint8_t) * - TOTAL_GPIO_COMM); + memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(value)); gpio_pm_configure(value, TOTAL_GPIO_COMM); }