Linux-IIO Archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Sean Rhodes <sean@starlabs.systems>,
	linux-iio@vger.kernel.org
Subject: [PATCH 1/4] iio: accel: kxcjk-1013: Simplify ACPI ROTM mount matrix retreival
Date: Wed, 17 Apr 2024 18:46:13 +0200	[thread overview]
Message-ID: <20240417164616.74651-2-hdegoede@redhat.com> (raw)
In-Reply-To: <20240417164616.74651-1-hdegoede@redhat.com>

There is no reason to limit the parsing of the ROTM mount matrix to only
ACPI devices with an ACPI HID (Hardware-ID) of "KIOX000A". If kxcjk-1013
ACPI devices with another HID have a ROTM method that should still be
parsed and if the method is not there then the:

	if (!adev || !acpi_has_method(adev->handle, "ROTM"))
		return false;

check will skip checking the ROTM method silently.

Move the check to see if there is an ACPI companion at all into
kxj_acpi_orientation() and drop the wrapper checking the HID.

Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/iio/accel/kxcjk-1013.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
index 126e8bdd6d0e..bb1660667bb0 100644
--- a/drivers/iio/accel/kxcjk-1013.c
+++ b/drivers/iio/accel/kxcjk-1013.c
@@ -637,8 +637,8 @@ static int kxcjk1013_set_power_state(struct kxcjk1013_data *data, bool on)
 }
 
 #ifdef CONFIG_ACPI
-static bool kxj_acpi_orientation(struct device *dev,
-				 struct iio_mount_matrix *orientation)
+static bool kxj1009_apply_acpi_orientation(struct device *dev,
+					   struct iio_mount_matrix *orientation)
 {
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 	struct acpi_device *adev = ACPI_COMPANION(dev);
@@ -648,7 +648,7 @@ static bool kxj_acpi_orientation(struct device *dev,
 	int i, j, val[3];
 	bool ret = false;
 
-	if (!acpi_has_method(adev->handle, "ROTM"))
+	if (!adev || !acpi_has_method(adev->handle, "ROTM"))
 		return false;
 
 	status = acpi_evaluate_object(adev->handle, "ROTM", NULL, &buffer);
@@ -695,17 +695,6 @@ static bool kxj_acpi_orientation(struct device *dev,
 	kfree(buffer.pointer);
 	return ret;
 }
-
-static bool kxj1009_apply_acpi_orientation(struct device *dev,
-					  struct iio_mount_matrix *orientation)
-{
-	struct acpi_device *adev = ACPI_COMPANION(dev);
-
-	if (adev && acpi_dev_hid_uid_match(adev, "KIOX000A", NULL))
-		return kxj_acpi_orientation(dev, orientation);
-
-	return false;
-}
 #else
 static bool kxj1009_apply_acpi_orientation(struct device *dev,
 					  struct iio_mount_matrix *orientation)
-- 
2.44.0


  reply	other threads:[~2024-04-17 16:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-17 16:46 [PATCH 0/4] iio: accel: Share ACPI ROTM parsing between drivers and add it to mxc4005 Hans de Goede
2024-04-17 16:46 ` Hans de Goede [this message]
2024-04-17 16:46 ` [PATCH 2/4] iio: accel: kxcjk-1013: Move ACPI ROTM parsing to new acpi-helpers.h Hans de Goede
2024-04-20 11:13   ` Jonathan Cameron
2024-04-22  9:17     ` Hans de Goede
2024-04-22  9:18     ` Hans de Goede
2024-04-22 17:06       ` Jonathan Cameron
2024-04-17 16:46 ` [PATCH 3/4] iio: bmc150-accel-core: Use acpi_read_mount_matrix() helper Hans de Goede
2024-04-17 16:46 ` [PATCH 4/4] iio: accel: mxc4005: Read orientation matrix from ACPI ROTM method Hans de Goede
2024-04-19  7:36 ` [PATCH 0/4] iio: accel: Share ACPI ROTM parsing between drivers and add it to mxc4005 Hans de Goede
2024-04-22  7:51 ` Andy Shevchenko
2024-04-22  7:55 ` Andy Shevchenko
2024-04-22  8:24   ` Hans de Goede
2024-04-22 11:33     ` Andy Shevchenko
2024-04-22 11:45       ` Hans de Goede
2024-04-22 12:28         ` Andy Shevchenko
2024-04-22 17:05           ` 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=20240417164616.74651-2-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=sean@starlabs.systems \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).