Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp146731rwn; Wed, 14 Sep 2022 17:47:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR4EZJG0JeIUc6pYZe/yz84IXLa67LVRRdyW6gSRx3jgYj5IRXQi+GruaxyXvBeCw236/Sg0 X-Received: by 2002:a17:907:2cc8:b0:77d:6f62:7661 with SMTP id hg8-20020a1709072cc800b0077d6f627661mr12563980ejc.233.1663202834958; Wed, 14 Sep 2022 17:47:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663202834; cv=none; d=google.com; s=arc-20160816; b=EnxChSO9t109TEPwvggQ97g/2XXqYQM4p9eKWjnrUBzXRLWqokDV2QdovRc07xppVT 6uqNAAJ8ByA8KghjP+aSMME530CQdXHCZw6UmmKXylXqHN/p9dlE6j0xdT8cFYypEbm/ Xud4wBPO6Nk9sM4lsWrZxUh5Fv88zeyoxJxbTmaVyTD5yClKUvfCmxvMP9XYDurqcXjh IL36BxeLgNtE+0z+GoKZDKiHQNyvzw3fuGut8+2DRPs9KwxkEfBEROI7E74fCHpDJ28W tjQnfa4qXoEwfedB2PdKfMHA2r5BwZDy+9JoXu4+ikx29EFsJI9/SOV2fRY/jl+ugkb4 ocLw== 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=OCX0ALmFpDseNwZd34txXLXcikk4OyNY0fVUx/aEF6vSNze/l2QRE+FV9szVstsAPW jFPiZJ8/xTdFJACgXDWEqWmxf9fhMHwZ2FdDofbz/1sKh6Q3Z3Iz4iBoj81hAxlsz5Zp B43cVjzp87EPeMeTSGObq8VXRCJ1t67g1H+E8ohVO1e9REdKs7/OHttnkgXiSsB36rGx oTbT0V+0dp4LK55tlL24TTwxfx5AmZowmWqCS7mkUCmbZre+n8o3wGOlj56LWq5pETy0 kW5G3uLgxgKgqW9NQhHDwBg8A9x8Q6HwA6nAlebcLC60TE42avOhTn4Sdmn0Bc8VchAO QJ4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EpH8pFpd; 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 f15-20020a50a6cf000000b00446fdce2a62si13998903edc.420.2022.09.14.17.46.45; Wed, 14 Sep 2022 17:47:14 -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=EpH8pFpd; 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 S229484AbiINX6h (ORCPT + 99 others); Wed, 14 Sep 2022 19:58:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229831AbiINX6M (ORCPT ); Wed, 14 Sep 2022 19:58:12 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A53F58981D for ; Wed, 14 Sep 2022 16:58:11 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id z191so13658021iof.10 for ; Wed, 14 Sep 2022 16:58:11 -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=EpH8pFpdO3xx3hvO3BSYcXVAywxj6PJQIgEpmQ6BF6AGJ2bg7E/C4hcBZ0rilevnND uW7yaSxKjUSoRUYuNLkKMMquKKgHpXLOwDFJnQL0HYx79jBHtdfC7sqv2bfxvUfdLfxl Tqtwjn91EwT3rQdk9dJSboqBGHankwVOk4gkw= 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=ePYOBGrzgxi3TgzmQgaRK06h8l0ZvYFhgU/gX6ud3w7qdzu8XAg29IhybGzafcCZzl apoBTB53zTG/iLnH4v7Lh2/c/g832djiK18nmmauOSitOQMzmwYnnSlZaryzksiEmCpn SWAivd+AdcB91BURIuZGhDoz1uerZ4xjSdXlYxeVti5Y4lzjauAbX5qt+4Hqruhp5PQo iURmCpMPPlQy6wNWXdqAXY0oNcyxuEyNi6SiaSqPG3MxabfMIzikL2cPd9piFHB4dm1k MxfgwpkBeg8SruVeeR7875RxCby0elC7VYlbKrznms9WusC01LEJDLy6iVWw+phXNLdr JwDQ== X-Gm-Message-State: ACgBeo23oTH9W25C1XizTyFC5PXhQIOK4xgCNakq7HkU9YBPqi3/kXOs ENP0Ez0d8NBGjkCcoX5yYL6nkQ== X-Received: by 2002:a05:6602:408c:b0:6a1:3fda:5633 with SMTP id bl12-20020a056602408c00b006a13fda5633mr7407200iob.194.1663199891047; Wed, 14 Sep 2022 16:58:11 -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 a14-20020a027a0e000000b0034c0e8829c0sm353721jac.0.2022.09.14.16.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:58:10 -0700 (PDT) From: Raul E Rangel To: linux-acpi@vger.kernel.org, linux-input@vger.kernel.org Cc: jingle.wu@emc.com.tw, rafael@kernel.org, andriy.shevchenko@linux.intel.com, mario.limonciello@amd.com, hdegoede@redhat.com, linus.walleij@linaro.org, timvp@google.com, dmitry.torokhov@gmail.com, Raul E Rangel , Cai Huoqing , Douglas Anderson , Guenter Roeck , Johnny Chuang , linux-kernel@vger.kernel.org Subject: [PATCH v3 03/13] Input: elants_i2c - Use PM subsystem to manage wake irq Date: Wed, 14 Sep 2022 17:57:51 -0600 Message-Id: <20220914155914.v3.3.I5862429ee3e4de0f9ad5ba01ce07ad99eec10cf0@changeid> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog In-Reply-To: <20220914235801.1731478-1-rrangel@chromium.org> References: <20220914235801.1731478-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,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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