mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Feng-Yi Hsueh <fyhsueh4linux@gmail.com>
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
Date: Mon, 30 Nov 2026 12:39:53 -0800	[thread overview]
Message-ID: <c35befc6eb7c89ce2491cadf7e043eb1@gmail.com> (raw)
In-Reply-To: <20261113090229.32838-1-fyhsueh4linux@gmail.com>

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 <fyhsueh4linux@gmail.com>

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

      reply	other threads:[~2026-11-30 20:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13  8:48 [PATCH v2 0/2] Add Nuvoton MA35D1 keypad controller support Feng-Yi Hsueh
2026-11-13  8:59 ` [PATCH v2 1/2] dt-bindings: input: Add Nuvoton MA35D1 keypad controller Feng-Yi Hsueh
2026-11-13 17:18   ` Conor Dooley
2026-11-13  9:02 ` [PATCH v2 2/2] Input: keyboard: Add Nuvoton MA35D1 keypad driver Feng-Yi Hsueh
2026-11-30 20:39   ` Dmitry Torokhov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c35befc6eb7c89ce2491cadf7e043eb1@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=fyhsueh4linux@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=schung@nuvoton.com \
    --cc=u.kleine-koenig@baylibre.com \
    --cc=ychuang3@nuvoton.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®