Skip to content

Commit 3ffcd75

Browse files
ndrs-pstcarlescufi
authored andcommitted
drivers: spi: set 'spi_driver_api' as 'static const'
This change marks each instance of the 'spi_driver_api' as 'static const'. The rationale is that 'spi_driver_api' is used for declaring internal module interfaces and is not intended to be modified at runtime. By using 'static const', we ensure immutability, leading to usage of only .rodata and a reduction in the .data area. Signed-off-by: Pisit Sawangvonganan <[email protected]>
1 parent 80e1482 commit 3ffcd75

15 files changed

+18
-16
lines changed

drivers/spi/mspi_ambiq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ static int mspi_ambiq_release(const struct device *dev, const struct spi_config
197197
return 0;
198198
}
199199

200-
static struct spi_driver_api mspi_ambiq_driver_api = {
200+
static const struct spi_driver_api mspi_ambiq_driver_api = {
201201
.transceive = mspi_ambiq_transceive,
202202
.release = mspi_ambiq_release,
203203
};

drivers/spi/spi_ambiq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ static int spi_ambiq_release(const struct device *dev, const struct spi_config *
219219
return 0;
220220
}
221221

222-
static struct spi_driver_api spi_ambiq_driver_api = {
222+
static const struct spi_driver_api spi_ambiq_driver_api = {
223223
.transceive = spi_ambiq_transceive,
224224
.release = spi_ambiq_release,
225225
};

drivers/spi/spi_andes_atcspi200.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ int spi_atcspi200_init(const struct device *dev)
283283
return 0;
284284
}
285285

286-
static struct spi_driver_api spi_atcspi200_api = {
286+
static const struct spi_driver_api spi_atcspi200_api = {
287287
.transceive = spi_atcspi200_transceive,
288288
#ifdef CONFIG_SPI_ASYNC
289289
.transceive_async = spi_atcspi200_transceive_async,

drivers/spi/spi_b91.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ static int spi_b91_release(const struct device *dev,
452452
}
453453

454454
/* SPI driver APIs structure */
455-
static struct spi_driver_api spi_b91_api = {
455+
static const struct spi_driver_api spi_b91_api = {
456456
.transceive = spi_b91_transceive,
457457
.release = spi_b91_release,
458458
#ifdef CONFIG_SPI_ASYNC

drivers/spi/spi_bitbang.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ int spi_bitbang_release(const struct device *dev,
247247
return 0;
248248
}
249249

250-
static struct spi_driver_api spi_bitbang_api = {
250+
static const struct spi_driver_api spi_bitbang_api = {
251251
.transceive = spi_bitbang_transceive,
252252
.release = spi_bitbang_release,
253253
#ifdef CONFIG_SPI_ASYNC

drivers/spi/spi_emul.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ int spi_emul_register(const struct device *dev, struct spi_emul *emul)
109109

110110
/* Device instantiation */
111111

112-
static struct spi_driver_api spi_emul_api = {
112+
static const struct spi_driver_api spi_emul_api = {
113113
.transceive = spi_emul_io,
114114
};
115115

drivers/spi/spi_gd32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ static int spi_gd32_release(const struct device *dev,
567567
return 0;
568568
}
569569

570-
static struct spi_driver_api spi_gd32_driver_api = {
570+
static const struct spi_driver_api spi_gd32_driver_api = {
571571
.transceive = spi_gd32_transceive,
572572
#ifdef CONFIG_SPI_ASYNC
573573
.transceive_async = spi_gd32_transceive_async,

drivers/spi/spi_gecko.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ static int spi_gecko_release(const struct device *dev,
357357
}
358358

359359
/* Device Instantiation */
360-
static struct spi_driver_api spi_gecko_api = {
360+
static const struct spi_driver_api spi_gecko_api = {
361361
.transceive = spi_gecko_transceive,
362362
#ifdef CONFIG_SPI_ASYNC
363363
.transceive_async = spi_gecko_transceive_async,

drivers/spi/spi_litespi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static int spi_litespi_release(const struct device *dev,
160160
}
161161

162162
/* Device Instantiation */
163-
static struct spi_driver_api spi_litespi_api = {
163+
static const struct spi_driver_api spi_litespi_api = {
164164
.transceive = spi_litespi_transceive,
165165
#ifdef CONFIG_SPI_ASYNC
166166
.transceive_async = spi_litespi_transceive_async,

drivers/spi/spi_numaker.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,10 @@ static int spi_numaker_release(const struct device *dev, const struct spi_config
270270
return 0;
271271
}
272272

273-
static struct spi_driver_api spi_numaker_driver_api = {.transceive = spi_numaker_transceive,
274-
.release = spi_numaker_release};
273+
static const struct spi_driver_api spi_numaker_driver_api = {
274+
.transceive = spi_numaker_transceive,
275+
.release = spi_numaker_release
276+
};
275277

276278
static int spi_numaker_init(const struct device *dev)
277279
{

0 commit comments

Comments
 (0)