mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-09 22:50:41 +00:00
iio:adxrs450: Use spi_sync_transfer()
Use the spi_sync_transfer() helper function instead of open-coding it. Makes the code a bit shorter. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
af3d5cad0a
commit
35734fbdb5
@ -90,7 +90,6 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev,
|
|||||||
u8 reg_address,
|
u8 reg_address,
|
||||||
u16 *val)
|
u16 *val)
|
||||||
{
|
{
|
||||||
struct spi_message msg;
|
|
||||||
struct adxrs450_state *st = iio_priv(indio_dev);
|
struct adxrs450_state *st = iio_priv(indio_dev);
|
||||||
u32 tx;
|
u32 tx;
|
||||||
int ret;
|
int ret;
|
||||||
@ -114,10 +113,7 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev,
|
|||||||
tx |= ADXRS450_P;
|
tx |= ADXRS450_P;
|
||||||
|
|
||||||
st->tx = cpu_to_be32(tx);
|
st->tx = cpu_to_be32(tx);
|
||||||
spi_message_init(&msg);
|
ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
|
||||||
spi_message_add_tail(&xfers[0], &msg);
|
|
||||||
spi_message_add_tail(&xfers[1], &msg);
|
|
||||||
ret = spi_sync(st->us, &msg);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n",
|
dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n",
|
||||||
reg_address);
|
reg_address);
|
||||||
@ -169,7 +165,6 @@ static int adxrs450_spi_write_reg_16(struct iio_dev *indio_dev,
|
|||||||
**/
|
**/
|
||||||
static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val)
|
static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val)
|
||||||
{
|
{
|
||||||
struct spi_message msg;
|
|
||||||
struct adxrs450_state *st = iio_priv(indio_dev);
|
struct adxrs450_state *st = iio_priv(indio_dev);
|
||||||
int ret;
|
int ret;
|
||||||
struct spi_transfer xfers[] = {
|
struct spi_transfer xfers[] = {
|
||||||
@ -188,10 +183,7 @@ static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val)
|
|||||||
mutex_lock(&st->buf_lock);
|
mutex_lock(&st->buf_lock);
|
||||||
st->tx = cpu_to_be32(ADXRS450_SENSOR_DATA);
|
st->tx = cpu_to_be32(ADXRS450_SENSOR_DATA);
|
||||||
|
|
||||||
spi_message_init(&msg);
|
ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
|
||||||
spi_message_add_tail(&xfers[0], &msg);
|
|
||||||
spi_message_add_tail(&xfers[1], &msg);
|
|
||||||
ret = spi_sync(st->us, &msg);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&st->us->dev, "Problem while reading sensor data\n");
|
dev_err(&st->us->dev, "Problem while reading sensor data\n");
|
||||||
goto error_ret;
|
goto error_ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user