[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VfReT-EjCV=cW8mV1MmoMPPdY9q1scoPwbD_DEHpQHd3g@mail.gmail.com>
Date: Thu, 3 Sep 2020 16:25:08 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Nishant Malpani <nish.malpani25@...il.com>
Cc: Jonathan Cameron <jic23@...nel.org>,
Rob Herring <robh+dt@...nel.org>,
"Bogdan, Dragos" <dragos.bogdan@...log.com>,
darius.berghe@...log.com,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-iio <linux-iio@...r.kernel.org>,
devicetree <devicetree@...r.kernel.org>
Subject: Re: [PATCH v2 3/3] iio: gyro: adxrs290: Add debugfs register access support
On Thu, Sep 3, 2020 at 4:10 PM Nishant Malpani <nish.malpani25@...il.com> wrote:
>
> Extend support to read/write byte data from/to the device using
> debugfs iio interface.
...
> +static int adxrs290_reg_access(struct iio_dev *indio_dev, unsigned int reg,
> + unsigned int writeval, unsigned int *readval)
> +{
> + struct adxrs290_state *st = iio_priv(indio_dev);
> + int ret;
> +
> + if (!readval)
> + return adxrs290_spi_write_reg(st->spi, reg, writeval);
> +
> + ret = spi_w8r8(st->spi, ADXRS290_READ_REG(reg));
> + if (ret < 0)
> + return ret;
> +
> + *readval = ret;
> +
> + return 0;
> +}
Hmm... I would suggest to have it like
adxrs290_reg_access_rw()
{
...
return 0;
}
adxrs290_reg_access()
{
if (readval)
return adxrs290_reg_access_rw();
else // it's redundant, but someone can use for better formatting
return adxrs290_spi_write_reg();
}
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists