From patchwork Fri Apr 21 07:38:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9691981 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 7FEA560383 for ; Fri, 21 Apr 2017 07:38:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71C3E28178 for ; Fri, 21 Apr 2017 07:38:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64E102860B; Fri, 21 Apr 2017 07:38:17 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham 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 0997B28178 for ; Fri, 21 Apr 2017 07:38:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1036108AbdDUHiQ (ORCPT ); Fri, 21 Apr 2017 03:38:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41764 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1036092AbdDUHiP (ORCPT ); Fri, 21 Apr 2017 03:38:15 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1ACFA469; Fri, 21 Apr 2017 07:38:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1ACFA469 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=hdegoede@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1ACFA469 Received: from shalem.localdomain.com (ovpn-117-71.ams2.redhat.com [10.36.117.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66AB978C26; Fri, 21 Apr 2017 07:38:13 +0000 (UTC) From: Hans de Goede To: Jonathan Cameron Cc: Hans de Goede , linux-acpi@vger.kernel.org, Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH] iio: accel: bma180: Add ACPI enumeration support Date: Fri, 21 Apr 2017 09:38:12 +0200 Message-Id: <20170421073812.12531-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 21 Apr 2017 07:38:15 +0000 (UTC) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some x86 tablets use the bms250 accelerometer, add support for this. Signed-off-by: Hans de Goede --- drivers/iio/accel/bma180.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index 0890934..5c75190 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -14,6 +14,7 @@ * BMA250: 7-bit I2C slave address 0x18 or 0x19 */ +#include #include #include #include @@ -705,6 +706,8 @@ static const struct iio_trigger_ops bma180_trigger_ops = { static int bma180_probe(struct i2c_client *client, const struct i2c_device_id *id) { + struct device *dev = &client->dev; + const struct acpi_device_id *acpi_id; struct bma180_data *data; struct iio_dev *indio_dev; int ret; @@ -716,7 +719,15 @@ static int bma180_probe(struct i2c_client *client, data = iio_priv(indio_dev); i2c_set_clientdata(client, indio_dev); data->client = client; - data->part_info = &bma180_part_info[id->driver_data]; + if (id) { + data->part_info = &bma180_part_info[id->driver_data]; + } else { + acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev); + if (!acpi_id) + return -ENODEV; + + data->part_info = &bma180_part_info[acpi_id->driver_data]; + } ret = data->part_info->chip_config(data); if (ret < 0) @@ -836,6 +847,12 @@ static SIMPLE_DEV_PM_OPS(bma180_pm_ops, bma180_suspend, bma180_resume); #define BMA180_PM_OPS NULL #endif +static const struct acpi_device_id bma180_acpi_match[] = { + { "BMA250E", BMA250 }, + { } +}; +MODULE_DEVICE_TABLE(acpi, bma180_acpi_match); + static struct i2c_device_id bma180_ids[] = { { "bma180", BMA180 }, { "bma250", BMA250 }, @@ -847,6 +864,7 @@ MODULE_DEVICE_TABLE(i2c, bma180_ids); static struct i2c_driver bma180_driver = { .driver = { .name = "bma180", + .acpi_match_table = ACPI_PTR(bma180_acpi_match), .pm = BMA180_PM_OPS, }, .probe = bma180_probe,