spi: Add helper functions for setting up transfers
Subsystems (6)
PATCH 1/3 spi: Add helper functions for setting up transfers
Quite often the pattern used for setting up and transferring a synchronous SPI transaction looks very much like the following:
struct spi_message msg;
struct spi_transfer xfers[] = {
...
};
spi_message_init(&msg);
spi_message_add_tail(&xfers[0], &msg);
...
spi_message_add_tail(&xfers[ARRAY_SIZE(xfers) - 1], &msg);
ret = spi_sync(&msg);This patch adds two new helper functions for handling this case. The first helper function spi_message_init_with_transfers() takes a spi_message and an array of spi_transfers. It will initialize the message and then call spi_message_add_tail() for each transfer in the array. E.g. the following
spi_message_init(&msg); spi_message_add_tail(&xfers[0], &msg); ... spi_message_add_tail(&xfers[ARRAY_SIZE(xfers) - 1], &msg);
can be rewritten as
spi_message_init_with_transfers(&msg, xfers, ARRAY_SIZE(xfers));
The second function spi_sync_transfer() takes a SPI device and an array of spi_transfers. It will allocate a new spi_message (on the stack) and add all transfers in the array to the message. Finally it will call spi_sync() on the message.
E.g. the follwing
struct spi_message msg;
struct spi_transfer xfers[] = {
...
};
spi_message_init(&msg);
spi_message_add_tail(&xfers[0], &msg);
...
spi_message_add_tail(&xfers[ARRAY_SIZE(xfers) - 1], &msg);
ret = spi_sync(spi, &msg);can be rewritten as
struct spi_transfer xfers[] = {
...
};
ret = spi_sync_transfer(spi, xfers, ARRAY_SIZE(xfers));The patch also adds a new cocci script which can detect such sequences as described above and transform them automatically to use the new helper functions.
---
I'm not entirely happy with names of the two new functions and I'm open for better suggestions.
--- include/linux/spi/spi.h | 44 ++++++++ scripts/coccinelle/api/spi_sync_transfer.cocci | 141 +++++++++++++++++++++++++ 2 files changed, 185 insertions(+) create mode 100644 scripts/coccinelle/api/spi_sync_transfer.cocci
include/linux/spi/spi.h +44 -0
@@ -591,6 +591,26 @@ spi_transfer_del(struct spi_transfer *t)list_del (&t->transfer_list); } +/** +* spi_message_init_with_transfers - Initialize spi_message and append transfers +* @m: spi_message to be initialized +* @xfers: An array of spi transfers +* @num_xfers: Number of items in the xfer array +* +* This function initializes the given spi_message and adds each spi_transfer in +* the given array to the message. +*/ +static inline void +spi_message_init_with_transfers (struct spi_message *m, +struct spi_transfer *xfers,unsigned int num_xfers) +{ +unsigned int i; + +spi_message_init (m); +for (i =0 ; i < num_xfers; ++i) +spi_message_add_tail (&xfers[i], m); +} +/* It's fine to embed message and transaction structures in other data * structures so long as you don't free them while they're in use. */
@@ -683,6 +703,30 @@ spi_read(struct spi_device *spi, void *buf, size_t len)return spi_sync (spi, &m); } +/** +* spi_sync_transfer - synchronous SPI data transfer +* @spi: device with which data will be exchanged +* @xfers: An array of spi_transfers +* @num_xfers: Number of items in the xfer array +* Context: can sleep +* +* Does a synchronous SPI data transfer of the given spi_transfer array. +* +* For more specific semantics see spi_sync(). +* +* It returns zero on success, else a negative error code. +*/ +static inline int +spi_sync_transfer (struct spi_device *spi,struct spi_transfer *xfers, +unsigned int num_xfers) +{ +struct spi_message msg; + +spi_message_init_with_transfers (&msg, xfers, num_xfers); + +return spi_sync (spi, &msg); +} +/* this copies txbuf and rxbuf data; for small transfers only! */ extern int spi_write_then_read(struct spi_device *spi, const void *txbuf, unsigned n_tx,
scripts/coccinelle/api/spi_sync_transfer.cocci new file +141 -0
141 lines not on this page · raw message
Signature · 1 line
1.8.0
PATCH 2/3 iio: Use spi_sync_transfer()
Use the new spi_sync_transfer() helper function instead of open-coding it.
--- drivers/iio/dac/ad5360.c | 7 +------ drivers/iio/dac/ad5421.c | 7 +------ drivers/iio/dac/ad5504.c | 6 +----- drivers/iio/dac/ad5686.c | 7 +------ drivers/iio/dac/ad5755.c | 7 +------ drivers/iio/dac/ad5764.c | 7 +------ drivers/iio/dac/ad5791.c | 6 +----- drivers/iio/frequency/ad9523.c | 14 ++------------ 8 files changed, 9 insertions(+), 52 deletions(-)
drivers/iio/dac/ad5360.c +1 -6
@@ -213,7 +213,6 @@ static int ad5360_read(struct iio_dev *indio_dev, unsigned int type, unsigned int addr) {struct ad5360_state *st =iio_priv (indio_dev); -struct spi_message m;int ret;struct spi_transfer t[] = { {
@@ -226,10 +225,6 @@ static int ad5360_read(struct iio_dev *indio_dev, unsigned int type, }, }; -spi_message_init (&m); -spi_message_add_tail (&t[0 ], &m); -spi_message_add_tail (&t[1 ], &m); -mutex_lock (&indio_dev->mlock); st->data[0].d32 = cpu_to_be32(AD5360_CMD(AD5360_CMD_SPECIAL_FUNCTION) |
@@ -237,7 +232,7 @@ static int ad5360_read(struct iio_dev *indio_dev, unsigned int type,AD5360_READBACK_TYPE (type) | AD5360_READBACK_ADDR(addr)); - ret =spi_sync (st->spi, &m); + ret =spi_sync_transfer (st->spi, t,ARRAY_SIZE (t));if (ret >=0 ) ret =be32_to_cpu (st->data[1 ].d32) &0xffff ;
drivers/iio/dac/ad5421.c +1 -6
@@ -127,7 +127,6 @@ static int ad5421_write(struct iio_dev *indio_dev, unsigned int reg,static int ad5421_read (struct iio_dev *indio_dev,unsigned int reg) {struct ad5421_state *st =iio_priv (indio_dev); -struct spi_message m;int ret;struct spi_transfer t[] = { {
@@ -140,15 +139,11 @@ static int ad5421_read(struct iio_dev *indio_dev, unsigned int reg) }, }; -spi_message_init (&m); -spi_message_add_tail (&t[0 ], &m); -spi_message_add_tail (&t[1 ], &m); -mutex_lock (&indio_dev->mlock); st->data[0 ].d32 =cpu_to_be32 ((1 <<23 ) | (reg <<16 )); - ret =spi_sync (st->spi, &m); + ret =spi_sync_transfer (st->spi, t,ARRAY_SIZE (t));if (ret >=0 ) ret =be32_to_cpu (st->data[1 ].d32) &0xffff ;
drivers/iio/dac/ad5504.c +1 -5
@@ -85,11 +85,7 @@ static int ad5504_spi_read(struct spi_device *spi, u8 addr) .rx_buf = &val, .len = 2, }; -struct spi_message m; - -spi_message_init (&m); -spi_message_add_tail (&t, &m); - ret =spi_sync (spi, &m); + ret =spi_sync_transfer (spi, &t,1 );if (ret <0 )return ret;
drivers/iio/dac/ad5686.c +1 -6
@@ -117,18 +117,13 @@ static int ad5686_spi_read(struct ad5686_state *st, u8 addr) .len = 3, }, }; -struct spi_message m;int ret; -spi_message_init (&m); -spi_message_add_tail (&t[0 ], &m); -spi_message_add_tail (&t[1 ], &m); - st->data[0 ].d32 =cpu_to_be32 (AD5686_CMD (AD5686_CMD_READBACK_ENABLE ) |AD5686_ADDR (addr)); st->data[1 ].d32 =cpu_to_be32 (AD5686_CMD (AD5686_CMD_NOOP )); - ret =spi_sync (st->spi, &m); + ret =spi_sync_transfer (st->spi, t,ARRAY_SIZE (t));if (ret <0 )return ret;
drivers/iio/dac/ad5755.c +1 -6
@@ -153,7 +153,6 @@ static int ad5755_write_ctrl(struct iio_dev *indio_dev, unsigned int channel,static int ad5755_read (struct iio_dev *indio_dev,unsigned int addr) {struct ad5755_state *st =iio_priv (indio_dev); -struct spi_message m;int ret;struct spi_transfer t[] = { {
@@ -167,16 +166,12 @@ static int ad5755_read(struct iio_dev *indio_dev, unsigned int addr) }, }; -spi_message_init (&m); -spi_message_add_tail (&t[0 ], &m); -spi_message_add_tail (&t[1 ], &m); -mutex_lock (&indio_dev->mlock); st->data[0 ].d32 =cpu_to_be32 (AD5755_READ_FLAG | (addr <<16 )); st->data[1 ].d32 =cpu_to_be32 (AD5755_NOOP ); - ret =spi_sync (st->spi, &m); + ret =spi_sync_transfer (st->spi, t,ARRAY_SIZE (t));if (ret >=0 ) ret =be32_to_cpu (st->data[1 ].d32) &0xffff ;
drivers/iio/dac/ad5764.c +1 -6
@@ -135,7 +135,6 @@ static int ad5764_read(struct iio_dev *indio_dev, unsigned int reg, unsigned int *val) {struct ad5764_state *st =iio_priv (indio_dev); -struct spi_message m;int ret;struct spi_transfer t[] = { {
@@ -148,15 +147,11 @@ static int ad5764_read(struct iio_dev *indio_dev, unsigned int reg, }, }; -spi_message_init (&m); -spi_message_add_tail (&t[0 ], &m); -spi_message_add_tail (&t[1 ], &m); -mutex_lock (&indio_dev->mlock); st->data[0 ].d32 =cpu_to_be32 ((1 <<23 ) | (reg <<16 )); - ret =spi_sync (st->spi, &m); + ret =spi_sync_transfer (st->spi, t,ARRAY_SIZE (t));if (ret >=0 ) *val =be32_to_cpu (st->data[1 ].d32) &0xffff ;
drivers/iio/dac/ad5791.c +1 -5
@@ -125,7 +125,6 @@ static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val)u8 d8[4 ]; } data[3 ];int ret; -struct spi_message msg;struct spi_transfer xfers[] = { { .tx_buf = &data[0 ].d8[1 ],
@@ -144,10 +143,7 @@ static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val) AD5791_ADDR(addr)); data[1 ].d32 =cpu_to_be32 (AD5791_ADDR (AD5791_ADDR_NOOP )); -spi_message_init (&msg); -spi_message_add_tail (&xfers[0 ], &msg); -spi_message_add_tail (&xfers[1 ], &msg); - ret =spi_sync (spi, &msg); + ret =spi_sync_transfer (spi, xfers,ARRAY_SIZE (xfers)); *val =be32_to_cpu (data[2 ].d32);
drivers/iio/frequency/ad9523.c +2 -12
@@ -287,7 +287,6 @@ struct ad9523_state {static int ad9523_read (struct iio_dev *indio_dev,unsigned addr) {struct ad9523_state *st =iio_priv (indio_dev); -struct spi_message m;int ret;/* We encode the register size 1..3 bytes into the register address.
@@ -305,15 +304,11 @@ static int ad9523_read(struct iio_dev *indio_dev, unsigned addr) }, }; -spi_message_init (&m); -spi_message_add_tail (&t[0 ], &m); -spi_message_add_tail (&t[1 ], &m); - st->data[0 ].d32 =cpu_to_be32 (AD9523_READ |AD9523_CNT (AD9523_TRANSF_LEN (addr)) |AD9523_ADDR (addr)); - ret =spi_sync (st->spi, &m); + ret =spi_sync_transfer (st->spi, t,ARRAY_SIZE (t));if (ret <0 )dev_err (&indio_dev->dev,"read failed (%d)" , ret);else
@@ -326,7 +321,6 @@ static int ad9523_read(struct iio_dev *indio_dev, unsigned addr)static int ad9523_write (struct iio_dev *indio_dev,unsigned addr,unsigned val) {struct ad9523_state *st =iio_priv (indio_dev); -struct spi_message m;int ret;struct spi_transfer t[] = { {
@@ -338,16 +332,12 @@ static int ad9523_write(struct iio_dev *indio_dev, unsigned addr, unsigned val) }, }; -spi_message_init (&m); -spi_message_add_tail (&t[0 ], &m); -spi_message_add_tail (&t[1 ], &m); - st->data[0 ].d32 =cpu_to_be32 (AD9523_WRITE |AD9523_CNT (AD9523_TRANSF_LEN (addr)) |AD9523_ADDR (addr)); st->data[1 ].d32 =cpu_to_be32 (val); - ret =spi_sync (st->spi, &m); + ret =spi_sync_transfer (st->spi, t,ARRAY_SIZE (t));if (ret <0 )dev_err (&indio_dev->dev,"write failed (%d)" , ret);
Signature · 1 line
1.8.0
PATCH 3/3 staging:iio: Use spi_sync_transfer()
In reply to Lars-Peter ClausenUse the new spi_sync_transfer() helper function instead of open-coding it.
--- drivers/staging/iio/accel/kxsd9.c | 6 +--- drivers/staging/iio/accel/lis3l02dq_core.c | 18 ++---------- drivers/staging/iio/accel/sca3000_core.c | 13 ++------- drivers/staging/iio/accel/sca3000_ring.c | 6 +--- drivers/staging/iio/adc/ad7280a.c | 6 +--- drivers/staging/iio/frequency/ad5930.c | 5 +--- drivers/staging/iio/frequency/ad9850.c | 5 +--- drivers/staging/iio/frequency/ad9852.c | 5 +--- drivers/staging/iio/gyro/adxrs450_core.c | 5 +--- drivers/staging/iio/meter/ade7753.c | 6 +--- drivers/staging/iio/meter/ade7754.c | 5 +--- drivers/staging/iio/meter/ade7758_core.c | 28 ++++--------------- drivers/staging/iio/meter/ade7759.c | 5 +--- drivers/staging/iio/meter/ade7854-spi.c | 44 ++++++------------------------ drivers/staging/iio/resolver/ad2s1210.c | 5 +--- 15 files changed, 29 insertions(+), 133 deletions(-)
drivers/staging/iio/accel/kxsd9.c +1 -5
@@ -94,7 +94,6 @@ error_ret:static int kxsd9_read (struct iio_dev *indio_dev,u8 address) { -struct spi_message msg;int ret;struct kxsd9_state *st =iio_priv (indio_dev);struct spi_transfer xfers[] = {
@@ -112,10 +111,7 @@ static int kxsd9_read(struct iio_dev *indio_dev, u8 address)mutex_lock (&st->buf_lock); st->tx[0 ] =KXSD9_READ (address); -spi_message_init (&msg); -spi_message_add_tail (&xfers[0 ], &msg); -spi_message_add_tail (&xfers[1 ], &msg); - ret =spi_sync (st->us, &msg); + ret =spi_sync_transfer (st->us, xfers,ARRAY_SIZE (xfers));if (ret)return ret;return (((u16)(st->rx[0 ])) <<8 ) | (st->rx[1 ] &0xF0 );
drivers/staging/iio/accel/lis3l02dq_core.c +3 -15
@@ -52,7 +52,6 @@ int lis3l02dq_spi_read_reg_8(struct iio_dev *indio_dev, u8 reg_address, u8 *val) { struct lis3l02dq_state *st = iio_priv(indio_dev); -struct spi_message msg;int ret; struct spi_transfer xfer = { .tx_buf = st->tx,
@@ -65,9 +64,7 @@ int lis3l02dq_spi_read_reg_8(struct iio_dev *indio_dev, st->tx[0 ] =LIS3L02DQ_READ_REG (reg_address); st->tx[1 ] =0 ; -spi_message_init (&msg); -spi_message_add_tail (&xfer, &msg); - ret =spi_sync (st->us, &msg); + ret =spi_sync_transfer (st->us, &xfer,1 ); *val = st->rx[1 ];mutex_unlock (&st->buf_lock);
@@ -108,7 +105,6 @@ static int lis3l02dq_spi_write_reg_s16(struct iio_dev *indio_dev, s16 value) {int ret; -struct spi_message msg;struct lis3l02dq_state *st =iio_priv (indio_dev);struct spi_transfer xfers[] = { { .tx_buf = st->tx,
@@ -128,10 +124,7 @@ static int lis3l02dq_spi_write_reg_s16(struct iio_dev *indio_dev, st->tx[2 ] =LIS3L02DQ_WRITE_REG (lower_reg_address +1 ); st->tx[3 ] = (value >>8 ) &0xFF ; -spi_message_init (&msg); -spi_message_add_tail (&xfers[0 ], &msg); -spi_message_add_tail (&xfers[1 ], &msg); - ret =spi_sync (st->us, &msg); + ret =spi_sync_transfer (st->us, xfers,ARRAY_SIZE (xfers));mutex_unlock (&st->buf_lock);return ret;
@@ -142,8 +135,6 @@ static int lis3l02dq_read_reg_s16(struct iio_dev *indio_dev, int *val) {struct lis3l02dq_state *st =iio_priv (indio_dev); - -struct spi_message msg;int ret;s16 tempval;struct spi_transfer xfers[] = { {
@@ -166,10 +157,7 @@ static int lis3l02dq_read_reg_s16(struct iio_dev *indio_dev, st->tx[2 ] =LIS3L02DQ_READ_REG (lower_reg_address +1 ); st->tx[3 ] =0 ; -spi_message_init (&msg); -spi_message_add_tail (&xfers[0 ], &msg); -spi_message_add_tail (&xfers[1 ], &msg); - ret =spi_sync (st->us, &msg); + ret =spi_sync_transfer (st->us, xfers,ARRAY_SIZE (xfers));if (ret) {dev_err (&st->us->dev,"problem when reading 16 bit register" ); goto error_ret;
drivers/staging/iio/accel/sca3000_core.c +2 -11
@@ -90,7 +90,6 @@ int sca3000_read_data_short(struct sca3000_state *st, uint8_t reg_address_high, int len) { -struct spi_message msg;struct spi_transfer xfer[2 ] = { { .len =1 ,
@@ -101,11 +100,8 @@ int sca3000_read_data_short(struct sca3000_state *st, } }; st->tx[0 ] =SCA3000_READ_REG (reg_address_high); -spi_message_init (&msg); -spi_message_add_tail (&xfer[0 ], &msg); -spi_message_add_tail (&xfer[1 ], &msg); -return spi_sync (st->us, &msg); +return spi_sync_transfer (st->us, xfer,ARRAY_SIZE (xfer)); }/**
@@ -133,7 +129,6 @@ static int sca3000_reg_lock_on(struct sca3000_state *st)**/ static int __sca3000_unlock_reg_lock (struct sca3000_state *st) { -struct spi_message msg;struct spi_transfer xfer[3 ] = { { .len =2 ,
@@ -154,12 +149,8 @@ static int __sca3000_unlock_reg_lock(struct sca3000_state *st) st->tx[3 ] =0x50 ; st->tx[4 ] =SCA3000_WRITE_REG (SCA3000_REG_ADDR_UNLOCK ); st->tx[5 ] =0xA0 ; -spi_message_init (&msg); -spi_message_add_tail (&xfer[0 ], &msg); -spi_message_add_tail (&xfer[1 ], &msg); -spi_message_add_tail (&xfer[2 ], &msg); -return spi_sync (st->us, &msg); +return spi_sync_transfer (st->us, xfer,ARRAY_SIZE (xfer)); }/**
drivers/staging/iio/accel/sca3000_ring.c +1 -5
@@ -39,7 +39,6 @@ static int sca3000_read_data(struct sca3000_state *st, int len) {int ret; -struct spi_message msg;struct spi_transfer xfer[2 ] = { { .len =1 ,
@@ -55,10 +54,7 @@ static int sca3000_read_data(struct sca3000_state *st, } xfer[1 ].rx_buf = *rx_p; st->tx[0 ] =SCA3000_READ_REG (reg_address_high); -spi_message_init (&msg); -spi_message_add_tail (&xfer[0 ], &msg); -spi_message_add_tail (&xfer[1 ], &msg); - ret =spi_sync (st->us, &msg); + ret =spi_sync_transfer (st->us, xfer,ARRAY_SIZE (xfer));if (ret) {dev_err (get_device (&st->us->dev),"problem reading register" ); goto error_free_rx;
drivers/staging/iio/adc/ad7280a.c +1 -5
@@ -199,12 +199,8 @@ static int __ad7280_read32(struct spi_device *spi, unsigned *val) .rx_buf = &rx_buf, .len = 4, }; -struct spi_message m; -spi_message_init (&m); -spi_message_add_tail (&t, &m); - - ret =spi_sync (spi, &m); + ret =spi_sync_transfer (spi, &t,1 );if (ret)return ret;
drivers/staging/iio/frequency/ad5930.c +1 -4
@@ -44,7 +44,6 @@ static ssize_t ad5930_set_parameter(struct device *dev, const char *buf, size_t len) { -struct spi_message msg;struct spi_transfer xfer;int ret;struct ad5903_config *config = (struct ad5903_config *)buf;
@@ -64,9 +63,7 @@ static ssize_t ad5930_set_parameter(struct device *dev, xfer.tx_buf = config;mutex_lock (&st->lock); -spi_message_init (&msg); -spi_message_add_tail (&xfer, &msg); - ret =spi_sync (st->sdev, &msg); + ret =spi_sync_transfer (st->sdev, &xfer,1 );if (ret) goto error_ret; error_ret:
drivers/staging/iio/frequency/ad9850.c +1 -4
@@ -39,7 +39,6 @@ static ssize_t ad9850_set_parameter(struct device *dev, const char *buf, size_t len) { -struct spi_message msg;struct spi_transfer xfer;int ret;struct ad9850_config *config = (struct ad9850_config *)buf;
@@ -50,9 +49,7 @@ static ssize_t ad9850_set_parameter(struct device *dev, xfer.tx_buf = config;mutex_lock (&st->lock); -spi_message_init (&msg); -spi_message_add_tail (&xfer, &msg); - ret =spi_sync (st->sdev, &msg); + ret =spi_sync_transfer (st->sdev, &xfer,1 );if (ret) goto error_ret; error_ret:
drivers/staging/iio/frequency/ad9852.c +1 -4
@@ -183,7 +183,6 @@ static IIO_DEVICE_ATTR(dds, S_IWUSR, NULL, ad9852_set_parameter, 0);static void ad9852_init (struct ad9852_state *st) { -struct spi_message msg;struct spi_transfer xfer;int ret;u8 config[5 ];
@@ -199,9 +198,7 @@ static void ad9852_init(struct ad9852_state *st) xfer.len =5 ; xfer.tx_buf = &config; -spi_message_init (&msg); -spi_message_add_tail (&xfer, &msg); - ret =spi_sync (st->sdev, &msg); + ret =spi_sync_transfer (st->sdev, &xfer,1 );if (ret) goto error_ret;
drivers/staging/iio/gyro/adxrs450_core.c +1 -4
@@ -141,7 +141,6 @@ error_ret:static int adxrs450_spi_initial (struct adxrs450_state *st,u32 *val,char chk) { -struct spi_message msg;int ret;struct spi_transfer xfers = { .tx_buf = st->tx,
@@ -157,9 +156,7 @@ static int adxrs450_spi_initial(struct adxrs450_state *st, st->tx[3 ] =0 ;if (chk) st->tx[3 ] |= (ADXRS450_CHK |ADXRS450_P ); -spi_message_init (&msg); -spi_message_add_tail (&xfers, &msg); - ret =spi_sync (st->us, &msg); + ret =spi_sync_transfer (st->us, &xfers,1 );if (ret) {dev_err (&st->us->dev,"Problem while reading initializing data\n" ); goto error_ret;
drivers/staging/iio/meter/ade7753.c +1 -5
@@ -103,7 +103,6 @@ static int ade7753_spi_read_reg_24(struct device *dev,u8 reg_address, u32 *val) { - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev);struct ade7753_state *st =iio_priv (indio_dev);int ret;
@@ -122,10 +121,7 @@ static int ade7753_spi_read_reg_24(struct device *dev,mutex_lock (&st->buf_lock); st->tx[0 ] =ADE7753_READ_REG (reg_address); -spi_message_init (&msg); -spi_message_add_tail (&xfers[0 ], &msg); -spi_message_add_tail (&xfers[1 ], &msg); - ret =spi_sync (st->us, &msg); + ret =spi_sync_transfer (st->us, xfers,ARRAY_SIZE (xfers));if (ret) {dev_err (&st->us->dev,"problem when reading 24 bit register 0x%02X" , reg_address);
drivers/staging/iio/meter/ade7754.c +1 -4
@@ -103,7 +103,6 @@ static int ade7754_spi_read_reg_24(struct device *dev,u8 reg_address, u32 *val) { - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev);struct ade7754_state *st =iio_priv (indio_dev);int ret;
@@ -122,9 +121,7 @@ static int ade7754_spi_read_reg_24(struct device *dev, st->tx[2 ] =0 ; st->tx[3 ] =0 ; -spi_message_init (&msg); -spi_message_add_tail (xfers, &msg); - ret =spi_sync (st->us, &msg); + ret =spi_sync_transfer (st->us, xfers,ARRAY_SIZE (xfers));if (ret) {dev_err (&st->us->dev,"problem when reading 24 bit register 0x%02X" , reg_address);
drivers/staging/iio/meter/ade7758_core.c +5 -23
@@ -47,7 +47,6 @@ static int ade7758_spi_write_reg_16(struct device *dev, u16 value) {int ret; -struct spi_message msg;struct iio_dev *indio_dev =dev_to_iio_dev (dev);struct ade7758_state *st =iio_priv (indio_dev);struct spi_transfer xfers[] = {
@@ -63,9 +62,7 @@ static int ade7758_spi_write_reg_16(struct device *dev, st->tx[1 ] = (value >>8 ) &0xFF ; st->tx[2 ] = value &0xFF ; -spi_message_init (&msg); -spi_message_add_tail (xfers, &msg); - ret =spi_sync (st->us, &msg); + ret =spi_sync_transfer (st->us, xfers,ARRAY_SIZE (xfers));mutex_unlock (&st->buf_lock);return ret;
@@ -76,7 +73,6 @@ static int ade7758_spi_write_reg_24(struct device *dev, u32 value) {int ret; -struct spi_message msg;struct iio_dev *indio_dev =dev_to_iio_dev (dev);struct ade7758_state *st =iio_priv (indio_dev);struct spi_transfer xfers[] = {
@@ -93,9 +89,7 @@ static int ade7758_spi_write_reg_24(struct device *dev, st->tx[2 ] = (value >>8 ) &0xFF ; st->tx[3 ] = value &0xFF ; -spi_message_init (&msg); -spi_message_add_tail (xfers, &msg); - ret =spi_sync (st->us, &msg); + ret =spi_sync_transfer (st->us, xfers,ARRAY_SIZE (xfers));mutex_unlock (&st->buf_lock);return ret;
@@ -105,7 +99,6 @@ int ade7758_spi_read_reg_8(struct device *dev,u8 reg_address, u8 *val) { - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev);struct ade7758_state *st =iio_priv (indio_dev);int ret;
@@ -128,10 +121,7 @@ int ade7758_spi_read_reg_8(struct device *dev, st->tx[0 ] =ADE7758_READ_REG (reg_address); st->tx[1 ] =0 ; -spi_message_init (&msg); -spi_message_add_tail (&xfers[0 ], &msg); -spi_message_add_tail (&xfers[1 ], &msg); - ret =spi_sync (st->us, &msg); + ret =spi_sync_transfer (st->us, xfers,ARRAY_SIZE (xfers));if (ret) {dev_err (&st->us->dev,"problem when reading 8 bit register 0x%02X" , reg_address);
@@ -148,7 +138,6 @@ static int ade7758_spi_read_reg_16(struct device *dev,u8 reg_address, u16 *val) { - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev);struct ade7758_state *st =iio_priv (indio_dev);int ret;
@@ -173,10 +162,7 @@ static int ade7758_spi_read_reg_16(struct device *dev, st->tx[1 ] =0 ; st->tx[2 ] =0 ; -spi_message_init (&msg); -spi_message_add_tail (&xfers[0 ], &msg); -spi_message_add_tail (&xfers[1 ], &msg); - ret =spi_sync (st->us, &msg); + ret =spi_sync_transfer (st->us, xfers,ARRAY_SIZE (xfers));if (ret) {dev_err (&st->us->dev,"problem when reading 16 bit register 0x%02X" , reg_address);
@@ -194,7 +180,6 @@ static int ade7758_spi_read_reg_24(struct device *dev,u8 reg_address, u32 *val) { - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev);struct ade7758_state *st =iio_priv (indio_dev);int ret;
@@ -219,10 +204,7 @@ static int ade7758_spi_read_reg_24(struct device *dev, st->tx[2 ] =0 ; st->tx[3 ] =0 ; -spi_message_init (&msg); -spi_message_add_tail (&xfers[0 ], &msg); -spi_message_add_tail (&xfers[1 ], &msg); - ret =spi_sync (st->us, &msg); + ret =spi_sync_transfer (st->us, xfers,ARRAY_SIZE (xfers));if (ret) {dev_err (&st->us->dev,"problem when reading 24 bit register 0x%02X" , reg_address);
drivers/staging/iio/meter/ade7759.c +1 -4
@@ -103,7 +103,6 @@ static int ade7759_spi_read_reg_40(struct device *dev,u8 reg_address, u64 *val) { - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev);struct ade7759_state *st =iio_priv (indio_dev);int ret;
@@ -120,9 +119,7 @@ static int ade7759_spi_read_reg_40(struct device *dev, st->tx[0 ] =ADE7759_READ_REG (reg_address);memset (&st->tx[1 ],0 ,5 ); -spi_message_init (&msg); -spi_message_add_tail (xfers, &msg); - ret =spi_sync (st->us, &msg); + ret =spi_sync_transfer (st->us, xfers,ARRAY_SIZE (xfers));if (ret) {dev_err (&st->us->dev,"problem when reading 40 bit register 0x%02X" , reg_address);
drivers/staging/iio/meter/ade7854-spi.c +8 -36
140 lines not on this page · raw message
drivers/staging/iio/resolver/ad2s1210.c +1 -4
@@ -130,15 +130,12 @@ static int ad2s1210_config_read(struct ad2s1210_state *st, .rx_buf = st->rx, .tx_buf = st->tx, }; -struct spi_message msg;int ret =0 ;ad2s1210_set_mode (MOD_CONFIG , st); -spi_message_init (&msg); -spi_message_add_tail (&xfer, &msg); st->tx[0 ] = address |AD2S1210_MSB_IS_HIGH ; st->tx[1 ] =AD2S1210_REG_FAULT ; - ret =spi_sync (st->sdev, &msg); + ret =spi_sync_transfer (st->sdev, &xfer,1 );if (ret <0 )return ret; st->old_data = true;
Signature · 1 line
1.8.0
Quoted 56 lines · Lars-Peter Clausen
Quite often the pattern used for setting up and transferring a synchronous SPI transaction looks very much like the following:
struct spi_message msg; struct spi_transfer xfers[] = { ... }; spi_message_init(&msg); spi_message_add_tail(&xfers[0], &msg); ... spi_message_add_tail(&xfers[ARRAY_SIZE(xfers) - 1], &msg); ret = spi_sync(&msg);This patch adds two new helper functions for handling this case. The first helper function
spi_message_init_with_transfers()takes aspi_messageand an array ofspi_transfers. It will initialize the message and then callspi_message_add_tail()for each transfer in the array. E.g. the followingspi_message_init(&msg); spi_message_add_tail(&xfers[0], &msg); ... spi_message_add_tail(&xfers[ARRAY_SIZE(xfers) - 1], &msg);can be rewritten as
spi_message_init_with_transfers(&msg, xfers, ARRAY_SIZE(xfers));The second function
spi_sync_transfer()takes a SPI device and an array ofspi_transfers. It will allocate a newspi_message(on the stack) and add all transfers in the array to the message. Finally it will callspi_sync()on the message.E.g. the follwing
struct spi_message msg; struct spi_transfer xfers[] = { ... }; spi_message_init(&msg); spi_message_add_tail(&xfers[0], &msg); ... spi_message_add_tail(&xfers[ARRAY_SIZE(xfers) - 1], &msg); ret = spi_sync(spi, &msg);can be rewritten as
struct spi_transfer xfers[] = { ... }; ret = spi_sync_transfer(spi, xfers, ARRAY_SIZE(xfers));
Quoted 6 lines
The patch also adds a new cocci script which can detect such sequences as described above and transform them automatically to use the new helper functions.
Signed-off-by Lars-Peter Clausen <lars-Qo5EllUWu/[email protected]>
Principle looks good to me and some nice little duplication removal savings.
My coccinelle isn't really up to checking that, but for the functions
When all comments are in on the code we'll have to think about how to merge this. If you have much else planned that will hit those iio drivers then things will get uggly unless it goes through that tree.
Guess it all depends on whether others like the patch though ;)
Quoted 219 lines
---
I'm not entirely happy with names of the two new functions and I'm open for better suggestions.--- include/linux/spi/spi.h | 44 ++++++++ scripts/coccinelle/api/spi_sync_transfer.cocci | 141 +++++++++++++++++++++++++ 2 files changed, 185 insertions(+) create mode 100644 scripts/coccinelle/api/spi_sync_transfer.cocciinclude/linux/spi/spi.h +44
-0@@ -591,6 +591,26 @@ spi_transfer_del(struct spi_transfer *t)list_del (&t->transfer_list); } +/** +* spi_message_init_with_transfers - Initialize spi_message and append transfers +* @m: spi_message to be initialized +* @xfers: An array of spi transfers +* @num_xfers: Number of items in the xfer array +* +* This function initializes the given spi_message and adds each spi_transfer in +* the given array to the message. +*/ +static inline void +spi_message_init_with_transfers (struct spi_message *m, +struct spi_transfer *xfers,unsigned int num_xfers) +{ +unsigned int i; + +spi_message_init (m); +for (i =0 ; i < num_xfers; ++i) +spi_message_add_tail (&xfers[i], m); +} +/* It's fine to embed message and transaction structures in other data * structures so long as you don't free them while they're in use. */ @@ -683,6 +703,30 @@ spi_read(struct spi_device *spi, void *buf, size_t len)return spi_sync (spi, &m); } +/** +* spi_sync_transfer - synchronous SPI data transfer +* @spi: device with which data will be exchanged +* @xfers: An array of spi_transfers +* @num_xfers: Number of items in the xfer array +* Context: can sleep +* +* Does a synchronous SPI data transfer of the given spi_transfer array. +* +* For more specific semantics see spi_sync(). +* +* It returns zero on success, else a negative error code. +*/ +static inline int +spi_sync_transfer (struct spi_device *spi,struct spi_transfer *xfers, +unsigned int num_xfers) +{ +struct spi_message msg; + +spi_message_init_with_transfers (&msg, xfers, num_xfers); + +return spi_sync (spi, &msg); +} +/* this copies txbuf and rxbuf data; for small transfers only! */ extern int spi_write_then_read(struct spi_device *spi, const void *txbuf, unsigned n_tx,scripts/coccinelle/api/spi_sync_transfer.cocci new file +141
-0@@ -0,0 +1,141 @@ +/// +/// Use spi_sync_transfer instead of open-coding it +/// +// Confidence: High +// Options: --no-includes +// +// Keywords: spi_sync, spi_sync_transfer +// Version min: 3.9 +// + +virtual context +virtual patch +virtual org +virtual report + +@r1@ +identifier fn; +identifier xfers; +@@ +fn(...) +{ + ... +( + struct spi_transfer xfers[...]; +| + struct spi_transfer xfers[]; +) + ... +} + +@depends on patch@ +identifier msg; +expression spi; +identifier r1.fn; +identifier r1.xfers; +@@ +fn(...) +{ +... +-struct spi_message msg; +... +-spi_message_init(&msg); +<... +-spi_message_add_tail(&xfers[...], &msg); +...> + +-spi_sync(spi, &msg) ++spi_sync_transfer(spi, xfers, ARRAY_SIZE(xfers)) +... +} + +@r3 depends on context || org || report@ +identifier msg; +expression spi; +identifier r1.xfers; +identifier r1.fn; +position p; +@@ +fn(...) +{ +... +*struct spi_message msg; +... +*spi_message_init(&msg); +<... +*spi_message_add_tail(&xfers[...], &msg); +...> +*spi_sync@p(spi, &msg) +... +} + +@r2@ +identifier fn; +identifier xfer; +@@ +fn(...) +{ + ... + struct spi_transfer xfer; + ... +} + +@depends on patch@ +identifier msg; +expression spi; +identifier r2.xfer; +identifier r2.fn; +@@ +fn(...) +{ +... +-struct spi_message msg; +... +-spi_message_init(&msg); +... +-spi_message_add_tail(&xfer, &msg); +... +-spi_sync(spi, &msg) ++spi_sync_transfer(spi, &xfer, 1) +... +} + +@r4 depends on context || org || report@ +identifier msg; +expression spi; +identifier r2.xfer; +identifier r2.fn; +position p; +@@ +fn(...) +{ +... +*struct spi_message msg; +... +*spi_message_init(&msg); +... +*spi_message_add_tail(&xfer, &msg); +... +*spi_sync@p(spi, &msg) +... +} + +@script:python depends on report@ +p << r3.p; +@@ +coccilib.report.print_report(p[0], "Consider using spi_sync_transfer instead of open-conding it.") + +@script:python depends on report@ +p << r4.p; +@@ +coccilib.report.print_report(p[0], "Consider using spi_sync_transfer instead of open-conding it.") + +@script:python depends on org@ +p << r3.p; +@@ +coccilib.org.print_todo(p[0], "Consider using spi_sync_transfer instead of open-conding it.") + +@script:python depends on org@ +p << r4.p; +@@ +coccilib.org.print_todo(p[0], "Consider using spi_sync_transfer instead of open-conding it.")
Quoted 66 lines · Jonathan Cameron
Quoted 56 lines · Lars-Peter Clausen
Quite often the pattern used for setting up and transferring a synchronous SPI transaction looks very much like the following:
struct spi_message msg; struct spi_transfer xfers[] = { ... }; spi_message_init(&msg); spi_message_add_tail(&xfers[0], &msg); ... spi_message_add_tail(&xfers[ARRAY_SIZE(xfers) - 1], &msg); ret = spi_sync(&msg);This patch adds two new helper functions for handling this case. The first helper function
spi_message_init_with_transfers()takes aspi_messageand an array ofspi_transfers. It will initialize the message and then callspi_message_add_tail()for each transfer in the array. E.g. the followingspi_message_init(&msg); spi_message_add_tail(&xfers[0], &msg); ... spi_message_add_tail(&xfers[ARRAY_SIZE(xfers) - 1], &msg);can be rewritten as
spi_message_init_with_transfers(&msg, xfers, ARRAY_SIZE(xfers));The second function
spi_sync_transfer()takes a SPI device and an array ofspi_transfers. It will allocate a newspi_message(on the stack) and add all transfers in the array to the message. Finally it will callspi_sync()on the message.E.g. the follwing
struct spi_message msg; struct spi_transfer xfers[] = { ... }; spi_message_init(&msg); spi_message_add_tail(&xfers[0], &msg); ... spi_message_add_tail(&xfers[ARRAY_SIZE(xfers) - 1], &msg); ret = spi_sync(spi, &msg);can be rewritten as
struct spi_transfer xfers[] = { ... }; ret = spi_sync_transfer(spi, xfers, ARRAY_SIZE(xfers));Quoted 6 lines
The patch also adds a new cocci script which can detect such sequences as described above and transform them automatically to use the new helper functions.
Signed-off-by Lars-Peter Clausen <[email protected]>Principle looks good to me and some nice little duplication removal savings.
Quoted 8 lines
My coccinelle isn't really up to checking that, but for the functions
Acked-by Jonathan Cameron <[email protected]>When all comments are in on the code we'll have to think about how to merge this. If you have much else planned that will hit those iio drivers then things will get uggly unless it goes through that tree.
Guess it all depends on whether others like the patch though ;)
The IIO patches can easily wait another release until the spi has made it's way up into mainline. I just didn't want to send out the helper functions without any realworld examples on how they can be used.
- Lars
Jonathan Cameron
maintainerQuoted 74 lines · Lars-Peter Clausen
Quoted 73 lines · Jonathan Cameron
Quoted 56 lines · Lars-Peter Clausen
Quite often the pattern used for setting up and transferring a synchronous SPI transaction looks very much like the following:
struct spi_message msg; struct spi_transfer xfers[] = { ... }; spi_message_init(&msg); spi_message_add_tail(&xfers[0], &msg); ... spi_message_add_tail(&xfers[ARRAY_SIZE(xfers) - 1], &msg); ret = spi_sync(&msg);This patch adds two new helper functions for handling this case. The first helper function
spi_message_init_with_transfers()takes aspi_messageand an array ofspi_transfers. It will initialize the message and then callspi_message_add_tail()for each transfer in the array. E.g. the followingspi_message_init(&msg); spi_message_add_tail(&xfers[0], &msg); ... spi_message_add_tail(&xfers[ARRAY_SIZE(xfers) - 1], &msg);can be rewritten as
spi_message_init_with_transfers(&msg, xfers, ARRAY_SIZE(xfers));The second function
spi_sync_transfer()takes a SPI device and an array ofspi_transfers. It will allocate a newspi_message(on the stack) and add all transfers in the array to the message. Finally it will callspi_sync()on the message.E.g. the follwing
struct spi_message msg; struct spi_transfer xfers[] = { ... }; spi_message_init(&msg); spi_message_add_tail(&xfers[0], &msg); ... spi_message_add_tail(&xfers[ARRAY_SIZE(xfers) - 1], &msg); ret = spi_sync(spi, &msg);can be rewritten as
struct spi_transfer xfers[] = { ... }; ret = spi_sync_transfer(spi, xfers, ARRAY_SIZE(xfers));Quoted 6 lines
The patch also adds a new cocci script which can detect such sequences as described above and transform them automatically to use the new helper functions.
Signed-off-by Lars-Peter Clausen <lars-Qo5EllUWu/[email protected]>Principle looks good to me and some nice little duplication removal savings.
My coccinelle isn't really up to checking that, but for the functions
Acked-by Jonathan Cameron <[email protected]>When all comments are in on the code we'll have to think about how to merge this. If you have much else planned that will hit those iio drivers then things will get uggly unless it goes through that tree.
Quoted 6 lines
Quoted 1 line
Guess it all depends on whether others like the patch though ;)
The IIO patches can easily wait another release until the spi has made it's way up into mainline. I just didn't want to send out the helper functions without any realworld examples on how they can be used.
Good point, though obviously send them again after this patch has merged given the fine nature of my memory ;)
------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery and much more. Keep your Java skills current with LearnJavaNow - 200+ hours of step-by-step video tutorials by Java experts. SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612
Quoted 4 lines
+@r1@
scripts/coccinelle/api/spi_sync_transfer.cocci new file +3
-0+identifier fn; +identifier xfers; +@@
scripts/coccinelle/api/spi_sync_transfer.cocci line 29
Quoted 10 lines
scripts/coccinelle/api/spi_sync_transfer.cocci new file +10
-0+fn(...) +{ + ... +( + struct spi_transfer xfers[...]; +| + struct spi_transfer xfers[]; +) + ... +}
Can it happen that there would be more than one spi_transfer or spi_message variable per function? This semantic patch will only treat the case where there is only one, because the ... before an after the variable declaration won't match another declaration of the same form.
julia
Quoted 20 lines · Julia Lawall
Quoted 4 lines
+@r1@
scripts/coccinelle/api/spi_sync_transfer.cocci new file +3
-0+identifier fn; +identifier xfers; +@@scripts/coccinelle/api/spi_sync_transfer.cocci line 29
Quoted 10 lines
scripts/coccinelle/api/spi_sync_transfer.cocci new file +10
-0+fn(...) +{ + ... +( + struct spi_transfer xfers[...]; +| + struct spi_transfer xfers[]; +) + ... +}Can it happen that there would be more than one
spi_transferorspi_messagevariable per function? This semantic patch will only treat the case where there is only one, because the ... before an after the variable declaration won't match another declaration of the same form.
Quoted 1 line
julia
I guess it could happen, but I would consider it to be very rare. There are a few examples of multiple transfers in the kernel. But most of them look like
struct spi_message msg;
struct spi_transfer xfer_foo;
struct spi_transfer xfer_bar;
...spi_message_add_tail(&xfer_foo, &msg);spi_message_add_tail(&xfer_bar, &msg);
So the transformation can't be applied here anyway.
Do you have an idea how to change the rule to work with multiple transfers/messages per function? If it would make the cocci file more complex I wouldn't bother to take care of it, since it basically has no practical use.
- Lars
Quoted 34 lines · Lars-Peter Clausen
Quoted 20 lines · Julia Lawall
Quoted 4 lines
+@r1@
scripts/coccinelle/api/spi_sync_transfer.cocci new file +3
-0+identifier fn; +identifier xfers; +@@scripts/coccinelle/api/spi_sync_transfer.cocci line 29
Quoted 10 lines
scripts/coccinelle/api/spi_sync_transfer.cocci new file +10
-0+fn(...) +{ + ... +( + struct spi_transfer xfers[...]; +| + struct spi_transfer xfers[]; +) + ... +}Can it happen that there would be more than one
spi_transferorspi_messagevariable per function? This semantic patch will only treat the case where there is only one, because the ... before an after the variable declaration won't match another declaration of the same form.Quoted 1 line
julia
I guess it could happen, but I would consider it to be very rare. There are a few examples of multiple transfers in the kernel. But most of them look like
struct
spi_messagemsg;
structspi_transferxfer_foo;
structspi_transferxfer_bar;...
spi_message_add_tail(&xfer_foo, &msg);spi_message_add_tail(&xfer_bar, &msg);
Quoted 6 lines
So the transformation can't be applied here anyway.
Do you have an idea how to change the rule to work with multiple transfers/messages per function? If it would make the cocci file more complex I wouldn't bother to take care of it, since it basically has no practical use.
Probably the simplest thing is to put when any on all of the ...s It might get slower, though.
Alternatively you could have a rule at the end that prints a warning for any cases that are not transformed.
julia
Quoted 4 lines · Lars-Peter Clausen
The second function
spi_sync_transfer()takes a SPI device and an array ofspi_transfers. It will allocate a newspi_message(on the stack) and add all transfers in the array to the message. Finally it will callspi_sync()on the message.
for the helpers, we should try to get them merged separately to the coccinelle rules if there's issue with those.
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
Quoted 8 lines · Mark Brown
Quoted 4 lines · Lars-Peter Clausen
The second function
spi_sync_transfer()takes a SPI device and an array ofspi_transfers. It will allocate a newspi_message(on the stack) and add all transfers in the array to the message. Finally it will callspi_sync()on the message.
Looks good to me also. Go ahead and merge this series through the iio tree since it is the first user.
g.
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
Jonathan Cameron
maintainerQuoted 8 lines · Grant Likely
Quoted 7 lines · Mark Brown
Quoted 4 lines · Lars-Peter Clausen
The second function
spi_sync_transfer()takes a SPI device and an array ofspi_transfers. It will allocate a newspi_message(on the stack) and add all transfers in the array to the message. Finally it will callspi_sync()on the message.
Quoted 4 lines
Quoted 1 line
Looks good to me also. Go ahead and merge this series through the iio tree since it is the first user.
Lars, when you are back on your feet, could you respin this series against the latest iio tree please. 2 drivers have moved which messes up patches 2 and 3. Now I could fix it up, but it's your patch series and I'm lazy ;)
Quoted 8 lines
g.
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Jonathan Cameron
maintainerQuoted 9 lines · Jonathan Cameron
Quoted 8 lines · Grant Likely
Quoted 7 lines · Mark Brown
Quoted 4 lines · Lars-Peter Clausen
The second function
spi_sync_transfer()takes a SPI device and an array ofspi_transfers. It will allocate a newspi_message(on the stack) and add all transfers in the array to the message. Finally it will callspi_sync()on the message.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Looks good to me also. Go ahead and merge this series through the iio tree since it is the first user.
Lars, when you are back on your feet, could you respin this series against the latest iio tree please. 2 drivers have moved which messes up patches 2 and 3. Now I could fix it up, but it's your patch series and I'm lazy ;)
I had a few spare minutes so I've respun the series with the driver moves. I have also, dropped the coccinelle script from the first patch. I was unclear on whether the questions about that had been resolved.
Anyhow, I've temporarily pushed out to togreg branch of iio.git. If Grant wants to add an ack, I'll pop that in before sending upstream if not I'll just put a note in the tag message (or if he is too slow for my arbitrary definition fo too slow ;)
Jonathan
Quoted 15 lines
Quoted 10 lines
g.
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Jonathan Cameron
maintainerQuoted 8 lines · Grant Likely
Quoted 7 lines · Mark Brown
Quoted 4 lines · Lars-Peter Clausen
The second function
spi_sync_transfer()takes a SPI device and an array ofspi_transfers. It will allocate a newspi_message(on the stack) and add all transfers in the array to the message. Finally it will callspi_sync()on the message.
Quoted 4 lines
Quoted 1 line
Looks good to me also. Go ahead and merge this series through the iio tree since it is the first user.
Grant, can I take that as an Acked-by? Its going to touch your tree so that would probably reduce questions as this goes up stream.
Quoted 8 lines
g.
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html