Skip to content

Commit f74d2a7

Browse files
ndrs-pstkartben
authored andcommitted
drivers: sensor: shell: make channel and attribute name tables as const
Make `sensor_channel_name` and `sensor_attribute_name arrays` to use `const char *const`. This ensures full immutability of the tables, placing them entirely in the `.rodata` section and reducing usage of the `.data` segment. Signed-off-by: Pisit Sawangvonganan <[email protected]>
1 parent 6014ff3 commit f74d2a7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/sensor/sensor_shell.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ LOG_MODULE_REGISTER(sensor_shell, CONFIG_SENSOR_LOG_LEVEL);
4545
"Get or set the trigger type on a sensor. Currently only supports `data_ready`.\n" \
4646
"<device_name> <on/off> <trigger_name>"
4747

48-
static const char *sensor_channel_name[SENSOR_CHAN_COMMON_COUNT] = {
48+
static const char *const sensor_channel_name[SENSOR_CHAN_COMMON_COUNT] = {
4949
[SENSOR_CHAN_ACCEL_X] = "accel_x",
5050
[SENSOR_CHAN_ACCEL_Y] = "accel_y",
5151
[SENSOR_CHAN_ACCEL_Z] = "accel_z",
@@ -113,7 +113,7 @@ static const char *sensor_channel_name[SENSOR_CHAN_COMMON_COUNT] = {
113113
[SENSOR_CHAN_ALL] = "all",
114114
};
115115

116-
static const char *sensor_attribute_name[SENSOR_ATTR_COMMON_COUNT] = {
116+
static const char *const sensor_attribute_name[SENSOR_ATTR_COMMON_COUNT] = {
117117
[SENSOR_ATTR_SAMPLING_FREQUENCY] = "sampling_frequency",
118118
[SENSOR_ATTR_LOWER_THRESH] = "lower_thresh",
119119
[SENSOR_ATTR_UPPER_THRESH] = "upper_thresh",
@@ -243,7 +243,7 @@ static enum dynamic_command_context current_cmd_ctx = NONE;
243243
/* Mutex for accessing shared RTIO/IODEV data structures */
244244
K_MUTEX_DEFINE(cmd_get_mutex);
245245

246-
/* Crate a single common config for one-shot reading */
246+
/* Create a single common config for one-shot reading */
247247
static struct sensor_chan_spec iodev_sensor_shell_channels[SENSOR_CHAN_ALL];
248248
static struct sensor_read_config iodev_sensor_shell_read_config = {
249249
.sensor = NULL,
@@ -257,7 +257,7 @@ RTIO_IODEV_DEFINE(iodev_sensor_shell_read, &__sensor_iodev_api, &iodev_sensor_sh
257257
/* Create the RTIO context to service the reading */
258258
RTIO_DEFINE_WITH_MEMPOOL(sensor_read_rtio, 8, 8, 32, 64, 4);
259259

260-
static int parse_named_int(const char *name, const char *heystack[], size_t count)
260+
static int parse_named_int(const char *name, const char *const heystack[], size_t count)
261261
{
262262
char *endptr;
263263
int i;

0 commit comments

Comments
 (0)