From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796071197; b=1d1YtaabEMzfDCPJe9n1WjSK44t+p7cN2xq5huWQwWHv8LsEFX2jilvDR/cL7nH2ms+1 xB9IIciSLwj2IH80LsbY86Uk8X9wAqW5htphdCDqM6DI2ttXX517VmA907e94Emb15VYN jj9FxgV1WlrLFLkVqTRhSJ7DDcTyHCz7ZqL0onyd2jQTdrpkfie/RTG6A+h/nR178xXWz WLm7k2F3RqI8NCNXKvwaWfS8Ofem5EwJhF5eGlnLjnaguF/pnafFa4fsbtuT9d0Wln0vL 05yqgxQZig13Uad40xWbME3G5wBXZ5adHgWphqiNQcPfq8SZ2we5Gm0vMxmdmvnMhcA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796071197; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding: Content-Disposition; bh=NN8sq79ue36UOD6eqi8/DzWoPJ/LckUJkoPwpdWWGyw=; b=0IkPstVRcQ484ALXLOSVqjrb/INmZlsG1YlGz/shIDDXiKa5wLfRQ6ZdPVULiVxOKjxB 93p4RCudiNHsAmt6r8790AQVNLCF761oSIzFJyVw2iVpZFVs+a9LVE3xC93ZSRFkQCh3s KGSZ9orbPwG9TJ3ISpY+wV1K1i8hI52HqH7Ne0iECWVJ32Lzmyj6cBxeoXEjcWRVopf6v 4RdJ3lnXVX51uBZxyfqrhw0RaVRIRKLCbUAt9Ri4K1j9jjgStgY0Vpew1kgBrlYRyQ7X7 5brrBDAll9AYUUfTFGjGLsMmOjrTbGlPNEOpnzwVP/n6e52auY32r6I02zU+Wri2MWw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=YH06g2SY; arc=none smtp.remote-ip=74.125.82.50 Received: from mail-dl1-f50.google.com (mail-dl1-f50.google.com [74.125.82.50]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41BDB606A327 for ; Mon, 30 Nov 2026 20:39:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 41BDB606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=YH06g2SY Received: by mail-dl1-f50.google.com with SMTP id a92af1059eb24-1b563e32936so6561262c88.1 for ; Mon, 30 Nov 2026 12:39:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796071195; x=1796675995; darn=vger.kernel.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=YH06g2SYnRLno5MDpMb31DeAcupMyw4WSBNt2gzf+aqWHNYv5w4uyclrPnib9AhH6s tppMo/TTfgx4Qi7wFORA041ciKDYO8eV3xwdKvesILQcyJQ1tplGGSsbWpnIXaiapkuP CGlYpuN7E+WW+5JP9RLBnhxEVj3bPMsWwXvLzsvqq9FtqbETBBmT4lX23QYEGsYoTM/m mvgb2PaKH9LM4/2EqrTxMizlErLkuesiGthIw0R1GjJTCekQ0ECcHcmVoLhhdQspRBeA Laby88Y+8WFbpmfgYzsa0J+lZxD37HTwcz/YKkjqZHoij8ArhFA7yEclUPhe7vE0udvG 3tiQ== 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=NN8sq79ue36UOD6eqi8/DzWoPJ/LckUJkoPwpdWWGyw=; b=JEZ5b2KPjKdlQi9tLsPr+VN37LJbmp0o81POnKDxWn0y+HHNp7F5d7y1MIx9EjAj3r 1omFjiWDUEtiTCNC0/aCMg+k5qIo+HJZ+NsTQZcgwzNjs46oqpzeQ5+Ut8mhY7geqaFJ gmNPQqoz3EYTYSYJUg14aZ7XA+Lb+7mkLFHUbRY1yuLYZODyRfA16CYtDHRD5gCSw66z UxyaKJatRWOszSAyNXng9+2JHPkZj4iALU9rCrmyQScvsqQlajIIM5vBm8oY7pO3R276 yQy/BOuw3JZoqdhAmkSeYSXluUj81nkDrrGehwDISbvUF8q+goJvUj34S1khhLDc+Paa 8t/A== X-Forwarded-Encrypted: i=1; AL+hErGVYTpQp37XIjDxCz+9d0QBR2z05G6XNjG3ryiLuC/DqYchQslyzZ6XPoSFgAJPtMD9aM6FnN9IrWsR@vger.kernel.org X-Gm-Message-State: APuU4Z8a2lQLv2KdiidtXYXsd0qr37OyLMTpsXPXB81o7qNfmNFCp3Ia 8K4K8HWF6kQPPCHreX1e6lsALL0bE7U0DfcRXmVBMorCxgSppWB+HIrJ X-Gm-Gg: AZFdTZccB9tmgyH02RhZIvfejmbbwgg30GMIUSlLBvqPDc/S5VRPjGcAIzp/0LATTMJ 2qIsPIjspgnPEuaRMf2WfzjCO+slTuCOs7u7ouwaOdmorWc74ma7y+a89LxnXYFVCYS8FlTin0f vuIoACgp+RBfA7T86p+NFhrEhOVyxXiyQp8rzDMn45bgiZ5Wm6bXw2U7Ao6Yt1REG8NBIjK7tFW XLC8gVUuuUuag0o9TGiOWnHlqL5n5il81slRe5QTgj/go8y6Dlg+wwa3XNgGhOBUKWADwn2GfgR 5ZmSkn45SJelvNpYuMgEb+A7AMHaRgXZEjIvURAgd6y2LVMwx7o9evD0+2bOj+AHNVW3Qqkzlgk 10YeSzwnH6jraZAj6wzPgmJz+e+gINZuJwF/djsA3NEy6J41c5cozJjK3/ldLBuXarsBE2AxZ0x otVni3zYmWGabHFxZ8EcaT0UqispYVb2+tSaokBMZWhyypj7e/EHg/ZqZHHcJHD8Je7dNG32jgt NuewGF1CGnqDjoRa7oB5n17TB4k7hNl3y8QGJLVyh8zZ/kRa19Xi7bZk7/igmHIMcM7s6ZHOFU4 8vMDjYOkkvV/LWEibFVkZ48z2BIDVvCRY7pTMNatQzZDi2IGP0mLrUW9r5NPJ3ogJx1S 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-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline 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