[PATCH] usb: gadget: ether: split start/stop from init/halt

Marek Vasut marex at denx.de
Sun Dec 18 02:50:35 CET 2022


On 12/12/22 16:29, Niel Fourie wrote:

[...]

> +static int _usb_eth_start(struct ether_priv *priv)
> +{
> +	unsigned long ts;
> +	unsigned long timeout = USB_CONNECT_TIMEOUT;
> +	struct eth_dev *dev = &priv->ethdev;
> +
> +	if (!dev->gadget)
> +		return -1;
>   
> +	dev->network_started = 0;

Will this work on systems which already have netconsole active ? I think 
this would break the netconsole connection, since the network would be 
reinitialized, won't it ?

I would expect this assignment to be in _init and _stop , not in _start 
callback.

But I wonder whether the current ethernet uclass interface running code 
does not make the entire network_started mechanism obsolete. See the 
patch which you referenced previously in related patch:

fa795f45254 ("net: eth-uclass: avoid running start() twice without stop()")

>   	packet_received = 0;
>   	packet_sent = 0;
>   
> -	gadget = dev->gadget;
> -	usb_gadget_connect(gadget);
> +	usb_gadget_connect(dev->gadget);
>   
>   	if (env_get("cdc_connect_timeout"))
>   		timeout = dectoul(env_get("cdc_connect_timeout"), NULL) * CONFIG_SYS_HZ;

[...]

> @@ -2493,9 +2509,13 @@ static void _usb_eth_halt(struct ether_priv *priv)
>   #ifndef CONFIG_DM_ETH
>   static int usb_eth_init(struct eth_device *netdev, struct bd_info *bd)
>   {
> +	int ret;
>   	struct ether_priv *priv = (struct ether_priv *)netdev->priv;

Keep the vars sorted as reverse xmas tree please, i.e. int ret goes 
below the struct .

[...]


More information about the U-Boot mailing list