9
0
Fork 0

net mii: Add mii_open/mii_close functions

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@pengutronix.de>
This commit is contained in:
Sascha Hauer 2012-04-13 10:40:05 +02:00
parent 6f20c7bc70
commit 7753263c50
2 changed files with 25 additions and 0 deletions

View File

@ -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,

View File

@ -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__ */