From patchwork Mon Jul 24 05:30:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 706791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1523C0015E for ; Mon, 24 Jul 2023 05:30:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229572AbjGXFae (ORCPT ); Mon, 24 Jul 2023 01:30:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229486AbjGXFac (ORCPT ); Mon, 24 Jul 2023 01:30:32 -0400 Received: from mail-yw1-x112e.google.com (mail-yw1-x112e.google.com [IPv6:2607:f8b0:4864:20::112e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A062E109; Sun, 23 Jul 2023 22:30:27 -0700 (PDT) Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-583d63ca1e9so13620087b3.1; Sun, 23 Jul 2023 22:30:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690176626; x=1690781426; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=TnxapSoOoqrx/JmjeK0D4Eqy+ziHuQAnxXeq35Wg/z4=; b=Eh9w1ztROQv0GBXKw5jQboCjf5CmerGXt1srqxDtS8JJYcJgFw1XG1VECXJetgpR9M p9XlmBV1Y29iuxEdXKhptSXxy/HGSBJoMOsY7f3IRlTdbChDBrq+PCslCkjgJfvF97HT YUsGvp63XlaEm1Xyv/RKQiUa3fkyudUZKUwkwZEMvueMR8ZaiqkWrRmRsBbwQj5V6vPP DtN5Jhtak3uclk1P4WNr6oZWbt6NmdO1+1HCuoI2OCBkfXHLxhESS6GZrTn76zsCtvHi cO6z9Nor38/187qX1wB6VqM+tklJ6iv959TzxMR6LgiRxSs/Z0OMzDV+IaTUL/COdO2h to3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690176626; x=1690781426; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TnxapSoOoqrx/JmjeK0D4Eqy+ziHuQAnxXeq35Wg/z4=; b=fIRrNGq6ciMf2Xd1gMpRDJUzqdJ+FSaKZvdoVr9uDNioTkNXW9gxtKDgM9UPS6sABP X8L7//o97aqtxm0TQQ45+hfiem3HMyEmTVJQ6ldgyVHIb3LrIQAbJC+Vd2uvY2wAiOej Zu22FWdOVviT/8MiR8IeU/wEnzW4I7NaYGrT7C1tFDD9HdjkL/HgefRcDz9QhGUxrWzZ trD/mI/tD+9XpW+0k6ou7yu8vOCTa8P2TfQNBHL++3mI1nv9ZzZolP11IeXTdTZuB6mT 0Pmm30De9EdUHi6FDqOi6s70woHOmubY/Dz4SwfCm/LRCCC5B9PUmRCE1eIhnfBQ4cE4 VZRg== X-Gm-Message-State: ABy/qLa0irUQd2I4Bxsm3ZaVgahokCztkC4iBGk73YIOCPI5xKPasg5D 4zn/DEJPSJqcOcpY37USh4MeNz6r2ig= X-Google-Smtp-Source: APBJJlHFNxoyfLX3t4i1b80DGBzxiqfEOqiDUPJWTHhotLZ5PDy1Hdbdiz1qixcmcFft00WqOMVejQ== X-Received: by 2002:a0d:d515:0:b0:573:cacd:3b6e with SMTP id x21-20020a0dd515000000b00573cacd3b6emr5678723ywd.30.1690176626563; Sun, 23 Jul 2023 22:30:26 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:b8db:3c3:1ff4:2ae3]) by smtp.gmail.com with ESMTPSA id j14-20020a170902758e00b001b81a97860asm7801937pll.27.2023.07.23.22.30.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jul 2023 22:30:26 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Yangtao Li , linux-kernel@vger.kernel.org Subject: [PATCH 1/5] Input: tca6416-keypad - always expect proper IRQ number in i2c client Date: Sun, 23 Jul 2023 22:30:18 -0700 Message-ID: <20230724053024.352054-1-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Remove option having i2c client contain raw gpio number instead of proper IRQ number. There are no users of this facility in mainline and it will allow cleaning up the driver code with regard to wakeup handling, etc. Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/tca6416-keypad.c | 27 +++++++++---------------- include/linux/tca6416_keypad.h | 1 - 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/input/keyboard/tca6416-keypad.c b/drivers/input/keyboard/tca6416-keypad.c index 2f745cabf4f2..01bc0b881188 100644 --- a/drivers/input/keyboard/tca6416-keypad.c +++ b/drivers/input/keyboard/tca6416-keypad.c @@ -148,7 +148,7 @@ static int tca6416_keys_open(struct input_dev *dev) if (chip->use_polling) schedule_delayed_work(&chip->dwork, msecs_to_jiffies(100)); else - enable_irq(chip->irqnum); + enable_irq(chip->client->irq); return 0; } @@ -160,7 +160,7 @@ static void tca6416_keys_close(struct input_dev *dev) if (chip->use_polling) cancel_delayed_work_sync(&chip->dwork); else - disable_irq(chip->irqnum); + disable_irq(chip->client->irq); } static int tca6416_setup_registers(struct tca6416_keypad_chip *chip) @@ -266,12 +266,7 @@ static int tca6416_keypad_probe(struct i2c_client *client) goto fail1; if (!chip->use_polling) { - if (pdata->irq_is_gpio) - chip->irqnum = gpio_to_irq(client->irq); - else - chip->irqnum = client->irq; - - error = request_threaded_irq(chip->irqnum, NULL, + error = request_threaded_irq(client->irq, NULL, tca6416_keys_isr, IRQF_TRIGGER_FALLING | IRQF_ONESHOT | IRQF_NO_AUTOEN, @@ -279,7 +274,7 @@ static int tca6416_keypad_probe(struct i2c_client *client) if (error) { dev_dbg(&client->dev, "Unable to claim irq %d; error %d\n", - chip->irqnum, error); + client->irq, error); goto fail1; } } @@ -298,8 +293,8 @@ static int tca6416_keypad_probe(struct i2c_client *client) fail2: if (!chip->use_polling) { - free_irq(chip->irqnum, chip); - enable_irq(chip->irqnum); + free_irq(client->irq, chip); + enable_irq(client->irq); } fail1: input_free_device(input); @@ -312,8 +307,8 @@ static void tca6416_keypad_remove(struct i2c_client *client) struct tca6416_keypad_chip *chip = i2c_get_clientdata(client); if (!chip->use_polling) { - free_irq(chip->irqnum, chip); - enable_irq(chip->irqnum); + free_irq(client->irq, chip); + enable_irq(client->irq); } input_unregister_device(chip->input); @@ -323,10 +318,9 @@ static void tca6416_keypad_remove(struct i2c_client *client) static int tca6416_keypad_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); - struct tca6416_keypad_chip *chip = i2c_get_clientdata(client); if (device_may_wakeup(dev)) - enable_irq_wake(chip->irqnum); + enable_irq_wake(client->irq); return 0; } @@ -334,10 +328,9 @@ static int tca6416_keypad_suspend(struct device *dev) static int tca6416_keypad_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); - struct tca6416_keypad_chip *chip = i2c_get_clientdata(client); if (device_may_wakeup(dev)) - disable_irq_wake(chip->irqnum); + disable_irq_wake(client->irq); return 0; } diff --git a/include/linux/tca6416_keypad.h b/include/linux/tca6416_keypad.h index b0d36a9934cc..5cf6f6f82aa7 100644 --- a/include/linux/tca6416_keypad.h +++ b/include/linux/tca6416_keypad.h @@ -25,7 +25,6 @@ struct tca6416_keys_platform_data { unsigned int rep:1; /* enable input subsystem auto repeat */ uint16_t pinmask; uint16_t invert; - int irq_is_gpio; int use_polling; /* use polling if Interrupt is not connected*/ }; #endif From patchwork Mon Jul 24 05:30:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 706792 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06806C001DE for ; Mon, 24 Jul 2023 05:30:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229546AbjGXFad (ORCPT ); Mon, 24 Jul 2023 01:30:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229492AbjGXFac (ORCPT ); Mon, 24 Jul 2023 01:30:32 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 366D8113; Sun, 23 Jul 2023 22:30:28 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6686708c986so3813751b3a.0; Sun, 23 Jul 2023 22:30:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690176627; x=1690781427; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+mBfTAXdbECKfZWYSzzClNT1MWFHwf0oInN5lmMc7Zo=; b=qelQGmEM8D2UOVsGzWD/+tKcbMFqhP/rsPQhWqRpsciysH+gEYd/tQxhvO8R3RJ6uL 6TkO9G30DNNlOF0heMtpfmiRniefRngKoQbAQuL+PDWSkuL+edmHNVeTHCyRY6qB0u7Z tVTZfV1yEWCyw0bfrekOe+2I1KhK2omSKrxX5xbYx5Zqe1006+Uefmcj6IiqnQ0WaNaJ 3yJzYZMQ88tnY+xSavK2MR1pQeay5np+NXxrVz136jsaeXqUUUYppL02SBuRZCb2kYTt p2T/6fynSBpo0y8ArrOnxe8OAHR/WnFP2tFc9MHOFUO7KYE75PlEOr3nGwN9A37dsmZp iA5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690176627; x=1690781427; 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:message-id:reply-to; bh=+mBfTAXdbECKfZWYSzzClNT1MWFHwf0oInN5lmMc7Zo=; b=eaSJt+4o4O71GTKC6MM7nuG+scvJuHTjn6QllWvpAuD8DM6JJDPgLudv2F9W7jFxY7 hqSNBvyyY2UZmC4eUqK0YXEMMvPfTp8yf1qfpHCdf9HnCc35HgWbnUJrTEVeYiwEaRiY pMr/TuDhi8uP2wwqkdW+MFiY3lJeLvVOmaCWcijp4DiZdbaQlxlGpx9/zPxt4ddcQCx9 tK9w6XjIjus4QCXu0wH/CLDa4Yq7XMPav2bCiV9skCjJz+8iQV61O6mWMJx8CQrYt6qk pvMPTiTIDiO7jTrWfhNht6uINQzbBLwAufjrqNv2aVyvihRwo6I3RkB4m6pjIaBxtmwx iMNw== X-Gm-Message-State: ABy/qLY537GyjscX6J5fjx/fwlY9unRKEFLIoLaCrfCVWDDzvg7abfvR WsMlyqYJBJ5rOiqf2A+D8f8yTNlLw/U= X-Google-Smtp-Source: APBJJlHMn/Vy0WKXwSzwW9qJEK4mwc1gnQgipnYWmICYuTlhAYX7Fxjh9UYydLw+hphrySGibltl2A== X-Received: by 2002:a17:902:ead1:b0:1bb:a4e4:54b6 with SMTP id p17-20020a170902ead100b001bba4e454b6mr2369869pld.62.1690176627406; Sun, 23 Jul 2023 22:30:27 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:b8db:3c3:1ff4:2ae3]) by smtp.gmail.com with ESMTPSA id j14-20020a170902758e00b001b81a97860asm7801937pll.27.2023.07.23.22.30.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jul 2023 22:30:27 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Yangtao Li , linux-kernel@vger.kernel.org Subject: [PATCH 2/5] Input: tca6416-keypad - rely on I2C core to set up suspend/resume Date: Sun, 23 Jul 2023 22:30:19 -0700 Message-ID: <20230724053024.352054-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230724053024.352054-1-dmitry.torokhov@gmail.com> References: <20230724053024.352054-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org tca6416_keypad_suspend() and tca6416_keypad_resume() only configure device IRQ for wakeup. I2C core already does this by registering interrupt as a wakeup IRQ in case when device is marked as wakeup-enabled, so we can simply remove this code from the driver. Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/tca6416-keypad.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/drivers/input/keyboard/tca6416-keypad.c b/drivers/input/keyboard/tca6416-keypad.c index 01bc0b881188..906dffbf171c 100644 --- a/drivers/input/keyboard/tca6416-keypad.c +++ b/drivers/input/keyboard/tca6416-keypad.c @@ -287,7 +287,6 @@ static int tca6416_keypad_probe(struct i2c_client *client) } i2c_set_clientdata(client, chip); - device_init_wakeup(&client->dev, 1); return 0; @@ -315,33 +314,9 @@ static void tca6416_keypad_remove(struct i2c_client *client) kfree(chip); } -static int tca6416_keypad_suspend(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - - if (device_may_wakeup(dev)) - enable_irq_wake(client->irq); - - return 0; -} - -static int tca6416_keypad_resume(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - - if (device_may_wakeup(dev)) - disable_irq_wake(client->irq); - - return 0; -} - -static DEFINE_SIMPLE_DEV_PM_OPS(tca6416_keypad_dev_pm_ops, - tca6416_keypad_suspend, tca6416_keypad_resume); - static struct i2c_driver tca6416_keypad_driver = { .driver = { .name = "tca6416-keypad", - .pm = pm_sleep_ptr(&tca6416_keypad_dev_pm_ops), }, .probe = tca6416_keypad_probe, .remove = tca6416_keypad_remove,