From patchwork Mon Nov 2 11:27:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Nikolaus Schaller" X-Patchwork-Id: 7535691 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3E3B49F327 for ; Mon, 2 Nov 2015 11:27:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0923120585 for ; Mon, 2 Nov 2015 11:27:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C3EC02057F for ; Mon, 2 Nov 2015 11:27:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753454AbbKBL1n (ORCPT ); Mon, 2 Nov 2015 06:27:43 -0500 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.163]:37215 "EHLO mo4-p00-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753337AbbKBL1m (ORCPT ); Mon, 2 Nov 2015 06:27:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1446463660; l=2400; s=domk; d=goldelico.com; h=References:In-Reply-To:References:In-Reply-To:Date:Subject:Cc:To: From; bh=ABaORTlGsFEdfaRBSp0yTz3Rd7TG85IY1SR21l1+chg=; b=equdzkAt0cWaqxdAayro1mAJzkLhk75HE6OOph3Lkez0JuUslrJM81IaOQ7fF3hXnrF ywixAAxdlWjxDaWQNYeiGLXbFJmUksXuodeSvtl0LbHsOF7PUuac/ENhb/wnhkRDwi6Pu n2ELlzHfmU6HPluCPJAITyywd12BjNe2IIQ= X-RZG-AUTH: :JGIXVUS7cutRB/49FwqZ7WcecEarQROEYabkiUo6mSAGQ+qKIDkoJ1Fv X-RZG-CLASS-ID: mo00 Received: from localhost.localdomain (p57AE0738.dip0.t-ipconnect.de [87.174.7.56]) by smtp.strato.de (RZmta 37.14 DYNA|AUTH) with ESMTPA id u02025rA2BRdG8P; Mon, 2 Nov 2015 12:27:39 +0100 (CET) From: "H. Nikolaus Schaller" To: =?UTF-8?q?Gra=C5=BEvydas=20Ignotas?= , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , Andreas Kemnade Cc: linux-pm@vger.kernel.org, gta04-owner@goldelico.com, linux-kernel@vger.kernel.org, "H. Nikolaus Schaller" Subject: [PATCH v2 2/3] drivers:power:twl4030-charger: don't return after allocating irq Date: Mon, 2 Nov 2015 12:27:35 +0100 Message-Id: <650004ea1e42a1ef7b39a609a1b5c45f9b5926d6.1446463653.git.hns@goldelico.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It appears that simply returning with error status (especially -EPROBE_DEFER) is very dangerous *after* allocating devm managed interrupts. See discussion of potential issues: https://lkml.org/lkml/2013/2/22/65 The result is that the boot process hangs if both, phy-twl4030-usb and this twl4030_charger driver are compiled as modules. This has been observed on gta04 and openpandora boards. So we move the search and check that the twl4030-phy transceiver link is available before we request to set up the interrupts. Signed-off-by: H. Nikolaus Schaller --- drivers/power/twl4030_charger.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c index 00697e9..05d693d 100644 --- a/drivers/power/twl4030_charger.c +++ b/drivers/power/twl4030_charger.c @@ -1031,23 +1031,6 @@ static int twl4030_bci_probe(struct platform_device *pdev) return ret; } - ret = devm_request_threaded_irq(&pdev->dev, bci->irq_chg, NULL, - twl4030_charger_interrupt, IRQF_ONESHOT, pdev->name, - bci); - if (ret < 0) { - dev_err(&pdev->dev, "could not request irq %d, status %d\n", - bci->irq_chg, ret); - return ret; - } - - ret = devm_request_threaded_irq(&pdev->dev, bci->irq_bci, NULL, - twl4030_bci_interrupt, IRQF_ONESHOT, pdev->name, bci); - if (ret < 0) { - dev_err(&pdev->dev, "could not request irq %d, status %d\n", - bci->irq_bci, ret); - return ret; - } - INIT_WORK(&bci->work, twl4030_bci_usb_work); INIT_DELAYED_WORK(&bci->current_worker, twl4030_current_worker); @@ -1066,6 +1049,23 @@ static int twl4030_bci_probe(struct platform_device *pdev) } } + ret = devm_request_threaded_irq(&pdev->dev, bci->irq_chg, NULL, + twl4030_charger_interrupt, IRQF_ONESHOT, pdev->name, + bci); + if (ret < 0) { + dev_err(&pdev->dev, "could not request irq %d, status %d\n", + bci->irq_chg, ret); + return ret; + } + + ret = devm_request_threaded_irq(&pdev->dev, bci->irq_bci, NULL, + twl4030_bci_interrupt, IRQF_ONESHOT, pdev->name, bci); + if (ret < 0) { + dev_err(&pdev->dev, "could not request irq %d, status %d\n", + bci->irq_bci, ret); + return ret; + } + /* Enable interrupts now. */ reg = ~(u32)(TWL4030_ICHGLOW | TWL4030_ICHGEOC | TWL4030_TBATOR2 | TWL4030_TBATOR1 | TWL4030_BATSTS);