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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e69ac41d-7c1a-78dd-06b2-cb7bffab9e80@gmail.com>
Date:   Wed, 7 Nov 2018 21:53:32 +0100
From:   Heiner Kallweit <hkallweit1@...il.com>
To:     Florian Fainelli <f.fainelli@...il.com>,
        Andrew Lunn <andrew@...n.ch>,
        David Miller <davem@...emloft.net>
Cc:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: [PATCH net-next 1/2] net: phy: use phy_id_mask value zero for exact
 match

A phy_id_mask value zero means every PHYID matches, therefore
value zero isn't used. So we can safely redefine the semantics
of value zero to mean "exact match". This allows to avoid some
boilerplate code in PHY driver configs.

Signed-off-by: Heiner Kallweit <hkallweit1@...il.com>
---
 drivers/net/phy/phy_device.c | 21 +++++++++++++++------
 include/linux/phy.h          |  2 +-
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index ab33d1777..d165a2c82 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -483,15 +483,24 @@ static int phy_bus_match(struct device *dev, struct device_driver *drv)
 			if (!(phydev->c45_ids.devices_in_package & (1 << i)))
 				continue;
 
-			if ((phydrv->phy_id & phydrv->phy_id_mask) ==
-			    (phydev->c45_ids.device_ids[i] &
-			     phydrv->phy_id_mask))
-				return 1;
+			if (!phydrv->phy_id_mask) {
+				if (phydrv->phy_id ==
+				    phydev->c45_ids.device_ids[i])
+					return 1;
+			} else {
+				if ((phydrv->phy_id & phydrv->phy_id_mask) ==
+				    (phydev->c45_ids.device_ids[i] &
+				     phydrv->phy_id_mask))
+					return 1;
+			}
 		}
 		return 0;
 	} else {
-		return (phydrv->phy_id & phydrv->phy_id_mask) ==
-			(phydev->phy_id & phydrv->phy_id_mask);
+		if (!phydrv->phy_id_mask)
+			return phydrv->phy_id == phydev->phy_id;
+		else
+			return (phydrv->phy_id & phydrv->phy_id_mask) ==
+			       (phydev->phy_id & phydrv->phy_id_mask);
 	}
 }
 
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 2090277ea..e30ca2fdd 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -500,7 +500,7 @@ struct phy_driver {
 	struct mdio_driver_common mdiodrv;
 	u32 phy_id;
 	char *name;
-	u32 phy_id_mask;
+	u32 phy_id_mask; /* value 0 means exact match */
 	const unsigned long * const features;
 	u32 flags;
 	const void *driver_data;
-- 
2.19.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ