From patchwork Sun May 20 13:28:50 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: 10413385 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 21F2A60365 for ; Sun, 20 May 2018 13:29:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1174B286FE for ; Sun, 20 May 2018 13:29:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05ED32871C; Sun, 20 May 2018 13:29:13 +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 A3001286FE for ; Sun, 20 May 2018 13:29:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751513AbeETN3J (ORCPT ); Sun, 20 May 2018 09:29:09 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41372 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751421AbeETN3H (ORCPT ); Sun, 20 May 2018 09:29:07 -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 7C40E40201A2; Sun, 20 May 2018 13:29:06 +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 E584C215CDA7; Sun, 20 May 2018 13:29:04 +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 2/9] i2c: Allow specifying irq-index to be used in i2c_device_probe() Date: Sun, 20 May 2018 15:28:50 +0200 Message-Id: <20180520132857.8103-3-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:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Sun, 20 May 2018 13:29:06 +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 Some types of interrupts are retrieved in i2c_device_probe() because getting them might fail with -EPROBE_DEFER. So far we've always assumed the first IRQ (index 0) in the firmware-node is the one we want. At least with ACPI enumerated i2c-clients in some cases the firmware-node is shared between multiple i2c-clients so we need to be able to specify the index rather then hardcoding it at 0. This commit adds a new fwnode_irq_index member to i2c_board_info and i2c_client which allows specifying the index. Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko --- drivers/i2c/i2c-core-base.c | 7 +++++-- include/linux/i2c.h | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 1ba40bb2b966..ae3fda2c96a4 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -312,9 +312,11 @@ static int i2c_device_probe(struct device *dev) } else if (dev->of_node) { irq = of_irq_get_byname(dev->of_node, "irq"); if (irq == -EINVAL || irq == -ENODATA) - irq = of_irq_get(dev->of_node, 0); + irq = of_irq_get(dev->of_node, + client->fwnode_irq_index); } else if (ACPI_COMPANION(dev)) { - irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev), 0); + irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev), + client->fwnode_irq_index); } if (irq == -EPROBE_DEFER) return irq; @@ -724,6 +726,7 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info) client->flags = info->flags; client->addr = info->addr; + client->fwnode_irq_index = info->fwnode_irq_index; client->irq = info->irq; if (!client->irq) client->irq = i2c_dev_irq_from_resources(info->resources, diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 44ad14e016b5..7f9506714a5e 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -316,6 +316,8 @@ struct i2c_driver { * generic enough to hide second-sourcing and compatible revisions. * @adapter: manages the bus segment hosting this I2C device * @dev: Driver model device node for the slave. + * @fwnode_irq_index: some devices share a single fwnode, this tells + * i2c_device_probe() to use the Nth irq from the fwnode * @irq: indicates the IRQ generated by this device (if any) * @detected: member of an i2c_driver.clients list or i2c-core's * userspace_devices list @@ -334,6 +336,7 @@ struct i2c_client { char name[I2C_NAME_SIZE]; struct i2c_adapter *adapter; /* the adapter we sit on */ struct device dev; /* the device structure */ + int fwnode_irq_index; /* index for irq lookup */ int irq; /* irq issued by device */ struct list_head detected; #if IS_ENABLED(CONFIG_I2C_SLAVE) @@ -400,6 +403,7 @@ static inline bool i2c_detect_slave_mode(struct device *dev) { return false; } * @properties: additional device properties for the device * @resources: resources associated with the device * @num_resources: number of resources in the @resources array + * @fwnode_irq_index: stored in i2c_client.fwnode_irq_index * @irq: stored in i2c_client.irq * * I2C doesn't actually support hardware probing, although controllers and @@ -425,6 +429,7 @@ struct i2c_board_info { const struct property_entry *properties; const struct resource *resources; unsigned int num_resources; + int fwnode_irq_index; int irq; };