mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-25 06:46:00 +00:00
net: eth-uclass: add function eth_start_udev()
Add a function to start a given network device, and update eth_init() to use it. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This commit is contained in:
parent
1d5d292b79
commit
7ad5e878cd
2 changed files with 26 additions and 13 deletions
|
@ -192,6 +192,7 @@ int eth_env_set_enetaddr_by_index(const char *base_name, int index,
|
||||||
int usb_ether_init(void);
|
int usb_ether_init(void);
|
||||||
|
|
||||||
int eth_init(void); /* Initialize the device */
|
int eth_init(void); /* Initialize the device */
|
||||||
|
int eth_start_udev(struct udevice *dev); /* ->start() if not already running */
|
||||||
int eth_send(void *packet, int length); /* Send a packet */
|
int eth_send(void *packet, int length); /* Send a packet */
|
||||||
#if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER)
|
#if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER)
|
||||||
int eth_receive(void *packet, int length); /* Receive a packet*/
|
int eth_receive(void *packet, int length); /* Receive a packet*/
|
||||||
|
|
|
@ -284,6 +284,27 @@ static int on_ethaddr(const char *name, const char *value, enum env_op op,
|
||||||
}
|
}
|
||||||
U_BOOT_ENV_CALLBACK(ethaddr, on_ethaddr);
|
U_BOOT_ENV_CALLBACK(ethaddr, on_ethaddr);
|
||||||
|
|
||||||
|
int eth_start_udev(struct udevice *dev)
|
||||||
|
{
|
||||||
|
struct eth_device_priv *priv = dev_get_uclass_priv(dev);
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (priv->running)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!device_active(dev))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
ret = eth_get_ops(dev)->start(dev);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
priv->state = ETH_STATE_ACTIVE;
|
||||||
|
priv->running = true;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int eth_init(void)
|
int eth_init(void)
|
||||||
{
|
{
|
||||||
struct udevice *current = NULL;
|
struct udevice *current = NULL;
|
||||||
|
@ -328,20 +349,11 @@ int eth_init(void)
|
||||||
if (current) {
|
if (current) {
|
||||||
debug("Trying %s\n", current->name);
|
debug("Trying %s\n", current->name);
|
||||||
|
|
||||||
if (device_active(current)) {
|
ret = eth_start_udev(current);
|
||||||
ret = eth_get_ops(current)->start(current);
|
if (ret < 0)
|
||||||
if (ret >= 0) {
|
|
||||||
struct eth_device_priv *priv =
|
|
||||||
dev_get_uclass_priv(current);
|
|
||||||
|
|
||||||
priv->state = ETH_STATE_ACTIVE;
|
|
||||||
priv->running = true;
|
|
||||||
ret = 0;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ret = eth_errno;
|
ret = eth_errno;
|
||||||
}
|
else
|
||||||
|
break;
|
||||||
|
|
||||||
debug("FAIL\n");
|
debug("FAIL\n");
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue