mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-05 12:16:29 -04:00
iio: light: ltr501: Replace a variant of iio_get_acpi_device_name_and_data()
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> Link: https://patch.msgid.link/20241024191200.229894-25-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
committed by
Jonathan Cameron
parent
c26acb09cc
commit
12c65c0f3e
@@ -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;
|
||||
const void *ddata = NULL;
|
||||
int partid, chip_idx;
|
||||
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 = <r501_chip_info_tbl[chip_idx];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user