From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Badhri Jagan Sridharan <badhri@google.com>,
Guenter Roeck <linux@roeck-us.net>, Kyle Tso <kyletso@google.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/3] usb: typec: tcpm: Add Callback to Usb Communication capable partner
Date: Mon, 1 Feb 2021 17:38:54 +0100 [thread overview]
Message-ID: <YBgunjrmQsFkYBvm@kroah.com> (raw)
In-Reply-To: <20210201160925.GA1433721@kuha.fi.intel.com>
On Mon, Feb 01, 2021 at 06:09:25PM +0200, Heikki Krogerus wrote:
> On Mon, Feb 01, 2021 at 04:19:38PM +0100, Greg Kroah-Hartman wrote:
> > On Mon, Feb 01, 2021 at 05:12:53PM +0200, Heikki Krogerus wrote:
> > > On Mon, Feb 01, 2021 at 01:53:07AM -0800, Badhri Jagan Sridharan wrote:
> > > > The USB Communications Capable bit indicates if port
> > > > partner is capable of communication over the USB data lines
> > > > (e.g. D+/- or SS Tx/Rx). Notify the status of the bit to low
> > > > level drivers to perform chip specific operation.
> > > > For instance, low level driver enables USB switches on D+/D-
> > > > lines to set up data path when the bit is set.
> > > >
> > > > Refactored from patch initially authored by
> > > > Kyle Tso <kyletso@google.com>
> > > >
> > > > Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
> > > > ---
> > > > drivers/usb/typec/tcpm/tcpm.c | 16 ++++++++++++++++
> > > > include/linux/usb/tcpm.h | 5 +++++
> > > > 2 files changed, 21 insertions(+)
> > >
> > > ...
> > >
> > > > diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
> > > > index 3af99f85e8b9..42fcfbe10590 100644
> > > > --- a/include/linux/usb/tcpm.h
> > > > +++ b/include/linux/usb/tcpm.h
> > > > @@ -108,6 +108,10 @@ enum tcpm_transmit_type {
> > > > * is supported by TCPC, set this callback for TCPM to query
> > > > * whether vbus is at VSAFE0V when needed.
> > > > * Returns true when vbus is at VSAFE0V, false otherwise.
> > > > + * @set_partner_usb_comm_capable:
> > > > + * Optional; The USB Communications Capable bit indicates if port
> > > > + * partner is capable of communication over the USB data lines
> > > > + * (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit.
> > > > */
> > > > struct tcpc_dev {
> > > > struct fwnode_handle *fwnode;
> > > > @@ -139,6 +143,7 @@ struct tcpc_dev {
> > > > int (*set_auto_vbus_discharge_threshold)(struct tcpc_dev *dev, enum typec_pwr_opmode mode,
> > > > bool pps_active, u32 requested_vbus_voltage);
> > > > bool (*is_vbus_vsafe0v)(struct tcpc_dev *dev);
> > > > + void (*set_partner_usb_comm_capable)(struct tcpc_dev *dev, bool enable);
> > > > };
> > > >
> > > > struct tcpm_port;
> > >
> > > There start to be a lot of callback there, separate for each function.
> > > And I guess flags too... Would it be possible to have a single
> > > notification callback instead, that would take the type of the
> > > notification as a parameter (we could have an enum for those), and
> > > then the specific object(s) for each type as another paramter (RDO I
> > > guess in this case)?
> > >
> > > It would then be up to the TCPC driver to extract the detail it needs
> > > from that object. That would somehow feel more cleaner to me, but what
> > > do you guys think?
> >
> > It's pretty much the same thing, a "mux" function vs. individual
> > function calls. Personally, individual callbacks are much more
> > explicit, and I think make it easier to determine what is really going
> > on in each driver.
> >
> > But it all does the same thing, if there's going to be loads of
> > callbacks needed, then a single one makes it easier to maintain over
> > time.
> >
> > So it's up to the maintainer what they want to see :)
>
> I understand your point, and I guess a "generic" notification callback
> for all that would not be a good idea. However, right now it looks
> like we are picking individual bits from various PD objects with those
> callbacks, and that does not feel ideal to me either. After all, each of
> those bits has its own flag now, even though the details is just
> extracted from some PD object that we should also have access to.
>
> I think there are ways we can improve this for example by attempting
> to create the notifications per transaction instead of for each
> individual result of those transactions. That way we would not need to
> store the flags at least because we could deliver the entire object
> that was the result of the specific transaction.
>
> So basically, I fear that dealing with these individual bits will in
> many case only serve individual device drivers, and in the worst case
> start making the tcpm.c a bit more difficult to manage if we start to
> have more and more of these bit callbacks.
>
> But on the other hand, I guess we are nowhere near that point, so
> let's forget about this for now.
If it gets unwieldy, we can always change it in the future, there's no
reason these types of in-kernel apis can not be modified and cleaned up
over time.
thanks,
greg k-h
next prev parent reply other threads:[~2021-02-01 16:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-01 9:53 [PATCH v1 1/3] usb: typec: tcpm: Add Callback to Usb Communication capable partner Badhri Jagan Sridharan
2021-02-01 9:53 ` [PATCH v1 2/3] usb: typec: tcpci: " Badhri Jagan Sridharan
2021-02-01 9:53 ` [PATCH v1 3/3] usb: typec: tcpci_maxim: Enable data path when partner is USB Comm capable Badhri Jagan Sridharan
2021-02-01 14:59 ` [PATCH v1 1/3] usb: typec: tcpm: Add Callback to Usb Communication capable partner Guenter Roeck
2021-02-02 0:30 ` Badhri Jagan Sridharan
2021-02-01 15:12 ` Heikki Krogerus
2021-02-01 15:19 ` Greg Kroah-Hartman
2021-02-01 16:09 ` Heikki Krogerus
2021-02-01 16:38 ` Greg Kroah-Hartman [this message]
2021-02-01 19:45 ` Guenter Roeck
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=YBgunjrmQsFkYBvm@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=badhri@google.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=kyletso@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
/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