Skip to content

Commit

Permalink
drivers/spi: Adding async mode to SAM and SAM0 drivers
Browse files Browse the repository at this point in the history
This mode was missing for some reason.

Signed-off-by: Tomasz Bursztyka <[email protected]>
  • Loading branch information
Tomasz Bursztyka authored and MaureenHelm committed Nov 16, 2018
1 parent 2719589 commit eae05d9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
18 changes: 16 additions & 2 deletions drivers/spi/spi_sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,28 @@ static int spi_sam_transceive(struct device *dev,
return err;
}

static int spi_sam0_transceive_sync(struct device *dev,
const struct spi_config *config,
const struct spi_buf_set *tx_bufs,
const struct spi_buf_set *rx_bufs)
{
struct spi_sam0_data *data = dev->driver_data;

spi_context_lock(&data->ctx, false, NULL);
return spi_sam0_transceive(dev, config, tx_bufs, rx_bufs);
}

#ifdef CONFIG_SPI_ASYNC
static int spi_sam_transceive_async(struct device *dev,
const struct spi_config *config,
const struct spi_buf_set *tx_bufs,
const struct spi_buf_set *rx_bufs,
struct k_poll_signal *async)
{
return -ENOTSUP;
struct spi_sam0_data *data = dev->driver_data;

spi_context_lock(&data->ctx, true, async);
return spi_sam0_transceive(dev, config, tx_bufs, rx_bufs);
}
#endif /* CONFIG_SPI_ASYNC */

Expand Down Expand Up @@ -441,7 +455,7 @@ static int spi_sam_init(struct device *dev)
}

static const struct spi_driver_api spi_sam_driver_api = {
.transceive = spi_sam_transceive,
.transceive = spi_sam_transceive_sync,
#ifdef CONFIG_SPI_ASYNC
.transceive_async = spi_sam_transceive_async,
#endif
Expand Down
18 changes: 16 additions & 2 deletions drivers/spi/spi_sam0.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,28 @@ static int spi_sam0_transceive(struct device *dev,
return err;
}

static int spi_sam0_transceive_sync(struct device *dev,
const struct spi_config *config,
const struct spi_buf_set *tx_bufs,
const struct spi_buf_set *rx_bufs)
{
struct spi_sam0_data *data = dev->driver_data;

spi_context_lock(&data->ctx, false, NULL);
return spi_sam0_transceive(dev, config, tx_bufs, rx_bufs);
}

#ifdef CONFIG_SPI_ASYNC
static int spi_sam0_transceive_async(struct device *dev,
const struct spi_config *config,
const struct spi_buf_set *tx_bufs,
const struct spi_buf_set *rx_bufs,
struct k_poll_signal *async)
{
return -ENOTSUP;
struct spi_sam0_data *data = dev->driver_data;

spi_context_lock(&data->ctx, true, async);
return spi_sam0_transceive(dev, config, tx_bufs, rx_bufs);
}
#endif /* CONFIG_SPI_ASYNC */

Expand Down Expand Up @@ -451,7 +465,7 @@ static int spi_sam0_init(struct device *dev)
}

static const struct spi_driver_api spi_sam0_driver_api = {
.transceive = spi_sam0_transceive,
.transceive = spi_sam0_transceive_sync,
#ifdef CONFIG_SPI_ASYNC
.transceive_async = spi_sam0_transceive_async,
#endif
Expand Down

0 comments on commit eae05d9

Please sign in to comment.