linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hartmut Knaack <knaack.h@gmx.de>
To: Crt Mori <cmo@melexis.com>
Cc: linux-iio@vger.kernel.org, Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald <pmeerw@pmeerw.net>,
	Tiberiu Breana <tiberiu.a.breana@intel.com>
Subject: Re: [PATCH v2 2/7] iio:accel:stk8312: check for invalid value
Date: Sat, 01 Aug 2015 00:54:30 +0200	[thread overview]
Message-ID: <55BBFCA6.1090803@gmx.de> (raw)
In-Reply-To: <CAKv63utc6+a5XS5eLkzggcnvcrfN=zTsTAJfNNethnPmr2S9Yg@mail.gmail.com>

Crt Mori schrieb am 30.07.2015 um 09:09:
> On 29 July 2015 at 23:39, Hartmut Knaack <knaack.h@gmx.de> wrote:
>> Revision 1.2 of the datasheet recommends on page 22 to only write non-zero
>> values read from OTP register 0x70 into AFECTRL register.
>>
>> Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
>> Reviewed-by: Tiberiu Breana <tiberiu.a.breana@intel.com>
>> ---
>>  drivers/iio/accel/stk8312.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c
>> index c2bd1444d6da..6592be8e6377 100644
>> --- a/drivers/iio/accel/stk8312.c
>> +++ b/drivers/iio/accel/stk8312.c
>> @@ -150,6 +150,8 @@ static int stk8312_otp_init(struct stk8312_data *data)
>>                 goto exit_err;
>>
>>         ret = i2c_smbus_read_byte_data(client, STK8312_REG_OTPDATA);
>> +       if (ret == 0)
>> +               ret = -EINVAL;
> This seems fishy. We have a macro value written to client which cannot really
> give us EINVAL, except if we are checking the client, but then this would only
> fail if we had some other i2c device on the line with stk8312 address, which
> would ack other i2c commands above this.

I'm not sure to really understand your point, or if you actually understood
this patch. I'm not totally happy with EINVAL as error code, but it just
seemed to fit better than any other possible error code. Of course I would
be happy to get recommendations for better fitting codes.
A short explanation why this is done: in the sample code provided in the
data sheet, it is mentioned that if the value read from that register 0x70
is zero, then it should not be written into the AFECTRL register. So, that's
what I have addressed here.

>>         if (ret < 0)
>>                 goto exit_err;
>>
>> --
>> 2.4.6
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majordomo@vger.kernel.org
>> 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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


  reply	other threads:[~2015-07-31 22:54 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-29 21:39 [PATCH v2 0/7] stk8312 fixes and cleanup Hartmut Knaack
2015-07-29 21:39 ` [PATCH v2 1/7] iio:accel:stk8312: add triggered buffer dependency Hartmut Knaack
2015-07-29 21:39 ` [PATCH v2 2/7] iio:accel:stk8312: check for invalid value Hartmut Knaack
2015-07-30  7:09   ` Crt Mori
2015-07-31 22:54     ` Hartmut Knaack [this message]
2015-08-01  7:35       ` Crt Mori
2015-08-06 22:23         ` Hartmut Knaack
2015-08-08 11:18           ` Jonathan Cameron
2015-08-10  9:24             ` Breana, Tiberiu A
2015-08-11 18:32               ` Hartmut Knaack
2015-07-29 21:39 ` [PATCH v2 3/7] iio:accel:stk8312: improve error handling Hartmut Knaack
2015-07-30  7:04   ` Crt Mori
2015-07-30  9:07     ` Breana, Tiberiu A
2015-07-30  9:39       ` Crt Mori
2015-07-31 23:45       ` Hartmut Knaack
2015-08-01  7:40         ` Crt Mori
2015-08-03  8:05           ` Breana, Tiberiu A
2015-08-08 11:21             ` Jonathan Cameron
2015-07-29 21:39 ` [PATCH v2 4/7] iio:accel:stk8312: rework macro definitions Hartmut Knaack
2015-08-08 11:22   ` Jonathan Cameron
2015-07-29 21:39 ` [PATCH v2 5/7] iio:accel:stk8312: use appropriate variable types Hartmut Knaack
2015-08-08 11:23   ` Jonathan Cameron
2015-07-29 21:39 ` [PATCH v2 6/7] iio:accel:stk8312: code style cleanup Hartmut Knaack
2015-08-08 11:24   ` Jonathan Cameron
2015-07-29 21:39 ` [PATCH v2 7/7] iio:accel:stk8312: drop local buffer Hartmut Knaack
2015-08-08 11:25   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55BBFCA6.1090803@gmx.de \
    --to=knaack.h@gmx.de \
    --cc=cmo@melexis.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    --cc=tiberiu.a.breana@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).