From patchwork Sun Jul 4 14:35:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Shtylyov X-Patchwork-Id: 1500435 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GHrwH0flPz9sWS for ; Mon, 5 Jul 2021 00:35:59 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229543AbhGDOic (ORCPT ); Sun, 4 Jul 2021 10:38:32 -0400 Received: from mxout01.lancloud.ru ([45.84.86.81]:39306 "EHLO mxout01.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229502AbhGDOic (ORCPT ); Sun, 4 Jul 2021 10:38:32 -0400 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout01.lancloud.ru 7B44620CDA20 Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: [PATCH v2 1/5] i2c: hix5hd2: fix IRQ check From: Sergey Shtylyov To: References: <3712e871-bf2f-32c5-f9c2-2968c42087f8@omp.ru> Organization: Open Mobile Platform Message-ID: Date: Sun, 4 Jul 2021 17:35:54 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <3712e871-bf2f-32c5-f9c2-2968c42087f8@omp.ru> Content-Language: en-US X-Originating-IP: [192.168.11.198] X-ClientProxiedBy: LFEXT01.lancloud.ru (fd00:f066::141) To LFEX1907.lancloud.ru (fd00:f066::207) Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Iff platform_get_irq() returns 0, the driver's probe() method will return 0 early (as if the method's call was successful). Let's consider IRQ0 valid for simplicity -- devm_request_irq() can always override that decision... Fixes: 15ef27756b23 ("i2c: hix5hd2: add i2c controller driver") Signed-off-by: Sergey Shtylyov --- drivers/i2c/busses/i2c-hix5hd2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux/drivers/i2c/busses/i2c-hix5hd2.c =================================================================== --- linux.orig/drivers/i2c/busses/i2c-hix5hd2.c +++ linux/drivers/i2c/busses/i2c-hix5hd2.c @@ -413,7 +413,7 @@ static int hix5hd2_i2c_probe(struct plat return PTR_ERR(priv->regs); irq = platform_get_irq(pdev, 0); - if (irq <= 0) + if (irq < 0) return irq; priv->clk = devm_clk_get(&pdev->dev, NULL); From patchwork Sun Jul 4 14:38:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Shtylyov X-Patchwork-Id: 1500436 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GHrzY4gJ8z9sWS for ; Mon, 5 Jul 2021 00:38:49 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229543AbhGDOlY (ORCPT ); Sun, 4 Jul 2021 10:41:24 -0400 Received: from mxout03.lancloud.ru ([45.84.86.113]:47854 "EHLO mxout03.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229502AbhGDOlX (ORCPT ); Sun, 4 Jul 2021 10:41:23 -0400 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout03.lancloud.ru C25A420F1D4C Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: [PATCH v2 2/5] i2c: mt65xx: fix IRQ check From: Sergey Shtylyov To: CC: Qii Wang , Matthias Brugger , , References: <3712e871-bf2f-32c5-f9c2-2968c42087f8@omp.ru> Organization: Open Mobile Platform Message-ID: Date: Sun, 4 Jul 2021 17:38:45 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <3712e871-bf2f-32c5-f9c2-2968c42087f8@omp.ru> Content-Language: en-US X-Originating-IP: [192.168.11.198] X-ClientProxiedBy: LFEXT02.lancloud.ru (fd00:f066::142) To LFEX1907.lancloud.ru (fd00:f066::207) Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Iff platform_get_irq() returns 0, the driver's probe() method will return 0 early (as if the method's call was successful). Let's consider IRQ0 valid for simplicity -- devm_request_irq() can always override that decision... Fixes: ce38815d39ea ("I2C: mediatek: Add driver for MediaTek I2C controller") Signed-off-by: Sergey Shtylyov Reviewed-by: Qii Wang --- drivers/i2c/busses/i2c-mt65xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux/drivers/i2c/busses/i2c-mt65xx.c =================================================================== --- linux.orig/drivers/i2c/busses/i2c-mt65xx.c +++ linux/drivers/i2c/busses/i2c-mt65xx.c @@ -1211,7 +1211,7 @@ static int mtk_i2c_probe(struct platform return PTR_ERR(i2c->pdmabase); irq = platform_get_irq(pdev, 0); - if (irq <= 0) + if (irq < 0) return irq; init_completion(&i2c->msg_complete); From patchwork Sun Jul 4 14:41:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Shtylyov X-Patchwork-Id: 1500437 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GHs3H4jFyz9sWq for ; Mon, 5 Jul 2021 00:42:03 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbhGDOoa (ORCPT ); Sun, 4 Jul 2021 10:44:30 -0400 Received: from mxout01.lancloud.ru ([45.84.86.81]:39428 "EHLO mxout01.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbhGDOo1 (ORCPT ); Sun, 4 Jul 2021 10:44:27 -0400 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout01.lancloud.ru 1FAF920CDDCA Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: [PATCH v2 3/5] i2c: pmcmsp: fix IRQ check From: Sergey Shtylyov To: References: <3712e871-bf2f-32c5-f9c2-2968c42087f8@omp.ru> Organization: Open Mobile Platform Message-ID: Date: Sun, 4 Jul 2021 17:41:50 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <3712e871-bf2f-32c5-f9c2-2968c42087f8@omp.ru> Content-Language: en-US X-Originating-IP: [192.168.11.198] X-ClientProxiedBy: LFEXT02.lancloud.ru (fd00:f066::142) To LFEX1907.lancloud.ru (fd00:f066::207) Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The driver's probe() method is written as if platform_get_irq() returns 0 on error, while actually it returns a negative error code (with all the other values considered valid IRQs). Rewrite the driver's IRQ checking code to pass the positive IRQ #s to request_irq() and use polling mode when platform_get_irq() returns negative error code (or IRQ0)... Fixes: 1b144df1d7d6 ("i2c: New PMC MSP71xx TWI bus driver") Signed-off-by: Sergey Shtylyov --- Changes in version 2: - fixed the IRQ validity check, assigning the result of platform_get_irq() call to the 'rc' variable first; - merging the code enforcing the polling mode on bad IRQ in one place (after calling request_irq() and handling its result); - removed explicit check for the deferred probe, fixed up the patch description accordingly; - removed the dashes in the patch subject; - refreshed the patch. drivers/i2c/busses/i2c-pmcmsp.c | 8 +++++--- drivers/i2c/busses/i2c-pmcmsp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) Index: linux/drivers/i2c/busses/i2c-pmcmsp.c =================================================================== --- linux.orig/drivers/i2c/busses/i2c-pmcmsp.c +++ linux/drivers/i2c/busses/i2c-pmcmsp.c @@ -291,8 +291,9 @@ static int pmcmsptwi_probe(struct platfo } /* request the irq */ - pmcmsptwi_data.irq = platform_get_irq(pldev, 0); - if (pmcmsptwi_data.irq) { + rc = platform_get_irq(pldev, 0); + pmcmsptwi_data.irq = rc; + if (rc > 0) { rc = request_irq(pmcmsptwi_data.irq, &pmcmsptwi_interrupt, IRQF_SHARED, pldev->name, &pmcmsptwi_data); if (rc == 0) { @@ -312,9 +313,14 @@ static int pmcmsptwi_probe(struct platfo "Could not assign TWI IRQ handler " "to irq %d (continuing with poll)\n", pmcmsptwi_data.irq); - pmcmsptwi_data.irq = 0; } } + /* + * We only get here with a negative rc if either platform_get_irq() or + * request_irq() call has failed; we have to enforce the polling mode... + */ + if (rc < 0) + pmcmsptwi_data.irq = 0; init_completion(&pmcmsptwi_data.wait); mutex_init(&pmcmsptwi_data.lock); From patchwork Sun Jul 4 14:45:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Shtylyov X-Patchwork-Id: 1500438 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GHs7G4P8mz9sWS for ; Mon, 5 Jul 2021 00:45:30 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229540AbhGDOsD (ORCPT ); Sun, 4 Jul 2021 10:48:03 -0400 Received: from mxout03.lancloud.ru ([45.84.86.113]:47968 "EHLO mxout03.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229502AbhGDOsD (ORCPT ); Sun, 4 Jul 2021 10:48:03 -0400 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout03.lancloud.ru EF26A20F200B Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: [PATCH v2 4/5] i2c: s3c2410: fix IRQ check From: Sergey Shtylyov To: CC: , Krzysztof Kozlowski , References: <3712e871-bf2f-32c5-f9c2-2968c42087f8@omp.ru> Organization: Open Mobile Platform Message-ID: <771d94cf-5e82-0cb7-fb1f-5af2f0b10dd4@omp.ru> Date: Sun, 4 Jul 2021 17:45:25 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <3712e871-bf2f-32c5-f9c2-2968c42087f8@omp.ru> Content-Language: en-US X-Originating-IP: [192.168.11.198] X-ClientProxiedBy: LFEXT02.lancloud.ru (fd00:f066::142) To LFEX1907.lancloud.ru (fd00:f066::207) Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Iff platform_get_irq() returns 0, the driver's probe() method will return 0 early (as if the method's call was successful). Let's consider IRQ0 valid for simplicity -- devm_request_irq() can always override that decision... Fixes: 2bbd681ba2b ("i2c-s3c2410: Change IRQ to be plain integer.") Signed-off-by: Sergey Shtylyov Reviewed-by: Krzysztof Kozlowski --- drivers/i2c/busses/i2c-s3c2410.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux/drivers/i2c/busses/i2c-s3c2410.c =================================================================== --- linux.orig/drivers/i2c/busses/i2c-s3c2410.c +++ linux/drivers/i2c/busses/i2c-s3c2410.c @@ -1137,7 +1137,7 @@ static int s3c24xx_i2c_probe(struct plat */ if (!(i2c->quirks & QUIRK_POLL)) { i2c->irq = ret = platform_get_irq(pdev, 0); - if (ret <= 0) { + if (ret < 0) { dev_err(&pdev->dev, "cannot find IRQ\n"); clk_unprepare(i2c->clk); return ret; From patchwork Sun Jul 4 14:47:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Shtylyov X-Patchwork-Id: 1500439 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GHsB74v28z9sWS for ; Mon, 5 Jul 2021 00:47:59 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229537AbhGDOuc (ORCPT ); Sun, 4 Jul 2021 10:50:32 -0400 Received: from mxout01.lancloud.ru ([45.84.86.81]:39548 "EHLO mxout01.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229502AbhGDOuc (ORCPT ); Sun, 4 Jul 2021 10:50:32 -0400 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout01.lancloud.ru DDDBC20CDDE4 Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: [PATCH v2 5/5] i2c: xlp9xx: fix main IRQ check From: Sergey Shtylyov To: CC: George Cherian References: <3712e871-bf2f-32c5-f9c2-2968c42087f8@omp.ru> Organization: Open Mobile Platform Message-ID: <88b0915b-de45-1ef3-0b03-ec9c2ff3ce88@omp.ru> Date: Sun, 4 Jul 2021 17:47:54 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <3712e871-bf2f-32c5-f9c2-2968c42087f8@omp.ru> Content-Language: en-US X-Originating-IP: [192.168.11.198] X-ClientProxiedBy: LFEXT01.lancloud.ru (fd00:f066::141) To LFEX1907.lancloud.ru (fd00:f066::207) Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Iff platform_get_irq() returns 0 for the main IRQ, the driver's probe() method will return 0 early (as if the method's call was successful). Let's consider IRQ0 valid for simplicity -- devm_request_irq() can always override that decision... Fixes: 2bbd681ba2b ("i2c: xlp9xx: Driver for Netlogic XLP9XX/5XX I2C controller") Signed-off-by: Sergey Shtylyov --- drivers/i2c/busses/i2c-xlp9xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux/drivers/i2c/busses/i2c-xlp9xx.c =================================================================== --- linux.orig/drivers/i2c/busses/i2c-xlp9xx.c +++ linux/drivers/i2c/busses/i2c-xlp9xx.c @@ -517,7 +517,7 @@ static int xlp9xx_i2c_probe(struct platf return PTR_ERR(priv->base); priv->irq = platform_get_irq(pdev, 0); - if (priv->irq <= 0) + if (priv->irq < 0) return priv->irq; /* SMBAlert irq */ priv->alert_data.irq = platform_get_irq(pdev, 1);