Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
[cascardo/linux.git] / drivers / net / ntb_netdev.c
index f3cdf64..5a7e639 100644 (file)
@@ -78,11 +78,19 @@ static void ntb_netdev_event_handler(void *data, int status)
        netdev_dbg(ndev, "Event %x, Link %x\n", status,
                   ntb_transport_link_query(dev->qp));
 
-       /* Currently, only link status event is supported */
-       if (status)
-               netif_carrier_on(ndev);
-       else
+       switch (status) {
+       case NTB_LINK_DOWN:
                netif_carrier_off(ndev);
+               break;
+       case NTB_LINK_UP:
+               if (!ntb_transport_link_query(dev->qp))
+                       return;
+
+               netif_carrier_on(ndev);
+               break;
+       default:
+               netdev_warn(ndev, "Unsupported event type %d\n", status);
+       }
 }
 
 static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data,
@@ -182,8 +190,10 @@ static int ntb_netdev_open(struct net_device *ndev)
 
                rc = ntb_transport_rx_enqueue(dev->qp, skb, skb->data,
                                              ndev->mtu + ETH_HLEN);
-               if (rc == -EINVAL)
+               if (rc == -EINVAL) {
+                       dev_kfree_skb(skb);
                        goto err;
+               }
        }
 
        netif_carrier_off(ndev);
@@ -288,7 +298,6 @@ static int ntb_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
        cmd->supported = SUPPORTED_Backplane;
        cmd->advertising = ADVERTISED_Backplane;
-       cmd->speed = SPEED_UNKNOWN;
        ethtool_cmd_speed_set(cmd, SPEED_UNKNOWN);
        cmd->duplex = DUPLEX_FULL;
        cmd->port = PORT_OTHER;
@@ -338,7 +347,7 @@ static int ntb_netdev_probe(struct pci_dev *pdev)
        memcpy(ndev->dev_addr, ndev->perm_addr, ndev->addr_len);
 
        ndev->netdev_ops = &ntb_netdev_ops;
-       SET_ETHTOOL_OPS(ndev, &ntb_ethtool_ops);
+       ndev->ethtool_ops = &ntb_ethtool_ops;
 
        dev->qp = ntb_transport_create_queue(ndev, pdev, &ntb_netdev_handlers);
        if (!dev->qp) {
@@ -367,12 +376,15 @@ static void ntb_netdev_remove(struct pci_dev *pdev)
 {
        struct net_device *ndev;
        struct ntb_netdev *dev;
+       bool found = false;
 
        list_for_each_entry(dev, &dev_list, list) {
-               if (dev->pdev == pdev)
+               if (dev->pdev == pdev) {
+                       found = true;
                        break;
+               }
        }
-       if (dev == NULL)
+       if (!found)
                return;
 
        list_del(&dev->list);