public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	Marius Cristea <marius.cristea@microchip.com>,
	Trevor Gamblin <tgamblin@baylibre.com>,
	Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>,
	Hans de Goede <hdegoede@redhat.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH v3 24/24] iio: light: ltr501: Replace a variant of iio_get_acpi_device_name_and_data()
Date: Thu, 24 Oct 2024 22:05:13 +0300	[thread overview]
Message-ID: <20241024191200.229894-25-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20241024191200.229894-1-andriy.shevchenko@linux.intel.com>

IIO core (ACPI part) provides a generic helper that may be used in
the driver. Replace a variant of iio_get_acpi_device_name_and_data().

Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/light/ltr501.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
index 4051d0d9e799..c389be6a106d 100644
--- a/drivers/iio/light/ltr501.c
+++ b/drivers/iio/light/ltr501.c
@@ -15,7 +15,6 @@
 #include <linux/err.h>
 #include <linux/delay.h>
 #include <linux/regmap.h>
-#include <linux/acpi.h>
 #include <linux/regulator/consumer.h>
 
 #include <linux/iio/iio.h>
@@ -1422,17 +1421,6 @@ static int ltr501_powerdown(struct ltr501_data *data)
 				  data->ps_contr & ~LTR501_CONTR_ACTIVE);
 }
 
-static const char *ltr501_match_acpi_device(struct device *dev, int *chip_idx)
-{
-	const struct acpi_device_id *id;
-
-	id = acpi_match_device(dev->driver->acpi_match_table, dev);
-	if (!id)
-		return NULL;
-	*chip_idx = id->driver_data;
-	return dev_name(dev);
-}
-
 static int ltr501_probe(struct i2c_client *client)
 {
 	const struct i2c_device_id *id = i2c_client_get_device_id(client);
@@ -1440,8 +1428,10 @@ static int ltr501_probe(struct i2c_client *client)
 	struct ltr501_data *data;
 	struct iio_dev *indio_dev;
 	struct regmap *regmap;
-	int ret, partid, chip_idx = 0;
-	const char *name = NULL;
+	int partid, chip_idx;
+	const void *ddata;
+	const char *name;
+	int ret;
 
 	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
 	if (!indio_dev)
@@ -1523,11 +1513,12 @@ static int ltr501_probe(struct i2c_client *client)
 	if (id) {
 		name = id->name;
 		chip_idx = id->driver_data;
-	} else  if (ACPI_HANDLE(&client->dev)) {
-		name = ltr501_match_acpi_device(&client->dev, &chip_idx);
 	} else {
-		return -ENODEV;
+		name = iio_get_acpi_device_name_and_data(&client->dev, &ddata);
+		chip_idx = (intptr_t)ddata;
 	}
+	if (!name)
+		return -ENODEV;
 
 	data->chip_info = &ltr501_chip_info_tbl[chip_idx];
 
-- 
2.43.0.rc1.1336.g36b5255a03ac


  parent reply	other threads:[~2024-10-24 19:12 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-24 19:04 [PATCH v3 00/24] iio: Clean up acpi_match_device() use cases Andy Shevchenko
2024-10-24 19:04 ` [PATCH v3 01/24] iio: magnetometer: bmc150: Drop dead code from the driver Andy Shevchenko
2024-10-26 11:02   ` Jonathan Cameron
2024-10-24 19:04 ` [PATCH v3 02/24] iio: adc: pac1934: Replace strange way of checking type of enumeration Andy Shevchenko
2024-10-26 11:03   ` Jonathan Cameron
2024-10-24 19:04 ` [PATCH v3 03/24] iio: imu: inv_mpu6050: " Andy Shevchenko
2024-10-26 11:04   ` Jonathan Cameron
2024-10-24 19:04 ` [PATCH v3 04/24] iio: acpi: Improve iio_read_acpi_mount_matrix() Andy Shevchenko
2024-10-26 11:07   ` Jonathan Cameron
2024-10-24 19:04 ` [PATCH v3 05/24] iio: acpi: Add iio_get_acpi_device_name_and_data() helper function Andy Shevchenko
2024-10-26 11:09   ` Jonathan Cameron
2024-10-24 19:04 ` [PATCH v3 06/24] iio: accel: kxcjk-1013: Remove redundant I²C ID Andy Shevchenko
2024-10-26 11:11   ` Jonathan Cameron
2024-10-24 19:04 ` [PATCH v3 07/24] iio: accel: kxcjk-1013: Revert "Add support for KX022-1020" Andy Shevchenko
2024-10-26 11:16   ` Jonathan Cameron
2024-10-26 14:58     ` Rayyan Ansari
2024-10-26 17:21       ` Jonathan Cameron
2024-10-28  9:02       ` Andy Shevchenko
2024-10-24 19:04 ` [PATCH v3 08/24] iio: accel: kxcjk-1013: Switch from CONFIG_PM guards to pm_ptr() etc Andy Shevchenko
2024-10-26 11:17   ` Jonathan Cameron
2024-10-24 19:04 ` [PATCH v3 09/24] iio: accel: kxcjk-1013: Use local variable for regs Andy Shevchenko
2024-10-26 11:18   ` Jonathan Cameron
2024-10-24 19:04 ` [PATCH v3 10/24] iio: accel: kxcjk-1013: Rename kxcjk1013_info Andy Shevchenko
2024-10-26 11:21   ` Jonathan Cameron
2024-10-24 19:05 ` [PATCH v3 11/24] iio: accel: kxcjk-1013: Start using chip_info variables instead of enum Andy Shevchenko
2024-10-26 11:26   ` Jonathan Cameron
2024-10-28  9:48     ` Andy Shevchenko
2024-10-24 19:05 ` [PATCH v3 12/24] iio: accel: kxcjk-1013: Move odr_start_up_times up in the code Andy Shevchenko
2024-10-26 11:30   ` Jonathan Cameron
2024-10-28  9:49     ` Andy Shevchenko
2024-10-24 19:05 ` [PATCH v3 13/24] iio: accel: kxcjk-1013: Convert ODR times array to variable in chip_info Andy Shevchenko
2024-10-26 11:34   ` Jonathan Cameron
2024-10-24 19:05 ` [PATCH v3 14/24] iio: accel: kxcjk-1013: Get rid of enum kx_chipset Andy Shevchenko
2024-10-26 11:37   ` Jonathan Cameron
2024-10-28  9:50     ` Andy Shevchenko
2024-10-24 19:05 ` [PATCH v3 15/24] iio: accel: kxcjk-1013: Replace a variant of iio_get_acpi_device_name_and_data() Andy Shevchenko
2024-10-26 11:38   ` Jonathan Cameron
2024-10-24 19:05 ` [PATCH v3 16/24] iio: accel: kxcjk-1013: drop ACPI_PTR() and move ID out of CONFIG_ACPI guards Andy Shevchenko
2024-10-26 11:41   ` Jonathan Cameron
2024-10-24 19:05 ` [PATCH v3 17/24] iio: accel: mma9551: Replace custom implementation of iio_get_acpi_device_name() Andy Shevchenko
2024-10-26 11:45   ` Jonathan Cameron
2024-10-24 19:05 ` [PATCH v3 18/24] iio: accel: mma9553: " Andy Shevchenko
2024-10-26 11:47   ` Jonathan Cameron
2024-10-24 19:05 ` [PATCH v3 19/24] iio: gyro: bmg160: " Andy Shevchenko
2024-10-26 11:48   ` Jonathan Cameron
2024-10-24 19:05 ` [PATCH v3 20/24] iio: light: isl29018: Replace a variant of iio_get_acpi_device_name_and_data() Andy Shevchenko
2024-10-26 11:50   ` Jonathan Cameron
2024-10-24 19:05 ` [PATCH v3 21/24] iio: light: isl29018: drop ACPI_PTR() and CONFIG_ACPI guards Andy Shevchenko
2024-10-26 11:52   ` Jonathan Cameron
2024-10-24 19:05 ` [PATCH v3 22/24] iio: light: ltr501: Drop most likely fake ACPI IDs Andy Shevchenko
2024-10-26 11:54   ` Jonathan Cameron
2024-10-24 19:05 ` [PATCH v3 23/24] iio: light: ltr501: Add LTER0303 to the supported devices Andy Shevchenko
2024-10-26 11:56   ` Jonathan Cameron
2024-10-28  9:52     ` Andy Shevchenko
2024-10-24 19:05 ` Andy Shevchenko [this message]
2024-10-26 11:58   ` [PATCH v3 24/24] iio: light: ltr501: Replace a variant of iio_get_acpi_device_name_and_data() Jonathan Cameron
2024-10-29  6:34 ` [PATCH v3 00/24] iio: Clean up acpi_match_device() use cases Matti Vaittinen
2024-10-30 14:56   ` Andy Shevchenko

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=20241024191200.229894-25-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=hdegoede@redhat.com \
    --cc=jean-baptiste.maneyrol@tdk.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marius.cristea@microchip.com \
    --cc=tgamblin@baylibre.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