[PATCH 07/11] staging: iio: ad2s1200: Ensure udelay(1) in all necessary code paths
David Julian Veenstra
davidjulianveenstra at gmail.com
Sat Mar 24 12:26:54 UTC 2018
On 23, March 2018 14:20, Jonathan Cameron wrote:
> On Sun, 18 Mar 2018 14:36:15 +0100
> David Veenstra <davidjulianveenstra at gmail.com> wrote:
>
>> After a successful spi transaction, a udelay(1) is needed.
>> This doesn't happen for the default case of the switch statement
>> in ad2s1200_read_raw. This patch makes sure that it does.
>>
>> Signed-off-by: David Veenstra <davidjulianveenstra at gmail.com>
> Given this one can't actually happen as the chan->type
> is always one of the two options, I can't see the point
> in making sure we sleep.
>
> The default is really just there to catch bugs and to suppress
> the build warning we would otherwise get.
>
> So I am unconvinced on this patch.
I wasn't sure about this patch, but tried to be as critical as possible.
I'll leave it out for V2.
Best regards,
David Veenstra
>
> Jonathan
>> ---
>> drivers/staging/iio/resolver/ad2s1200.c | 8 +++++---
>> 1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c
>> index e0e7c88368ed..6ce9ca13094a 100644
>> --- a/drivers/staging/iio/resolver/ad2s1200.c
>> +++ b/drivers/staging/iio/resolver/ad2s1200.c
>> @@ -78,20 +78,22 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev,
>> switch (chan->type) {
>> case IIO_ANGL:
>> *val = vel >> 4;
>> + ret = IIO_VAL_INT;
>> break;
>> case IIO_ANGL_VEL:
>> *val = sign_extend32((s16)vel >> 4, 11);
>> + ret = IIO_VAL_INT;
>> break;
>> default:
>> - mutex_unlock(&st->lock);
>> - return -EINVAL;
>> + ret = -EINVAL;
>> + break;
>> }
>>
>> /* delay (2 * AD2S1200_TSCLK + 20) ns for sample pulse */
>> udelay(1);
>> mutex_unlock(&st->lock);
>>
>> - return IIO_VAL_INT;
>> + return ret;
>> }
>>
>> static const struct iio_chan_spec ad2s1200_channels[] = {
More information about the devel
mailing list