From patchwork Thu Jun 3 04:37:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 12296057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 338C1C47080 for ; Thu, 3 Jun 2021 04:38:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1837D613F0 for ; Thu, 3 Jun 2021 04:38:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229506AbhFCEkb (ORCPT ); Thu, 3 Jun 2021 00:40:31 -0400 Received: from mail-pl1-f177.google.com ([209.85.214.177]:34594 "EHLO mail-pl1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbhFCEka (ORCPT ); Thu, 3 Jun 2021 00:40:30 -0400 Received: by mail-pl1-f177.google.com with SMTP id u9so2170616plr.1; Wed, 02 Jun 2021 21:38:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bwoFt+YDQyQhxfnq961VZU5Jf/+5sxsJJaX0acjEBXE=; b=C3DXv7NMl/Uw80vgRKQfdquRd/YoCx8tRMrG/BDd/N1mjJ77Mi01CSrNSbkKkmmwYB IMoXTND/eW0oLppwffL+MpyRj+uRxEp4cyyOT6DK+aLvKKsrfBqOphxqRWR63U63cwM4 M6bufKVt9T1NCIEwcN6qF9qUaGS7ztfR3FE7iR290Rg3tc7HV2++Chjm9Z72S3Y0okQ/ TJWOcip9ogAEOSclWPpX4b94XCSW45RbhzidzQ+FzBhz625GuMVEcxQ1kQ582rE/Lwj8 wNz4ii1HCdOK+AHIe3pzF0rb82Cj5rNdk6KyWQWyZMzEck7cf4mwnXMmprF4hCV+W6Jn DcRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bwoFt+YDQyQhxfnq961VZU5Jf/+5sxsJJaX0acjEBXE=; b=kMLG6cgzxjBHNxLMYkma/B2+SeirSZ/WuckedgTfTTYmZjFwnE7M9PqNzmJg/aJcvn AUXdyGJkhnJ6gd570iOK2XJkRx5BV/TUnduO9j1fm8mja5J/vNJyfEfsOl7NRTTwk0F6 K15RF3iY3JzTU6kvPKTzhVSYqp+QyMkfhG8URHhzjDPCvToGXrN1d2g89jL40HJ4vNNk 1zkmeTeokv+ZyFz9gCZSSieEXDLUvU+jQsNkCmcCObmBF6bHW0dCOTB8hDQDvQatcs5c W1EEaUocq46yDJ4eo/Frwh8uL3KyrH80yqI0pcCQQUgJ9HVg7EIoxLUQK0Azg4qMQScF ML5A== X-Gm-Message-State: AOAM530QiO+jObhK/DcezczP8Wfr5t2uboDNQ6BLVW8zUOxFzheXeX4d 8GmFI93uVMsHqG/eRq1Fn9ef8vWD2tc= X-Google-Smtp-Source: ABdhPJwQXXCQGpLHiBRaSEb/7Erz/reTDL3D8w099btb2Xvd717wf5IqDBRnNY5XudQd4eBQTxhhxA== X-Received: by 2002:a17:90a:5282:: with SMTP id w2mr34770518pjh.145.1622695049797; Wed, 02 Jun 2021 21:37:29 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:fc6a:97ca:f00c:8377]) by smtp.gmail.com with ESMTPSA id f28sm1132414pgb.12.2021.06.02.21.37.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 21:37:28 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Linus Walleij , linux-kernel@vger.kernel.org Subject: [PATCH 1/7] Input: cy8ctmg110_ts - rely on platform code to supply interrupt Date: Wed, 2 Jun 2021 21:37:20 -0700 Message-Id: <20210603043726.3793876-1-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.32.0.rc0.204.g9fa02ecfa5-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Instead of using platform data to specify GPIO that is used as interrupt source, rely on the platform and I2C core to set it up properly. Signed-off-by: Dmitry Torokhov Reviewed-by: Linus Walleij --- drivers/input/touchscreen/cy8ctmg110_ts.c | 32 +---------------------- include/linux/input/cy8ctmg110_pdata.h | 1 - 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/drivers/input/touchscreen/cy8ctmg110_ts.c b/drivers/input/touchscreen/cy8ctmg110_ts.c index f465bae618fe..691f35f1bdd7 100644 --- a/drivers/input/touchscreen/cy8ctmg110_ts.c +++ b/drivers/input/touchscreen/cy8ctmg110_ts.c @@ -46,7 +46,6 @@ struct cy8ctmg110 { char phys[32]; struct i2c_client *client; int reset_pin; - int irq_pin; }; /* @@ -191,7 +190,6 @@ static int cy8ctmg110_probe(struct i2c_client *client, ts->client = client; ts->input = input_dev; ts->reset_pin = pdata->reset_pin; - ts->irq_pin = pdata->irq_pin; snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&client->dev)); @@ -222,38 +220,13 @@ static int cy8ctmg110_probe(struct i2c_client *client, cy8ctmg110_power(ts, true); cy8ctmg110_set_sleepmode(ts, false); - err = gpio_request(ts->irq_pin, "touch_irq_key"); - if (err < 0) { - dev_err(&client->dev, - "Failed to request GPIO %d, error %d\n", - ts->irq_pin, err); - goto err_shutoff_device; - } - - err = gpio_direction_input(ts->irq_pin); - if (err < 0) { - dev_err(&client->dev, - "Failed to configure input direction for GPIO %d, error %d\n", - ts->irq_pin, err); - goto err_free_irq_gpio; - } - - client->irq = gpio_to_irq(ts->irq_pin); - if (client->irq < 0) { - err = client->irq; - dev_err(&client->dev, - "Unable to get irq number for GPIO %d, error %d\n", - ts->irq_pin, err); - goto err_free_irq_gpio; - } - err = request_threaded_irq(client->irq, NULL, cy8ctmg110_irq_thread, IRQF_TRIGGER_RISING | IRQF_ONESHOT, "touch_reset_key", ts); if (err < 0) { dev_err(&client->dev, "irq %d busy? error %d\n", client->irq, err); - goto err_free_irq_gpio; + goto err_shutoff_device; } err = input_register_device(input_dev); @@ -266,8 +239,6 @@ static int cy8ctmg110_probe(struct i2c_client *client, err_free_irq: free_irq(client->irq, ts); -err_free_irq_gpio: - gpio_free(ts->irq_pin); err_shutoff_device: cy8ctmg110_set_sleepmode(ts, true); cy8ctmg110_power(ts, false); @@ -318,7 +289,6 @@ static int cy8ctmg110_remove(struct i2c_client *client) free_irq(client->irq, ts); input_unregister_device(ts->input); - gpio_free(ts->irq_pin); if (ts->reset_pin) gpio_free(ts->reset_pin); kfree(ts); diff --git a/include/linux/input/cy8ctmg110_pdata.h b/include/linux/input/cy8ctmg110_pdata.h index 77582ae1745a..ee1d44545f30 100644 --- a/include/linux/input/cy8ctmg110_pdata.h +++ b/include/linux/input/cy8ctmg110_pdata.h @@ -5,7 +5,6 @@ struct cy8ctmg110_pdata { int reset_pin; /* Reset pin is wired to this GPIO (optional) */ - int irq_pin; /* IRQ pin is wired to this GPIO */ }; #endif From patchwork Thu Jun 3 04:37:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 12296059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F2E7C47082 for ; Thu, 3 Jun 2021 04:38:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 772B0613B8 for ; Thu, 3 Jun 2021 04:38:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229810AbhFCEkc (ORCPT ); Thu, 3 Jun 2021 00:40:32 -0400 Received: from mail-pj1-f51.google.com ([209.85.216.51]:38701 "EHLO mail-pj1-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbhFCEkc (ORCPT ); Thu, 3 Jun 2021 00:40:32 -0400 Received: by mail-pj1-f51.google.com with SMTP id m13-20020a17090b068db02901656cc93a75so4728161pjz.3; Wed, 02 Jun 2021 21:38:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LUTD/0JVHZqpR5tku85xORtPHS0kkXWJ/rRsE1xJMms=; b=QSCbT58cY1IB4g29SGun7iPl3pfkbPujDh6tsThxphFEBHDwncc6hg1PG10StS70w7 RIXgtiYHEpHiLZWoLvnfjSTsdSwrNxVaK1uAMcGR5YHE8U83eqU8uIgIjX5zcxuNHVbp GoGF/IC7IXhw3jVsgUBpRiJoT2iJ//Ki2YQVYftFuy66Z3l4gjjEEQwa0R42GQ44wv5n vCZGwJXCMUN6u8XDLb23iuEdAg40AYUTsR00ktzEr66DdPoOrTbhTbzkcbDY1J/qVrwe c4SLUPSKk0Q8S5Jdy5WqyzpCS6XteY5llGe09aJv0f5+r7tF7o5R08RFbEvjo5erOp99 LYdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LUTD/0JVHZqpR5tku85xORtPHS0kkXWJ/rRsE1xJMms=; b=fXuJR/WT03Yxv+eRMqwo8TuGdmtWoWxOJdif5/PZouak0XV/+EcwJhugWbVL+2fXVP Zr/VjXqHYHta7RG62pxHemASr6fk+3h+y1vBg7SFpKz+dDl1yEAptOgaTpbUrO+vMZJs dKuNDd7oPCRc+aM1PDq7T2FQVjW03KAuw/SGh/UAkdO5DV1O6Rferk+DsmAaQbzTJDV4 wy96E+iIQTCbw0CUOjbNuDoDpn/UmJy+WJH8am2B9QFOoXkNaJYQdgSqMbWfGSLjSzLA CLbW7zonvKnXyaKXB/AkZDbEGfZA/phcs4v6rC5NLXwBSZ9HWNrYhPmIOJXW8rEapNn2 S4hQ== X-Gm-Message-State: AOAM531OHjye5IZLLlERG80owPCBIhBCBzQvWCc5LLF9GJKa4RV8IB4d T61CM3QVioUwffENWyTb2QuHWKgkSgI= X-Google-Smtp-Source: ABdhPJzjhttXQrMrtSGqxfZnLvLIlMor5yUi8W4MYQy/KFV+0pl0KaLDIqCmelZj+At/nbIYG60/Zg== X-Received: by 2002:a17:90a:b782:: with SMTP id m2mr911189pjr.147.1622695051748; Wed, 02 Jun 2021 21:37:31 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:fc6a:97ca:f00c:8377]) by smtp.gmail.com with ESMTPSA id f28sm1132414pgb.12.2021.06.02.21.37.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 21:37:30 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Linus Walleij , linux-kernel@vger.kernel.org Subject: [PATCH 2/7] Input: cy8ctmg110_ts - do not hard code interrupt trigger Date: Wed, 2 Jun 2021 21:37:21 -0700 Message-Id: <20210603043726.3793876-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.32.0.rc0.204.g9fa02ecfa5-goog In-Reply-To: <20210603043726.3793876-1-dmitry.torokhov@gmail.com> References: <20210603043726.3793876-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Rely on the platform to set up interrupt polarity/type properly instead of hard-coding falling edge. Signed-off-by: Dmitry Torokhov Reviewed-by: Linus Walleij --- drivers/input/touchscreen/cy8ctmg110_ts.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/cy8ctmg110_ts.c b/drivers/input/touchscreen/cy8ctmg110_ts.c index 691f35f1bdd7..d83257284537 100644 --- a/drivers/input/touchscreen/cy8ctmg110_ts.c +++ b/drivers/input/touchscreen/cy8ctmg110_ts.c @@ -221,8 +221,7 @@ static int cy8ctmg110_probe(struct i2c_client *client, cy8ctmg110_set_sleepmode(ts, false); err = request_threaded_irq(client->irq, NULL, cy8ctmg110_irq_thread, - IRQF_TRIGGER_RISING | IRQF_ONESHOT, - "touch_reset_key", ts); + IRQF_ONESHOT, "touch_reset_key", ts); if (err < 0) { dev_err(&client->dev, "irq %d busy? error %d\n", client->irq, err); From patchwork Thu Jun 3 04:37:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 12296049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F355C47080 for ; Thu, 3 Jun 2021 04:37:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45537613F1 for ; Thu, 3 Jun 2021 04:37:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229692AbhFCEjf (ORCPT ); Thu, 3 Jun 2021 00:39:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbhFCEje (ORCPT ); Thu, 3 Jun 2021 00:39:34 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BED0C06175F; Wed, 2 Jun 2021 21:37:37 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id v12so2233966plo.10; Wed, 02 Jun 2021 21:37:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Lml8gDdVcBir/4+S7RISpcXFgqdlzoZ+ng9XmF/Tb4M=; b=cnsSp0vY49gsZ5hEcOCaS8jac47v0uDYaa3BCIAqIpdH4PFYan0Wsk9EW/lz50Ns0H qgQ6qoidT/NZl+UlwxuSDPz+/7x0paHb0apwJSlWlkDEJ/csV4gxsawscKo6WEtf8+aB IoTZ0HrclAkVKj7hND+GxE1Ltm2YotmQHTioeZlZDJ4rw0dtFZjAXtzVVq4W7x3xZD5U M7K1B9BgM7fc3/yS+92nmEBRc4DH2DvI/FPZyFwK6L8AkNComrFUa+Yu7nt0d/HGVsc4 b6s3tHuaynKI5lhWnswn+9s3MAPHDLFlLGWU80UnItZvYKHZqOsfMK0NjjaLNUKpplmY 8KBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Lml8gDdVcBir/4+S7RISpcXFgqdlzoZ+ng9XmF/Tb4M=; b=tKTsM4RKdT/LC1+635c597TA34rO3LDfnLHkwsOXPT9xwjdQDS98hfWC2zI/68K8CV IGwXtN0mHDfw4pCVetg8RPbuZ/0K/a1CYq/uGNLgyMN/lseY2WvkmnfE2BLM3VYtuk0K qHHXPlUsOQwNGVvmaamGj/aD/PGoDrolqopFQjLoU8UDPi64HAmulU4j/KeX5jZdBXjx x2DFx3OmuYo7fD6RyOt0kGgaR5VVzqSVHLWMX1a8CzOQoaOaOrb5048phPgNurQGYWfl b+BQ4bM5rAzM55AwmyniYwRA0U8jllG+hJtx79DIen9MYmxldF9/Z/cb65EKmbN3v3QZ nK7A== X-Gm-Message-State: AOAM530XaXCCg9g5jI9EmSPy1BIIT/r2dxkGg3oiYz8uiahmzXvlsPD7 AJw36mwHPv2FDYpPN9zac8QPHkroJM8= X-Google-Smtp-Source: ABdhPJyM5PV+paY5MQb2INGlLRS4HQZ12puPJ5TGk9cgavjmWvgx4UVckaR9FXy8OjeJ1ORtQPgQcg== X-Received: by 2002:a17:90a:bf15:: with SMTP id c21mr11851279pjs.206.1622695053301; Wed, 02 Jun 2021 21:37:33 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:fc6a:97ca:f00c:8377]) by smtp.gmail.com with ESMTPSA id f28sm1132414pgb.12.2021.06.02.21.37.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 21:37:32 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Linus Walleij , linux-kernel@vger.kernel.org Subject: [PATCH 3/7] Input: cy8ctmg110_ts - do not hardcode as wakeup source Date: Wed, 2 Jun 2021 21:37:22 -0700 Message-Id: <20210603043726.3793876-3-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.32.0.rc0.204.g9fa02ecfa5-goog In-Reply-To: <20210603043726.3793876-1-dmitry.torokhov@gmail.com> References: <20210603043726.3793876-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Let platform specify whether the controller should be a wakeup source by registering as I2C_CLIENT_WAKE. Signed-off-by: Dmitry Torokhov Reviewed-by: Linus Walleij --- drivers/input/touchscreen/cy8ctmg110_ts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/cy8ctmg110_ts.c b/drivers/input/touchscreen/cy8ctmg110_ts.c index d83257284537..d83bf82f02d4 100644 --- a/drivers/input/touchscreen/cy8ctmg110_ts.c +++ b/drivers/input/touchscreen/cy8ctmg110_ts.c @@ -233,7 +233,7 @@ static int cy8ctmg110_probe(struct i2c_client *client, goto err_free_irq; i2c_set_clientdata(client, ts); - device_init_wakeup(&client->dev, 1); + return 0; err_free_irq: From patchwork Thu Jun 3 04:37:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 12296051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52F08C47080 for ; Thu, 3 Jun 2021 04:37:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3DCC8613F4 for ; Thu, 3 Jun 2021 04:37:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229744AbhFCEjg (ORCPT ); Thu, 3 Jun 2021 00:39:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbhFCEjg (ORCPT ); Thu, 3 Jun 2021 00:39:36 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECDFCC06174A; Wed, 2 Jun 2021 21:37:35 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id 27so4182461pgy.3; Wed, 02 Jun 2021 21:37:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CJvO80dxevF+V+lMZl/68xv8hBdr0mxfCcEJ+eTeeJY=; b=CQD+vd4lD1BGkwLrBGhuYoAwIkA9y+lLMucLQDXYYJ+cbh9G8DiXZqh+69Dg7mgj3z +DiUcaURoXL3pLABHYHKc9I1U5HG9fZaUy5IP5Dw+oNeK9ifZO9SuYY2EMs4iHFRoRja nnwfZh22nfkwito3OIrpY7AjVg7yazKu/Fkk4xZCjjkgHyMBkUHkvzzWq9159ptOkmbT +xuxDyeKZ4ufFv64zavRbmrx/GfhmP8AYHH5iaAL0bgY0niSio7vI/MtFvpbU368F194 BBHj/8HXc0LlLqzw6kUnWRLNE2WXVcmH9ErigFCioptV8Ei11Wz8hU51BPVOlZS0qqzu NjUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CJvO80dxevF+V+lMZl/68xv8hBdr0mxfCcEJ+eTeeJY=; b=Htv/2npLkkLIG0UCtvJQDjHv6+8xFTqY/gADfuW6kK2Oc9YSy8aSi0+MqdnRhBgKpT mKBF3048okf5v4cS2lBaPpffXP6djFr0WRPR7iVN6mH0Pe1PzfIGypuwxXBNL4Mv8DBk K8LEi5IlHopXT9bey/cdxlUW4IAZtzs3c62TqQ4E7MdT3yvw8R7fUi/odzA/359VJ3VC PL8Ig8SACKZv+jRtkz5KZgz9YUIUmMKVQOa3it9GrlHAQr4QGJHQKKYO4RVlkvoJzI3e dvteS8a9dwF9/QIe6LzGKSFFzWEB4vFa8BzRwD0PqkZqS9miri4Hnx1SiyoHLCdswnhG gRTA== X-Gm-Message-State: AOAM531oMrIVoLEVwwXTzjoRAcL0qN0TuT5U2qZEmXsOtFQoJI6ALZbF G19dcAy8B1H0uxuXJfXJT5ALjIL+bUw= X-Google-Smtp-Source: ABdhPJwdfuMI4uJCwI/uX6HJR2P3I9ZA/XJstWxIOnJdtFZrCB0XHvL5dQGCRl73nRE0cqrUtI/qHg== X-Received: by 2002:a62:1d0f:0:b029:2d5:3ec2:feb8 with SMTP id d15-20020a621d0f0000b02902d53ec2feb8mr31091467pfd.19.1622695054800; Wed, 02 Jun 2021 21:37:34 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:fc6a:97ca:f00c:8377]) by smtp.gmail.com with ESMTPSA id f28sm1132414pgb.12.2021.06.02.21.37.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 21:37:34 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Linus Walleij , linux-kernel@vger.kernel.org Subject: [PATCH 4/7] Input: cy8ctmg110_ts - let I2C core configure wake interrupt Date: Wed, 2 Jun 2021 21:37:23 -0700 Message-Id: <20210603043726.3793876-4-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.32.0.rc0.204.g9fa02ecfa5-goog In-Reply-To: <20210603043726.3793876-1-dmitry.torokhov@gmail.com> References: <20210603043726.3793876-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org I2C core already configures interrupt as wakeup source when device is registered using I2C_CLIENT_WAKE flag, so let's rely on it instead of configuring it ourselves. Signed-off-by: Dmitry Torokhov Reviewed-by: Linus Walleij --- drivers/input/touchscreen/cy8ctmg110_ts.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/input/touchscreen/cy8ctmg110_ts.c b/drivers/input/touchscreen/cy8ctmg110_ts.c index d83bf82f02d4..f8d7ab3b6c25 100644 --- a/drivers/input/touchscreen/cy8ctmg110_ts.c +++ b/drivers/input/touchscreen/cy8ctmg110_ts.c @@ -254,12 +254,11 @@ static int __maybe_unused cy8ctmg110_suspend(struct device *dev) struct i2c_client *client = to_i2c_client(dev); struct cy8ctmg110 *ts = i2c_get_clientdata(client); - if (device_may_wakeup(&client->dev)) - enable_irq_wake(client->irq); - else { + if (!device_may_wakeup(&client->dev)) { cy8ctmg110_set_sleepmode(ts, true); cy8ctmg110_power(ts, false); } + return 0; } @@ -268,12 +267,11 @@ static int __maybe_unused cy8ctmg110_resume(struct device *dev) struct i2c_client *client = to_i2c_client(dev); struct cy8ctmg110 *ts = i2c_get_clientdata(client); - if (device_may_wakeup(&client->dev)) - disable_irq_wake(client->irq); - else { + if (!device_may_wakeup(&client->dev)) { cy8ctmg110_power(ts, true); cy8ctmg110_set_sleepmode(ts, false); } + return 0; } From patchwork Thu Jun 3 04:37:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 12296053 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9255BC47093 for ; Thu, 3 Jun 2021 04:37:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AF37613B8 for ; Thu, 3 Jun 2021 04:37:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229751AbhFCEjh (ORCPT ); Thu, 3 Jun 2021 00:39:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229738AbhFCEjg (ORCPT ); Thu, 3 Jun 2021 00:39:36 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44738C061756; Wed, 2 Jun 2021 21:37:37 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id n12so4132832pgs.13; Wed, 02 Jun 2021 21:37:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WU0LMmPiA/gi0hM1H/SSB6uKAA2ksvr9jOLLh3Q1VC4=; b=PoBAZd9LjCGkhI6W80kOeVbhM+dzv1hren2aAuCgtyloMl1WRD1Jh28mmm11H5VOeS yaK2jNEPVvykLSQvKfUwxI5RZRqD81opJbPDn+ayL//W3hiBQWtUi6HdYLNM7mZNB9T8 sXe4R8Wc89OVsUsJLzvBGWvvSJ5S+uDsCBIooQrT+YxbwivB+mC/obaYkGso9LbyP46s vmVmGiqr2u18uFkDzw2hASwP7nWa954+Yy2CLY+crQ4oEvTolkyehkjB6aRkW+USXfLd MdFX/YbCUq0kc3t+oEGTGFOdRHSsVgc+SV96ggkSFxoLvtqvwmGgcNdUFlp5gzzkqImu gxVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WU0LMmPiA/gi0hM1H/SSB6uKAA2ksvr9jOLLh3Q1VC4=; b=UCLpafpzpeIs0A+Uq+Q7BH8pQcxLiYSScENKyYVWqEYH+fxgdZlX4RJfNRSrfS4rza 0EPs98ezTiz0Jln9dxxNlth2VDEiwAFs3hg7d+kVIhFzqqeX+YehiHvn/BWPPyyfkHkS 6QQGB/VdaF6X5eKi1KENv+0rx0IRPsj/y2kZKO2evCzVaNRp9D3Qb6eHFIBjEoch7rXP 25r5yTMmPNaIp3v/5k2xAqiPMQzxvSGWqMT9Yu8M2IwkNueDiooAnXCA+7Fazmiia7Sd 7TLwko7TXH8xmGZHvd94sa3nh0NXje2b7LS1FR2zooZTZ/MZelfKBBAiRVEpdLhGHRCy R9FA== X-Gm-Message-State: AOAM533wQUdOSWlbSaR3ameObCMDqyG2Q4WXT8UxXWtMfOHgWngMTYF5 iBqZiM44/+sNhit4Bp75n/TYhycoZdo= X-Google-Smtp-Source: ABdhPJxvAIF8ytZpOT8dCAssGtufK0Y9Pm0gOMj9TDstxB14NSuGx52vXN0nSthbo/bGEHffsGu5dw== X-Received: by 2002:a05:6a00:cd3:b029:27f:c296:4a5d with SMTP id b19-20020a056a000cd3b029027fc2964a5dmr30366150pfv.38.1622695056331; Wed, 02 Jun 2021 21:37:36 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:fc6a:97ca:f00c:8377]) by smtp.gmail.com with ESMTPSA id f28sm1132414pgb.12.2021.06.02.21.37.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 21:37:35 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Linus Walleij , linux-kernel@vger.kernel.org Subject: [PATCH 5/7] Input: cy8ctmg110_ts - use endian helpers when converting data on wire Date: Wed, 2 Jun 2021 21:37:24 -0700 Message-Id: <20210603043726.3793876-5-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.32.0.rc0.204.g9fa02ecfa5-goog In-Reply-To: <20210603043726.3793876-1-dmitry.torokhov@gmail.com> References: <20210603043726.3793876-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Switch to using be16_to_cpup() instead of shifting and combining data by hand. Signed-off-by: Dmitry Torokhov Reviewed-by: Linus Walleij --- drivers/input/touchscreen/cy8ctmg110_ts.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/input/touchscreen/cy8ctmg110_ts.c b/drivers/input/touchscreen/cy8ctmg110_ts.c index f8d7ab3b6c25..33c1360a251c 100644 --- a/drivers/input/touchscreen/cy8ctmg110_ts.c +++ b/drivers/input/touchscreen/cy8ctmg110_ts.c @@ -16,6 +16,7 @@ #include #include #include +#include #define CY8CTMG110_DRIVER_NAME "cy8ctmg110" @@ -111,7 +112,6 @@ static int cy8ctmg110_touch_pos(struct cy8ctmg110 *tsc) { struct input_dev *input = tsc->input; unsigned char reg_p[CY8CTMG110_REG_MAX]; - int x, y; memset(reg_p, 0, CY8CTMG110_REG_MAX); @@ -119,16 +119,15 @@ static int cy8ctmg110_touch_pos(struct cy8ctmg110 *tsc) if (cy8ctmg110_read_regs(tsc, reg_p, 9, CY8CTMG110_TOUCH_X1) != 0) return -EIO; - y = reg_p[2] << 8 | reg_p[3]; - x = reg_p[0] << 8 | reg_p[1]; - /* Number of touch */ if (reg_p[8] == 0) { input_report_key(input, BTN_TOUCH, 0); } else { input_report_key(input, BTN_TOUCH, 1); - input_report_abs(input, ABS_X, x); - input_report_abs(input, ABS_Y, y); + input_report_abs(input, ABS_X, + be16_to_cpup((__be16 *)(reg_p + 0))); + input_report_abs(input, ABS_Y, + be16_to_cpup((__be16 *)(reg_p + 2))); } input_sync(input); From patchwork Thu Jun 3 04:37:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 12296047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C530C47080 for ; Thu, 3 Jun 2021 04:37:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E666C613EE for ; Thu, 3 Jun 2021 04:37:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229620AbhFCEjX (ORCPT ); Thu, 3 Jun 2021 00:39:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbhFCEjX (ORCPT ); Thu, 3 Jun 2021 00:39:23 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 344AEC061760; Wed, 2 Jun 2021 21:37:39 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id d5-20020a17090ab305b02901675357c371so4403045pjr.1; Wed, 02 Jun 2021 21:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g/gMhdEoqowTYEWix8YSTA+qLiDKomFphX1/sf/ZHqo=; b=Tt033Y3HybZ6JX3NcnD8iLIqHctigtwCUC21/EVel/aQIvwGc5rO4YVZEP/TSBlNLH sT6jEe2NM5nG+2IyeCicwgP9UMhwXc3Lli6yKcY2o0IIR9tnhr9JLVkNhlPR71k/Pooc WiVkjxY4g2VZdYYEaG8JEOQinp23xLYnZ5j0HkeoqbQ6/u5tXzBHq5IL7/DzxMIhkb/L NwggF8BTh0sMoooCG7OyjBT3vvGih5sIshZXHwHOLiNc9TyWWJUcgxoIWusOvcFxwc/Y wi7nmxmM43Oh2/UjmDH+Jovc4rfCH509oKCdOvxyrhcQ6p1lra7i0GTQvSW5L3QCA8UG 9OIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g/gMhdEoqowTYEWix8YSTA+qLiDKomFphX1/sf/ZHqo=; b=Hfkt5GfrOEEv8uMsYZ6t3fvOIxgwUNhG0VCYKbm8+oGc61di6g2s7bN9XjNgpvj/lj t89iYhyjFxKjUgshhqFl1FQhCyqXwiNrlRCQy64Wz842xC41rqBEiOpUYs/T/DSK7znO 4S6i2AvoqhTw+iqzafZUGIljGXLaKF7PAB9ZDDbF7iVeNNYEwerGzYS61ZBMuYlsc8pW 6aWjVRrsnAg1iJIhNzxMRVW4BrTqTEumB9K6W3cC2tSBF+cdAKGO7q+Ndx8bctTvaHAk Hv2JGWMnj3tr84dz7EPd45ZPlNtowl/s9CjIHt1nYuBaeEBgZYbMATkJ6tnSGj1Y7tz9 4sxQ== X-Gm-Message-State: AOAM533nwYmLlrME47md0k2A77/+uONJukLOBSweTayDa6BFF46gb1dm so/UjgNU7gqEc8TTJPC5F9tErr4m454= X-Google-Smtp-Source: ABdhPJybJ7tvroqV9M4LP/TCHYgHuz+ThXZJnBHGrVYKSqgGAJxYR4g1VnFu2050+ZHhHYiHhDMljA== X-Received: by 2002:a17:90a:668d:: with SMTP id m13mr30013638pjj.144.1622695058088; Wed, 02 Jun 2021 21:37:38 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:fc6a:97ca:f00c:8377]) by smtp.gmail.com with ESMTPSA id f28sm1132414pgb.12.2021.06.02.21.37.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 21:37:37 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Linus Walleij , linux-kernel@vger.kernel.org Subject: [PATCH 6/7] Input: cy8ctmg110_ts - switch to using managed resources Date: Wed, 2 Jun 2021 21:37:25 -0700 Message-Id: <20210603043726.3793876-6-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.32.0.rc0.204.g9fa02ecfa5-goog In-Reply-To: <20210603043726.3793876-1-dmitry.torokhov@gmail.com> References: <20210603043726.3793876-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This simplifies error handling paths and allows to get rid of cy8ctmg110_remove() method. Signed-off-by: Dmitry Torokhov Reviewed-by: Linus Walleij --- drivers/input/touchscreen/cy8ctmg110_ts.c | 74 +++++++++-------------- 1 file changed, 28 insertions(+), 46 deletions(-) diff --git a/drivers/input/touchscreen/cy8ctmg110_ts.c b/drivers/input/touchscreen/cy8ctmg110_ts.c index 33c1360a251c..33ccb31cad52 100644 --- a/drivers/input/touchscreen/cy8ctmg110_ts.c +++ b/drivers/input/touchscreen/cy8ctmg110_ts.c @@ -161,6 +161,14 @@ static irqreturn_t cy8ctmg110_irq_thread(int irq, void *dev_id) return IRQ_HANDLED; } +static void cy8ctmg110_shut_off(void *_ts) +{ + struct cy8ctmg110 *ts = _ts; + + cy8ctmg110_set_sleepmode(ts, true); + cy8ctmg110_power(ts, false); +} + static int cy8ctmg110_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -179,12 +187,13 @@ static int cy8ctmg110_probe(struct i2c_client *client, I2C_FUNC_SMBUS_READ_WORD_DATA)) return -EIO; - ts = kzalloc(sizeof(struct cy8ctmg110), GFP_KERNEL); - input_dev = input_allocate_device(); - if (!ts || !input_dev) { - err = -ENOMEM; - goto err_free_mem; - } + ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); + if (!ts) + return -ENOMEM; + + input_dev = devm_input_allocate_device(&client->dev); + if (!input_dev) + return -ENOMEM; ts->client = client; ts->input = input_dev; @@ -196,56 +205,46 @@ static int cy8ctmg110_probe(struct i2c_client *client, input_dev->name = CY8CTMG110_DRIVER_NAME " Touchscreen"; input_dev->phys = ts->phys; input_dev->id.bustype = BUS_I2C; - input_dev->dev.parent = &client->dev; - - input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); - input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); + input_set_capability(input_dev, EV_KEY, BTN_TOUCH); input_set_abs_params(input_dev, ABS_X, CY8CTMG110_X_MIN, CY8CTMG110_X_MAX, 4, 0); input_set_abs_params(input_dev, ABS_Y, CY8CTMG110_Y_MIN, CY8CTMG110_Y_MAX, 4, 0); if (ts->reset_pin) { - err = gpio_request(ts->reset_pin, NULL); + err = devm_gpio_request(&client->dev, ts->reset_pin, NULL); if (err) { dev_err(&client->dev, "Unable to request GPIO pin %d.\n", ts->reset_pin); - goto err_free_mem; + return err; } } cy8ctmg110_power(ts, true); cy8ctmg110_set_sleepmode(ts, false); - err = request_threaded_irq(client->irq, NULL, cy8ctmg110_irq_thread, - IRQF_ONESHOT, "touch_reset_key", ts); - if (err < 0) { + err = devm_add_action_or_reset(&client->dev, cy8ctmg110_shut_off, ts); + if (err) + return err; + + err = devm_request_threaded_irq(&client->dev, client->irq, + NULL, cy8ctmg110_irq_thread, + IRQF_ONESHOT, "touch_reset_key", ts); + if (err) { dev_err(&client->dev, "irq %d busy? error %d\n", client->irq, err); - goto err_shutoff_device; + return err; } err = input_register_device(input_dev); if (err) - goto err_free_irq; + return err; i2c_set_clientdata(client, ts); return 0; - -err_free_irq: - free_irq(client->irq, ts); -err_shutoff_device: - cy8ctmg110_set_sleepmode(ts, true); - cy8ctmg110_power(ts, false); - if (ts->reset_pin) - gpio_free(ts->reset_pin); -err_free_mem: - input_free_device(input_dev); - kfree(ts); - return err; } static int __maybe_unused cy8ctmg110_suspend(struct device *dev) @@ -276,22 +275,6 @@ static int __maybe_unused cy8ctmg110_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(cy8ctmg110_pm, cy8ctmg110_suspend, cy8ctmg110_resume); -static int cy8ctmg110_remove(struct i2c_client *client) -{ - struct cy8ctmg110 *ts = i2c_get_clientdata(client); - - cy8ctmg110_set_sleepmode(ts, true); - cy8ctmg110_power(ts, false); - - free_irq(client->irq, ts); - input_unregister_device(ts->input); - if (ts->reset_pin) - gpio_free(ts->reset_pin); - kfree(ts); - - return 0; -} - static const struct i2c_device_id cy8ctmg110_idtable[] = { { CY8CTMG110_DRIVER_NAME, 1 }, { } @@ -306,7 +289,6 @@ static struct i2c_driver cy8ctmg110_driver = { }, .id_table = cy8ctmg110_idtable, .probe = cy8ctmg110_probe, - .remove = cy8ctmg110_remove, }; module_i2c_driver(cy8ctmg110_driver); From patchwork Thu Jun 3 04:37:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 12296055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79F67C47080 for ; Thu, 3 Jun 2021 04:38:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 63FC7613B8 for ; Thu, 3 Jun 2021 04:38:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229611AbhFCEkZ (ORCPT ); Thu, 3 Jun 2021 00:40:25 -0400 Received: from mail-pj1-f54.google.com ([209.85.216.54]:51105 "EHLO mail-pj1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhFCEkY (ORCPT ); Thu, 3 Jun 2021 00:40:24 -0400 Received: by mail-pj1-f54.google.com with SMTP id i22so2944368pju.0; Wed, 02 Jun 2021 21:38:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sId2ExzAnq7rqy61mih6ScWMic6zfpfyFkAfotLhFTg=; b=UGpvhahrKOZD62tyRn42uCscBYd4ckwMgN1rN6/zg6EjQRUdkJaD8JxEbkh9QIb5+7 OXNJofE42BQMwFkqYqLvGIgyXOS0suux7wNLeDoGbVmDXlsvD5suZ/aeiIKwABCHAZid czQKdZxYOV6aCsn6uuCaFIFMG25LiJ6JxubglKSjTlxyVdejmN/m78mIud9ByPjIjOYP nkNu2fxkA7Ak2WeRDXDU5DcaTMACOpRYnJPlewICA03o4utgLMDi5MGfhoUJLaCs7l+N u5+9Y/Irn579fw3cUMhXBlIsoCDZysS57rxol50RG4NRDugZIacGFCSmxyNcpwx7cJW6 K9UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sId2ExzAnq7rqy61mih6ScWMic6zfpfyFkAfotLhFTg=; b=n8VV8TpklJEOl+KZNRlgylgU1T3tsebaqY9QMD6Y6z0B9NmhGec9x8932mEBo4bHNQ qT34UtNAHMwJgO3ce3hrpWlpsuiI5Za73JihxaMRtD1qB2RS0sz0tAmSydozd60GaWVS SzOAFyXnnlp1HkLAKTmpaeFdqKVxZptOnPJZdyQx34IuwoXc3CConbKCbnCmKCpd+cSn dAYZnTJ5BNmUUWWbwFWegRFNxldU181yAeNjoOq+jGLmnysqyjxbcKTVds63FrWG5icz 4aj0UIjLFNOB9IZLxoZRxuGC0i2xL7kzeB56YyxjSeLF+E9Aycnj4hpxzkrMZchhOV+k W8fw== X-Gm-Message-State: AOAM530DS1XFyaY24pXW5gfwzhQvcF8uMXtwoNOb3Ui5mNbzz17tGZ5H T11htx5I4lUVuepLap6f5At18o5qIZk= X-Google-Smtp-Source: ABdhPJx8dOYSl4dbKAnA6zL2QvbS9lBitKuBAyNnPH5FZnsBem9tK10fBdC/+kwHv+ythNtVUfnsMg== X-Received: by 2002:a17:90b:1283:: with SMTP id fw3mr30106775pjb.133.1622695059852; Wed, 02 Jun 2021 21:37:39 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:fc6a:97ca:f00c:8377]) by smtp.gmail.com with ESMTPSA id f28sm1132414pgb.12.2021.06.02.21.37.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 21:37:39 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Linus Walleij , linux-kernel@vger.kernel.org Subject: [PATCH 7/7] Input: cy8ctmg110_ts - switch to using gpiod API Date: Wed, 2 Jun 2021 21:37:26 -0700 Message-Id: <20210603043726.3793876-7-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.32.0.rc0.204.g9fa02ecfa5-goog In-Reply-To: <20210603043726.3793876-1-dmitry.torokhov@gmail.com> References: <20210603043726.3793876-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Instead of legacy gpio API let's use newer gpiod API. This also allows us to get rid of platform data. Signed-off-by: Dmitry Torokhov Reviewed-by: Linus Walleij --- drivers/input/touchscreen/cy8ctmg110_ts.c | 41 +++++++++-------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/drivers/input/touchscreen/cy8ctmg110_ts.c b/drivers/input/touchscreen/cy8ctmg110_ts.c index 33ccb31cad52..3e2d64fb1620 100644 --- a/drivers/input/touchscreen/cy8ctmg110_ts.c +++ b/drivers/input/touchscreen/cy8ctmg110_ts.c @@ -7,15 +7,13 @@ * Some cleanups by Alan Cox */ -#include -#include +#include #include -#include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #define CY8CTMG110_DRIVER_NAME "cy8ctmg110" @@ -46,7 +44,7 @@ struct cy8ctmg110 { struct input_dev *input; char phys[32]; struct i2c_client *client; - int reset_pin; + struct gpio_desc *reset_gpio; }; /* @@ -55,8 +53,8 @@ struct cy8ctmg110 { */ static void cy8ctmg110_power(struct cy8ctmg110 *ts, bool poweron) { - if (ts->reset_pin) - gpio_direction_output(ts->reset_pin, 1 - poweron); + if (ts->reset_gpio) + gpiod_set_value_cansleep(ts->reset_gpio, !poweron); } static int cy8ctmg110_write_regs(struct cy8ctmg110 *tsc, unsigned char reg, @@ -172,17 +170,10 @@ static void cy8ctmg110_shut_off(void *_ts) static int cy8ctmg110_probe(struct i2c_client *client, const struct i2c_device_id *id) { - const struct cy8ctmg110_pdata *pdata = dev_get_platdata(&client->dev); struct cy8ctmg110 *ts; struct input_dev *input_dev; int err; - /* No pdata no way forward */ - if (pdata == NULL) { - dev_err(&client->dev, "no pdata\n"); - return -ENODEV; - } - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_WORD_DATA)) return -EIO; @@ -197,7 +188,6 @@ static int cy8ctmg110_probe(struct i2c_client *client, ts->client = client; ts->input = input_dev; - ts->reset_pin = pdata->reset_pin; snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&client->dev)); @@ -212,14 +202,13 @@ static int cy8ctmg110_probe(struct i2c_client *client, input_set_abs_params(input_dev, ABS_Y, CY8CTMG110_Y_MIN, CY8CTMG110_Y_MAX, 4, 0); - if (ts->reset_pin) { - err = devm_gpio_request(&client->dev, ts->reset_pin, NULL); - if (err) { - dev_err(&client->dev, - "Unable to request GPIO pin %d.\n", - ts->reset_pin); - return err; - } + ts->reset_gpio = devm_gpiod_get_optional(&client->dev, NULL, + GPIOD_OUT_HIGH); + if (IS_ERR(ts->reset_gpio)) { + err = PTR_ERR(ts->reset_gpio); + dev_err(&client->dev, + "Unable to request reset GPIO: %d\n", err); + return err; } cy8ctmg110_power(ts, true);