[net-next PATCH RFC v3 3/8] net: phy: add support for shared priv data size for PHY package in DT

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

 



Add support for defining shared data size for PHY package defined in DT.

A PHY driver has to define the value .phy_package_priv_data_size to make
the generic OF PHY package function alloc priv data in the shared struct
for the PHY package.

Signed-off-by: Christian Marangi <ansuelsmth@xxxxxxxxx>
---
 drivers/net/phy/phy_device.c | 7 ++++++-
 include/linux/phy.h          | 3 +++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index f416f7434697..87f06b4ecbfe 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3178,6 +3178,7 @@ static int of_phy_package(struct phy_device *phydev)
 {
 	struct device_node *node = phydev->mdio.dev.of_node;
 	struct device_node *package_node;
+	int shared_priv_data_size;
 	u32 base_addr;
 	int ret;
 
@@ -3194,8 +3195,12 @@ static int of_phy_package(struct phy_device *phydev)
 	if (of_property_read_u32(package_node, "reg", &base_addr))
 		return -EINVAL;
 
+	shared_priv_data_size = 0;
+	if (phydev->drv->phy_package_priv_data_size)
+		shared_priv_data_size = phydev->drv->phy_package_priv_data_size;
+
 	ret = devm_phy_package_join(&phydev->mdio.dev, phydev,
-				    base_addr, 0);
+				    base_addr, shared_priv_data_size);
 	if (ret)
 		return ret;
 
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 80a4adaeb817..c4e6d0b3a86c 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -884,6 +884,8 @@ struct phy_led {
  * @flags: A bitfield defining certain other features this PHY
  *   supports (like interrupts)
  * @driver_data: Static driver data
+ * @phy_package_priv_data_size: Size of the priv data to alloc
+ *   for shared struct of PHY package.
  *
  * All functions are optional. If config_aneg or read_status
  * are not implemented, the phy core uses the genphy versions.
@@ -901,6 +903,7 @@ struct phy_driver {
 	const unsigned long * const features;
 	u32 flags;
 	const void *driver_data;
+	unsigned int phy_package_priv_data_size;
 
 	/**
 	 * @soft_reset: Called to issue a PHY software reset
-- 
2.40.1





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux