summaryrefslogtreecommitdiffstats
path: root/drivers/s390/net/qeth_core_sys.c
diff options
context:
space:
mode:
authorJulian Wiedmann2018-07-19 12:43:51 +0200
committerDavid S. Miller2018-07-21 19:12:29 +0200
commitd3d1b205e89f1e4194b9f8924022c77ea749d113 (patch)
tree575b7890dee4c90605ce91c931c1e456ccd15d90 /drivers/s390/net/qeth_core_sys.c
parents390/qeth: remove redundant netif_carrier_ok() checks (diff)
downloadkernel-qcow2-linux-d3d1b205e89f1e4194b9f8924022c77ea749d113.tar.gz
kernel-qcow2-linux-d3d1b205e89f1e4194b9f8924022c77ea749d113.tar.xz
kernel-qcow2-linux-d3d1b205e89f1e4194b9f8924022c77ea749d113.zip
s390/qeth: allocate netdevice early
Allocation of the netdevice is currently delayed until a qeth card first goes online. This complicates matters in several places, where we need to cache values instead of applying them straight to the netdevice. Improve on this by moving the allocation up to where the qeth card itself is created. This is also one step in direction of eventually placing the qeth card into netdev_priv(). In all subsequent code, remove the now redundant checks whether card->dev is valid. Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/s390/net/qeth_core_sys.c')
-rw-r--r--drivers/s390/net/qeth_core_sys.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/s390/net/qeth_core_sys.c b/drivers/s390/net/qeth_core_sys.c
index cfb659747693..9bef19ed7e04 100644
--- a/drivers/s390/net/qeth_core_sys.c
+++ b/drivers/s390/net/qeth_core_sys.c
@@ -144,8 +144,7 @@ static ssize_t qeth_dev_portno_store(struct device *dev,
goto out;
}
card->info.portno = portno;
- if (card->dev)
- card->dev->dev_port = portno;
+ card->dev->dev_port = portno;
out:
mutex_unlock(&card->conf_mutex);
return rc ? rc : count;
@@ -388,6 +387,7 @@ static ssize_t qeth_dev_layer2_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct qeth_card *card = dev_get_drvdata(dev);
+ struct net_device *ndev;
char *tmp;
int i, rc = 0;
enum qeth_discipline_id newdis;
@@ -424,9 +424,19 @@ static ssize_t qeth_dev_layer2_store(struct device *dev,
card->info.mac_bits = 0;
if (card->discipline) {
+ /* start with a new, pristine netdevice: */
+ ndev = qeth_clone_netdev(card->dev);
+ if (!ndev) {
+ rc = -ENOMEM;
+ goto out;
+ }
+
card->discipline->remove(card->gdev);
qeth_core_free_discipline(card);
card->options.layer2 = -1;
+
+ free_netdev(card->dev);
+ card->dev = ndev;
}
rc = qeth_core_load_discipline(card, newdis);