[VLAN]: Avoid expensive divides
authorEric Dumazet <dada1@cosmosbay.com>
Wed, 9 Jan 2008 07:54:43 +0000 (23:54 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 23:01:06 +0000 (15:01 -0800)
We can avoid divides (as seen with CONFIG_CC_OPTIMIZE_FOR_SIZE=y on
x86) changing vlan_group_get_device()/vlan_group_set_device() id
parameter from signed to unsigned.

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/if_vlan.h

index 976d4b1067d1fb80ac72abc23f9e66e466e523f9..4562105fdb2b6735fc3efd2b7de78fd61a6d02fe 100644 (file)
@@ -81,14 +81,16 @@ struct vlan_group {
        struct rcu_head         rcu;
 };
 
-static inline struct net_device *vlan_group_get_device(struct vlan_group *vg, int vlan_id)
+static inline struct net_device *vlan_group_get_device(struct vlan_group *vg,
+                                                      unsigned int vlan_id)
 {
        struct net_device **array;
        array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN];
        return array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN];
 }
 
-static inline void vlan_group_set_device(struct vlan_group *vg, int vlan_id,
+static inline void vlan_group_set_device(struct vlan_group *vg,
+                                        unsigned int vlan_id,
                                         struct net_device *dev)
 {
        struct net_device **array;