]> Pileus Git - ~andy/linux/blobdiff - drivers/firewire/net.c
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[~andy/linux] / drivers / firewire / net.c
index d83c54587a63731b82e3662294b5f414485e7710..a42209a73aed3ef5ec6393d4a5df6d495829c9b4 100644 (file)
@@ -628,13 +628,8 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
                                skb->pkt_type = PACKET_MULTICAST;
 #endif
                } else {
-                       if (memcmp(eth->h_dest, net->dev_addr, net->addr_len)) {
-                               u64 a1, a2;
-
-                               memcpy(&a1, eth->h_dest, sizeof(u64));
-                               memcpy(&a2, net->dev_addr, sizeof(u64));
+                       if (memcmp(eth->h_dest, net->dev_addr, net->addr_len))
                                skb->pkt_type = PACKET_OTHERHOST;
-                       }
                }
                if (ntohs(eth->h_proto) >= 1536) {
                        protocol = eth->h_proto;
@@ -815,29 +810,27 @@ static void fwnet_receive_packet(struct fw_card *card, struct fw_request *r,
                int speed, unsigned long long offset, void *payload,
                size_t length, void *callback_data)
 {
-       struct fwnet_device *dev;
-       int status;
+       struct fwnet_device *dev = callback_data;
+       int rcode;
 
-       dev = callback_data;
-       if (tcode != TCODE_WRITE_BLOCK_REQUEST
-           || destination != card->node_id     /* <- FIXME */
-           || generation != card->generation   /* <- FIXME */
-           || offset != dev->handler.offset) {
-               fw_send_response(card, r, RCODE_CONFLICT_ERROR);
+       if (destination == IEEE1394_ALL_NODES) {
+               kfree(r);
 
                return;
        }
 
-       status = fwnet_incoming_packet(dev, payload, length,
-                                      source, generation, false);
-       if (status != 0) {
+       if (offset != dev->handler.offset)
+               rcode = RCODE_ADDRESS_ERROR;
+       else if (tcode != TCODE_WRITE_BLOCK_REQUEST)
+               rcode = RCODE_TYPE_ERROR;
+       else if (fwnet_incoming_packet(dev, payload, length,
+                                      source, generation, false) != 0) {
                fw_error("Incoming packet failure\n");
-               fw_send_response(card, r, RCODE_CONFLICT_ERROR);
-
-               return;
-       }
+               rcode = RCODE_CONFLICT_ERROR;
+       } else
+               rcode = RCODE_COMPLETE;
 
-       fw_send_response(card, r, RCODE_COMPLETE);
+       fw_send_response(card, r, rcode);
 }
 
 static void fwnet_receive_broadcast(struct fw_iso_context *context,
@@ -1333,13 +1326,6 @@ static int fwnet_tx(struct sk_buff *skb, struct net_device *net)
        return NETDEV_TX_OK;
 }
 
-static void fwnet_tx_timeout(struct net_device *net)
-{
-       fw_error("%s: timeout\n", net->name);
-
-       /* FIXME: What to do if we timeout? */
-}
-
 static int fwnet_change_mtu(struct net_device *net, int new_mtu)
 {
        if (new_mtu < 68)
@@ -1364,7 +1350,6 @@ static const struct net_device_ops fwnet_netdev_ops = {
        .ndo_open       = fwnet_open,
        .ndo_stop       = fwnet_stop,
        .ndo_start_xmit = fwnet_tx,
-       .ndo_tx_timeout = fwnet_tx_timeout,
        .ndo_change_mtu = fwnet_change_mtu,
 };
 
@@ -1372,13 +1357,13 @@ static void fwnet_init_dev(struct net_device *net)
 {
        net->header_ops         = &fwnet_header_ops;
        net->netdev_ops         = &fwnet_netdev_ops;
-       net->watchdog_timeo     = 100000; /* ? FIXME */
+       net->watchdog_timeo     = 2 * HZ;
        net->flags              = IFF_BROADCAST | IFF_MULTICAST;
        net->features           = NETIF_F_HIGHDMA;
        net->addr_len           = FWNET_ALEN;
        net->hard_header_len    = FWNET_HLEN;
        net->type               = ARPHRD_IEEE1394;
-       net->tx_queue_len       = 1000; /* ? FIXME */
+       net->tx_queue_len       = 10;
        SET_ETHTOOL_OPS(net, &fwnet_ethtool_ops);
 }
 
@@ -1403,7 +1388,8 @@ static int fwnet_add_peer(struct fwnet_device *dev,
        if (!peer)
                return -ENOMEM;
 
-       unit->device.driver_data = peer;
+       dev_set_drvdata(&unit->device, peer);
+
        peer->dev = dev;
        peer->guid = (u64)device->config_rom[3] << 32 | device->config_rom[4];
        peer->fifo = FWNET_NO_FIFO_ADDR;
@@ -1430,27 +1416,26 @@ static int fwnet_probe(struct device *_dev)
        struct fw_device *device = fw_parent_device(unit);
        struct fw_card *card = device->card;
        struct net_device *net;
+       bool allocated_netdev = false;
        struct fwnet_device *dev;
        unsigned max_mtu;
-       bool new_netdev;
        int ret;
 
        mutex_lock(&fwnet_device_mutex);
 
        dev = fwnet_dev_find(card);
        if (dev) {
-               new_netdev = false;
                net = dev->netdev;
                goto have_dev;
        }
 
-       new_netdev = true;
        net = alloc_netdev(sizeof(*dev), "firewire%d", fwnet_init_dev);
        if (net == NULL) {
                ret = -ENOMEM;
                goto out;
        }
 
+       allocated_netdev = true;
        SET_NETDEV_DEV(net, card->device);
        dev = netdev_priv(net);
 
@@ -1492,12 +1477,12 @@ static int fwnet_probe(struct device *_dev)
                  net->name, (unsigned long long)card->guid);
  have_dev:
        ret = fwnet_add_peer(dev, unit, device);
-       if (ret && new_netdev) {
+       if (ret && allocated_netdev) {
                unregister_netdev(net);
                list_del(&dev->dev_link);
        }
  out:
-       if (ret && new_netdev)
+       if (ret && allocated_netdev)
                free_netdev(net);
 
        mutex_unlock(&fwnet_device_mutex);
@@ -1521,7 +1506,7 @@ static void fwnet_remove_peer(struct fwnet_peer *peer)
 
 static int fwnet_remove(struct device *_dev)
 {
-       struct fwnet_peer *peer = _dev->driver_data;
+       struct fwnet_peer *peer = dev_get_drvdata(_dev);
        struct fwnet_device *dev = peer->dev;
        struct net_device *net;
        struct fwnet_packet_task *ptask, *pt_next;
@@ -1557,6 +1542,8 @@ static int fwnet_remove(struct device *_dev)
                        dev_kfree_skb_any(ptask->skb);
                        kmem_cache_free(fwnet_packet_task_cache, ptask);
                }
+               list_del(&dev->dev_link);
+
                free_netdev(net);
        }
 
@@ -1572,7 +1559,7 @@ static int fwnet_remove(struct device *_dev)
 static void fwnet_update(struct fw_unit *unit)
 {
        struct fw_device *device = fw_parent_device(unit);
-       struct fwnet_peer *peer = unit->device.driver_data;
+       struct fwnet_peer *peer = dev_get_drvdata(&unit->device);
        int generation;
 
        generation = device->generation;