Commit 6a9afcb1 authored by Alexandru Ardelean's avatar Alexandru Ardelean Committed by Jonathan Cameron

iio: imu: adis: rename txrx_lock -> state_lock

The lock can be extended a bit to protect other elements that are not
particular to just TX/RX. Another idea would have been to just add a new
`state_lock`, but that would mean 2 locks which would be redundant, and
probably cause more potential for dead-locks.

What will be done in the next patches, will be to add some unlocked
versions for read/write_reg functions.
Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent a33db947
...@@ -70,7 +70,7 @@ int adis_write_reg(struct adis *adis, unsigned int reg, ...@@ -70,7 +70,7 @@ int adis_write_reg(struct adis *adis, unsigned int reg,
}, },
}; };
mutex_lock(&adis->txrx_lock); mutex_lock(&adis->state_lock);
spi_message_init(&msg); spi_message_init(&msg);
...@@ -114,7 +114,7 @@ int adis_write_reg(struct adis *adis, unsigned int reg, ...@@ -114,7 +114,7 @@ int adis_write_reg(struct adis *adis, unsigned int reg,
} }
out_unlock: out_unlock:
mutex_unlock(&adis->txrx_lock); mutex_unlock(&adis->state_lock);
return ret; return ret;
} }
...@@ -166,7 +166,7 @@ int adis_read_reg(struct adis *adis, unsigned int reg, ...@@ -166,7 +166,7 @@ int adis_read_reg(struct adis *adis, unsigned int reg,
}, },
}; };
mutex_lock(&adis->txrx_lock); mutex_lock(&adis->state_lock);
spi_message_init(&msg); spi_message_init(&msg);
if (adis->current_page != page) { if (adis->current_page != page) {
...@@ -211,7 +211,7 @@ int adis_read_reg(struct adis *adis, unsigned int reg, ...@@ -211,7 +211,7 @@ int adis_read_reg(struct adis *adis, unsigned int reg,
} }
out_unlock: out_unlock:
mutex_unlock(&adis->txrx_lock); mutex_unlock(&adis->state_lock);
return ret; return ret;
} }
...@@ -438,7 +438,7 @@ EXPORT_SYMBOL_GPL(adis_single_conversion); ...@@ -438,7 +438,7 @@ EXPORT_SYMBOL_GPL(adis_single_conversion);
int adis_init(struct adis *adis, struct iio_dev *indio_dev, int adis_init(struct adis *adis, struct iio_dev *indio_dev,
struct spi_device *spi, const struct adis_data *data) struct spi_device *spi, const struct adis_data *data)
{ {
mutex_init(&adis->txrx_lock); mutex_init(&adis->state_lock);
adis->spi = spi; adis->spi = spi;
adis->data = data; adis->data = data;
iio_device_set_drvdata(indio_dev, adis); iio_device_set_drvdata(indio_dev, adis);
......
...@@ -129,7 +129,7 @@ static irqreturn_t adis_trigger_handler(int irq, void *p) ...@@ -129,7 +129,7 @@ static irqreturn_t adis_trigger_handler(int irq, void *p)
return -ENOMEM; return -ENOMEM;
if (adis->data->has_paging) { if (adis->data->has_paging) {
mutex_lock(&adis->txrx_lock); mutex_lock(&adis->state_lock);
if (adis->current_page != 0) { if (adis->current_page != 0) {
adis->tx[0] = ADIS_WRITE_REG(ADIS_REG_PAGE_ID); adis->tx[0] = ADIS_WRITE_REG(ADIS_REG_PAGE_ID);
adis->tx[1] = 0; adis->tx[1] = 0;
...@@ -144,7 +144,7 @@ static irqreturn_t adis_trigger_handler(int irq, void *p) ...@@ -144,7 +144,7 @@ static irqreturn_t adis_trigger_handler(int irq, void *p)
if (adis->data->has_paging) { if (adis->data->has_paging) {
adis->current_page = 0; adis->current_page = 0;
mutex_unlock(&adis->txrx_lock); mutex_unlock(&adis->state_lock);
} }
iio_push_to_buffers_with_timestamp(indio_dev, adis->buffer, iio_push_to_buffers_with_timestamp(indio_dev, adis->buffer,
......
...@@ -61,7 +61,7 @@ struct adis { ...@@ -61,7 +61,7 @@ struct adis {
const struct adis_data *data; const struct adis_data *data;
struct adis_burst *burst; struct adis_burst *burst;
struct mutex txrx_lock; struct mutex state_lock;
struct spi_message msg; struct spi_message msg;
struct spi_transfer *xfer; struct spi_transfer *xfer;
unsigned int current_page; unsigned int current_page;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment