Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp861385ybr; Fri, 22 May 2020 23:20:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyhv8igvlRds2oob/EsiGCRNzr5LEMCHK1F1ZuuqxiNx51HVX5O2zJhxGILj9rJs8q7eFO X-Received: by 2002:a17:906:55c3:: with SMTP id z3mr10686021ejp.180.1590214840378; Fri, 22 May 2020 23:20:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590214840; cv=none; d=google.com; s=arc-20160816; b=JmtKAnkURa/bYMTzf7cOpQuMAwAELfGmdhc6zgiaVa2tZp5WxZBfravrEwKizSYuNC jVY4Klm9TeU1moyssxI7V/iwvyRP3KsLG7pDvilvC8JNKK2zmfOT8ByLvJQu4ruqMw7k oeHGXq/sg/vfHXJ8dTW79WeqDWQvbXchd62wmNSt7J0KY2r67txJZodbNBMThpaQU2DQ WqMCI6jPMXztxR/l+EDprGlQHriiUMDjh7Zx13VIHbKx7BvYQ3YRDSH9LFgwv0vDhrCy r4kzpumO/rQ/bVb+L6M8ySfMtzyp2j2DkZ7Sx4mCnb9015AzoZCont8P7WnpRWQ47hyW bnTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=SetuH8KF9YlqIXIZgIMGuZNNClkg7WPU1XZDGEnuMpg=; b=NsjTR5WwBcXQ9YzVUyqSICnNMga2bl0pK5ilrz9GstaqbjvlAteVEGVL8HHrXgCUJA NyIth6lWDhBPI71geJc3Ra3rE/JwVpTg3Q9nHbBgvjbB1rqbvAJq4rKfdZcbjB8Kk31j ijWHmah+VrTkE8RBUaNhm0XHBLBuFFLGs1dXORDo/AzEFQJla0t840nKQD43z6c+PUjm E0LBlA0mBhxGP6dVQsdpR6s1V6AT0c/hB0Hh0gk0JESZgBk/wA44EkiJ7e0lQ+UnEowf Uk7U3r10kyvHFidIO9jKwiP/95RFJkavuWEO15PRDfTHvlV/x6HhDRxGcXJsOx9nZawE VtBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r13si5538549edt.263.2020.05.22.23.20.17; Fri, 22 May 2020 23:20:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387604AbgEWGRl (ORCPT + 99 others); Sat, 23 May 2020 02:17:41 -0400 Received: from mail.zju.edu.cn ([61.164.42.155]:64332 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387443AbgEWGRk (ORCPT ); Sat, 23 May 2020 02:17:40 -0400 Received: from localhost.localdomain (unknown [222.205.77.158]) by mail-app2 (Coremail) with SMTP id by_KCgA3H5L3v8heJgO4AQ--.35290S4; Sat, 23 May 2020 14:17:30 +0800 (CST) From: Dinghao Liu To: dinghao.liu@zju.edu.cn, kjlu@umn.edu Cc: MyungJoo Ham , Chanwoo Choi , patches@opensource.cirrus.com, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] extcon: arizona: Fix runtime PM imbalance on error Date: Sat, 23 May 2020 14:17:26 +0800 Message-Id: <20200523061726.25903-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: by_KCgA3H5L3v8heJgO4AQ--.35290S4 X-Coremail-Antispam: 1UD129KBjvJXoWxZr4UtFy5tF45Wr15uFW3Wrg_yoW5XF4DpF 4kXFW5tFW8u34I9340yrnYv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k List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When arizona_request_irq() returns an error code, a pairing runtime PM usage counter decrement is needed to keep the counter balanced. For error paths after this function, things are the same. Also, remove calls to pm_runtime_disable() when pm_runtime_enable() has not been executed. Signed-off-by: Dinghao Liu --- Changelog: v2: - Add a new label "err_pm" to balance refcount. Remove 3 calls to pm_runtime_disable(). Move pm_runtime_put() from the front of input_register_device() to the back. --- drivers/extcon/extcon-arizona.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index 7401733db08b..aae82db542a5 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -1460,7 +1460,7 @@ static int arizona_extcon_probe(struct platform_device *pdev) if (!info->input) { dev_err(arizona->dev, "Can't allocate input dev\n"); ret = -ENOMEM; - goto err_register; + return ret; } info->input->name = "Headset"; @@ -1492,7 +1492,7 @@ static int arizona_extcon_probe(struct platform_device *pdev) if (ret != 0) { dev_err(arizona->dev, "Failed to request GPIO%d: %d\n", pdata->micd_pol_gpio, ret); - goto err_register; + return ret; } info->micd_pol_gpio = gpio_to_desc(pdata->micd_pol_gpio); @@ -1515,7 +1515,7 @@ static int arizona_extcon_probe(struct platform_device *pdev) dev_err(arizona->dev, "Failed to get microphone polarity GPIO: %d\n", ret); - goto err_register; + return ret; } } @@ -1672,7 +1672,7 @@ static int arizona_extcon_probe(struct platform_device *pdev) if (ret != 0) { dev_err(&pdev->dev, "Failed to get JACKDET rise IRQ: %d\n", ret); - goto err_gpio; + goto err_pm; } ret = arizona_set_irq_wake(arizona, jack_irq_rise, 1); @@ -1721,14 +1721,14 @@ static int arizona_extcon_probe(struct platform_device *pdev) dev_warn(arizona->dev, "Failed to set MICVDD to bypass: %d\n", ret); - pm_runtime_put(&pdev->dev); - ret = input_register_device(info->input); if (ret) { dev_err(&pdev->dev, "Can't register input device: %d\n", ret); goto err_hpdet; } + pm_runtime_put(&pdev->dev); + return 0; err_hpdet: @@ -1743,10 +1743,11 @@ static int arizona_extcon_probe(struct platform_device *pdev) arizona_set_irq_wake(arizona, jack_irq_rise, 0); err_rise: arizona_free_irq(arizona, jack_irq_rise, info); +err_pm: + pm_runtime_put(&pdev->dev); + pm_runtime_disable(&pdev->dev); err_gpio: gpiod_put(info->micd_pol_gpio); -err_register: - pm_runtime_disable(&pdev->dev); return ret; } -- 2.17.1