Re: [PATCH v2 6/6] usb: typec: Link all ports during connector registration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?)

> +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.

thanks,

greg k-h



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux