Merged
authorMartin Troxler <martin.troxler@komaxgroup.com>
Mon, 04 Jan 2010 14:17:31 +0100
changeset 1610 d46de2278ac6
parent 1607 be4dd9c80f42 (diff)
parent 1609 94010c6d8198 (current diff)
child 1611 7c49cd56f96f
child 1775 576c400d74d5
child 1798 e7733f825982
Merged
--- a/devices/generic.c	Mon Jan 04 11:28:29 2010 +0100
+++ b/devices/generic.c	Mon Jan 04 14:17:31 2010 +0100
@@ -70,14 +70,16 @@
 typedef struct {
     struct list_head list;
     struct net_device *netdev;
-    struct socket *socket;
+	struct net_device *used_netdev;
+	struct socket *socket;
     ec_device_t *ecdev;
     uint8_t *rx_buf;
 } ec_gen_device_t;
 
 typedef struct {
     struct list_head list;
-    char name[IFNAMSIZ];
+	struct net_device *netdev;
+	char name[IFNAMSIZ];
     int ifindex;
     uint8_t dev_addr[ETH_ALEN];
 } ec_gen_interface_desc_t;
@@ -200,7 +202,7 @@
     int ret;
     struct sockaddr_ll sa;
 
-    dev->rx_buf = kmalloc(EC_GEN_RX_BUF_SIZE, GFP_KERNEL);
+	dev->rx_buf = kmalloc(EC_GEN_RX_BUF_SIZE, GFP_KERNEL);
     if (!dev->rx_buf) {
         return -ENOMEM;
     }
@@ -240,7 +242,8 @@
 {
     int ret = 0;
 
-    memcpy(dev->netdev->dev_addr, desc->dev_addr, ETH_ALEN);
+	dev->used_netdev = desc->netdev;
+	memcpy(dev->netdev->dev_addr, desc->dev_addr, ETH_ALEN);
 
     dev->ecdev = ecdev_offer(dev->netdev, ec_gen_poll, THIS_MODULE);
     if (dev->ecdev) {
@@ -251,7 +254,7 @@
             ecdev_withdraw(dev->ecdev);
             dev->ecdev = NULL;
         } else {
-            ecdev_set_link(dev->ecdev, 1); // FIXME
+			ecdev_set_link(dev->ecdev, netif_carrier_ok(dev->used_netdev)); // FIXME
             ret = 1;
         }
     }
@@ -293,6 +296,8 @@
     size_t len = skb->len;
     int ret;
 
+	ecdev_set_link(dev->ecdev,netif_carrier_ok(dev->used_netdev));
+
     iov.iov_base = skb->data;
     iov.iov_len = len;
     memset(&msg, 0, sizeof(msg));
@@ -314,7 +319,8 @@
     struct kvec iov;
     int ret, budget = 10; // FIXME
 
-    do {
+	ecdev_set_link(dev->ecdev,netif_carrier_ok(dev->used_netdev));
+	do {
         iov.iov_base = dev->rx_buf;
         iov.iov_len = EC_GEN_RX_BUF_SIZE;
         memset(&msg, 0, sizeof(msg));
@@ -408,6 +414,7 @@
             goto out_err;
         }
         strncpy(desc->name, netdev->name, IFNAMSIZ);
+		desc->netdev = netdev;
         desc->ifindex = netdev->ifindex;
         memcpy(desc->dev_addr, netdev->dev_addr, ETH_ALEN);
         list_add_tail(&desc->list, &descs);