Commit cf5b36b5 authored by Andrey Shvetsov's avatar Andrey Shvetsov Committed by Greg Kroah-Hartman

staging: most: net: use dormant state

This replaces the call of wait_for_completion in case of an invalid MAC
address in the function most_nd_open() with the dormant state of the
network device.

As a side effect, opening the network device cannot fail anymore.
Signed-off-by: default avatarAndrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: default avatarChristian Gromm <christian.gromm@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a73470f2
...@@ -69,7 +69,6 @@ struct net_dev_context { ...@@ -69,7 +69,6 @@ struct net_dev_context {
struct net_device *dev; struct net_device *dev;
struct net_dev_channel rx; struct net_dev_channel rx;
struct net_dev_channel tx; struct net_dev_channel tx;
struct completion mac_compl;
struct list_head list; struct list_head list;
}; };
...@@ -180,7 +179,6 @@ static int most_nd_set_mac_address(struct net_device *dev, void *p) ...@@ -180,7 +179,6 @@ static int most_nd_set_mac_address(struct net_device *dev, void *p)
static int most_nd_open(struct net_device *dev) static int most_nd_open(struct net_device *dev)
{ {
struct net_dev_context *nd = dev->ml_priv; struct net_dev_context *nd = dev->ml_priv;
long ret;
netdev_info(dev, "open net device\n"); netdev_info(dev, "open net device\n");
...@@ -199,29 +197,13 @@ static int most_nd_open(struct net_device *dev) ...@@ -199,29 +197,13 @@ static int most_nd_open(struct net_device *dev)
return -EBUSY; return -EBUSY;
} }
if (!is_valid_ether_addr(dev->dev_addr)) { if (is_valid_ether_addr(dev->dev_addr))
nd->iface->request_netinfo(nd->iface, nd->tx.ch_id); netif_dormant_off(dev);
ret = wait_for_completion_interruptible_timeout( else
&nd->mac_compl, msecs_to_jiffies(5000)); netif_dormant_on(dev);
if (!ret) {
netdev_err(dev, "mac timeout\n");
ret = -EBUSY;
goto err;
}
if (ret < 0) {
netdev_warn(dev, "mac waiting interrupted\n");
goto err;
}
}
netif_wake_queue(dev); netif_wake_queue(dev);
nd->iface->request_netinfo(nd->iface, nd->tx.ch_id);
return 0; return 0;
err:
most_stop_channel(nd->iface, nd->tx.ch_id, &aim);
most_stop_channel(nd->iface, nd->rx.ch_id, &aim);
return ret;
} }
static int most_nd_stop(struct net_device *dev) static int most_nd_stop(struct net_device *dev)
...@@ -337,7 +319,6 @@ static int aim_probe_channel(struct most_interface *iface, int channel_idx, ...@@ -337,7 +319,6 @@ static int aim_probe_channel(struct most_interface *iface, int channel_idx,
if (!nd) if (!nd)
return -ENOMEM; return -ENOMEM;
init_completion(&nd->mac_compl);
nd->iface = iface; nd->iface = iface;
spin_lock_irqsave(&list_lock, flags); spin_lock_irqsave(&list_lock, flags);
...@@ -569,7 +550,7 @@ void most_deliver_netinfo(struct most_interface *iface, ...@@ -569,7 +550,7 @@ void most_deliver_netinfo(struct most_interface *iface,
netdev_info(dev, "set mac %02x-%02x-%02x-%02x-%02x-%02x\n", netdev_info(dev, "set mac %02x-%02x-%02x-%02x-%02x-%02x\n",
m[0], m[1], m[2], m[3], m[4], m[5]); m[0], m[1], m[2], m[3], m[4], m[5]);
ether_addr_copy(dev->dev_addr, m); ether_addr_copy(dev->dev_addr, m);
complete(&nd->mac_compl); netif_dormant_off(dev);
} else if (!ether_addr_equal(dev->dev_addr, m)) { } else if (!ether_addr_equal(dev->dev_addr, m)) {
netdev_warn(dev, "reject mac %02x-%02x-%02x-%02x-%02x-%02x\n", netdev_warn(dev, "reject mac %02x-%02x-%02x-%02x-%02x-%02x\n",
m[0], m[1], m[2], m[3], m[4], m[5]); m[0], m[1], m[2], m[3], m[4], m[5]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment