lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <4847013B.4090408@openwrt.org>
Date:	Wed, 04 Jun 2008 22:55:23 +0200
From:	Felix Fietkau <nbd@...nwrt.org>
To:	netdev@...r.kernel.org
Subject: RFC: Custom PHY device detection functions

Hi,

I'm working on Linux on small consumer grade wireless routers. Many of 
these have switches that connect directly to the Ethernet controller 
through MII/MDIO. These typically support 6-8 ports, one of which connects 
to the CPU. I am working on supporting some of these with PHY drivers, 
which I will submit for review when they're ready.
Most of these devices can be detected with the regular PHY ID and mask, but 
unfortunately there are some that lay out their registers a bit differently 
and thus need custom detection.
I worked around this with the following patch, that allows drivers to do 
their own detection, but I'm not sure if this is suitable for inclusion in 
the PHY layer or if there is a different way to solve this.
Any ideas?

- Felix

--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -132,6 +132,9 @@
  	struct phy_device *phydev = to_phy_device(dev);
  	struct phy_driver *phydrv = to_phy_driver(drv);

+	if (phydrv->detect)
+		return (phydrv->detect(phydev->bus, phydev->addr));
+
  	return ((phydrv->phy_id & phydrv->phy_id_mask) ==
  		(phydev->phy_id & phydrv->phy_id_mask));
  }
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -325,6 +325,11 @@
  	u32 features;
  	u32 flags;

+	/* Called during discovery to test if the
+	 * device can attach to the bus, even if
+	 * phy id and mask do not match */
+	bool (*detect)(struct mii_bus *bus, int addr);
+
  	/* Called to initialize the PHY,
  	 * including after a reset */
  	int (*config_init)(struct phy_device *phydev);

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ