api/spi: Make cs attribute in struct spi_config constant
Content is never modified by any driver. Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
9b27f29c99
commit
f44ba8e7d4
|
@ -54,7 +54,7 @@ _SYSCALL_HANDLER(spi_transceive, dev, config_p, tx_bufs, rx_bufs)
|
|||
}
|
||||
|
||||
if (config->cs) {
|
||||
struct spi_cs_control *cs = config->cs;
|
||||
const struct spi_cs_control *cs = config->cs;
|
||||
|
||||
_SYSCALL_MEMORY_READ(cs, sizeof(*cs));
|
||||
if (cs->gpio_dev) {
|
||||
|
|
|
@ -164,7 +164,7 @@ struct spi_config {
|
|||
u16_t operation;
|
||||
u16_t slave;
|
||||
|
||||
struct spi_cs_control *cs;
|
||||
const struct spi_cs_control *cs;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -67,19 +67,18 @@ struct spi_config spi_cfg_fast = {
|
|||
.cs = SPI_CS,
|
||||
};
|
||||
|
||||
static int cs_ctrl_gpio_config(struct spi_cs_control *cs)
|
||||
#if defined(CONFIG_SPI_LOOPBACK_CS_GPIO)
|
||||
static int cs_ctrl_gpio_config(void)
|
||||
{
|
||||
if (cs) {
|
||||
cs->gpio_dev = device_get_binding(CS_CTRL_GPIO_DRV_NAME);
|
||||
if (!cs->gpio_dev) {
|
||||
SYS_LOG_ERR("Cannot find %s!\n",
|
||||
CS_CTRL_GPIO_DRV_NAME);
|
||||
return -1;
|
||||
}
|
||||
spi_cs.gpio_dev = device_get_binding(CS_CTRL_GPIO_DRV_NAME);
|
||||
if (!spi_cs.gpio_dev) {
|
||||
SYS_LOG_ERR("Cannot find %s!", CS_CTRL_GPIO_DRV_NAME);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_SPI_LOOPBACK_CS_GPIO */
|
||||
|
||||
static int spi_complete_loop(struct device *dev, struct spi_config *spi_conf)
|
||||
{
|
||||
|
@ -408,10 +407,11 @@ void main(void)
|
|||
|
||||
SYS_LOG_INF("SPI test on buffers TX/RX %p/%p", buffer_tx, buffer_rx);
|
||||
|
||||
if (cs_ctrl_gpio_config(spi_cfg_slow.cs) ||
|
||||
cs_ctrl_gpio_config(spi_cfg_fast.cs)) {
|
||||
#if defined(CONFIG_SPI_LOOPBACK_CS_GPIO)
|
||||
if (cs_ctrl_gpio_config()) {
|
||||
return;
|
||||
}
|
||||
#endif /* CONFIG_SPI_LOOPBACK_CS_GPIO */
|
||||
|
||||
spi_slow = device_get_binding(SPI_DRV_NAME);
|
||||
if (!spi_slow) {
|
||||
|
|
Loading…
Reference in a new issue