net: Get rid of DEVICE_TYPE_ETHER usage
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
aa611e7e69
commit
bac65c6cde
|
@ -278,7 +278,6 @@ U_BOOT_CMD_END
|
|||
|
||||
static int do_ethact (cmd_tbl_t *cmdtp, int argc, char *argv[])
|
||||
{
|
||||
struct device_d *dev;
|
||||
struct eth_device *edev;
|
||||
|
||||
if (argc != 2) {
|
||||
|
@ -286,20 +285,14 @@ static int do_ethact (cmd_tbl_t *cmdtp, int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
dev = get_device_by_path(argv[1]);
|
||||
if (!dev) {
|
||||
perror("open");
|
||||
edev = eth_get_byname(argv[1]);
|
||||
if (edev)
|
||||
eth_set_current(edev);
|
||||
else {
|
||||
printf("no such net device: %s\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (dev->type != DEVICE_TYPE_ETHER) {
|
||||
printf("nat a net device: %s\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
edev = dev->type_data;
|
||||
eth_set_current(edev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,8 @@ struct eth_device {
|
|||
struct param_d param_ethaddr;
|
||||
|
||||
struct device_d *dev;
|
||||
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
int eth_register(struct eth_device* dev); /* Register network device */
|
||||
|
@ -422,5 +424,6 @@ void ethaddr_to_string(const unsigned char *enetaddr, char *str);
|
|||
|
||||
void eth_set_current(struct eth_device *eth);
|
||||
struct eth_device *eth_get_current(void);
|
||||
struct eth_device *eth_get_byname(char *name);
|
||||
|
||||
#endif /* __NET_H__ */
|
||||
|
|
18
net/eth.c
18
net/eth.c
|
@ -32,6 +32,8 @@
|
|||
|
||||
static struct eth_device *eth_current;
|
||||
|
||||
static LIST_HEAD(netdev_list);
|
||||
|
||||
void eth_set_current(struct eth_device *eth)
|
||||
{
|
||||
eth_current = eth;
|
||||
|
@ -42,6 +44,17 @@ struct eth_device * eth_get_current(void)
|
|||
return eth_current;
|
||||
}
|
||||
|
||||
struct eth_device *eth_get_byname(char *name)
|
||||
{
|
||||
struct eth_device *edev;
|
||||
|
||||
list_for_each_entry(edev, &netdev_list, list) {
|
||||
if (!strcmp(edev->dev->id, name))
|
||||
return edev;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int eth_open(void)
|
||||
{
|
||||
if (!eth_current)
|
||||
|
@ -117,7 +130,6 @@ int eth_register(struct eth_device *edev)
|
|||
}
|
||||
|
||||
dev->type_data = edev;
|
||||
dev->type = DEVICE_TYPE_ETHER;
|
||||
edev->param_ip.name = "ipaddr";
|
||||
edev->param_ip.set = ð_set_ipaddr;
|
||||
edev->param_ethaddr.name = "ethaddr";
|
||||
|
@ -136,6 +148,8 @@ int eth_register(struct eth_device *edev)
|
|||
|
||||
edev->init(edev);
|
||||
|
||||
list_add_tail(&edev->list, &netdev_list);
|
||||
|
||||
if (edev->get_ethaddr(edev, ethaddr) == 0) {
|
||||
ethaddr_to_string(ethaddr, ethaddr_str);
|
||||
printf("got MAC address from EEPROM: %s\n",ethaddr_str);
|
||||
|
@ -163,5 +177,7 @@ void eth_unregister(struct eth_device *edev)
|
|||
|
||||
if (eth_current == edev)
|
||||
eth_current = NULL;
|
||||
|
||||
list_del(&edev->list);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue