spi:quark_se ss: Use locking mechanism to guard critical regions.

This will allow the driver to be fiber and task safe

Jira: ZEP-410

Change-Id: I61d3d9e4128bae781f1c86c07af79eb6e43ebeda
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
This commit is contained in:
Sergio Rodriguez 2016-05-27 14:03:03 -07:00 committed by Anas Nashif
parent d6f039ed79
commit 7c00c4d3be

View file

@ -45,6 +45,7 @@ struct ss_spi_qmsi_runtime {
struct device *gpio_cs;
#endif
device_sync_call_t sync;
struct nano_sem sem;
qm_ss_spi_config_t cfg;
int rc;
bool loopback;
@ -154,11 +155,14 @@ static int ss_spi_qmsi_transceive(struct device *dev,
qm_ss_spi_async_transfer_t *xfer;
int rc;
nano_sem_take(&context->sem, TICKS_UNLIMITED);
if (pending_transfers[spi_id].dev) {
nano_sem_give(&context->sem);
return -EBUSY;
}
pending_transfers[spi_id].dev = dev;
nano_sem_give(&context->sem);
xfer = &pending_transfers[spi_id].xfer;
xfer->rx = rx_buf;
@ -395,6 +399,8 @@ static int ss_spi_qmsi_init(struct device *dev)
context->gpio_cs = gpio_cs_init(spi_config);
#endif
device_sync_call_init(&context->sync);
nano_sem_init(&context->sem);
nano_sem_give(&context->sem);
dev->driver_api = &ss_spi_qmsi_api;