[PATCH 5/7] net mii: Add mii_open/mii_close functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Some phys need board specific fixups. To be able to do this
from board code add mii_open/mii_close functions so that the
board can use the regular mii_read/mii_write functions.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 drivers/net/miidev.c |   20 ++++++++++++++++++++
 include/miidev.h     |    5 +++++
 2 files changed, 25 insertions(+)

diff --git a/drivers/net/miidev.c b/drivers/net/miidev.c
index 3b73133..cc84e63 100644
--- a/drivers/net/miidev.c
+++ b/drivers/net/miidev.c
@@ -28,6 +28,8 @@
 #include <net.h>
 #include <malloc.h>
 
+static LIST_HEAD(miidev_list);
+
 int miidev_restart_aneg(struct mii_device *mdev)
 {
 	int status, timeout;
@@ -226,6 +228,7 @@ static int miidev_probe(struct device_d *dev)
 	mdev->cdev.priv = mdev;
 	mdev->cdev.dev = dev;
 	devfs_create(&mdev->cdev);
+	list_add_tail(&mdev->list, &miidev_list);
 	return 0;
 }
 
@@ -233,10 +236,27 @@ static void miidev_remove(struct device_d *dev)
 {
 	struct mii_device *mdev = dev->priv;
 
+	list_del(&mdev->list);
+
 	free(mdev->cdev.name);
 	devfs_remove(&mdev->cdev);
 }
 
+struct mii_device *mii_open(const char *name)
+{
+	struct mii_device *mdev;
+
+	list_for_each_entry(mdev, &miidev_list, list) {
+		if (!strcmp(name, mdev->cdev.name))
+			return mdev;
+	}
+	return NULL;
+}
+
+void mii_close(struct mii_device *mdev)
+{
+}
+
 static struct driver_d miidev_drv = {
         .name  = "miidev",
         .probe = miidev_probe,
diff --git a/include/miidev.h b/include/miidev.h
index 8cd4c45..622784f 100644
--- a/include/miidev.h
+++ b/include/miidev.h
@@ -43,6 +43,7 @@ struct mii_device {
 
 	struct eth_device *edev;
 	struct cdev cdev;
+	struct list_head list;
 };
 
 int mii_register(struct mii_device *dev);
@@ -65,4 +66,8 @@ static int inline mii_read(struct mii_device *dev, int addr, int reg)
 {
 	return dev->read(dev, addr, reg);
 }
+
+struct mii_device *mii_open(const char *name);
+void mii_close(struct mii_device *mdev);
+
 #endif /* __MIIDEV_H__ */
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox


[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Free Online Dating]     [Linux Kernel]     [Linux SCSI]     [XFree86]

Add to Google Powered by Linux