From patchwork Fri Jun 21 10:08:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 1120095 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=opensource.cirrus.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=cirrus.com header.i=@cirrus.com header.b="USRpQ+Ow"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45VZCJ2QVzz9s4Y for ; Fri, 21 Jun 2019 20:08:44 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726299AbfFUKIh (ORCPT ); Fri, 21 Jun 2019 06:08:37 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:51158 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726218AbfFUKIh (ORCPT ); Fri, 21 Jun 2019 06:08:37 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5LA3vgs008660; Fri, 21 Jun 2019 05:08:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=8Wq63RwT0blreLIdF8TfbK/0UxW1qpD8JdYoP8le1Ts=; b=USRpQ+OwEAwgqy+/6zPcMRT98741GCovng+bp/JuqNdH6ZDkeAW/HxKwWGCeMspWsp5Z WDUTGVYsDd2Yyll5vpB+YSPr4dFDxNUbrebgG+/Zqw5agl6w3LB+ieGtQwE4vTYz4thb vWOi7pU/V3PUmc3rLLO3n31UcIIf3Ge9dL7PhyAuk/yjYQX0TPAmYgT9P0uM6dH5xhnm VBloodQxh7OIhZnZG4JAvufV5j0OGFfkOjx7EsfcEd0WjR5YmOj6Ar01zGQ8cVq4Jm9+ Jv5VDbx7bC5+M2gm6dY7zR5dyPcO5m7XxAe0OIhc49zduIxOS/wtzm/KhyBRjEVzcqEW JQ== Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail2.cirrus.com (mail2.cirrus.com [141.131.128.20]) by mx0a-001ae601.pphosted.com with ESMTP id 2t780gm6v6-1; Fri, 21 Jun 2019 05:08:18 -0500 Received: from EDIEX02.ad.cirrus.com (unknown [198.61.84.81]) by mail2.cirrus.com (Postfix) with ESMTP id C3B5D605A6A0; Fri, 21 Jun 2019 05:08:15 -0500 (CDT) Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Fri, 21 Jun 2019 11:08:15 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Fri, 21 Jun 2019 11:08:15 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 257F72A1; Fri, 21 Jun 2019 11:08:15 +0100 (BST) From: Charles Keepax To: , CC: , , , , , , , Subject: [PATCH v6 1/7] i2c: core: Allow whole core to use i2c_dev_irq_from_resources Date: Fri, 21 Jun 2019 11:08:09 +0100 Message-ID: <20190621100815.12417-2-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190621100815.12417-1-ckeepax@opensource.cirrus.com> References: <20190621100815.12417-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=669 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906210085 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Remove the static from i2c_dev_irq_from _resources so that other parts of the core code can use this helper function. Reviewed-by: Mika Westerberg Reviewed-by: Andy Shevchenko Signed-off-by: Charles Keepax --- No changes since v5. Thanks, Charles drivers/i2c/i2c-core-base.c | 4 ++-- drivers/i2c/i2c-core.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 2569e97f9bf35..8a303246d534b 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -679,8 +679,8 @@ static void i2c_dev_set_name(struct i2c_adapter *adap, i2c_encode_flags_to_addr(client)); } -static int i2c_dev_irq_from_resources(const struct resource *resources, - unsigned int num_resources) +int i2c_dev_irq_from_resources(const struct resource *resources, + unsigned int num_resources) { struct irq_data *irqd; int i; diff --git a/drivers/i2c/i2c-core.h b/drivers/i2c/i2c-core.h index 851c11b4c0f3a..2a3b28bf826b1 100644 --- a/drivers/i2c/i2c-core.h +++ b/drivers/i2c/i2c-core.h @@ -19,6 +19,8 @@ extern struct list_head __i2c_board_list; extern int __i2c_first_dynamic_bus_num; int i2c_check_7bit_addr_validity_strict(unsigned short addr); +int i2c_dev_irq_from_resources(const struct resource *resources, + unsigned int num_resources); /* * We only allow atomic transfers for very late communication, e.g. to send From patchwork Fri Jun 21 10:08:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 1120101 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=opensource.cirrus.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=cirrus.com header.i=@cirrus.com header.b="mXKem9+P"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45VZCs63c9z9s4V for ; Fri, 21 Jun 2019 20:09:13 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726521AbfFUKIn (ORCPT ); Fri, 21 Jun 2019 06:08:43 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:11732 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726498AbfFUKIn (ORCPT ); Fri, 21 Jun 2019 06:08:43 -0400 Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5LA4Qou000349; Fri, 21 Jun 2019 05:08:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=1NgFvVDhvCHqSR/CePJrSFYwI0WzzG6j+CKs/AV+u6Y=; b=mXKem9+PZFl4SV/dnAvDtezRzEWZ8qgnlHG2Jai8vONemgHFzoK81SwdBdR/PgIYPWdf FtvlNMt/tLysY6X/rUPTiFgmRAAPFr2VLiL/D9NKiNzJGkC3iB3WBwydjshMTwI+ToHc 0V29oAD+uuHfCPuZl6qO+pQH/T6AIgT82YBsOgfCZUo9S0WvJCcWLLTg4pZnavUNO1i0 dmbfSgh8ykAxuceJHyXVe8w3QnDZzce+g7QZkeRr9N9nKIf/vQL/LkKPgG55X/H9X0l0 37/ssyTrzyRosJEGDhX108I2OZdXymCst/Kp+6T0gPVgfeG42lur9F2iPV063rEKEeAz EQ== Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail2.cirrus.com (mail2.cirrus.com [141.131.128.20]) by mx0b-001ae601.pphosted.com with ESMTP id 2t780cuxbr-1; Fri, 21 Jun 2019 05:08:16 -0500 Received: from EDIEX02.ad.cirrus.com (unknown [198.61.84.81]) by mail2.cirrus.com (Postfix) with ESMTP id 7BA9B605A6BF; Fri, 21 Jun 2019 05:08:16 -0500 (CDT) Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Fri, 21 Jun 2019 11:08:15 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Fri, 21 Jun 2019 11:08:15 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 2C0DE2DB; Fri, 21 Jun 2019 11:08:15 +0100 (BST) From: Charles Keepax To: , CC: , , , , , , , Subject: [PATCH v6 2/7] i2c: acpi: Use available IRQ helper functions Date: Fri, 21 Jun 2019 11:08:10 +0100 Message-ID: <20190621100815.12417-3-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190621100815.12417-1-ckeepax@opensource.cirrus.com> References: <20190621100815.12417-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=993 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906210085 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Use the available IRQ helper functions, most of the functions have additional helpful side affects like configuring the trigger type of the IRQ. Signed-off-by: Charles Keepax --- Changes since v5: - Pass info->irq to i2c_acpi_add_resource directly - Remove call to acpi_dev_free_resource_list since we never add anything to the list. Thanks, Charles drivers/i2c/i2c-core-acpi.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index f1d648962b223..3951e352317ff 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -133,13 +133,24 @@ static int i2c_acpi_do_lookup(struct acpi_device *adev, return 0; } +static int i2c_acpi_add_resource(struct acpi_resource *ares, void *data) +{ + int *irq = data; + struct resource r; + + if (*irq <= 0 && acpi_dev_resource_interrupt(ares, 0, &r)) + *irq = i2c_dev_irq_from_resources(&r, 1); + + /* No need to add resource to the list, free list if this changes */ + return 1; +} + static int i2c_acpi_get_info(struct acpi_device *adev, struct i2c_board_info *info, struct i2c_adapter *adapter, acpi_handle *adapter_handle) { struct list_head resource_list; - struct resource_entry *entry; struct i2c_acpi_lookup lookup; int ret; @@ -172,19 +183,11 @@ static int i2c_acpi_get_info(struct acpi_device *adev, /* Then fill IRQ number if any */ INIT_LIST_HEAD(&resource_list); - ret = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); + ret = acpi_dev_get_resources(adev, &resource_list, + i2c_acpi_add_resource, &info->irq); if (ret < 0) return -EINVAL; - resource_list_for_each_entry(entry, &resource_list) { - if (resource_type(entry->res) == IORESOURCE_IRQ) { - info->irq = entry->res->start; - break; - } - } - - acpi_dev_free_resource_list(&resource_list); - acpi_set_modalias(adev, dev_name(&adev->dev), info->type, sizeof(info->type)); From patchwork Fri Jun 21 10:08:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 1120097 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=opensource.cirrus.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=cirrus.com header.i=@cirrus.com header.b="gRvibSR/"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45VZCd0yqbz9s4Y for ; Fri, 21 Jun 2019 20:09:01 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726689AbfFUKIv (ORCPT ); Fri, 21 Jun 2019 06:08:51 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:61486 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726668AbfFUKIv (ORCPT ); Fri, 21 Jun 2019 06:08:51 -0400 Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5LA4Qot000349; Fri, 21 Jun 2019 05:08:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=LXfKiBcitALEhcT0OeQ7qJQiQ+c2JkVF+KsqYJhdbbU=; b=gRvibSR/NW0HKrEGI6d+4vsxplqQHtnAzo308YLCM2gIQoW3Fw/ptP+AfWekYJ0+V4t1 lO8wbY77wIBlCcNMJFh5+Q6D/NWvn4HlTftwT4tEi9MGto1/06eW1wM220OYN9OA3gvi 7Cb+uEdgLw8JENKLZA2zEcOouloePlqzlXNcnv0kDCmp3Xoukjj/ixxk4jRKgKndQS+E UC8UpcuxXFm7BbjSmTZq/J8ZV3Mzkso9WrhCHIvZ82+0CWCrs0EgaPj9q17vnILaMKlQ Otj6fv1WGpMYq/Ygb3OlmLqDGG1YU3U0rXpmop8U+mO/F65O6HBK80859qTLbxo/pRnO LA== Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail4.cirrus.com ([87.246.98.35]) by mx0b-001ae601.pphosted.com with ESMTP id 2t780cuxbq-1; Fri, 21 Jun 2019 05:08:16 -0500 Received: from EDIEX01.ad.cirrus.com (ediex01.ad.cirrus.com [198.61.84.80]) by mail4.cirrus.com (Postfix) with ESMTP id 68FAF611C8A7; Fri, 21 Jun 2019 05:08:15 -0500 (CDT) Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Fri, 21 Jun 2019 11:08:15 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Fri, 21 Jun 2019 11:08:15 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 3C9A52DA; Fri, 21 Jun 2019 11:08:15 +0100 (BST) From: Charles Keepax To: , CC: , , , , , , , Subject: [PATCH v6 3/7] i2c: acpi: Factor out getting the IRQ from ACPI Date: Fri, 21 Jun 2019 11:08:11 +0100 Message-ID: <20190621100815.12417-4-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190621100815.12417-1-ckeepax@opensource.cirrus.com> References: <20190621100815.12417-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=802 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906210085 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org In preparation for future refactoring factor out the fetch of the IRQ into its own helper function. Whilst we are at it update the handling to return the actual error code returned from acpi_dev_get_resources as well. Signed-off-by: Charles Keepax --- Changes since v5: - Return error code from acpi_dev_get_resources - Bail out if i2c_acpi_get_irq fails Thanks, Charles drivers/i2c/i2c-core-acpi.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index 3951e352317ff..c91492eaacd93 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -145,12 +145,29 @@ static int i2c_acpi_add_resource(struct acpi_resource *ares, void *data) return 1; } +static int i2c_acpi_get_irq(struct acpi_device *adev) +{ + struct list_head resource_list; + int irq = -ENOENT; + int ret; + + INIT_LIST_HEAD(&resource_list); + + ret = acpi_dev_get_resources(adev, &resource_list, + i2c_acpi_add_resource, &irq); + if (ret < 0) + return ret; + + acpi_dev_free_resource_list(&resource_list); + + return irq; +} + static int i2c_acpi_get_info(struct acpi_device *adev, struct i2c_board_info *info, struct i2c_adapter *adapter, acpi_handle *adapter_handle) { - struct list_head resource_list; struct i2c_acpi_lookup lookup; int ret; @@ -182,11 +199,9 @@ static int i2c_acpi_get_info(struct acpi_device *adev, *adapter_handle = lookup.adapter_handle; /* Then fill IRQ number if any */ - INIT_LIST_HEAD(&resource_list); - ret = acpi_dev_get_resources(adev, &resource_list, - i2c_acpi_add_resource, &info->irq); - if (ret < 0) - return -EINVAL; + info->irq = i2c_acpi_get_irq(adev); + if (info->irq < 0) + return info->irq; acpi_set_modalias(adev, dev_name(&adev->dev), info->type, sizeof(info->type)); From patchwork Fri Jun 21 10:08:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 1120098 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=opensource.cirrus.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=cirrus.com header.i=@cirrus.com header.b="iWtGWfyA"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45VZCd54nvz9sND for ; Fri, 21 Jun 2019 20:09:01 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726676AbfFUKIu (ORCPT ); Fri, 21 Jun 2019 06:08:50 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:65394 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726651AbfFUKIt (ORCPT ); Fri, 21 Jun 2019 06:08:49 -0400 Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5LA4Qov000349; Fri, 21 Jun 2019 05:08:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=oTtNnnbZGJLJy4HFzqLOvJvW0A05UConAokanpdr8uQ=; b=iWtGWfyAiGm6VAkMqW/n36ytq3xH3WnGgNq6Ie6gbmTvk7fADVHKjRw/SVzzf33tj/LD +nz+l0X3M044EcjSkL0Bt7PA/KUXw1BbeWOie8ydVlV+YvLtb+5mhaIgM39+ZCk7nigU jFJzZk/Y0nZRWrY8ALw6vzKziz/MQwERRlXVgtxzmV9a+vJnRedClxsSux0J22b8oScU Nh1XfzH8utK463AzlIhJKOip7wAqvnBjCQi3dCtRjC905KMFW5gDSLqaaqtsuEsS87PI /MhKvLRQ03etOQQFMjjL6351RSjh3o8W6r5jNOhz86IfJVVqCZC4GqWWgql1QUqhVbWU HA== Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail2.cirrus.com (mail2.cirrus.com [141.131.128.20]) by mx0b-001ae601.pphosted.com with ESMTP id 2t780cuxbt-1; Fri, 21 Jun 2019 05:08:17 -0500 Received: from EDIEX02.ad.cirrus.com (unknown [198.61.84.81]) by mail2.cirrus.com (Postfix) with ESMTP id 324F6605A6BD; Fri, 21 Jun 2019 05:08:17 -0500 (CDT) Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Fri, 21 Jun 2019 11:08:15 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Fri, 21 Jun 2019 11:08:15 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 4E1722A1; Fri, 21 Jun 2019 11:08:15 +0100 (BST) From: Charles Keepax To: , CC: , , , , , , , Subject: [PATCH v6 4/7] i2c: core: Make i2c_acpi_get_irq available to the rest of the I2C core Date: Fri, 21 Jun 2019 11:08:12 +0100 Message-ID: <20190621100815.12417-5-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190621100815.12417-1-ckeepax@opensource.cirrus.com> References: <20190621100815.12417-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=898 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906210085 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org In preparation for more refactoring make i2c_acpi_get_irq available outside i2c-core-acpi.c. Signed-off-by: Charles Keepax --- Changes since v5: - Pass a struct device rather than acpi_device to i2c_acpi_get_irq, note this is more awkward than I would have liked as I am very unconvinced that adev->dev can actually be passed to ACPI_COMPANION. If anyone can answer that for sure that would be very helpful. Thanks, Charles drivers/i2c/i2c-core-acpi.c | 13 +++++++++++-- drivers/i2c/i2c-core.h | 7 +++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index c91492eaacd93..37bf80b35365f 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -145,8 +145,17 @@ static int i2c_acpi_add_resource(struct acpi_resource *ares, void *data) return 1; } -static int i2c_acpi_get_irq(struct acpi_device *adev) +/** + * i2c_acpi_get_irq - get device IRQ number from ACPI + * @client: Pointer to the I2C client device + * + * Find the IRQ number used by a specific client device. + * + * Return: The IRQ number or an error code. + */ +int i2c_acpi_get_irq(struct device *dev) { + struct acpi_device *adev = container_of(dev, struct acpi_device, dev); struct list_head resource_list; int irq = -ENOENT; int ret; @@ -199,7 +208,7 @@ static int i2c_acpi_get_info(struct acpi_device *adev, *adapter_handle = lookup.adapter_handle; /* Then fill IRQ number if any */ - info->irq = i2c_acpi_get_irq(adev); + info->irq = i2c_acpi_get_irq(&adev->dev); if (info->irq < 0) return info->irq; diff --git a/drivers/i2c/i2c-core.h b/drivers/i2c/i2c-core.h index 2a3b28bf826b1..1735ac17a957a 100644 --- a/drivers/i2c/i2c-core.h +++ b/drivers/i2c/i2c-core.h @@ -63,6 +63,8 @@ const struct acpi_device_id * i2c_acpi_match_device(const struct acpi_device_id *matches, struct i2c_client *client); void i2c_acpi_register_devices(struct i2c_adapter *adap); + +int i2c_acpi_get_irq(struct device *dev); #else /* CONFIG_ACPI */ static inline void i2c_acpi_register_devices(struct i2c_adapter *adap) { } static inline const struct acpi_device_id * @@ -71,6 +73,11 @@ i2c_acpi_match_device(const struct acpi_device_id *matches, { return NULL; } + +static inline int i2c_acpi_get_irq(struct device *dev) +{ + return 0; +} #endif /* CONFIG_ACPI */ extern struct notifier_block i2c_acpi_notifier; From patchwork Fri Jun 21 10:08:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 1120096 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=opensource.cirrus.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=cirrus.com header.i=@cirrus.com header.b="KQ+X0YEh"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45VZCP3Y4Yz9s4Y for ; Fri, 21 Jun 2019 20:08:49 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726653AbfFUKIs (ORCPT ); Fri, 21 Jun 2019 06:08:48 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:37092 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726620AbfFUKIs (ORCPT ); Fri, 21 Jun 2019 06:08:48 -0400 Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5LA3kSr032314; Fri, 21 Jun 2019 05:08:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=FGdKuH0EgrNIwtAmIG3f5mfcO86eNYlY2sk+4u+Uq0o=; b=KQ+X0YEhSd9A1s68Xk+27TF4ALYPkTWZEAuTqWQKcZyBOEL62Q8oCLwDiRqZhQjFMZrR lBLqpaEDURbzy6Ww5gfEno2++BTzH+D/TCyt76b1gBK5K4+2tz1P+UJfddKEqPN4hsnA nF5lNXNAlFdi1s9a9M6j6+Dkwj+yZyX63NVIL6wCwo19rH0LGy30OFSPqnn0QE37cLJ5 Uo8jOCJ0ZcJ50S3ZbDZtZcT04yGDyVapCN4irN+8CxfxMjP8XL9H+xO1mhgkXg1OJEUO FHeKk5tbGGyGBF77I3vFnwSSaxi0JVW47ufnd34HC30ceUne9m5WNzjCfopcYWQAX1hj XQ== Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail2.cirrus.com (mail2.cirrus.com [141.131.128.20]) by mx0b-001ae601.pphosted.com with ESMTP id 2t780cuxbs-1; Fri, 21 Jun 2019 05:08:17 -0500 Received: from EDIEX02.ad.cirrus.com (unknown [198.61.84.81]) by mail2.cirrus.com (Postfix) with ESMTP id D110E605A6AF; Fri, 21 Jun 2019 05:08:16 -0500 (CDT) Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Fri, 21 Jun 2019 11:08:15 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Fri, 21 Jun 2019 11:08:15 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 5CC532DD; Fri, 21 Jun 2019 11:08:15 +0100 (BST) From: Charles Keepax To: , CC: , , , , , , , Subject: [PATCH v6 5/7] i2c: core: Move ACPI IRQ handling to probe time Date: Fri, 21 Jun 2019 11:08:13 +0100 Message-ID: <20190621100815.12417-6-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190621100815.12417-1-ckeepax@opensource.cirrus.com> References: <20190621100815.12417-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906210085 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Bring the ACPI path in sync with the device tree path and handle all the IRQ fetching at probe time. This leaves the only IRQ handling at device registration time being that which is passed directly through the board info as either a resource or an actual IRQ number. Signed-off-by: Charles Keepax --- Changes since v5: - Pass a struct device rather than acpi_device to i2c_acpi_get_irq. Thanks, Charles drivers/i2c/i2c-core-acpi.c | 7 +------ drivers/i2c/i2c-core-base.c | 5 ++++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index 37bf80b35365f..aaca1e216be66 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -155,7 +155,7 @@ static int i2c_acpi_add_resource(struct acpi_resource *ares, void *data) */ int i2c_acpi_get_irq(struct device *dev) { - struct acpi_device *adev = container_of(dev, struct acpi_device, dev); + struct acpi_device *adev = ACPI_COMPANION(dev); struct list_head resource_list; int irq = -ENOENT; int ret; @@ -207,11 +207,6 @@ static int i2c_acpi_get_info(struct acpi_device *adev, if (adapter_handle) *adapter_handle = lookup.adapter_handle; - /* Then fill IRQ number if any */ - info->irq = i2c_acpi_get_irq(&adev->dev); - if (info->irq < 0) - return info->irq; - acpi_set_modalias(adev, dev_name(&adev->dev), info->type, sizeof(info->type)); diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 8a303246d534b..34de732598533 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -327,7 +327,10 @@ static int i2c_device_probe(struct device *dev) if (irq == -EINVAL || irq == -ENODATA) irq = of_irq_get(dev->of_node, 0); } else if (ACPI_COMPANION(dev)) { - irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev), 0); + irq = i2c_acpi_get_irq(dev); + + if (irq == -ENOENT) + irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev), 0); } if (irq == -EPROBE_DEFER) return irq; From patchwork Fri Jun 21 10:08:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 1120102 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=opensource.cirrus.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=cirrus.com header.i=@cirrus.com header.b="fQOMtgXw"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45VZCt3Jf5z9sBr for ; Fri, 21 Jun 2019 20:09:14 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726452AbfFUKIl (ORCPT ); Fri, 21 Jun 2019 06:08:41 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:15976 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726218AbfFUKIl (ORCPT ); Fri, 21 Jun 2019 06:08:41 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5LA4s3o009159; Fri, 21 Jun 2019 05:08:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=a5umfxpQ6L+20Vsyn6NyItos8JeMJ4pwMns4M4xNiTo=; b=fQOMtgXwakjFd2Uo6SvRP8nw0WKea66Y17JTgGQYwmL1KrCMLpBzAd6W1JeTOI3L4eBC U7/RbbL/iO1mZ3BmFBwmcJkAHg/yxY2Gp92mRa91x/hDFZZ7LlVQl2W2j+182O3bSZ9N 20JhR3lCtE3kpy7/GArE/p2iJT7TtreV0TQtWeddcxqwVRCSFT905okq0OawqHEhrCXM sYGYZO3ui8YBsvRoIyfR0LkYh4qMuDKz0xj6Af4As81D3im1b6Jn2j8fVHroRKVLqXOg tLipWJH8q699vGGhSxWR9aCQLRtBO8PkUmI+PvqE3aM28B4KcmkNv/kXsr1rs552LSYq Uw== Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail1.cirrus.com (mail1.cirrus.com [141.131.3.20]) by mx0a-001ae601.pphosted.com with ESMTP id 2t780gm6v8-1; Fri, 21 Jun 2019 05:08:17 -0500 Received: from EDIEX01.ad.cirrus.com (unknown [198.61.84.80]) by mail1.cirrus.com (Postfix) with ESMTP id 39DF0611C8BC; Fri, 21 Jun 2019 05:08:16 -0500 (CDT) Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Fri, 21 Jun 2019 11:08:15 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Fri, 21 Jun 2019 11:08:15 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 6B11144; Fri, 21 Jun 2019 11:08:15 +0100 (BST) From: Charles Keepax To: , CC: , , , , , , , Subject: [PATCH v6 6/7] i2c: core: Move ACPI gpio IRQ handling into i2c_acpi_get_irq Date: Fri, 21 Jun 2019 11:08:14 +0100 Message-ID: <20190621100815.12417-7-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190621100815.12417-1-ckeepax@opensource.cirrus.com> References: <20190621100815.12417-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=827 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906210085 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org It makes sense to contain all the ACPI IRQ handling in a single helper function. Reviewed-by: Mika Westerberg Reviewed-by: Andy Shevchenko Signed-off-by: Charles Keepax --- drivers/i2c/i2c-core-acpi.c | 3 +++ drivers/i2c/i2c-core-base.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index aaca1e216be66..042c1cb148bc6 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -169,6 +169,9 @@ int i2c_acpi_get_irq(struct device *dev) acpi_dev_free_resource_list(&resource_list); + if (irq == -ENOENT) + irq = acpi_dev_gpio_irq_get(adev, 0); + return irq; } diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 34de732598533..87a2ad8f41a76 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -328,9 +328,6 @@ static int i2c_device_probe(struct device *dev) irq = of_irq_get(dev->of_node, 0); } else if (ACPI_COMPANION(dev)) { irq = i2c_acpi_get_irq(dev); - - if (irq == -ENOENT) - irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev), 0); } if (irq == -EPROBE_DEFER) return irq; From patchwork Fri Jun 21 10:08:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 1120099 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=opensource.cirrus.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=cirrus.com header.i=@cirrus.com header.b="f7xjDjeh"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45VZCg5Gt8z9sND for ; Fri, 21 Jun 2019 20:09:03 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726736AbfFUKJD (ORCPT ); Fri, 21 Jun 2019 06:09:03 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:33360 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726622AbfFUKIs (ORCPT ); Fri, 21 Jun 2019 06:08:48 -0400 Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5LA3kSs032314; Fri, 21 Jun 2019 05:08:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=UKo5CllAPGADG3RdYfRA7XHfkfa9kmT6PUJVXJZbPt4=; b=f7xjDjehuoy+ShhADBH8cChc9jfUmwhdrKLF6A2jWig2qyU5IzYF3WGGYrhz+gVhCRoc LgV8NDtJDfzw6vX7kPw7gm7eznUzUMS5qSJbm0+dlOfmI2IEHsBXG+TqjZ7C5BDrHkDW uPwReaDlwAB5VWv0Wdo4rpQdOjLVD3S/O+ai2cjg1iyhhriQcLj4ZZGTwJ4RHLhOeuwz R99sZKUAcbcZjgEm+5zVV/6o3ice/Lq0frsRMXLDxMqixXrd5j2k8Ad5GjW9aI5Mhqdd rN56DkL+inpgOAAmseaxE6MBhKVHTQTz6kjKEeLLG73VG0DO3PO8iaez6wme72pu5mB1 ZQ== Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail2.cirrus.com (mail2.cirrus.com [141.131.128.20]) by mx0b-001ae601.pphosted.com with ESMTP id 2t780cuxbs-2; Fri, 21 Jun 2019 05:08:17 -0500 Received: from EDIEX02.ad.cirrus.com (unknown [198.61.84.81]) by mail2.cirrus.com (Postfix) with ESMTP id 88001605DBF0; Fri, 21 Jun 2019 05:08:17 -0500 (CDT) Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Fri, 21 Jun 2019 11:08:15 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Fri, 21 Jun 2019 11:08:15 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 794BF2DA; Fri, 21 Jun 2019 11:08:15 +0100 (BST) From: Charles Keepax To: , CC: , , , , , , , Subject: [PATCH v6 7/7] i2c: core: Tidy up handling of init_irq Date: Fri, 21 Jun 2019 11:08:15 +0100 Message-ID: <20190621100815.12417-8-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190621100815.12417-1-ckeepax@opensource.cirrus.com> References: <20190621100815.12417-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906210085 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Only set init_irq during i2c_device_new and only handle client->irq on the probe/remove paths. Suggested-by: Benjamin Tissoires Reviewed-by: Mika Westerberg Reviewed-by: Andy Shevchenko Signed-off-by: Charles Keepax --- No changes since v5. Thanks, Charles drivers/i2c/i2c-core-base.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 87a2ad8f41a76..b3cc581f6465b 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -314,6 +314,8 @@ static int i2c_device_probe(struct device *dev) driver = to_i2c_driver(dev->driver); + client->irq = client->init_irq; + if (!client->irq && !driver->disable_i2c_core_irq_mapping) { int irq = -ENOENT; @@ -424,7 +426,7 @@ static int i2c_device_remove(struct device *dev) dev_pm_clear_wake_irq(&client->dev); device_init_wakeup(&client->dev, false); - client->irq = client->init_irq; + client->irq = 0; if (client->flags & I2C_CLIENT_HOST_NOTIFY) pm_runtime_put(&client->adapter->dev); @@ -741,7 +743,6 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf if (!client->init_irq) client->init_irq = i2c_dev_irq_from_resources(info->resources, info->num_resources); - client->irq = client->init_irq; strlcpy(client->name, info->type, sizeof(client->name));