OSDN Git Service

net-sysfs: get_netdev_queue_index() cleanup
authorThadeu Lima de Souza Cascardo <cascardo@redhat.com>
Tue, 15 Sep 2015 21:28:00 +0000 (18:28 -0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 17 Sep 2015 23:35:15 +0000 (16:35 -0700)
Redo commit ed1acc8cd8c22efa919da8d300bab646e01c2dce.

Commit 822b3b2ebfff8e9b3d006086c527738a7ca00cd0 ("net: Add max rate tx queue
attribute") moved get_netdev_queue_index around, but kept the old version.
Probably because of a reuse of the original patch from before Eric's change to
that function.

Remove one inline keyword, and no need for a loop to find
an index into a table.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Fixes: 822b3b2ebfff ("net: Add max rate tx queue attribute")
Acked-by: Or Gerlitz <ogerlitz@mellanox.com>
Acked-by: John Fastabend <john.r.fastabend@intel.com>
Cc: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/net-sysfs.c

index b279077..49b5990 100644 (file)
@@ -1004,15 +1004,12 @@ static ssize_t show_trans_timeout(struct netdev_queue *queue,
 }
 
 #ifdef CONFIG_XPS
-static inline unsigned int get_netdev_queue_index(struct netdev_queue *queue)
+static unsigned int get_netdev_queue_index(struct netdev_queue *queue)
 {
        struct net_device *dev = queue->dev;
-       int i;
-
-       for (i = 0; i < dev->num_tx_queues; i++)
-               if (queue == &dev->_tx[i])
-                       break;
+       unsigned int i;
 
+       i = queue - dev->_tx;
        BUG_ON(i >= dev->num_tx_queues);
 
        return i;