[PATCH 2/6] miidev: actually probe the PHY
Johannes Stezenbach
js at sig21.net
Mon Jun 18 10:47:56 EDT 2012
Check if the PHY is really accessible (e.g. the
PHY address is correct) during probe.
Signed-off-by: Johannes Stezenbach <js at sig21.net>
---
drivers/net/miidev.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/net/miidev.c b/drivers/net/miidev.c
index 272234e..3545889 100644
--- a/drivers/net/miidev.c
+++ b/drivers/net/miidev.c
@@ -225,6 +225,14 @@ static struct file_operations miidev_ops = {
static int miidev_probe(struct device_d *dev)
{
struct mii_device *mdev = dev->priv;
+ int val;
+
+ val = mii_read(mdev, mdev->address, MII_PHYSID1);
+ if (val < 0 || val == 0xffff)
+ goto err_out;
+ val = mii_read(mdev, mdev->address, MII_PHYSID2);
+ if (val < 0 || val == 0xffff)
+ goto err_out;
mdev->cdev.name = asprintf("phy%d", dev->id);
mdev->cdev.size = 64;
@@ -234,6 +242,10 @@ static int miidev_probe(struct device_d *dev)
devfs_create(&mdev->cdev);
list_add_tail(&mdev->list, &miidev_list);
return 0;
+
+err_out:
+ dev_err(dev, "cannot read PHY registers (addr %d)\n", mdev->address);
+ return -ENODEV;
}
static void miidev_remove(struct device_d *dev)
--
1.7.10.4
More information about the barebox
mailing list