aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Ciocca <denis.ciocca@gmail.com>2013-02-09 11:08:00 -0500
committerJonathan Cameron <jic23@kernel.org>2013-03-16 06:18:10 -0400
commit43bb786ad2886ea38364e57924c19e9d29f37201 (patch)
tree8d5fd1df4713eeff6823e5f9297cf49142bc7806
parent0eac259db28fde88767cab5fd0380f4024e08c02 (diff)
iio:common: Use spi_sync_transfer() in STMicroelectronics common library
Use the new spi_sync_transfer() helper function instead of open-coding it. Signed-off-by: Denis Ciocca <denis.ciocca@st.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_spi.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/drivers/iio/common/st_sensors/st_sensors_spi.c b/drivers/iio/common/st_sensors/st_sensors_spi.c
index f0aa2f105222..251baf6abc25 100644
--- a/drivers/iio/common/st_sensors/st_sensors_spi.c
+++ b/drivers/iio/common/st_sensors/st_sensors_spi.c
@@ -29,7 +29,6 @@ static unsigned int st_sensors_spi_get_irq(struct iio_dev *indio_dev)
29static int st_sensors_spi_read(struct st_sensor_transfer_buffer *tb, 29static int st_sensors_spi_read(struct st_sensor_transfer_buffer *tb,
30 struct device *dev, u8 reg_addr, int len, u8 *data, bool multiread_bit) 30 struct device *dev, u8 reg_addr, int len, u8 *data, bool multiread_bit)
31{ 31{
32 struct spi_message msg;
33 int err; 32 int err;
34 33
35 struct spi_transfer xfers[] = { 34 struct spi_transfer xfers[] = {
@@ -51,10 +50,7 @@ static int st_sensors_spi_read(struct st_sensor_transfer_buffer *tb,
51 else 50 else
52 tb->tx_buf[0] = reg_addr | ST_SENSORS_SPI_READ; 51 tb->tx_buf[0] = reg_addr | ST_SENSORS_SPI_READ;
53 52
54 spi_message_init(&msg); 53 err = spi_sync_transfer(to_spi_device(dev), xfers, ARRAY_SIZE(xfers));
55 spi_message_add_tail(&xfers[0], &msg);
56 spi_message_add_tail(&xfers[1], &msg);
57 err = spi_sync(to_spi_device(dev), &msg);
58 if (err) 54 if (err)
59 goto acc_spi_read_error; 55 goto acc_spi_read_error;
60 56
@@ -83,7 +79,6 @@ static int st_sensors_spi_read_multiple_byte(
83static int st_sensors_spi_write_byte(struct st_sensor_transfer_buffer *tb, 79static int st_sensors_spi_write_byte(struct st_sensor_transfer_buffer *tb,
84 struct device *dev, u8 reg_addr, u8 data) 80 struct device *dev, u8 reg_addr, u8 data)
85{ 81{
86 struct spi_message msg;
87 int err; 82 int err;
88 83
89 struct spi_transfer xfers = { 84 struct spi_transfer xfers = {
@@ -96,9 +91,7 @@ static int st_sensors_spi_write_byte(struct st_sensor_transfer_buffer *tb,
96 tb->tx_buf[0] = reg_addr; 91 tb->tx_buf[0] = reg_addr;
97 tb->tx_buf[1] = data; 92 tb->tx_buf[1] = data;
98 93
99 spi_message_init(&msg); 94 err = spi_sync_transfer(to_spi_device(dev), &xfers, 1);
100 spi_message_add_tail(&xfers, &msg);
101 err = spi_sync(to_spi_device(dev), &msg);
102 mutex_unlock(&tb->buf_lock); 95 mutex_unlock(&tb->buf_lock);
103 96
104 return err; 97 return err;