All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alan Stern <stern@rowland.harvard.edu>,
	Benson Leung <bleung@google.com>,
	Prashant Malani <pmalani@chromium.org>,
	Guenter Roeck <linux@roeck-us.net>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 6/6] usb: typec: Link all ports during connector registration
Date: Mon, 29 Mar 2021 12:17:52 +0300	[thread overview]
Message-ID: <YGGbQA/mIAu2JUWs@kuha.fi.intel.com> (raw)
In-Reply-To: <YGGUU2z0qHsfgKrV@kroah.com>

On Mon, Mar 29, 2021 at 10:48:19AM +0200, Greg Kroah-Hartman wrote:
> On Mon, Mar 29, 2021 at 11:44:26AM +0300, Heikki Krogerus wrote:
> > +#ifdef CONFIG_USB
> 
> This feels odd in a file under drivers/usb/ is it still relevant?  Will
> this code get built for non-USB systems (i.e. gadget only?)

Yes, later. The typec connector class can not depend on CONFIG_USB for
sure.

> > +static int each_port(struct device *port, void *connector)
> > +{
> > +	struct port_node *node;
> > +	int ret;
> > +
> > +	node = create_port_node(port);
> > +	if (IS_ERR(node))
> > +		return PTR_ERR(node);
> > +
> > +	if (!connector_match(connector, node)) {
> > +		remove_port_node(node);
> > +		return 0;
> > +	}
> > +
> > +	ret = link_port(to_typec_port(connector), node);
> > +	if (ret) {
> > +		remove_port_node(node->pld);
> > +		return ret;
> > +	}
> > +
> > +	get_device(connector);
> > +
> > +	return 0;
> > +}
> > +#endif
> > +
> > +int typec_link_ports(struct typec_port *con)
> > +{
> > +	int ret = 0;
> > +
> > +	con->pld = get_pld(&con->dev);
> > +	if (!con->pld)
> > +		return 0;
> > +
> > +#ifdef CONFIG_USB
> > +	ret = usb_for_each_port(&con->dev, each_port);
> > +	if (ret)
> > +		typec_unlink_ports(con);
> 
> If you have proper #ifdef for CONFIG_USB in the .h file, then there's no
> need for the #ifdef in the .c file.

We could do that now, but we will have to move the ifdef back to the
C file the moment we add support for Thunderbolt ports and/or
DisplayPorts.

I could make a stub for the usb_for_each_port() function in case
CONFIG_USB is not enable. Would that work?


thanks,

-- 
heikki

  reply	other threads:[~2021-03-29  9:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29  8:44 [PATCH v2 0/6] usb: Linking ports to their Type-C connectors Heikki Krogerus
2021-03-29  8:44 ` [PATCH v2 1/6] usb: typec: Organize the private headers properly Heikki Krogerus
2021-03-29  8:44 ` [PATCH v2 2/6] usb: typec: Declare the typec_class static Heikki Krogerus
2021-03-29  8:44 ` [PATCH v2 3/6] usb: typec: Port mapping utility Heikki Krogerus
2021-03-29 15:15   ` kernel test robot
2021-03-29 15:15     ` kernel test robot
2021-03-29 16:06   ` kernel test robot
2021-03-29 16:06     ` kernel test robot
2021-03-29  8:44 ` [PATCH v2 4/6] usb: Link the ports to the connectors they are attached to Heikki Krogerus
2021-03-29  8:44 ` [PATCH v2 5/6] usb: Iterator for ports Heikki Krogerus
2021-03-29 18:49   ` Alan Stern
2021-03-30  9:07     ` Heikki Krogerus
2021-03-30 15:49       ` Alan Stern
2021-03-29  8:44 ` [PATCH v2 6/6] usb: typec: Link all ports during connector registration Heikki Krogerus
2021-03-29  8:48   ` Greg Kroah-Hartman
2021-03-29  9:17     ` Heikki Krogerus [this message]
2021-03-29  9:19       ` Heikki Krogerus
2021-03-29  9:21         ` Greg Kroah-Hartman
2021-03-29 12:19 kernel test robot

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=YGGbQA/mIAu2JUWs@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=bleung@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=pmalani@chromium.org \
    --cc=stern@rowland.harvard.edu \
    /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.