Linux IIO development
 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>,
	linux-iio@vger.kernel.org
Subject: [PATCH] iio: accel: da280: Simplify id-matching
Date: Mon,  1 Jan 2024 14:32:34 +0100	[thread overview]
Message-ID: <20240101133234.10310-1-hdegoede@redhat.com> (raw)

da280_match_acpi_device() is a DIY version of acpi_device_get_match_data(),
so it can be dropped.

And things can be simplified further by using i2c_get_match_data() which
will also check i2c_client_id style ids.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/iio/accel/da280.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/iio/accel/da280.c b/drivers/iio/accel/da280.c
index 572bfe9694b0..e4cd4b3a28ab 100644
--- a/drivers/iio/accel/da280.c
+++ b/drivers/iio/accel/da280.c
@@ -89,17 +89,6 @@ static const struct iio_info da280_info = {
 	.read_raw	= da280_read_raw,
 };
 
-static enum da280_chipset da280_match_acpi_device(struct device *dev)
-{
-	const struct acpi_device_id *id;
-
-	id = acpi_match_device(dev->driver->acpi_match_table, dev);
-	if (!id)
-		return -EINVAL;
-
-	return (enum da280_chipset) id->driver_data;
-}
-
 static void da280_disable(void *client)
 {
 	da280_enable(client, false);
@@ -107,7 +96,6 @@ static void da280_disable(void *client)
 
 static int da280_probe(struct i2c_client *client)
 {
-	const struct i2c_device_id *id = i2c_client_get_device_id(client);
 	int ret;
 	struct iio_dev *indio_dev;
 	struct da280_data *data;
@@ -128,11 +116,7 @@ static int da280_probe(struct i2c_client *client)
 	indio_dev->modes = INDIO_DIRECT_MODE;
 	indio_dev->channels = da280_channels;
 
-	if (ACPI_HANDLE(&client->dev)) {
-		chip = da280_match_acpi_device(&client->dev);
-	} else {
-		chip = id->driver_data;
-	}
+	chip = (uintptr_t)i2c_get_match_data(client);
 
 	if (chip == da217) {
 		indio_dev->name = "da217";
-- 
2.43.0


             reply	other threads:[~2024-01-01 13:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-01 13:32 Hans de Goede [this message]
2024-01-01 15:42 ` [PATCH] iio: accel: da280: Simplify id-matching Jonathan Cameron
2024-01-04 15:42   ` Hans de Goede
  -- strict thread matches above, loose matches on Subject: below --
2024-01-04 16:01 Hans de Goede
2024-01-04 16:02 ` Hans de Goede
2024-01-07 16:10 ` 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=20240101133234.10310-1-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.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