From patchwork Wed Nov 25 08:36:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 11930607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D55E4C56201 for ; Wed, 25 Nov 2020 08:36:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F1E7208C3 for ; Wed, 25 Nov 2020 08:36:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Y3+N/c//" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726192AbgKYIga (ORCPT ); Wed, 25 Nov 2020 03:36:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:44324 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725287AbgKYIg3 (ORCPT ); Wed, 25 Nov 2020 03:36:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606293388; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mmDrXg1/nVJWCDWoUl8t/ciR7+jylop17aKdlxYsU28=; b=Y3+N/c//m6/R+UxKqptk9LY96LMZmpqSfh+uhrNiMiVb43pEgj47oss5FOfyIASzMMLrRC eMeLj3H7HbDlBt1Layit+4jVFWOsgoJgjapqT/4dYtj+jVEqbShg85G6Q7ZvPCnZuq4mGh z1rhc3wnHG3OXpLrCRYVqtXUQOT6MCI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-316-97P2FFQVMViLeVqAJvV4Pw-1; Wed, 25 Nov 2020 03:36:26 -0500 X-MC-Unique: 97P2FFQVMViLeVqAJvV4Pw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3BD3981CBE1; Wed, 25 Nov 2020 08:36:25 +0000 (UTC) Received: from x1.localdomain (ovpn-114-185.ams2.redhat.com [10.36.114.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id 195FD5C1A1; Wed, 25 Nov 2020 08:36:20 +0000 (UTC) From: Hans de Goede To: Jonathan Cameron Cc: Hans de Goede , Lars-Peter Clausen , Peter Meerwald-Stadler , Jeremy Cline , linux-iio@vger.kernel.org Subject: [PATCH 1/3] iio: accel: bmc150: Removed unused bmc150_accel_dat irq member Date: Wed, 25 Nov 2020 09:36:16 +0100 Message-Id: <20201125083618.10989-2-hdegoede@redhat.com> In-Reply-To: <20201125083618.10989-1-hdegoede@redhat.com> References: <20201125083618.10989-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The bmc150_accel_dat struct irq member is only ever used inside bmc150_accel_core_probe, drop it and just use the function argument directly. Signed-off-by: Hans de Goede --- drivers/iio/accel/bmc150-accel-core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 48435865fdaf..088716d55855 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -183,7 +183,6 @@ enum bmc150_accel_trigger_id { struct bmc150_accel_data { struct regmap *regmap; - int irq; struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS]; struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS]; struct mutex mutex; @@ -1568,7 +1567,6 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, data = iio_priv(indio_dev); dev_set_drvdata(dev, indio_dev); - data->irq = irq; data->regmap = regmap; @@ -1599,9 +1597,8 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, return ret; } - if (data->irq > 0) { - ret = devm_request_threaded_irq( - dev, data->irq, + if (irq > 0) { + ret = devm_request_threaded_irq(dev, irq, bmc150_accel_irq_handler, bmc150_accel_irq_thread_handler, IRQF_TRIGGER_RISING, From patchwork Wed Nov 25 08:36:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 11930611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48A4BC56201 for ; Wed, 25 Nov 2020 08:36:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC9EA206F9 for ; Wed, 25 Nov 2020 08:36:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hsnY18MK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726839AbgKYIgf (ORCPT ); Wed, 25 Nov 2020 03:36:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21614 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725287AbgKYIge (ORCPT ); Wed, 25 Nov 2020 03:36:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606293392; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z5GM97dKeR9r7f0v2dh4w8NDe0CvyAP23VY4gT54TVw=; b=hsnY18MKZnDpT1+7sqgjqWkzKCZg+Q5lUnb+/vY3yIE0O4C/ntpey/3jl+Ab/fbFFqWTR+ 604qP7FeFlqfoAm2LGEZYL0cyKH0rv3o2l9gWWDf5hpDcQ1U0Le+lVaT5sWGwPLhgcyT8G iaU1Pi3Zwau+2VbbZGgia+uYeeOJrfA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-153-bLTzH7YrOj6rgE3SwSFQ9A-1; Wed, 25 Nov 2020 03:36:28 -0500 X-MC-Unique: bLTzH7YrOj6rgE3SwSFQ9A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E16E3107ACFB; Wed, 25 Nov 2020 08:36:26 +0000 (UTC) Received: from x1.localdomain (ovpn-114-185.ams2.redhat.com [10.36.114.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81B905C1A1; Wed, 25 Nov 2020 08:36:25 +0000 (UTC) From: Hans de Goede To: Jonathan Cameron Cc: Hans de Goede , Lars-Peter Clausen , Peter Meerwald-Stadler , Jeremy Cline , linux-iio@vger.kernel.org Subject: [PATCH 2/3] iio: accel: bmc150: Check for a second ACPI device for BOSC0200 Date: Wed, 25 Nov 2020 09:36:17 +0100 Message-Id: <20201125083618.10989-3-hdegoede@redhat.com> In-Reply-To: <20201125083618.10989-1-hdegoede@redhat.com> References: <20201125083618.10989-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jeremy Cline Some BOSC0200 acpi_device-s describe two accelerometers in a single ACPI device. Normally we would handle this by letting the special drivers/platform/x86/i2c-multi-instantiate.c driver handle the BOSC0200 ACPI id and let it instantiate 2 bmc150_accel type i2c_client-s for us. But doing so changes the modalias for the first accelerometer (which is already supported and used on many devices) from acpi:BOSC0200 to i2c:bmc150_accel. The modalias is not only used to load the driver, but is also used by hwdb matches in /lib/udev/hwdb.d/60-sensor.hwdb which provide a mountmatrix to userspace by setting the ACCEL_MOUNT_MATRIX udev property. Switching the handling of the BOSC0200 over to i2c-multi-instantiate.c will break the hwdb matches causing the ACCEL_MOUNT_MATRIX udev prop to no longer be set. So switching over to i2c-multi-instantiate.c is not an option. Changes by Hans de Goede: -Add explanation to the commit message why i2c-multi-instantiate.c cannot be used -Also set the dev_name, fwnode and irq i2c_board_info struct members for the 2nd client BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=198671 Signed-off-by: Jeremy Cline Signed-off-by: Hans de Goede --- drivers/iio/accel/bmc150-accel-core.c | 21 ++++++++++++++++ drivers/iio/accel/bmc150-accel-i2c.c | 35 +++++++++++++++++++++++++-- drivers/iio/accel/bmc150-accel.h | 2 ++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 088716d55855..2976aefad89b 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -203,6 +203,7 @@ struct bmc150_accel_data { int ev_enable_state; int64_t timestamp, old_timestamp; /* Only used in hw fifo mode. */ const struct bmc150_accel_chip_info *chip_info; + struct i2c_client *second_device; struct iio_mount_matrix orientation; }; @@ -1659,6 +1660,26 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, } EXPORT_SYMBOL_GPL(bmc150_accel_core_probe); +struct i2c_client *bmc150_get_second_device(struct i2c_client *client) +{ + struct bmc150_accel_data *data = i2c_get_clientdata(client); + + if (!data) + return NULL; + + return data->second_device; +} +EXPORT_SYMBOL_GPL(bmc150_get_second_device); + +void bmc150_set_second_device(struct i2c_client *client) +{ + struct bmc150_accel_data *data = i2c_get_clientdata(client); + + if (data) + data->second_device = client; +} +EXPORT_SYMBOL_GPL(bmc150_set_second_device); + int bmc150_accel_core_remove(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); diff --git a/drivers/iio/accel/bmc150-accel-i2c.c b/drivers/iio/accel/bmc150-accel-i2c.c index 06021c8685a7..117184159bb6 100644 --- a/drivers/iio/accel/bmc150-accel-i2c.c +++ b/drivers/iio/accel/bmc150-accel-i2c.c @@ -29,6 +29,8 @@ static int bmc150_accel_probe(struct i2c_client *client, i2c_check_functionality(client->adapter, I2C_FUNC_I2C) || i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK); + struct acpi_device *adev = ACPI_COMPANION(&client->dev); + int ret; regmap = devm_regmap_init_i2c(client, &bmc150_regmap_conf); if (IS_ERR(regmap)) { @@ -39,12 +41,41 @@ static int bmc150_accel_probe(struct i2c_client *client, if (id) name = id->name; - return bmc150_accel_core_probe(&client->dev, regmap, client->irq, name, - block_supported); + ret = bmc150_accel_core_probe(&client->dev, regmap, client->irq, name, block_supported); + if (ret) + return ret; + + /* + * Some BOSC0200 acpi_devices describe 2 accelerometers in a single ACPI + * device, try instantiating a second i2c_client for an I2cSerialBusV2 + * ACPI resource with index 1. The !id check avoids recursion when + * bmc150_accel_probe() gets called for the second client. + */ + if (!id && adev && strcmp(acpi_device_hid(adev), "BOSC0200") == 0) { + struct i2c_board_info board_info = { + .type = "bmc150_accel", + /* The 2nd accel sits in the base of 2-in-1s */ + .dev_name = "BOSC0200:base", + .fwnode = client->dev.fwnode, + .irq = -ENOENT, + }; + struct i2c_client *second_dev; + + second_dev = i2c_acpi_new_device(&client->dev, 1, &board_info); + if (!IS_ERR(second_dev)) + bmc150_set_second_device(second_dev); + } + + return 0; } static int bmc150_accel_remove(struct i2c_client *client) { + struct i2c_client *second_dev = bmc150_get_second_device(client); + + if (second_dev) + i2c_unregister_device(second_dev); + return bmc150_accel_core_remove(&client->dev); } diff --git a/drivers/iio/accel/bmc150-accel.h b/drivers/iio/accel/bmc150-accel.h index ae6118ae11b1..6e965a3ca322 100644 --- a/drivers/iio/accel/bmc150-accel.h +++ b/drivers/iio/accel/bmc150-accel.h @@ -16,6 +16,8 @@ enum { int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, const char *name, bool block_supported); int bmc150_accel_core_remove(struct device *dev); +struct i2c_client *bmc150_get_second_device(struct i2c_client *second_device); +void bmc150_set_second_device(struct i2c_client *second_device); extern const struct dev_pm_ops bmc150_accel_pm_ops; extern const struct regmap_config bmc150_regmap_conf; From patchwork Wed Nov 25 08:36:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 11930609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B400C5519F for ; Wed, 25 Nov 2020 08:36:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 94A8920B1F for ; Wed, 25 Nov 2020 08:36:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VzPnQ5PB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727057AbgKYIgf (ORCPT ); Wed, 25 Nov 2020 03:36:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38755 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726839AbgKYIge (ORCPT ); Wed, 25 Nov 2020 03:36:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606293393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FpofnXCAi8A/y7sN3P0RDH6SjXrWGNmiuHHZACYYIFY=; b=VzPnQ5PBWnpPAxYE0xVLVvpdxQlASSlX6n80JP7e5VL4td6Y1LyfX1QB1rUKNDOamH8yBh xGrqHTNigMdAk1WBPc1+9SEFa6uTzRTyXrD0zC2X3u3xH7o3oFDmSlLPjuhXAANiuNivFP Z0flBFP3eZ/YrtAwe2CzZzeA7UXAIAs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-589-NO4K74DaOWWGAV1DkXWwtg-1; Wed, 25 Nov 2020 03:36:29 -0500 X-MC-Unique: NO4K74DaOWWGAV1DkXWwtg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6DA4718C8C01; Wed, 25 Nov 2020 08:36:28 +0000 (UTC) Received: from x1.localdomain (ovpn-114-185.ams2.redhat.com [10.36.114.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35D835C1A1; Wed, 25 Nov 2020 08:36:27 +0000 (UTC) From: Hans de Goede To: Jonathan Cameron Cc: Hans de Goede , Lars-Peter Clausen , Peter Meerwald-Stadler , Jeremy Cline , linux-iio@vger.kernel.org Subject: [PATCH 3/3] iio: accel: bmc150: Get mount-matrix from ACPI Date: Wed, 25 Nov 2020 09:36:18 +0100 Message-Id: <20201125083618.10989-4-hdegoede@redhat.com> In-Reply-To: <20201125083618.10989-1-hdegoede@redhat.com> References: <20201125083618.10989-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org bmc150 accelerometers with an ACPI hardware-id of BOSC0200 have an ACPI method providing their mount-matrix, add support for retrieving this. Signed-off-by: Hans de Goede --- drivers/iio/accel/bmc150-accel-core.c | 82 +++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 4 deletions(-) diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 2976aefad89b..2ce65d509f93 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -410,6 +410,78 @@ static int bmc150_accel_set_power_state(struct bmc150_accel_data *data, bool on) } #endif +#ifdef CONFIG_ACPI +static bool bmc150_apply_acpi_orientation(struct device *dev, + struct iio_mount_matrix *orientation) +{ + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + struct acpi_device *adev = ACPI_COMPANION(dev); + union acpi_object *obj, *elements; + char *name, *alt_name, *str; + acpi_status status; + int i, j, val[3]; + + if (!adev || !acpi_dev_hid_uid_match(adev, "BOSC0200", NULL)) + return false; + + if (strcmp(dev_name(dev), "i2c-BOSC0200:base") == 0) + alt_name = "ROMK"; + else + alt_name = "ROMS"; + + if (acpi_has_method(adev->handle, "ROTM")) + name = "ROTM"; + else if (acpi_has_method(adev->handle, alt_name)) + name = alt_name; + else + return false; + + status = acpi_evaluate_object(adev->handle, name, NULL, &buffer); + if (ACPI_FAILURE(status)) { + dev_warn(dev, "Failed to get ACPI mount matrix: %d\n", status); + return false; + } + + obj = buffer.pointer; + if (obj->type != ACPI_TYPE_PACKAGE || obj->package.count != 3) + goto unknown_format; + + elements = obj->package.elements; + for (i = 0; i < 3; i++) { + if (elements[i].type != ACPI_TYPE_STRING) + goto unknown_format; + + str = elements[i].string.pointer; + if (sscanf(str, "%d %d %d", &val[0], &val[1], &val[2]) != 3) + goto unknown_format; + + for (j = 0; j < 3; j++) { + switch (val[j]) { + case -1: str = "-1"; break; + case 0: str = "0"; break; + case 1: str = "1"; break; + default: goto unknown_format; + } + orientation->rotation[i * 3 + j] = str; + } + } + + kfree(buffer.pointer); + return true; + +unknown_format: + dev_warn(dev, "Unknown ACPI mount matrix format, ignoring\n"); + kfree(buffer.pointer); + return false; +} +#else +static bool bmc150_apply_acpi_orientation(struct device *dev, + struct iio_mount_matrix *orientation) +{ + return false; +} +#endif + static const struct bmc150_accel_interrupt_info { u8 map_reg; u8 map_bitmask; @@ -1571,10 +1643,12 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, data->regmap = regmap; - ret = iio_read_mount_matrix(dev, "mount-matrix", - &data->orientation); - if (ret) - return ret; + if (!bmc150_apply_acpi_orientation(dev, &data->orientation)) { + ret = iio_read_mount_matrix(dev, "mount-matrix", + &data->orientation); + if (ret) + return ret; + } ret = bmc150_accel_chip_init(data); if (ret < 0)