From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4BBA647F2E7 for ; Thu, 4 Jun 2026 16:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780590325; cv=none; b=TxBLZ4ER9MTnPSfawKvVp2oGziVO7lx6oiVe3KeE9zkM9+wwUMmLieMwhlBO7HgaAHYBFdZoB+WdwB9hppGfcNlrbL913s6EUfxWeKLxKi59kIB++I9MOq1sM78C8H1AOOCf/rk0uVLby49yjft2KTlk6om5bNTFsgL9zWS59uQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780590325; c=relaxed/simple; bh=Whih+JWKmu9jFo69xcLTlAF4euy+afhANQbgekqyfGI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Kr5iMfFUtZvKlo8OWyATGf/jV0iUfzhBKr6+36GkV8Deru6zlGDmUPcGRaCuAugODHEvj93VPfjfGeuVlmA0sBblcdeK1mLTZyRrUb52Mk8WwlKLWj0N5hQ8497Xa27mld9YmBZSBrJEvaiWWQEMu+F60zMueciPoO0JolpgWWU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hVKN5ZE5; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hVKN5ZE5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B116F1F00893; Thu, 4 Jun 2026 16:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780590322; bh=ofgGCR6nA0op7UZA0mQuKPx88aHTzIvRuDDoEmhfIXM=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=hVKN5ZE5YWx3yWHbsRdYLJQzUg7VtuQa2MIzGhA5s3fzRPFr3jgDRSI/AJS5POltJ iMseilPxnwDCsntzcS/Fvn7KNA/bMyR92Xnsi9mUueWe1b2Snb5K7JInDq9MWRJn15 yRFG77HCetbjlw7j4o0itST27i9pdfGn9pMKbGzbD8iHnPQ4WNOzg/j96PXKgORXQa 5ZksP1Eawj3wzEuWs07QGuO8OWdxxcQeluCqKdR5+vHXggZC6o2d+E6KS2BVSrG8+n +XNkvC4tSW9s56BP+Z08mKy3fNfsMcUIj11IR9nz+uH4yUKlqoGvOBes7OZXFLp42m IFYDw2M46eVEQ== Date: Thu, 4 Jun 2026 17:25:19 +0100 From: Lee Jones To: a0282524688@gmail.com Cc: Ming Yu , linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 3/7] mfd: nct6694: Introduce transport abstraction with function pointers Message-ID: <20260604162519.GE4151951@google.com> References: <20260525081736.2904310-1-a0282524688@gmail.com> <20260525081736.2904310-4-a0282524688@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260525081736.2904310-4-a0282524688@gmail.com> On Mon, 25 May 2026, a0282524688@gmail.com wrote: > From: Ming Yu > > 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 > --- > 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