diff mbox series

[v2,9/9] iio: accel: bmc150: Set label based on accel-location for ACPI DUAL250E fwnodes

Message ID 20210523170103.176958-10-hdegoede@redhat.com (mailing list archive)
State Accepted
Headers show
Series iio: accel: bmc150: Add support for yoga's with dual accelerometers with an ACPI HID of DUAL250E | expand

Commit Message

Hans de Goede May 23, 2021, 5:01 p.m. UTC
Some Yoga laptops with 1 accelerometer in the display and 1 in the base,
use an ACPI HID of DUAL250E instead of BOSC0200.

Set the iio-device's label for DUAL250E devices to a value indicating which
sensor is which, mirroring how we do this for BOSC0200 dual sensor devices.

Note the DUAL250E fwnode unfortunately does not include a mount-matrix.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
- Rebase on top of the new "iio: accel: bmc150: Refactor
  bmc150_apply_acpi_orientation()" patch
---
 drivers/iio/accel/bmc150-accel-core.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
index f685ed617424..95a9ef2d333e 100644
--- a/drivers/iio/accel/bmc150-accel-core.c
+++ b/drivers/iio/accel/bmc150-accel-core.c
@@ -453,6 +453,19 @@  static bool bmc150_apply_bosc0200_acpi_orientation(struct device *dev,
 	return false;
 }
 
+static bool bmc150_apply_dual250e_acpi_orientation(struct device *dev,
+						   struct iio_mount_matrix *orientation)
+{
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+
+	if (strcmp(dev_name(dev), "i2c-DUAL250E:base") == 0)
+		indio_dev->label = "accel-base";
+	else
+		indio_dev->label = "accel-display";
+
+	return false; /* DUAL250E fwnodes have no mount matrix info */
+}
+
 static bool bmc150_apply_acpi_orientation(struct device *dev,
 					  struct iio_mount_matrix *orientation)
 {
@@ -461,6 +474,9 @@  static bool bmc150_apply_acpi_orientation(struct device *dev,
 	if (adev && acpi_dev_hid_uid_match(adev, "BOSC0200", NULL))
 		return bmc150_apply_bosc0200_acpi_orientation(dev, orientation);
 
+	if (adev && acpi_dev_hid_uid_match(adev, "DUAL250E", NULL))
+		return bmc150_apply_dual250e_acpi_orientation(dev, orientation);
+
 	return false;
 }
 #else