From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7A9E606A31A for ; Mon, 30 Nov 2026 20:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=yA+cJjwK; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=WsUP7C/e DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Subject:Cc:To:From: Message-ID:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=NN8sq79ue36UOD6eqi8/DzWoPJ/LckUJkoPwpdWWGyw=; b=yA+cJjwK02gWcpx4jNl6rTHu1O NI2NGcquH3/10W1a/TU7603rykfQNTTfZm65VeSrNf6N4LaWNUIa5YdQhHl1gfpEYNFMT1QyMPHMw Q7dEt0tkJTSB2dC8T1ieOPh3kbUuNsFP4loYKJyT+5kkE7TOtf3pVy3EtYLqYF0Mscqnd6BsNoAwg 9o3xGV3gmIcBTN+N0f93E6ZZxQQPb5yYz7TcQvB49hp7VTfpCYj0S55hSX0vJwAYaC+hjeop4lURi pydQTYDjuUcwgGXqhqN+xgNKiMFF8AuKTtif7d5Hm1LRD4EpDA+BoVEoasNSUlQmYfmeNSnrVpgJp zoSC8liA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xY8AS-00000005ooy-33wI; Mon, 30 Nov 2026 20:40:08 +0000 Received: from mail-dl1-x1230.google.com ([2607:f8b0:4864:20::1230]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xY8AG-00000005omY-1PQQ for linux-arm-kernel@lists.infradead.org; Mon, 30 Nov 2026 20:39:58 +0000 Received: by mail-dl1-x1230.google.com with SMTP id a92af1059eb24-1b563e32936so6561259c88.1 for ; Mon, 30 Nov 2026 12:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796071195; x=1796675995; darn=lists.infradead.org; h=content-disposition:content-transfer-encoding:content-type :mime-version:references:in-reply-to:subject:cc:to:from:message-id :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=NN8sq79ue36UOD6eqi8/DzWoPJ/LckUJkoPwpdWWGyw=; b=WsUP7C/ecNLGVzX57U8AYoBL7ALq9kcCBZ/5DtpBcwCIyeZQ6TJzoEJaDPo9JFZ8T6 ZNP/tYTaFsNybrYGxNV8GTRXobYF+re/XSGTz+gkkYXfUSaFf1gzgMp1dahIb56ig2Yd cVF2TARXdXaCwMPzP1rHDXNNP0FlX1QMGGeBVkmJIUBZYFh5VsfQ+J8ugZzjL46g1+3o D062fsusdiie8VcQ6e7pS4Hzz+Qzke7DIuLFmpMDOj5c72jA7mNrbbOrZRFSj3IR+DkQ QOnb+R09sL6+UULPHmzLiVaR/Dzx0R8Agn260Ne0w7IHiz9iMBYSuuQ37QJ6GPgClYC7 4Siw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796071195; x=1796675995; h=content-disposition:content-transfer-encoding:content-type :mime-version:references:in-reply-to:subject:cc:to:from:message-id :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=NN8sq79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7Cthpq7uAxnB0Pu9 drIC3FFN/5gy2ctRqmAM08/7t0fgvuCKv8Lz/5gUuV4ZzCau9yR/31LHYFwEjzzUOCQHoSx5qkw +9k7GZXNBF5Gl4GD1SfiByjDi6lBJTrj49yHal7ECkPyOoATs0sCVvWCik4fVLDHFV/pVFbuc/n vt2UnlrlwZ51nb77MqAp7ZxVI4vulXQ5IH79sb167K2hpxzxglC6CPaEC+WgAGTRapc4 X-Received: by 2002:a05:7022:3f07:b0:1a9:cad6:5b58 with SMTP id a92af1059eb24-1b55693c483mr33693941c88.39.1796071194979; Mon, 30 Nov 2026 12:39:54 -0800 (PST) Received: from localhost ([2a00:79e0:2ebe:8:9f42:1ffe:38c8:d6a]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b562a82b3fsm98237353c88.5.2026.11.30.12.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 12:39:54 -0800 (PST) Date: Mon, 30 Nov 2026 12:39:53 -0800 Message-ID: From: Dmitry Torokhov To: Feng-Yi Hsueh Cc: linux-input@vger.kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, ychuang3@nuvoton.com, schung@nuvoton.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, u.kleine-koenig@baylibre.com Subject: Re: [PATCH v2 2/2] Input: keyboard: Add Nuvoton MA35D1 keypad driver In-Reply-To: <20261113090229.32838-1-fyhsueh4linux@gmail.com> References: <20261113084852.32727-1-fyhsueh4linux@gmail.com> <20261113090229.32838-1-fyhsueh4linux@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261130_123956_639597_E0222DC6 X-CRM114-Status: GOOD ( 22.72 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-7.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Hi Feng-Yi, On Fri, Nov 13, 2026 at 05:02:29PM +0800, Feng-Yi Hsueh wrote: > Add support for the Nuvoton MA35D1 hardware matrix keypad > controller. > > The driver handles key press and release interrupts, reports > key events through the Linux input subsystem, and manages > the peripheral clock during device open, close, and system > suspend and resume. > > Signed-off-by: Feng-Yi Hsueh Thank you for the driver, a few comments below. ... > obj-$(CONFIG_KEYBOARD_LPC32XX) += lpc32xx-keys.o > +obj-$(CONFIG_KEYBOARD_MA35D1) += ma35d1_keypad.o Stray space before the tabs. ... > + int irq; > + bool running; /* protected by input->mutex */ > +}; Why do we need "running"? Input core pairs open() and close() under input->mutex on input_device_enabled() transitions, and suspend() and resume() both check input_device_enabled() while userspace is frozen. The only case where it makes a difference is if clk_prepare_enable() fails on resume and a later close() or suspend() calls ma35d1_keypad_disable() again. If that is what you are guarding against, please add a brief comment; otherwise please drop it. ... > +/* Release software key states when hardware scanning is stopped. */ > +static void ma35d1_keypad_release_keys(struct ma35d1_keypad *keypad) > +{ > + struct input_dev *input = keypad->input; > + unsigned int row, col, scan, code; > + bool reported = false; > + > + for (row = 0; row < keypad->rows; row++) { > + for (col = 0; col < keypad->cols; col++) { > + scan = MATRIX_SCAN_CODE(row, col, keypad->row_shift); > + code = keypad->keycodes[scan]; > + if (code == KEY_RESERVED || !test_bit(code, input->key)) > + continue; > + > + input_event(input, EV_MSC, MSC_SCAN, scan); > + input_report_key(input, code, 0); > + reported = true; > + } > + } > + > + if (reported) > + input_sync(input); > +} Input core already releases pressed keys on suspend, freeze, inhibit, and disconnect. Only plain close() does not, and scanning keycodes[] against input->key here will emit a bogus MSC_SCAN if two matrix positions map to the same keycode (it also checks input->key and keycodes[] outside input->event_lock). If you want to release keys on close, dropping the synthetic MSC_SCAN would be cleaner, or you can just drop this helper and let input core handle it. ... > + while (events) { > + bit = __ffs(events); > + events &= ~BIT(bit); Making "events" an unsigned long and using for_each_set_bit(bit, &events, 32) would be cleaner than iterating with __ffs() manually. ... > + keypad = devm_kzalloc(dev, sizeof(*keypad), GFP_KERNEL); Please use devm_kzalloc_obj(dev, *keypad). ... > + keypad->clk = devm_clk_get(dev, NULL); > + if (IS_ERR(keypad->clk)) > + return dev_err_probe(dev, PTR_ERR(keypad->clk), > + "failed to get KPI clock\n"); Patch 1/2 adds an optional "resets" property to the binding, but the driver does not handle it at all. Should probe acquire and deassert it with devm_reset_control_get_optional_exclusive_deasserted(), or is there a reason to leave reset handling out? Thanks. -- Dmitry