Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1783726pxp; Mon, 7 Mar 2022 02:13:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpZpVuYyrjL7G5jXgZFBO6RgMOSYWXMn2HqY3og+pGKNdWiUTAq5yyuqzaXMgxPawON0QY X-Received: by 2002:a17:906:2646:b0:6d5:d889:c92b with SMTP id i6-20020a170906264600b006d5d889c92bmr8611881ejc.696.1646647897065; Mon, 07 Mar 2022 02:11:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646647897; cv=none; d=google.com; s=arc-20160816; b=WR+yv310HYphFwCRBPlTMz4MttkXObZS8cvO7+sSCOZd9fp3reMY36k5rYCyL6BoVo BbdhLe28DzsLVQv4PccYY5mmapmrvkrlVfWS2cQqtIBZJ2Q7NiChIz8a3KZi6mvjpIOk iaut0fUFzd3B7Xzn/UNQGBSwKbI5eXL8wR2tg5VY8e883f5BpPNFv+DmJ7daW6+DyuKX BGwgGkcaiSbzsI+8NgB9xETy2xGIhA6jBVRYPW7vIspOVE5gNvbVZNe/2j2lB4Wd/mNv yxJpu0yE4FmiKOBH+VEKBKwi4VCRLGEKT5uCg5Zx5bWKuvMK42rQL1jLV15RodTIfi3h XIng== 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=Bbs82Yat79ear890Y7Sd1Z8dWyjc6qDlVYOMnb7sdUk=; b=ShCpxNbW174ZpGQ3pbdkiRXrVa2XXgTjZqoVkPuQbzNwEm5x41JUyW4j3tbCtEIsLa 726GeMq3Tmy4AjnMIX1PpWG109Eor/Dtvt/lPtpdHM7mClqzsS/2jsKg8cw57Gnlbqu9 uKDEFOHswL2RjwjkeMfptFChEE87iBXGw7ZOq2mVaUbRKNsd/lYohLt1NoRzyrAp4sCd iMEHHb+KlEm5s8qmKa1DpIZ+fUb6nXzfhLEv1h7Re8pB23cTpn6zysqVjS4/e9RezlIa MdEfMqDSuXgX51PavWR+TplgtHYFS4vm/pOjKbJ9/fIAIs7rOJHAOAPg9cFBGNc6Bf61 lodg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OlePlp5w; 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 v9-20020a056402174900b004163e646370si2208496edx.91.2022.03.07.02.11.14; Mon, 07 Mar 2022 02:11:37 -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=OlePlp5w; 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 S237452AbiCGJhA (ORCPT + 99 others); Mon, 7 Mar 2022 04:37:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237458AbiCGJ2H (ORCPT ); Mon, 7 Mar 2022 04:28:07 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F14125BD2B; Mon, 7 Mar 2022 01:25:27 -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 dfw.source.kernel.org (Postfix) with ESMTPS id BD9156116E; Mon, 7 Mar 2022 09:25:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7D89C340E9; Mon, 7 Mar 2022 09:25:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645127; bh=tE+SRykjlDp+0GPDg+fRo4wqoqrwo7iuHomBhDw7ft4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OlePlp5wehCqcIIYRaPa+NccNIgp3xzCxuY3L1qk09hEcOvqQHExwikB4zrnxhvWr AjvMULkAO059qLWLgxy72BEAFdQT4EBcLf/8AX+ksOrrI3Zbm7FA6EQM+Oa6vOsx7b wwBGEusCqJjRF4hTDlbrBPLatk9QlT+DPDpC6Z1E= 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.19 46/51] Input: elan_i2c - fix regulator enable count imbalance after suspend/resume Date: Mon, 7 Mar 2022 10:19:21 +0100 Message-Id: <20220307091638.300519420@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091636.988950823@linuxfoundation.org> References: <20220307091636.988950823@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 @@ -1280,17 +1280,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);