Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1775743pxp; Mon, 7 Mar 2022 02:02:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxFYCO5oX1VgYE98IIwqoSP3BeOIrOT2A9LO+wOV6T2HFV4/nyhLTWE+91nRHLQMIo9P7WO X-Received: by 2002:a17:906:2403:b0:6d1:ca2:4da7 with SMTP id z3-20020a170906240300b006d10ca24da7mr8182853eja.533.1646647373363; Mon, 07 Mar 2022 02:02:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646647373; cv=none; d=google.com; s=arc-20160816; b=0OVUTpZ+ruvqcj7B9SN8DHhT3J7P/RwBu/Cs1YvpFaAFMxZOJNHo+a8/LJ+nbsJ5am OFyX4WR9aU+r1FTTkQaCaT2HNEldTmG3OVr6Zwnk/2FzCClWl+zyYuljyzmcnGTuTkVf eQo91Dv8BMf+FRyADEt/JPIfN+Z+07eEHbZpcCn8yaEvHp6su7fN0dHwyl30ynwNUHmv k2EN9OECrxOT53XByXbtMDLn6eKhEDsod/3relqM7pa0PC80JYvYlicykwP3nzYsg5wy wb+hglZPd+gICJl9suKbheUh8BZia3VnOJEQKhtoCZWJlZ63lKswbqpa2dp3quPBk/yv 2ZPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ekRVxBliWJ4ly8mljC49+mYmhTqOzIAYmOaagFA7BMM=; b=z5gq2mxfV1HRgLMYPpR1nKrkIQWaTetW46OUKzjMgu6rN72VfEhakLGSO83ExMHmYB zfGlWMZBtMAmH0RX++KzFKBGvKl5bx7Jyyq5UuH1p6BIKzzyvkFSzoSb+lu5Ah9Ljd4+ J3SwI6U/Nd3ve5zF6+1jib5+pkRZvpifXwixNbyAvYTIDJdx0OzWMwPE6d1etXBe3l2d 5H6uUQJOmnzRG9jLmB5ZfVuTx85AK6F8AxlbnNu7InHMO1CJQZc28emx/Cdr0F8259SD S6svR65uo0M7u92Z+LWS1hbxqsFIFK6azkY9uqbMP2bp0vETHu7xiGMFqmKdhV6i3gwT nn3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mur4AuBq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw20-20020a1709066a1400b006db29d024basi2377152ejc.775.2022.03.07.02.02.30; Mon, 07 Mar 2022 02:02:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mur4AuBq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236711AbiCGJZJ (ORCPT + 99 others); Mon, 7 Mar 2022 04:25:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237342AbiCGJXr (ORCPT ); Mon, 7 Mar 2022 04:23:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0D7752E21; Mon, 7 Mar 2022 01:22:52 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6A6A8B810B9; Mon, 7 Mar 2022 09:22:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CA58C340F4; Mon, 7 Mar 2022 09:22:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646644970; bh=Wn8ULIxJQkYh/HLpNVlOqhHrSl1FCYL7i/ThgofIHgU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mur4AuBql/TJtLMoC4iFp2tws+lkFOHlG1TULNyeDlDiVuzjJjBCBqPwRlOEJ8OYK ls1W0JUi3MRuqrynsFPSGgrznuIGrQLf49kd0f5FC0M9515pg51z5TxonQT5PD32KS V1v6nWgtq6fed9RkQAib28JKVE4OYWmxyakbE4rU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Dmitry Torokhov Subject: [PATCH 4.14 39/42] Input: elan_i2c - fix regulator enable count imbalance after suspend/resume Date: Mon, 7 Mar 2022 10:19:13 +0100 Message-Id: <20220307091637.291336452@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091636.146155347@linuxfoundation.org> References: <20220307091636.146155347@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans de Goede commit 04b7762e37c95d9b965d16bb0e18dbd1fa2e2861 upstream. Before these changes elan_suspend() would only disable the regulator when device_may_wakeup() returns false; whereas elan_resume() would unconditionally enable it, leading to an enable count imbalance when device_may_wakeup() returns true. This triggers the "WARN_ON(regulator->enable_count)" in regulator_put() when the elan_i2c driver gets unbound, this happens e.g. with the hot-plugable dock with Elan I2C touchpad for the Asus TF103C 2-in-1. Fix this by making the regulator_enable() call also be conditional on device_may_wakeup() returning false. Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20220131135436.29638-2-hdegoede@redhat.com Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/mouse/elan_i2c_core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c @@ -1195,17 +1195,17 @@ static int __maybe_unused elan_resume(st struct elan_tp_data *data = i2c_get_clientdata(client); int error; - if (device_may_wakeup(dev) && data->irq_wake) { + if (!device_may_wakeup(dev)) { + error = regulator_enable(data->vcc); + if (error) { + dev_err(dev, "error %d enabling regulator\n", error); + goto err; + } + } else if (data->irq_wake) { disable_irq_wake(client->irq); data->irq_wake = false; } - error = regulator_enable(data->vcc); - if (error) { - dev_err(dev, "error %d enabling regulator\n", error); - goto err; - } - error = elan_set_power(data, true); if (error) { dev_err(dev, "power up when resuming failed: %d\n", error);