Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Marius Hoch <mail@mariushoch.de>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH] iio: accel: st_accel: Fix invalid mount_matrix on devices without ACPI _ONT method
Date: Sun, 23 Apr 2023 11:48:55 +0100	[thread overview]
Message-ID: <20230423114855.1596fe0c@jic23-huawei> (raw)
In-Reply-To: <822cff64-f7f8-b998-1b8e-5ada542b86b7@mariushoch.de>

On Tue, 18 Apr 2023 14:32:42 +0200
Marius Hoch <mail@mariushoch.de> wrote:

> On 16/04/2023 23:24, Hans de Goede wrote:
> > When apply_acpi_orientation() fails, st_accel_common_probe() will fall back
> > to iio_read_mount_matrix(), which checks for a mount-matrix device property
> > and if that is not set falls back to the identity matrix.
> >
> > But when a sensor has no ACPI companion fwnode, or when the ACPI fwnode
> > does not have a "_ONT" method apply_acpi_orientation() was returning 0,
> > causing iio_read_mount_matrix() to never get called resulting in an
> > invalid mount_matrix:
> >
> > [root@fedora ~]# cat /sys/bus/iio/devices/iio\:device0/mount_matrix
> > (null), (null), (null); (null), (null), (null); (null), (null), (null)
> >
> > Fix this by making apply_acpi_orientation() always return an error when
> > it did not set the mount_matrix.
> >
> > Signed-off-by: Hans de Goede <hdegoede@redhat.com>  
> Tested, with the LSM303D patches applied, on a Lenovo Yoga Tablet 2 1051-F.
> 
> Tested-by: Marius Hoch <mail@mariushoch.de>

Needs a fixes tag:. I think...

Fixes: 3d8ad94bb175 ("iio: accel: st_sensors: Support generic mounting matrix")

actually introduced the issue rather than the patch that added the _ONT support

Linus, that's one of yours.  Could you also take a glance at this.

Seems 'obviously' correct but I've been wrong before :)
> 
> 
> > ---
> >   drivers/iio/accel/st_accel_core.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
> > index 1628b177d0ed..f7b823ebc96b 100644
> > --- a/drivers/iio/accel/st_accel_core.c
> > +++ b/drivers/iio/accel/st_accel_core.c
> > @@ -1291,12 +1291,12 @@ static int apply_acpi_orientation(struct iio_dev *indio_dev)
> >   
> >   	adev = ACPI_COMPANION(indio_dev->dev.parent);
> >   	if (!adev)
> > -		return 0;
> > +		return -ENXIO;
> >   
> >   	/* Read _ONT data, which should be a package of 6 integers. */
> >   	status = acpi_evaluate_object(adev->handle, "_ONT", NULL, &buffer);
> >   	if (status == AE_NOT_FOUND) {
> > -		return 0;
> > +		return -ENXIO;
> >   	} else if (ACPI_FAILURE(status)) {
> >   		dev_warn(&indio_dev->dev, "failed to execute _ONT: %d\n",
> >   			 status);  
> 


  reply	other threads:[~2023-04-23 10:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-16 21:24 [PATCH] iio: accel: st_accel: Fix invalid mount_matrix on devices without ACPI _ONT method Hans de Goede
2023-04-18 12:32 ` Marius Hoch
2023-04-23 10:48   ` Jonathan Cameron [this message]
2023-04-24  7:59     ` Linus Walleij
2023-05-01 15:52       ` Jonathan Cameron
2023-04-24  9:30     ` Hans de Goede

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=20230423114855.1596fe0c@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=mail@mariushoch.de \
    /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