iio: accel: adxl345: Set driver_data for OF enumeration
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 22 Feb 2022 09:00:03 +0000 (11:00 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 26 Feb 2022 19:10:56 +0000 (19:10 +0000)
In order to enable this driver on mode platforms, assign driver_data
field in the OF device ID table.

While at it, make sure that device type is not 0 which may be wrongly
interpreted by device property APIs in the future.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20220222090009.2060-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/accel/adxl345.h
drivers/iio/accel/adxl345_i2c.c
drivers/iio/accel/adxl345_spi.c

index af0fdd02c4f260cf0cd841f6860cdf58e77c3634..5a68d4dac7177117d827e642b8fe9070e58821b1 100644 (file)
@@ -9,8 +9,8 @@
 #define _ADXL345_H_
 
 enum adxl345_device_type {
-       ADXL345,
-       ADXL375,
+       ADXL345 = 1,
+       ADXL375 = 2,
 };
 
 int adxl345_core_probe(struct device *dev, struct regmap *regmap,
index e3205dce91b886276b91bbe5fd7a33b2bd6d7f8e..4c6efe2eefc11d32495046391243f34d9edadf30 100644 (file)
@@ -44,8 +44,8 @@ static const struct i2c_device_id adxl345_i2c_id[] = {
 MODULE_DEVICE_TABLE(i2c, adxl345_i2c_id);
 
 static const struct of_device_id adxl345_of_match[] = {
-       { .compatible = "adi,adxl345" },
-       { .compatible = "adi,adxl375" },
+       { .compatible = "adi,adxl345", .data = (const void *)ADXL345 },
+       { .compatible = "adi,adxl375", .data = (const void *)ADXL375 },
        { },
 };
 
index 9223302fdd463ccdf58012faeb9babf3d0d96d7b..72550132b1bbab08f20aefa4a150043173392edd 100644 (file)
@@ -46,8 +46,8 @@ static const struct spi_device_id adxl345_spi_id[] = {
 MODULE_DEVICE_TABLE(spi, adxl345_spi_id);
 
 static const struct of_device_id adxl345_of_match[] = {
-       { .compatible = "adi,adxl345" },
-       { .compatible = "adi,adxl375" },
+       { .compatible = "adi,adxl345", .data = (const void *)ADXL345 },
+       { .compatible = "adi,adxl375", .data = (const void *)ADXL375 },
        { },
 };