mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 19:07:52 +00:00
Merge remote-tracking branch 'spi/topic/wr' into spi-next
This commit is contained in:
commit
82f85cf98f
5 changed files with 31 additions and 12 deletions
|
@ -42,13 +42,8 @@ static const u8 adt7310_reg_table[] = {
|
||||||
static int adt7310_spi_read_word(struct device *dev, u8 reg)
|
static int adt7310_spi_read_word(struct device *dev, u8 reg)
|
||||||
{
|
{
|
||||||
struct spi_device *spi = to_spi_device(dev);
|
struct spi_device *spi = to_spi_device(dev);
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = spi_w8r16(spi, AD7310_COMMAND(reg) | ADT7310_CMD_READ);
|
return spi_w8r16be(spi, AD7310_COMMAND(reg) | ADT7310_CMD_READ);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return be16_to_cpu((__force __be16)ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int adt7310_spi_write_word(struct device *dev, u8 reg, u16 data)
|
static int adt7310_spi_write_word(struct device *dev, u8 reg, u16 data)
|
||||||
|
|
|
@ -86,7 +86,7 @@ static int ade7753_spi_read_reg_16(struct device *dev,
|
||||||
struct ade7753_state *st = iio_priv(indio_dev);
|
struct ade7753_state *st = iio_priv(indio_dev);
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
ret = spi_w8r16(st->us, ADE7753_READ_REG(reg_address));
|
ret = spi_w8r16be(st->us, ADE7753_READ_REG(reg_address));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
|
dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
|
||||||
reg_address);
|
reg_address);
|
||||||
|
@ -94,7 +94,6 @@ static int ade7753_spi_read_reg_16(struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
*val = ret;
|
*val = ret;
|
||||||
*val = be16_to_cpup(val);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ static int ade7754_spi_read_reg_16(struct device *dev,
|
||||||
struct ade7754_state *st = iio_priv(indio_dev);
|
struct ade7754_state *st = iio_priv(indio_dev);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = spi_w8r16(st->us, ADE7754_READ_REG(reg_address));
|
ret = spi_w8r16be(st->us, ADE7754_READ_REG(reg_address));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
|
dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
|
||||||
reg_address);
|
reg_address);
|
||||||
|
@ -94,7 +94,6 @@ static int ade7754_spi_read_reg_16(struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
*val = ret;
|
*val = ret;
|
||||||
*val = be16_to_cpup(val);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ static int ade7759_spi_read_reg_16(struct device *dev,
|
||||||
struct ade7759_state *st = iio_priv(indio_dev);
|
struct ade7759_state *st = iio_priv(indio_dev);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = spi_w8r16(st->us, ADE7759_READ_REG(reg_address));
|
ret = spi_w8r16be(st->us, ADE7759_READ_REG(reg_address));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
|
dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
|
||||||
reg_address);
|
reg_address);
|
||||||
|
@ -94,7 +94,6 @@ static int ade7759_spi_read_reg_16(struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
*val = ret;
|
*val = ret;
|
||||||
*val = be16_to_cpup(val);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -853,6 +853,33 @@ static inline ssize_t spi_w8r16(struct spi_device *spi, u8 cmd)
|
||||||
return (status < 0) ? status : result;
|
return (status < 0) ? status : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* spi_w8r16be - SPI synchronous 8 bit write followed by 16 bit big-endian read
|
||||||
|
* @spi: device with which data will be exchanged
|
||||||
|
* @cmd: command to be written before data is read back
|
||||||
|
* Context: can sleep
|
||||||
|
*
|
||||||
|
* This returns the (unsigned) sixteen bit number returned by the device in cpu
|
||||||
|
* endianness, or else a negative error code. Callable only from contexts that
|
||||||
|
* can sleep.
|
||||||
|
*
|
||||||
|
* This function is similar to spi_w8r16, with the exception that it will
|
||||||
|
* convert the read 16 bit data word from big-endian to native endianness.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static inline ssize_t spi_w8r16be(struct spi_device *spi, u8 cmd)
|
||||||
|
|
||||||
|
{
|
||||||
|
ssize_t status;
|
||||||
|
__be16 result;
|
||||||
|
|
||||||
|
status = spi_write_then_read(spi, &cmd, 1, &result, 2);
|
||||||
|
if (status < 0)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
return be16_to_cpu(result);
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue