From patchwork Sun May 20 13:28:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10413403 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9CDF56032C for ; Sun, 20 May 2018 13:29:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D4B3286FE for ; Sun, 20 May 2018 13:29:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 818282871C; Sun, 20 May 2018 13:29:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 346DF286FE for ; Sun, 20 May 2018 13:29:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751529AbeETN3S (ORCPT ); Sun, 20 May 2018 09:29:18 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41682 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751372AbeETN3P (ORCPT ); Sun, 20 May 2018 09:29:15 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57DC7BB41A; Sun, 20 May 2018 13:29:15 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1B2D215CDA7; Sun, 20 May 2018 13:29:13 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" , Len Brown , Andy Shevchenko , Mika Westerberg , Wolfram Sang , Jonathan Cameron Cc: Hans de Goede , linux-acpi@vger.kernel.org, linux-i2c@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , linux-iio@vger.kernel.org Subject: [PATCH 7/9] iio: accel: bmc150: Add support for BSG1160 ACPI HID Date: Sun, 20 May 2018 15:28:55 +0200 Message-Id: <20180520132857.8103-8-hdegoede@redhat.com> In-Reply-To: <20180520132857.8103-1-hdegoede@redhat.com> References: <20180520132857.8103-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Sun, 20 May 2018 13:29:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Sun, 20 May 2018 13:29:15 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'hdegoede@redhat.com' RCPT:'' Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The BSG1160 ACPI HID is a HID describing a sensor complex consisting of 3 sensors: Accel: BMC150A at addr 0x11 Gyro: BMG160 at addr 0x68 Magneto: BMC150B at addr 0x13 A previous patch on this series has added the BSG1160 HID to the i2c_acpi_multiple_devices_ids list, so that one i2c_client gets instantiated per sensor. This commit not only adds the BSG1160 HID to the bmc150 code, but it also makes the i2c probe function check the client address for devices with a BSG1160 HID and only bind to the one at address 0x11. Signed-off-by: Hans de Goede --- drivers/iio/accel/bmc150-accel-i2c.c | 8 ++++++++ drivers/iio/accel/bmc150-accel.h | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/iio/accel/bmc150-accel-i2c.c b/drivers/iio/accel/bmc150-accel-i2c.c index 8ffc308d5fd0..e0d7b507e397 100644 --- a/drivers/iio/accel/bmc150-accel-i2c.c +++ b/drivers/iio/accel/bmc150-accel-i2c.c @@ -31,13 +31,20 @@ static int bmc150_accel_probe(struct i2c_client *client, const struct i2c_device_id *id) { + const struct acpi_device_id *acpi_id; struct regmap *regmap; + struct device *dev = &client->dev; const char *name = NULL; bool block_supported = i2c_check_functionality(client->adapter, I2C_FUNC_I2C) || i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK); + /* The BSG1160 ACPI id describes multiple sensors, only bind to ours */ + acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev); + if (acpi_id && acpi_id->driver_data == bsg1160 && client->addr != 0x11) + return -ENODEV; + regmap = devm_regmap_init_i2c(client, &bmc150_regmap_conf); if (IS_ERR(regmap)) { dev_err(&client->dev, "Failed to initialize i2c regmap\n"); @@ -64,6 +71,7 @@ static const struct acpi_device_id bmc150_accel_acpi_match[] = { {"BMA250E", bma250e}, {"BMA222E", bma222e}, {"BMA0280", bma280}, + {"BSG1160", bsg1160}, {"BOSC0200"}, { }, }; diff --git a/drivers/iio/accel/bmc150-accel.h b/drivers/iio/accel/bmc150-accel.h index ae6118ae11b1..ac540a775d54 100644 --- a/drivers/iio/accel/bmc150-accel.h +++ b/drivers/iio/accel/bmc150-accel.h @@ -11,6 +11,7 @@ enum { bma250e, bma222e, bma280, + bsg1160, }; int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,