From patchwork Sun May 20 13:28:52 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: 10413391 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 DBA5A60365 for ; Sun, 20 May 2018 13:29:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC9BC286FE for ; Sun, 20 May 2018 13:29:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C185028723; Sun, 20 May 2018 13:29: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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 08156286FE for ; Sun, 20 May 2018 13:29:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751547AbeETN3M (ORCPT ); Sun, 20 May 2018 09:29:12 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41400 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751514AbeETN3K (ORCPT ); Sun, 20 May 2018 09:29:10 -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 0BC40401DEAC; Sun, 20 May 2018 13:29:10 +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 768D6215CDA7; Sun, 20 May 2018 13:29:08 +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 4/9] i2c: acpi: Allow get info by index in i2c_acpi_get_info() Date: Sun, 20 May 2018 15:28:52 +0200 Message-Id: <20180520132857.8103-5-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.6]); Sun, 20 May 2018 13:29:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Sun, 20 May 2018 13:29:10 +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 From: Andy Shevchenko For some devices we need to get info based on index. As a preparation of support such, slightly modify i2c_acpi_get_info() helper. While here, assume that interrupt resources are provided in the same amount with 1:1 mapping to serial bus resources. This will not affect existing behaviour because only first resource of each type is considered. Signed-off-by: Andy Shevchenko Signed-off-by: Hans de Goede --- drivers/i2c/i2c-core-acpi.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index 7b1b0aeced36..75352b3744e5 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -129,17 +129,19 @@ static int i2c_acpi_do_lookup(struct acpi_device *adev, static int i2c_acpi_get_info(struct acpi_device *adev, struct i2c_board_info *info, + int index, struct i2c_adapter *adapter, acpi_handle *adapter_handle) { struct list_head resource_list; struct resource_entry *entry; struct i2c_acpi_lookup lookup; + unsigned int n; int ret; memset(&lookup, 0, sizeof(lookup)); lookup.info = info; - lookup.index = -1; + lookup.index = index; ret = i2c_acpi_do_lookup(adev, &lookup); if (ret) @@ -170,10 +172,13 @@ static int i2c_acpi_get_info(struct acpi_device *adev, if (ret < 0) return -EINVAL; + n = 0; resource_list_for_each_entry(entry, &resource_list) { if (resource_type(entry->res) == IORESOURCE_IRQ) { - info->irq = entry->res->start; - break; + if (index == -1 || n++ == index) { + info->irq = entry->res->start; + break; + } } } @@ -210,7 +215,7 @@ static acpi_status i2c_acpi_add_device(acpi_handle handle, u32 level, if (acpi_bus_get_device(handle, &adev)) return AE_OK; - if (i2c_acpi_get_info(adev, &info, adapter, NULL)) + if (i2c_acpi_get_info(adev, &info, -1, adapter, NULL)) return AE_OK; i2c_acpi_register_device(adapter, adev, &info); @@ -356,7 +361,7 @@ static int i2c_acpi_notify(struct notifier_block *nb, unsigned long value, switch (value) { case ACPI_RECONFIG_DEVICE_ADD: - if (i2c_acpi_get_info(adev, &info, NULL, &adapter_handle)) + if (i2c_acpi_get_info(adev, &info, -1, NULL, &adapter_handle)) break; adapter = i2c_acpi_find_adapter_by_handle(adapter_handle);