All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Ming Yu <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: Wed, 17 Jun 2026 15:39:43 +0100	[thread overview]
Message-ID: <20260617143943.GI10056@google.com> (raw)
In-Reply-To: <CAOoeyxVR_9hHq7dcpE1mJvNk0B=H0c7oWaMWdBQvx+cn_DgfcQ@mail.gmail.com>

On Fri, 05 Jun 2026, Ming Yu wrote:

> Dear Lee,
> 
> Thanks for the review.
> 
> Lee Jones <lee@kernel.org> 於 2026年6月5日週五 上午12:25寫道:
> >
> > > @@ -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?
> >
> 
> The reason for the abstraction is that patch 7/7 introduces a second
> transport (HIF/eSPI), and the sub-device drivers need a way to perform
> I/O without being coupled to a specific transport.
> 
> I'd like to rework this -- could you let me know which approach you'd prefer?
> 
> Keep nct6694_read_msg()/nct6694_write_msg() as exported functions in
> nct6694-core.c, with the core dispatching to the appropriate
> transport-specific implementation based on an internal transport type
> indicator.
> 
> Use a const struct nct6694_transport_ops *ops in struct nct6694,
> following the pattern used by subsystems like regmap_bus and
> spi_controller_mem_ops.
> 
> Happy to go with whichever direction you think is cleaner.

Can you let Regmap handle it?

Most of our multi-bus drivers either create a Regmap in their
bus-specific leaf driver then pass it up when initialising via the core,
or use the Ops offered by Regmap Bus.

Calling from core (higher level) _back_ into the leaf bus-specific
drivers (lower level) is generally decried as are driver level Ops.  I'm
aware we have 2 drivers already doing this, but this has not been the
way for the past 16 and 13 years!

-- 
Lee Jones

  reply	other threads:[~2026-06-17 14:39 UTC|newest]

Thread overview: 11+ 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:25   ` sashiko-bot
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
2026-06-05  2:00     ` Ming Yu
2026-06-17 14:39       ` Lee Jones [this message]
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=20260617143943.GI10056@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.