public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: barnabas.czeman@mainlining.org
To: Jonathan Cameron <jic23@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Jonathan Albrieux <jonathan.albrieux@gmail.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, linux@mainlining.org
Subject: Re: [PATCH v3 2/4] iio: magnetometer: ak8975: Fix reading for ak099xx sensors
Date: Sat, 17 Aug 2024 14:58:42 +0200	[thread overview]
Message-ID: <a7da0c7296188542c14a54985995a8fa@mainlining.org> (raw)
In-Reply-To: <20240817132641.2902418e@jic23-huawei>

On 2024-08-17 14:26, Jonathan Cameron wrote:
> On Fri, 09 Aug 2024 22:25:40 +0200
> Barnabás Czémán <barnabas.czeman@mainlining.org> wrote:
> 
>> Move ST2 reading with overflow handling after measurement data
>> reading.
>> ST2 register read have to be read after read measurment data,
>> because it means end of the reading and realease the lock on the data.
>> Remove ST2 read skip on interrupt based waiting because ST2 required 
>> to
>> be read out at and of the axis read.
>> 
>> Signed-off-by: Barnabás Czémán <barnabas.czeman@mainlining.org>
> This still needs a fixes tag to tell us when the bug was first
> introduced into the driver so that we know how far to back port it.
I have got some test results from a device with ak09916 and that was 
working
without the fix so it seems only ak09918 is strict about ST2.
In theory all ak099xx should work like this so:
Fixes: 57e73a423b1e (iio: ak8975: add ak09911 and ak09912 support)
> 
> One other comment inline.
> 
> Thanks,
> 
> Jonathan
> 
>> ---
>>  drivers/iio/magnetometer/ak8975.c | 33 
>> ++++++++++++++++-----------------
>>  1 file changed, 16 insertions(+), 17 deletions(-)
>> 
>> diff --git a/drivers/iio/magnetometer/ak8975.c 
>> b/drivers/iio/magnetometer/ak8975.c
>> index 6357666edd34..f8355170f529 100644
>> --- a/drivers/iio/magnetometer/ak8975.c
>> +++ b/drivers/iio/magnetometer/ak8975.c
>> @@ -692,22 +692,7 @@ static int ak8975_start_read_axis(struct 
>> ak8975_data *data,
>>  	if (ret < 0)
>>  		return ret;
>> 
>> -	/* This will be executed only for non-interrupt based waiting case 
>> */
>> -	if (ret & data->def->ctrl_masks[ST1_DRDY]) {
>> -		ret = i2c_smbus_read_byte_data(client,
>> -					       data->def->ctrl_regs[ST2]);
>> -		if (ret < 0) {
>> -			dev_err(&client->dev, "Error in reading ST2\n");
>> -			return ret;
>> -		}
>> -		if (ret & (data->def->ctrl_masks[ST2_DERR] |
>> -			   data->def->ctrl_masks[ST2_HOFL])) {
>> -			dev_err(&client->dev, "ST2 status error 0x%x\n", ret);
>> -			return -EINVAL;
>> -		}
>> -	}
>> -
>> -	return 0;
>> +	return !data->def->ctrl_regs[ST1_DRDY];
>>  }
>> 
>>  /* Retrieve raw flux value for one of the x, y, or z axis.  */
>> @@ -734,6 +719,20 @@ static int ak8975_read_axis(struct iio_dev 
>> *indio_dev, int index, int *val)
>>  	if (ret < 0)
>>  		goto exit;
>> 
>> +	/* Read out ST2 for release lock */
>> +	ret = i2c_smbus_read_byte_data(client, data->def->ctrl_regs[ST2]);
>> +	if (ret < 0) {
>> +		dev_err(&client->dev, "Error in reading ST2\n");
>> +		goto exit;
>> +	}
>> +
>> +	if (ret & (data->def->ctrl_masks[ST2_DERR] |
>> +		   data->def->ctrl_masks[ST2_HOFL])) {
>> +		dev_err(&client->dev, "ST2 status error 0x%x\n", ret);
>> +		ret = -EINVAL;
>> +		goto exit;
>> +	}
>> +
>>  	mutex_unlock(&data->lock);
>> 
>>  	pm_runtime_mark_last_busy(&data->client->dev);
>> @@ -746,7 +745,7 @@ static int ak8975_read_axis(struct iio_dev 
>> *indio_dev, int index, int *val)
>> 
>>  exit:
>>  	mutex_unlock(&data->lock);
>> -	dev_err(&client->dev, "Error in reading axis\n");
>> +	dev_err(&client->dev, "Error in reading axis %d\n", ret);
> 
> In most of the paths above there is already a detailed print. I'd not 
> bother
> adding the return value to this one.  It just adds noise to the patch.
> 
>>  	return ret;
>>  }
>> 
>> 

  reply	other threads:[~2024-08-17 12:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-09 20:25 [PATCH v3 0/4] Add support for AK09918 Barnabás Czémán
2024-08-09 20:25 ` [PATCH v3 1/4] iio: magnetometer: ak8975: Relax failure on unknown id Barnabás Czémán
2024-08-09 20:25 ` [PATCH v3 2/4] iio: magnetometer: ak8975: Fix reading for ak099xx sensors Barnabás Czémán
2024-08-17 12:26   ` Jonathan Cameron
2024-08-17 12:58     ` barnabas.czeman [this message]
2024-08-09 20:25 ` [PATCH v3 3/4] dt-bindings: iio: imu: magnetometer: Add ak09118 Barnabás Czémán
2024-08-10 12:15   ` Krzysztof Kozlowski
2024-08-11 18:28     ` barnabas.czeman
2024-08-12  6:17       ` Krzysztof Kozlowski
2024-08-17 12:32         ` Jonathan Cameron
2024-08-17 12:46   ` Jonathan Cameron
2024-08-09 20:25 ` [PATCH v3 4/4] iio: magnetometer: ak8975: Add AK09118 support Barnabás Czémán

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=a7da0c7296188542c14a54985995a8fa@mainlining.org \
    --to=barnabas.czeman@mainlining.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=jonathan.albrieux@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@mainlining.org \
    --cc=robh@kernel.org \
    /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