[PATCH v2] iio: accel: mma8452: add ACPI match table

Danil Sirin <[email protected]>
Newsgroups org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
The mma8452 driver supports obtaining chip-specific data through
i2c_get_match_data(), but only provides Device Tree and I2C match
tables.

On ACPI-based x86 systems, compatible devices such as the MMA8653 are
enumerated via ACPI, preventing the driver from binding.

Add an ACPI match table mapping the supported devices to the existing
chip information structures.

Tested on a Bay Trail tablet exposing an MMA8653 device via ACPI. With
this change the driver successfully probes, reads the expected chip ID
(0x5a), and registers an IIO device.

Signed-off-by: Danil Sirin <[email protected]>
---
v2:
- Update Signed-off-by tag with real name

 drivers/iio/accel/mma8452.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index cefc7cf4b..8cb78e4cf 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -1822,6 +1822,17 @@ static const struct dev_pm_ops mma8452_pm_ops = {
 			   mma8452_runtime_resume, NULL)
 };

+static const struct acpi_device_id mma8452_acpi_id[] = {
+	{ "FXLS8471", (kernel_ulong_t)&mma_chip_info_table[fxls8471] },
+	{ "MMA8451", (kernel_ulong_t)&mma_chip_info_table[mma8451] },
+	{ "MMA8452", (kernel_ulong_t)&mma_chip_info_table[mma8452] },
+	{ "MMA8453", (kernel_ulong_t)&mma_chip_info_table[mma8453] },
+	{ "MMA8652", (kernel_ulong_t)&mma_chip_info_table[mma8652] },
+	{ "MMA8653", (kernel_ulong_t)&mma_chip_info_table[mma8653] },
+	{ }
+};
+MODULE_DEVICE_TABLE(acpi, mma8452_acpi_id);
+
 static const struct i2c_device_id mma8452_id[] = {
 	{ "fxls8471", (kernel_ulong_t)&mma_chip_info_table[fxls8471] },
 	{ "mma8451", (kernel_ulong_t)&mma_chip_info_table[mma8451] },
@@ -1837,6 +1848,7 @@ static struct i2c_driver mma8452_driver = {
 	.driver = {
 		.name	= "mma8452",
 		.of_match_table = mma8452_dt_ids,
+		.acpi_match_table = mma8452_acpi_id,
 		.pm	= &mma8452_pm_ops,
 	},
 	.probe = mma8452_probe,
--
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.