From: Lee Jones <lee@kernel.org>
To: a0282524688@gmail.com
Cc: Ming Yu <tmyu0@nuvoton.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 3/7] mfd: nct6694: Introduce transport abstraction with function pointers
Date: Thu, 4 Jun 2026 17:25:19 +0100 [thread overview]
Message-ID: <20260604162519.GE4151951@google.com> (raw)
In-Reply-To: <20260525081736.2904310-4-a0282524688@gmail.com>
On Mon, 25 May 2026, a0282524688@gmail.com wrote:
> From: Ming Yu <a0282524688@gmail.com>
>
> Add `read_msg` and `write_msg` function pointers to `struct nct6694`
> and provide static inline helpers for sub-devices. The USB-specific
> I/O functions are made static and assigned during probe.
>
> This decouples sub-device drivers from the underlying USB implementation,
> paving the way for alternative transport interfaces (e.g., HIF) in the
> future without modifying client drivers.
>
> Signed-off-by: Ming Yu <a0282524688@gmail.com>
> ---
> Changes in v5:
> - Split from the monolithic v4 patch to follow the single logical change principle.
>
> drivers/mfd/nct6694.c | 12 ++++++++----
> include/linux/mfd/nct6694.h | 22 ++++++++++++++++++++--
> 2 files changed, 28 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mfd/nct6694.c b/drivers/mfd/nct6694.c
> index 58c1cbcbe3f2..b88863a0b70f 100644
> --- a/drivers/mfd/nct6694.c
> +++ b/drivers/mfd/nct6694.c
> @@ -115,7 +115,9 @@ static int nct6694_response_err_handling(struct nct6694 *nct6694, unsigned char
> *
> * Return: Negative value on error or 0 on success.
> */
> -int nct6694_read_msg(struct nct6694 *nct6694, const struct nct6694_cmd_header *cmd_hd, void *buf)
> +static int nct6694_read_msg(struct nct6694 *nct6694,
> + const struct nct6694_cmd_header *cmd_hd,
> + void *buf)
> {
> struct nct6694_usb_data *udata = nct6694->priv;
> union nct6694_usb_msg *msg = udata->usb_msg;
> @@ -153,7 +155,6 @@ int nct6694_read_msg(struct nct6694 *nct6694, const struct nct6694_cmd_header *c
>
> return nct6694_response_err_handling(nct6694, msg->response_header.sts);
> }
> -EXPORT_SYMBOL_GPL(nct6694_read_msg);
>
> /**
> * nct6694_write_msg() - Write message to NCT6694 device
> @@ -166,7 +167,9 @@ EXPORT_SYMBOL_GPL(nct6694_read_msg);
> *
> * Return: Negative value on error or 0 on success.
> */
> -int nct6694_write_msg(struct nct6694 *nct6694, const struct nct6694_cmd_header *cmd_hd, void *buf)
> +static int nct6694_write_msg(struct nct6694 *nct6694,
> + const struct nct6694_cmd_header *cmd_hd,
> + void *buf)
> {
> struct nct6694_usb_data *udata = nct6694->priv;
> union nct6694_usb_msg *msg = udata->usb_msg;
> @@ -210,7 +213,6 @@ int nct6694_write_msg(struct nct6694 *nct6694, const struct nct6694_cmd_header *
>
> return nct6694_response_err_handling(nct6694, msg->response_header.sts);
> }
> -EXPORT_SYMBOL_GPL(nct6694_write_msg);
>
> static void usb_int_callback(struct urb *urb)
> {
> @@ -327,6 +329,8 @@ static int nct6694_usb_probe(struct usb_interface *iface,
> udata->udev = udev;
>
> nct6694->priv = udata;
> + nct6694->read_msg = nct6694_read_msg;
> + nct6694->write_msg = nct6694_write_msg;
>
> nct6694->domain = irq_domain_create_simple(NULL, NCT6694_NR_IRQS, 0,
> &nct6694_irq_domain_ops,
> diff --git a/include/linux/mfd/nct6694.h b/include/linux/mfd/nct6694.h
> index 3f5dd53f38de..3079c74110aa 100644
> --- a/include/linux/mfd/nct6694.h
> +++ b/include/linux/mfd/nct6694.h
> @@ -92,9 +92,27 @@ struct nct6694 {
> spinlock_t irq_lock;
> unsigned int irq_enable;
> void *priv;
> +
> + int (*read_msg)(struct nct6694 *nct6694,
> + const struct nct6694_cmd_header *cmd_hd,
> + void *buf);
> + int (*write_msg)(struct nct6694 *nct6694,
> + const struct nct6694_cmd_header *cmd_hd,
> + void *buf);
> };
>
> -int nct6694_read_msg(struct nct6694 *nct6694, const struct nct6694_cmd_header *cmd_hd, void *buf);
> -int nct6694_write_msg(struct nct6694 *nct6694, const struct nct6694_cmd_header *cmd_hd, void *buf);
> +static inline int nct6694_read_msg(struct nct6694 *nct6694,
> + const struct nct6694_cmd_header *cmd_hd,
> + void *buf)
> +{
> + return nct6694->read_msg(nct6694, cmd_hd, buf);
> +}
> +
> +static inline int nct6694_write_msg(struct nct6694 *nct6694,
> + const struct nct6694_cmd_header *cmd_hd,
> + void *buf)
> +{
> + return nct6694->write_msg(nct6694, cmd_hd, buf);
> +}
I very much dislike pointers to functions and abstraction for the sake
of abstraction, at least at the driver-level.
Can you find another way to solve this problem please?
--
Lee Jones
next prev parent reply other threads:[~2026-06-04 16:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260525081736.2904310-1-a0282524688@gmail.com>
2026-05-25 8:17 ` [PATCH v5 1/7] mfd: nct6694: Move module type macros to shared header a0282524688
2026-05-25 8:17 ` [PATCH v5 2/7] mfd: nct6694: Refactor USB-specific data into nct6694_usb_data a0282524688
2026-05-25 8:17 ` [PATCH v5 3/7] mfd: nct6694: Introduce transport abstraction with function pointers a0282524688
2026-06-04 16:25 ` Lee Jones [this message]
2026-06-05 2:00 ` Ming Yu
2026-05-25 8:17 ` [PATCH v5 4/7] mfd: nct6694: Rename static I/O functions with _usb_ prefix a0282524688
2026-05-25 8:17 ` [PATCH v5 5/7] mfd: nct6694: Rename driver to nct6694-usb and update Kconfig a0282524688
2026-05-25 8:17 ` [PATCH v5 6/7] mfd: nct6694: Extract core device management into a separate module a0282524688
2026-05-25 8:17 ` [PATCH v5 7/7] mfd: nct6694: Add Host Interface (HIF) eSPI transport driver a0282524688
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=20260604162519.GE4151951@google.com \
--to=lee@kernel.org \
--cc=a0282524688@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tmyu0@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