From fa29170aa72ca35059cb9875e33c3c41b5d958e7 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 30 Jun 2014 07:39:51 -0600 Subject: [PATCH] Make variable definitions 'static const' when possible to save RAM usage. From Kosma Moczek --- arch/arm/src/stm32/stm32_i2c.c | 10 +++++----- arch/arm/src/stm32/stm32_i2c_alt.c | 10 +++++----- libc/time/lib_daysbeforemonth.c | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/arm/src/stm32/stm32_i2c.c b/arch/arm/src/stm32/stm32_i2c.c index 4036f50562..fdbdcd874a 100644 --- a/arch/arm/src/stm32/stm32_i2c.c +++ b/arch/arm/src/stm32/stm32_i2c.c @@ -278,7 +278,7 @@ struct stm32_i2c_priv_s struct stm32_i2c_inst_s { - struct i2c_ops_s *ops; /* Standard I2C operations */ + const struct i2c_ops_s *ops; /* Standard I2C operations */ struct stm32_i2c_priv_s *priv; /* Common driver private data structure */ uint32_t frequency; /* Frequency used in this instantiation */ @@ -384,7 +384,7 @@ static const struct stm32_i2c_config_s stm32_i2c1_config = #endif }; -struct stm32_i2c_priv_s stm32_i2c1_priv = +static struct stm32_i2c_priv_s stm32_i2c1_priv = { .config = &stm32_i2c1_config, .refs = 0, @@ -413,7 +413,7 @@ static const struct stm32_i2c_config_s stm32_i2c2_config = #endif }; -struct stm32_i2c_priv_s stm32_i2c2_priv = +static struct stm32_i2c_priv_s stm32_i2c2_priv = { .config = &stm32_i2c2_config, .refs = 0, @@ -442,7 +442,7 @@ static const struct stm32_i2c_config_s stm32_i2c3_config = #endif }; -struct stm32_i2c_priv_s stm32_i2c3_priv = +static struct stm32_i2c_priv_s stm32_i2c3_priv = { .config = &stm32_i2c3_config, .refs = 0, @@ -458,7 +458,7 @@ struct stm32_i2c_priv_s stm32_i2c3_priv = /* Device Structures, Instantiation */ -struct i2c_ops_s stm32_i2c_ops = +static const struct i2c_ops_s stm32_i2c_ops = { .setfrequency = stm32_i2c_setfrequency, .setaddress = stm32_i2c_setaddress, diff --git a/arch/arm/src/stm32/stm32_i2c_alt.c b/arch/arm/src/stm32/stm32_i2c_alt.c index 11e82629bb..c86b903b73 100755 --- a/arch/arm/src/stm32/stm32_i2c_alt.c +++ b/arch/arm/src/stm32/stm32_i2c_alt.c @@ -306,7 +306,7 @@ struct stm32_i2c_priv_s struct stm32_i2c_inst_s { - struct i2c_ops_s *ops; /* Standard I2C operations */ + const struct i2c_ops_s *ops; /* Standard I2C operations */ struct stm32_i2c_priv_s *priv; /* Common driver private data structure */ uint32_t frequency; /* Frequency used in this instantiation */ @@ -412,7 +412,7 @@ static const struct stm32_i2c_config_s stm32_i2c1_config = #endif }; -struct stm32_i2c_priv_s stm32_i2c1_priv = +static struct stm32_i2c_priv_s stm32_i2c1_priv = { .config = &stm32_i2c1_config, .refs = 0, @@ -441,7 +441,7 @@ static const struct stm32_i2c_config_s stm32_i2c2_config = #endif }; -struct stm32_i2c_priv_s stm32_i2c2_priv = +static struct stm32_i2c_priv_s stm32_i2c2_priv = { .config = &stm32_i2c2_config, .refs = 0, @@ -470,7 +470,7 @@ static const struct stm32_i2c_config_s stm32_i2c3_config = #endif }; -struct stm32_i2c_priv_s stm32_i2c3_priv = +static struct stm32_i2c_priv_s stm32_i2c3_priv = { .config = &stm32_i2c3_config, .refs = 0, @@ -486,7 +486,7 @@ struct stm32_i2c_priv_s stm32_i2c3_priv = /* Device Structures, Instantiation */ -struct i2c_ops_s stm32_i2c_ops = +static const struct i2c_ops_s stm32_i2c_ops = { .setfrequency = stm32_i2c_setfrequency, .setaddress = stm32_i2c_setaddress, diff --git a/libc/time/lib_daysbeforemonth.c b/libc/time/lib_daysbeforemonth.c index 28f4d67a97..ec08afbdae 100644 --- a/libc/time/lib_daysbeforemonth.c +++ b/libc/time/lib_daysbeforemonth.c @@ -64,15 +64,15 @@ * Public Variables ****************************************************************************/ -uint16_t g_daysbeforemonth[13] = -{ - 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 -}; - /**************************************************************************** * Private Variables ****************************************************************************/ +static const uint16_t g_daysbeforemonth[13] = +{ + 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 +}; + /**************************************************************************** * Private Functions ****************************************************************************/