Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2722648rwb; Mon, 19 Sep 2022 09:02:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7XqZvd9EaZLL0H7lRoC9RlejhP/X8PwLu4WyNDN0xl/F6mc2vo7A7PIdvZlvbgaCfHMPS2 X-Received: by 2002:a17:90a:cf92:b0:202:ae52:43a4 with SMTP id i18-20020a17090acf9200b00202ae5243a4mr20369788pju.141.1663603375530; Mon, 19 Sep 2022 09:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663603375; cv=none; d=google.com; s=arc-20160816; b=iFAvgs54VuLu2z6DLZMyw6pYG/zcR2itml6ab0L6y86EYJACJtDgweFU9VB+7HbIno SXuos5PvewkXQIf19w0Dwh15SxQu1a8n4g8e+OkADDEHLQriokJQu4PkioHDWZVxKIid 1Cr7d92gnU9YrUsC5yLy0a37/WSa4F+Zah+oG5OFhfKDOJ85Up2k/03vCRC1aLOnVxdi OCEkvfJH3vrRuWtJF7uO6cWjgTgAg0Xlz1r/zIGj8GzOBBhUGZhLmA8wAGowFDAVbZx/ 3d42UF1ufkhRitC9pesl+PvDFBsEngdoKUckC1eZtKOlddYOlT5G7hdi2T/1o8CeEZjF XS3w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uLFsVomnZ3NOv94HIF7hfztjoJa5WoPp5LmQm5BO1Bo=; b=mHsxhy6ObsDEwkDBEJV0jb6nf8af6Kl6H5wVUNGVLatW2XWsh3/z7FfD9qNw2+7u6l 4z6eowmUQ3g5LfFULQxkIBxcGSRYHCApqBGlJ5RbiPbCOyikYuW0GDvnbhDjVEIy6XwS zSftAqMoUctB8cxBRSl55VamDJAYi/uh4GDZh4q6D1ZWDy60kEZM+cp3xy+53bdyKAJ4 HEmX9wKv4jiJ1qByfK7ITEJrsxKixjNvO8Eec0Be71pDansitqzHuvtigysFySRnjnfa iXL3iXPfdnDDZmc8vzDKXjuZIidHVlpCRyAuVCYOi09WFiOo9MyIu7mOuXBC1khWikX0 nFJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=adhgguZ3; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q10-20020a170902f78a00b0017535568d5dsi31774828pln.256.2022.09.19.09.02.43; Mon, 19 Sep 2022 09:02:55 -0700 (PDT) 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=@chromium.org header.s=google header.b=adhgguZ3; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229810AbiISP7s (ORCPT + 99 others); Mon, 19 Sep 2022 11:59:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230359AbiISP71 (ORCPT ); Mon, 19 Sep 2022 11:59:27 -0400 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 715C82C138 for ; Mon, 19 Sep 2022 08:59:23 -0700 (PDT) Received: by mail-il1-x12d.google.com with SMTP id l6so15020437ilk.13 for ; Mon, 19 Sep 2022 08:59:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=uLFsVomnZ3NOv94HIF7hfztjoJa5WoPp5LmQm5BO1Bo=; b=adhgguZ3/jkoq54Ux4JQdP94x9fs+qUO+1yVoIOE8+jcSOfv7mJJAyhMb/fPqVbrj7 oy3X9S8/qa9d2IhQitudZq3ja1RgmMIFG6U7eWF6IK/0eJdsDwI1tYpjACd6fODEBnbn MYRjib6QiExCxohjxbSw647pAlE7Lq3QbYuoU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=uLFsVomnZ3NOv94HIF7hfztjoJa5WoPp5LmQm5BO1Bo=; b=eTUEXqkJcTb/0N+SP0enPvmO+j4kn1XinKpYr1SjeuiWTIF28O+W3INtSduW/yq0T/ qxGiwx+QbOfTnZ7Mrfexu4Q2+bp/l7JdNrAB6OS7/zqGucQHJv44tLrg30tdfmIGxg7T 89VqgWjYQtuKu57L/E2Jskjl2y8wx6P1W83211EhaT+/3kMmnR3sTzgocyrd44U1zug4 iybu02pouTs1SuiOnpyNz6TrQT9y5Z6HRfGgRLdUEXnY1lPIBfEI3WkCWUTEOkj4Wws7 Nm1PBZIDaUps4DLSnH6iYaaCO5GopmT9GE3pno2aphYX8e1zkLdKhHkEXxFni6aO7+wX JxUw== X-Gm-Message-State: ACrzQf1GIxEkyQhBGyQ3z/+R35d3EtLV7OpSYbvh14Ec+10T5gWg7oCn j7T17wAX4eJfCDC7tqeZhu2GJQ== X-Received: by 2002:a05:6e02:b2a:b0:2f1:73e7:9e0c with SMTP id e10-20020a056e020b2a00b002f173e79e0cmr7880913ilu.298.1663603162669; Mon, 19 Sep 2022 08:59:22 -0700 (PDT) Received: from rrangel920.bld.corp.google.com (h24-56-189-219.arvdco.broadband.dynamic.tds.net. [24.56.189.219]) by smtp.gmail.com with ESMTPSA id t70-20020a025449000000b00349fb9b1abesm5634154jaa.106.2022.09.19.08.59.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 08:59:21 -0700 (PDT) From: Raul E Rangel To: linux-acpi@vger.kernel.org, linux-input@vger.kernel.org Cc: timvp@google.com, hdegoede@redhat.com, andriy.shevchenko@linux.intel.com, rafael@kernel.org, mario.limonciello@amd.com, jingle.wu@emc.com.tw, mika.westerberg@linux.intel.com, dmitry.torokhov@gmail.com, linus.walleij@linaro.org, Raul E Rangel , Cai Huoqing , Douglas Anderson , Johnny Chuang , linux-kernel@vger.kernel.org Subject: [PATCH v4 03/13] Input: elants_i2c - Use PM subsystem to manage wake irq Date: Mon, 19 Sep 2022 09:59:05 -0600 Message-Id: <20220919095504.v4.3.I5862429ee3e4de0f9ad5ba01ce07ad99eec10cf0@changeid> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog In-Reply-To: <20220919155916.1044219-1-rrangel@chromium.org> References: <20220919155916.1044219-1-rrangel@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 The Elan I2C touchscreen driver is currently manually managing the wake IRQ. This change removes the explicit enable_irq_wake/disable_irq_wake and instead relies on the PM subsystem. This is done by calling dev_pm_set_wake_irq. i2c_device_probe already calls dev_pm_set_wake_irq when using device tree, and i2c_device_remove also already calls dev_pm_clear_wake_irq. There could be some device tree systems that have incorrectly declared `wake` capabilities, so this change will set the wake irq if one is missing. This matches the previous behavior. Signed-off-by: Raul E Rangel --- (no changes since v2) Changes in v2: - Added elants_i2c to series drivers/input/touchscreen/elants_i2c.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index a56f042adf9d82..80e16b533c452a 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -180,7 +181,6 @@ struct elants_data { u8 cmd_resp[HEADER_SIZE]; struct completion cmd_done; - bool wake_irq_enabled; bool keep_power_in_suspend; /* Must be last to be used for DMA operations */ @@ -1582,6 +1582,15 @@ static int elants_i2c_probe(struct i2c_client *client) if (!client->dev.of_node) device_init_wakeup(&client->dev, true); + /* + * The wake IRQ should be declared via device tree instead of assuming + * the IRQ can wake the system. This is here for legacy reasons and + * will be removed once the i2c-core supports querying ACPI for wake + * capabilities. + */ + if (!client->dev.power.wakeirq) + dev_pm_set_wake_irq(&client->dev, client->irq); + error = devm_device_add_group(&client->dev, &elants_attribute_group); if (error) { dev_err(&client->dev, "failed to create sysfs attributes: %d\n", @@ -1626,7 +1635,7 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev) * The device will automatically enter idle mode * that has reduced power consumption. */ - ts->wake_irq_enabled = (enable_irq_wake(client->irq) == 0); + return 0; } else if (ts->keep_power_in_suspend) { for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) { error = elants_i2c_send(client, set_sleep_cmd, @@ -1655,8 +1664,6 @@ static int __maybe_unused elants_i2c_resume(struct device *dev) int error; if (device_may_wakeup(dev)) { - if (ts->wake_irq_enabled) - disable_irq_wake(client->irq); elants_i2c_sw_reset(client); } else if (ts->keep_power_in_suspend) { for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) { -- 2.37.3.968.ga6b4b080e4-goog