summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@conectiva.com.br>2003-10-28 20:20:49 -0800
committerArnaldo Carvalho de Melo <acme@conectiva.com.br>2003-10-28 20:20:49 -0800
commitfbe0d04d5c63435b5a0c198e28055cbb24f05490 (patch)
tree34a32fcdd9770771b23457bfade3d64541fd8028
parent217e86f8ee7f2275c5e35309bfd7696d8efe9387 (diff)
[NET]: Introduce dev_getbyfirsthwtype.
-rw-r--r--include/linux/netdevice.h2
-rw-r--r--net/core/dev.c26
2 files changed, 28 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 2533f7b9c701..1d79d6e49672 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -498,6 +498,8 @@ extern void probe_old_netdevs(void);
extern int netdev_boot_setup_add(char *name, struct ifmap *map);
extern int netdev_boot_setup_check(struct net_device *dev);
extern struct net_device *dev_getbyhwaddr(unsigned short type, char *hwaddr);
+extern struct net_device *__dev_getfirstbyhwtype(unsigned short type);
+extern struct net_device *dev_getfirstbyhwtype(unsigned short type);
extern void dev_add_pack(struct packet_type *pt);
extern void dev_remove_pack(struct packet_type *pt);
extern void __dev_remove_pack(struct packet_type *pt);
diff --git a/net/core/dev.c b/net/core/dev.c
index f336cf2e1e84..78eea438fe07 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -550,6 +550,32 @@ struct net_device *dev_getbyhwaddr(unsigned short type, char *ha)
return dev;
}
+struct net_device *__dev_getfirstbyhwtype(unsigned short type)
+{
+ struct net_device *dev;
+
+ for (dev = dev_base; dev; dev = dev->next)
+ if (dev->type == type)
+ break;
+ return dev;
+}
+
+EXPORT_SYMBOL(__dev_getfirstbyhwtype);
+
+struct net_device *dev_getfirstbyhwtype(unsigned short type)
+{
+ struct net_device *dev;
+
+ rtnl_lock();
+ dev = __dev_getfirstbyhwtype(type);
+ if (dev)
+ dev_hold(dev);
+ rtnl_unlock();
+ return dev;
+}
+
+EXPORT_SYMBOL(dev_getfirstbyhwtype);
+
/**
* dev_get_by_flags - find any device with given flags
* @if_flags: IFF_* values