[PATCH 4/4] iio: accel: adxl345: Add ACPI support

From: Eva Rachel Retuya
Date: Thu Feb 16 2017 - 05:03:04 EST


Allow probing the adxl345 on both I2C and SPI protocols using ACPI.

Signed-off-by: Eva Rachel Retuya <eraretuya@xxxxxxxxx>
---
drivers/iio/accel/adxl345_i2c.c | 9 +++++++++
drivers/iio/accel/adxl345_spi.c | 9 +++++++++
2 files changed, 18 insertions(+)

diff --git a/drivers/iio/accel/adxl345_i2c.c b/drivers/iio/accel/adxl345_i2c.c
index b114eb0..13080ff 100644
--- a/drivers/iio/accel/adxl345_i2c.c
+++ b/drivers/iio/accel/adxl345_i2c.c
@@ -12,6 +12,7 @@
* 0x53 (ALT ADDRESS pin grounded)
*/

+#include <linux/acpi.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/regmap.h>
@@ -54,9 +55,17 @@ static const struct i2c_device_id adxl345_i2c_id[] = {

MODULE_DEVICE_TABLE(i2c, adxl345_i2c_id);

+static const struct acpi_device_id adxl345_acpi_id[] = {
+ { "ADX0345", 0 },
+ { }
+};
+
+MODULE_DEVICE_TABLE(acpi, adxl345_acpi_id);
+
static struct i2c_driver adxl345_i2c_driver = {
.driver = {
.name = "adxl345_i2c",
+ .acpi_match_table = ACPI_PTR(adxl345_acpi_id),
},
.probe = adxl345_i2c_probe,
.remove = adxl345_i2c_remove,
diff --git a/drivers/iio/accel/adxl345_spi.c b/drivers/iio/accel/adxl345_spi.c
index 5fcd1fa..3f2a1db 100644
--- a/drivers/iio/accel/adxl345_spi.c
+++ b/drivers/iio/accel/adxl345_spi.c
@@ -10,6 +10,7 @@
* SPI driver for ADXL345
*/

+#include <linux/acpi.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/spi/spi.h>
@@ -59,9 +60,17 @@ static const struct spi_device_id adxl345_spi_id[] = {

MODULE_DEVICE_TABLE(spi, adxl345_spi_id);

+static const struct acpi_device_id adxl345_acpi_id[] = {
+ { "ADX0345", 0 },
+ { }
+};
+
+MODULE_DEVICE_TABLE(acpi, adxl345_acpi_id);
+
static struct spi_driver adxl345_spi_driver = {
.driver = {
.name = "adxl345_spi",
+ .acpi_match_table = ACPI_PTR(adxl345_acpi_id),
},
.probe = adxl345_spi_probe,
.remove = adxl345_spi_remove,
--
2.7.4