* [PATCH net-next 0/8] net: phy: move PHY package code to its own source file
@ 2025-02-19 21:01 Heiner Kallweit
2025-02-19 21:03 ` [PATCH net-next 1/8] net: phy: move PHY package code from phy_device.c to " Heiner Kallweit
` (7 more replies)
0 siblings, 8 replies; 15+ messages in thread
From: Heiner Kallweit @ 2025-02-19 21:01 UTC (permalink / raw)
To: Andrew Lunn, Russell King - ARM Linux, Paolo Abeni,
Jakub Kicinski, Eric Dumazet, David Miller, Daniel Golle,
Qingfang Deng, SkyLake Huang, Matthias Brugger,
AngeloGioacchino Del Regno, Richard Cochran
Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek, linux-arm-msm
This series contributes to cleaning up phylib by moving PHY package
related code to its own source file.
Heiner Kallweit (8):
net: phy: move PHY package code from phy_device.c to own source file
net: phy: move PHY package related code from phy.h to phy_package.c
net: phy: add getters for public members in struct phy_package_shared
net: phy: qca807x: use new phy_package_shared getters
net: phy: micrel: use new phy_package_shared getters
net: phy: mtk-ge-soc: use new phy_package_shared getters
net: phy: mscc: use new phy_package_shared getters
net: phy: make struct phy_package_shared private to phylib
drivers/net/phy/Makefile | 3 +-
drivers/net/phy/mediatek/mtk-ge-soc.c | 10 +-
drivers/net/phy/micrel.c | 12 +-
drivers/net/phy/mscc/mscc_ptp.c | 15 +-
drivers/net/phy/phy_device.c | 237 ------------------
drivers/net/phy/phy_package.c | 348 ++++++++++++++++++++++++++
drivers/net/phy/qcom/qca807x.c | 20 +-
include/linux/phy.h | 125 +--------
8 files changed, 396 insertions(+), 374 deletions(-)
create mode 100644 drivers/net/phy/phy_package.c
--
2.48.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH net-next 1/8] net: phy: move PHY package code from phy_device.c to own source file
2025-02-19 21:01 [PATCH net-next 0/8] net: phy: move PHY package code to its own source file Heiner Kallweit
@ 2025-02-19 21:03 ` Heiner Kallweit
2025-02-19 21:03 ` [PATCH net-next 2/8] net: phy: move PHY package related code from phy.h to phy_package.c Heiner Kallweit
` (6 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Heiner Kallweit @ 2025-02-19 21:03 UTC (permalink / raw)
To: Andrew Lunn, Russell King - ARM Linux, Paolo Abeni,
Jakub Kicinski, Eric Dumazet, David Miller, Daniel Golle,
Qingfang Deng, SkyLake Huang, Matthias Brugger,
AngeloGioacchino Del Regno, Richard Cochran
Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek, linux-arm-msm
This patch is the first step in moving the PHY package related code
to its own source file. No functional change intended.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/Makefile | 3 +-
drivers/net/phy/phy_device.c | 237 ---------------------------------
drivers/net/phy/phy_package.c | 244 ++++++++++++++++++++++++++++++++++
3 files changed, 246 insertions(+), 238 deletions(-)
create mode 100644 drivers/net/phy/phy_package.c
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index c8dac6e92..8f9ba5e82 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -2,7 +2,8 @@
# Makefile for Linux PHY drivers
libphy-y := phy.o phy-c45.o phy-core.o phy_device.o \
- linkmode.o phy_link_topology.o
+ linkmode.o phy_link_topology.o \
+ phy_package.o
mdio-bus-y += mdio_bus.o mdio_device.o
ifdef CONFIG_MDIO_DEVICE
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 7d21379fa..22588dce1 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1686,243 +1686,6 @@ bool phy_driver_is_genphy_10g(struct phy_device *phydev)
}
EXPORT_SYMBOL_GPL(phy_driver_is_genphy_10g);
-/**
- * phy_package_join - join a common PHY group
- * @phydev: target phy_device struct
- * @base_addr: cookie and base PHY address of PHY package for offset
- * calculation of global register access
- * @priv_size: if non-zero allocate this amount of bytes for private data
- *
- * This joins a PHY group and provides a shared storage for all phydevs in
- * this group. This is intended to be used for packages which contain
- * more than one PHY, for example a quad PHY transceiver.
- *
- * The base_addr parameter serves as cookie which has to have the same values
- * for all members of one group and as the base PHY address of the PHY package
- * for offset calculation to access generic registers of a PHY package.
- * Usually, one of the PHY addresses of the different PHYs in the package
- * provides access to these global registers.
- * The address which is given here, will be used in the phy_package_read()
- * and phy_package_write() convenience functions as base and added to the
- * passed offset in those functions.
- *
- * This will set the shared pointer of the phydev to the shared storage.
- * If this is the first call for a this cookie the shared storage will be
- * allocated. If priv_size is non-zero, the given amount of bytes are
- * allocated for the priv member.
- *
- * Returns < 1 on error, 0 on success. Esp. calling phy_package_join()
- * with the same cookie but a different priv_size is an error.
- */
-int phy_package_join(struct phy_device *phydev, int base_addr, size_t priv_size)
-{
- struct mii_bus *bus = phydev->mdio.bus;
- struct phy_package_shared *shared;
- int ret;
-
- if (base_addr < 0 || base_addr >= PHY_MAX_ADDR)
- return -EINVAL;
-
- mutex_lock(&bus->shared_lock);
- shared = bus->shared[base_addr];
- if (!shared) {
- ret = -ENOMEM;
- shared = kzalloc(sizeof(*shared), GFP_KERNEL);
- if (!shared)
- goto err_unlock;
- if (priv_size) {
- shared->priv = kzalloc(priv_size, GFP_KERNEL);
- if (!shared->priv)
- goto err_free;
- shared->priv_size = priv_size;
- }
- shared->base_addr = base_addr;
- shared->np = NULL;
- refcount_set(&shared->refcnt, 1);
- bus->shared[base_addr] = shared;
- } else {
- ret = -EINVAL;
- if (priv_size && priv_size != shared->priv_size)
- goto err_unlock;
- refcount_inc(&shared->refcnt);
- }
- mutex_unlock(&bus->shared_lock);
-
- phydev->shared = shared;
-
- return 0;
-
-err_free:
- kfree(shared);
-err_unlock:
- mutex_unlock(&bus->shared_lock);
- return ret;
-}
-EXPORT_SYMBOL_GPL(phy_package_join);
-
-/**
- * of_phy_package_join - join a common PHY group in PHY package
- * @phydev: target phy_device struct
- * @priv_size: if non-zero allocate this amount of bytes for private data
- *
- * This is a variant of phy_package_join for PHY package defined in DT.
- *
- * The parent node of the @phydev is checked as a valid PHY package node
- * structure (by matching the node name "ethernet-phy-package") and the
- * base_addr for the PHY package is passed to phy_package_join.
- *
- * With this configuration the shared struct will also have the np value
- * filled to use additional DT defined properties in PHY specific
- * probe_once and config_init_once PHY package OPs.
- *
- * Returns < 0 on error, 0 on success. Esp. calling phy_package_join()
- * with the same cookie but a different priv_size is an error. Or a parent
- * node is not detected or is not valid or doesn't match the expected node
- * name for PHY package.
- */
-int of_phy_package_join(struct phy_device *phydev, size_t priv_size)
-{
- struct device_node *node = phydev->mdio.dev.of_node;
- struct device_node *package_node;
- u32 base_addr;
- int ret;
-
- if (!node)
- return -EINVAL;
-
- package_node = of_get_parent(node);
- if (!package_node)
- return -EINVAL;
-
- if (!of_node_name_eq(package_node, "ethernet-phy-package")) {
- ret = -EINVAL;
- goto exit;
- }
-
- if (of_property_read_u32(package_node, "reg", &base_addr)) {
- ret = -EINVAL;
- goto exit;
- }
-
- ret = phy_package_join(phydev, base_addr, priv_size);
- if (ret)
- goto exit;
-
- phydev->shared->np = package_node;
-
- return 0;
-exit:
- of_node_put(package_node);
- return ret;
-}
-EXPORT_SYMBOL_GPL(of_phy_package_join);
-
-/**
- * phy_package_leave - leave a common PHY group
- * @phydev: target phy_device struct
- *
- * This leaves a PHY group created by phy_package_join(). If this phydev
- * was the last user of the shared data between the group, this data is
- * freed. Resets the phydev->shared pointer to NULL.
- */
-void phy_package_leave(struct phy_device *phydev)
-{
- struct phy_package_shared *shared = phydev->shared;
- struct mii_bus *bus = phydev->mdio.bus;
-
- if (!shared)
- return;
-
- /* Decrease the node refcount on leave if present */
- if (shared->np)
- of_node_put(shared->np);
-
- if (refcount_dec_and_mutex_lock(&shared->refcnt, &bus->shared_lock)) {
- bus->shared[shared->base_addr] = NULL;
- mutex_unlock(&bus->shared_lock);
- kfree(shared->priv);
- kfree(shared);
- }
-
- phydev->shared = NULL;
-}
-EXPORT_SYMBOL_GPL(phy_package_leave);
-
-static void devm_phy_package_leave(struct device *dev, void *res)
-{
- phy_package_leave(*(struct phy_device **)res);
-}
-
-/**
- * devm_phy_package_join - resource managed phy_package_join()
- * @dev: device that is registering this PHY package
- * @phydev: target phy_device struct
- * @base_addr: cookie and base PHY address of PHY package for offset
- * calculation of global register access
- * @priv_size: if non-zero allocate this amount of bytes for private data
- *
- * Managed phy_package_join(). Shared storage fetched by this function,
- * phy_package_leave() is automatically called on driver detach. See
- * phy_package_join() for more information.
- */
-int devm_phy_package_join(struct device *dev, struct phy_device *phydev,
- int base_addr, size_t priv_size)
-{
- struct phy_device **ptr;
- int ret;
-
- ptr = devres_alloc(devm_phy_package_leave, sizeof(*ptr),
- GFP_KERNEL);
- if (!ptr)
- return -ENOMEM;
-
- ret = phy_package_join(phydev, base_addr, priv_size);
-
- if (!ret) {
- *ptr = phydev;
- devres_add(dev, ptr);
- } else {
- devres_free(ptr);
- }
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(devm_phy_package_join);
-
-/**
- * devm_of_phy_package_join - resource managed of_phy_package_join()
- * @dev: device that is registering this PHY package
- * @phydev: target phy_device struct
- * @priv_size: if non-zero allocate this amount of bytes for private data
- *
- * Managed of_phy_package_join(). Shared storage fetched by this function,
- * phy_package_leave() is automatically called on driver detach. See
- * of_phy_package_join() for more information.
- */
-int devm_of_phy_package_join(struct device *dev, struct phy_device *phydev,
- size_t priv_size)
-{
- struct phy_device **ptr;
- int ret;
-
- ptr = devres_alloc(devm_phy_package_leave, sizeof(*ptr),
- GFP_KERNEL);
- if (!ptr)
- return -ENOMEM;
-
- ret = of_phy_package_join(phydev, priv_size);
-
- if (!ret) {
- *ptr = phydev;
- devres_add(dev, ptr);
- } else {
- devres_free(ptr);
- }
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(devm_of_phy_package_join);
-
/**
* phy_detach - detach a PHY device from its network device
* @phydev: target phy_device struct
diff --git a/drivers/net/phy/phy_package.c b/drivers/net/phy/phy_package.c
new file mode 100644
index 000000000..260469f02
--- /dev/null
+++ b/drivers/net/phy/phy_package.c
@@ -0,0 +1,244 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * PHY package support
+ */
+
+#include <linux/of.h>
+#include <linux/phy.h>
+
+/**
+ * phy_package_join - join a common PHY group
+ * @phydev: target phy_device struct
+ * @base_addr: cookie and base PHY address of PHY package for offset
+ * calculation of global register access
+ * @priv_size: if non-zero allocate this amount of bytes for private data
+ *
+ * This joins a PHY group and provides a shared storage for all phydevs in
+ * this group. This is intended to be used for packages which contain
+ * more than one PHY, for example a quad PHY transceiver.
+ *
+ * The base_addr parameter serves as cookie which has to have the same values
+ * for all members of one group and as the base PHY address of the PHY package
+ * for offset calculation to access generic registers of a PHY package.
+ * Usually, one of the PHY addresses of the different PHYs in the package
+ * provides access to these global registers.
+ * The address which is given here, will be used in the phy_package_read()
+ * and phy_package_write() convenience functions as base and added to the
+ * passed offset in those functions.
+ *
+ * This will set the shared pointer of the phydev to the shared storage.
+ * If this is the first call for a this cookie the shared storage will be
+ * allocated. If priv_size is non-zero, the given amount of bytes are
+ * allocated for the priv member.
+ *
+ * Returns < 1 on error, 0 on success. Esp. calling phy_package_join()
+ * with the same cookie but a different priv_size is an error.
+ */
+int phy_package_join(struct phy_device *phydev, int base_addr, size_t priv_size)
+{
+ struct mii_bus *bus = phydev->mdio.bus;
+ struct phy_package_shared *shared;
+ int ret;
+
+ if (base_addr < 0 || base_addr >= PHY_MAX_ADDR)
+ return -EINVAL;
+
+ mutex_lock(&bus->shared_lock);
+ shared = bus->shared[base_addr];
+ if (!shared) {
+ ret = -ENOMEM;
+ shared = kzalloc(sizeof(*shared), GFP_KERNEL);
+ if (!shared)
+ goto err_unlock;
+ if (priv_size) {
+ shared->priv = kzalloc(priv_size, GFP_KERNEL);
+ if (!shared->priv)
+ goto err_free;
+ shared->priv_size = priv_size;
+ }
+ shared->base_addr = base_addr;
+ shared->np = NULL;
+ refcount_set(&shared->refcnt, 1);
+ bus->shared[base_addr] = shared;
+ } else {
+ ret = -EINVAL;
+ if (priv_size && priv_size != shared->priv_size)
+ goto err_unlock;
+ refcount_inc(&shared->refcnt);
+ }
+ mutex_unlock(&bus->shared_lock);
+
+ phydev->shared = shared;
+
+ return 0;
+
+err_free:
+ kfree(shared);
+err_unlock:
+ mutex_unlock(&bus->shared_lock);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(phy_package_join);
+
+/**
+ * of_phy_package_join - join a common PHY group in PHY package
+ * @phydev: target phy_device struct
+ * @priv_size: if non-zero allocate this amount of bytes for private data
+ *
+ * This is a variant of phy_package_join for PHY package defined in DT.
+ *
+ * The parent node of the @phydev is checked as a valid PHY package node
+ * structure (by matching the node name "ethernet-phy-package") and the
+ * base_addr for the PHY package is passed to phy_package_join.
+ *
+ * With this configuration the shared struct will also have the np value
+ * filled to use additional DT defined properties in PHY specific
+ * probe_once and config_init_once PHY package OPs.
+ *
+ * Returns < 0 on error, 0 on success. Esp. calling phy_package_join()
+ * with the same cookie but a different priv_size is an error. Or a parent
+ * node is not detected or is not valid or doesn't match the expected node
+ * name for PHY package.
+ */
+int of_phy_package_join(struct phy_device *phydev, size_t priv_size)
+{
+ struct device_node *node = phydev->mdio.dev.of_node;
+ struct device_node *package_node;
+ u32 base_addr;
+ int ret;
+
+ if (!node)
+ return -EINVAL;
+
+ package_node = of_get_parent(node);
+ if (!package_node)
+ return -EINVAL;
+
+ if (!of_node_name_eq(package_node, "ethernet-phy-package")) {
+ ret = -EINVAL;
+ goto exit;
+ }
+
+ if (of_property_read_u32(package_node, "reg", &base_addr)) {
+ ret = -EINVAL;
+ goto exit;
+ }
+
+ ret = phy_package_join(phydev, base_addr, priv_size);
+ if (ret)
+ goto exit;
+
+ phydev->shared->np = package_node;
+
+ return 0;
+exit:
+ of_node_put(package_node);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(of_phy_package_join);
+
+/**
+ * phy_package_leave - leave a common PHY group
+ * @phydev: target phy_device struct
+ *
+ * This leaves a PHY group created by phy_package_join(). If this phydev
+ * was the last user of the shared data between the group, this data is
+ * freed. Resets the phydev->shared pointer to NULL.
+ */
+void phy_package_leave(struct phy_device *phydev)
+{
+ struct phy_package_shared *shared = phydev->shared;
+ struct mii_bus *bus = phydev->mdio.bus;
+
+ if (!shared)
+ return;
+
+ /* Decrease the node refcount on leave if present */
+ if (shared->np)
+ of_node_put(shared->np);
+
+ if (refcount_dec_and_mutex_lock(&shared->refcnt, &bus->shared_lock)) {
+ bus->shared[shared->base_addr] = NULL;
+ mutex_unlock(&bus->shared_lock);
+ kfree(shared->priv);
+ kfree(shared);
+ }
+
+ phydev->shared = NULL;
+}
+EXPORT_SYMBOL_GPL(phy_package_leave);
+
+static void devm_phy_package_leave(struct device *dev, void *res)
+{
+ phy_package_leave(*(struct phy_device **)res);
+}
+
+/**
+ * devm_phy_package_join - resource managed phy_package_join()
+ * @dev: device that is registering this PHY package
+ * @phydev: target phy_device struct
+ * @base_addr: cookie and base PHY address of PHY package for offset
+ * calculation of global register access
+ * @priv_size: if non-zero allocate this amount of bytes for private data
+ *
+ * Managed phy_package_join(). Shared storage fetched by this function,
+ * phy_package_leave() is automatically called on driver detach. See
+ * phy_package_join() for more information.
+ */
+int devm_phy_package_join(struct device *dev, struct phy_device *phydev,
+ int base_addr, size_t priv_size)
+{
+ struct phy_device **ptr;
+ int ret;
+
+ ptr = devres_alloc(devm_phy_package_leave, sizeof(*ptr),
+ GFP_KERNEL);
+ if (!ptr)
+ return -ENOMEM;
+
+ ret = phy_package_join(phydev, base_addr, priv_size);
+
+ if (!ret) {
+ *ptr = phydev;
+ devres_add(dev, ptr);
+ } else {
+ devres_free(ptr);
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(devm_phy_package_join);
+
+/**
+ * devm_of_phy_package_join - resource managed of_phy_package_join()
+ * @dev: device that is registering this PHY package
+ * @phydev: target phy_device struct
+ * @priv_size: if non-zero allocate this amount of bytes for private data
+ *
+ * Managed of_phy_package_join(). Shared storage fetched by this function,
+ * phy_package_leave() is automatically called on driver detach. See
+ * of_phy_package_join() for more information.
+ */
+int devm_of_phy_package_join(struct device *dev, struct phy_device *phydev,
+ size_t priv_size)
+{
+ struct phy_device **ptr;
+ int ret;
+
+ ptr = devres_alloc(devm_phy_package_leave, sizeof(*ptr),
+ GFP_KERNEL);
+ if (!ptr)
+ return -ENOMEM;
+
+ ret = of_phy_package_join(phydev, priv_size);
+
+ if (!ret) {
+ *ptr = phydev;
+ devres_add(dev, ptr);
+ } else {
+ devres_free(ptr);
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(devm_of_phy_package_join);
--
2.48.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 2/8] net: phy: move PHY package related code from phy.h to phy_package.c
2025-02-19 21:01 [PATCH net-next 0/8] net: phy: move PHY package code to its own source file Heiner Kallweit
2025-02-19 21:03 ` [PATCH net-next 1/8] net: phy: move PHY package code from phy_device.c to " Heiner Kallweit
@ 2025-02-19 21:03 ` Heiner Kallweit
2025-02-21 1:56 ` Andrew Lunn
2025-02-19 21:04 ` [PATCH net-next 3/8] net: phy: add getters for public members of struct phy_package_shared Heiner Kallweit
` (5 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Heiner Kallweit @ 2025-02-19 21:03 UTC (permalink / raw)
To: Andrew Lunn, Russell King - ARM Linux, Paolo Abeni,
Jakub Kicinski, Eric Dumazet, David Miller, Daniel Golle,
Qingfang Deng, SkyLake Huang, Matthias Brugger,
AngeloGioacchino Del Regno, Richard Cochran
Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek, linux-arm-msm
Move PHY package related inline functions from phy.h to phy_package.c.
While doing so remove locked versions phy_package_read() and
phy_package_write() which have no user.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/phy_package.c | 61 +++++++++++++++++++++++
include/linux/phy.h | 91 +++--------------------------------
2 files changed, 68 insertions(+), 84 deletions(-)
diff --git a/drivers/net/phy/phy_package.c b/drivers/net/phy/phy_package.c
index 260469f02..9b9c200ae 100644
--- a/drivers/net/phy/phy_package.c
+++ b/drivers/net/phy/phy_package.c
@@ -6,6 +6,67 @@
#include <linux/of.h>
#include <linux/phy.h>
+int phy_package_address(struct phy_device *phydev, unsigned int addr_offset)
+{
+ struct phy_package_shared *shared = phydev->shared;
+ u8 base_addr = shared->base_addr;
+
+ if (addr_offset >= PHY_MAX_ADDR - base_addr)
+ return -EIO;
+
+ /* we know that addr will be in the range 0..31 and thus the
+ * implicit cast to a signed int is not a problem.
+ */
+ return base_addr + addr_offset;
+}
+EXPORT_SYMBOL_GPL(phy_package_address);
+
+int __phy_package_read(struct phy_device *phydev, unsigned int addr_offset,
+ u32 regnum)
+{
+ int addr = phy_package_address(phydev, addr_offset);
+
+ if (addr < 0)
+ return addr;
+
+ return __mdiobus_read(phydev->mdio.bus, addr, regnum);
+}
+EXPORT_SYMBOL_GPL(__phy_package_read);
+
+int __phy_package_write(struct phy_device *phydev, unsigned int addr_offset,
+ u32 regnum, u16 val)
+{
+ int addr = phy_package_address(phydev, addr_offset);
+
+ if (addr < 0)
+ return addr;
+
+ return __mdiobus_write(phydev->mdio.bus, addr, regnum, val);
+}
+EXPORT_SYMBOL_GPL(__phy_package_write);
+
+static bool __phy_package_set_once(struct phy_device *phydev, unsigned int b)
+{
+ struct phy_package_shared *shared = phydev->shared;
+
+ if (!shared)
+ return false;
+
+ return !test_and_set_bit(b, &shared->flags);
+}
+
+bool phy_package_init_once(struct phy_device *phydev)
+{
+ return __phy_package_set_once(phydev, 0);
+}
+EXPORT_SYMBOL_GPL(phy_package_init_once);
+
+bool phy_package_probe_once(struct phy_device *phydev)
+{
+ return __phy_package_set_once(phydev, 1);
+}
+EXPORT_SYMBOL_GPL(phy_package_probe_once);
+
/**
* phy_package_join - join a common PHY group
* @phydev: target phy_device struct
diff --git a/include/linux/phy.h b/include/linux/phy.h
index e36eb247c..a8f39e817 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -353,10 +353,6 @@ struct phy_package_shared {
void *priv;
};
-/* used as bit number in atomic bitops */
-#define PHY_SHARED_F_INIT_DONE 0
-#define PHY_SHARED_F_PROBE_DONE 1
-
/**
* struct mii_bus - Represents an MDIO bus
*
@@ -2135,66 +2131,11 @@ int __phy_hwtstamp_set(struct phy_device *phydev,
struct kernel_hwtstamp_config *config,
struct netlink_ext_ack *extack);
-static inline int phy_package_address(struct phy_device *phydev,
- unsigned int addr_offset)
-{
- struct phy_package_shared *shared = phydev->shared;
- u8 base_addr = shared->base_addr;
-
- if (addr_offset >= PHY_MAX_ADDR - base_addr)
- return -EIO;
-
- /* we know that addr will be in the range 0..31 and thus the
- * implicit cast to a signed int is not a problem.
- */
- return base_addr + addr_offset;
-}
-
-static inline int phy_package_read(struct phy_device *phydev,
- unsigned int addr_offset, u32 regnum)
-{
- int addr = phy_package_address(phydev, addr_offset);
-
- if (addr < 0)
- return addr;
-
- return mdiobus_read(phydev->mdio.bus, addr, regnum);
-}
-
-static inline int __phy_package_read(struct phy_device *phydev,
- unsigned int addr_offset, u32 regnum)
-{
- int addr = phy_package_address(phydev, addr_offset);
-
- if (addr < 0)
- return addr;
-
- return __mdiobus_read(phydev->mdio.bus, addr, regnum);
-}
-
-static inline int phy_package_write(struct phy_device *phydev,
- unsigned int addr_offset, u32 regnum,
- u16 val)
-{
- int addr = phy_package_address(phydev, addr_offset);
-
- if (addr < 0)
- return addr;
-
- return mdiobus_write(phydev->mdio.bus, addr, regnum, val);
-}
-
-static inline int __phy_package_write(struct phy_device *phydev,
- unsigned int addr_offset, u32 regnum,
- u16 val)
-{
- int addr = phy_package_address(phydev, addr_offset);
-
- if (addr < 0)
- return addr;
-
- return __mdiobus_write(phydev->mdio.bus, addr, regnum, val);
-}
+int phy_package_address(struct phy_device *phydev, unsigned int addr_offset);
+int __phy_package_read(struct phy_device *phydev, unsigned int addr_offset,
+ u32 regnum);
+int __phy_package_write(struct phy_device *phydev, unsigned int addr_offset,
+ u32 regnum, u16 val);
int __phy_package_read_mmd(struct phy_device *phydev,
unsigned int addr_offset, int devad,
@@ -2212,26 +2153,8 @@ int phy_package_write_mmd(struct phy_device *phydev,
unsigned int addr_offset, int devad,
u32 regnum, u16 val);
-static inline bool __phy_package_set_once(struct phy_device *phydev,
- unsigned int b)
-{
- struct phy_package_shared *shared = phydev->shared;
-
- if (!shared)
- return false;
-
- return !test_and_set_bit(b, &shared->flags);
-}
-
-static inline bool phy_package_init_once(struct phy_device *phydev)
-{
- return __phy_package_set_once(phydev, PHY_SHARED_F_INIT_DONE);
-}
-
-static inline bool phy_package_probe_once(struct phy_device *phydev)
-{
- return __phy_package_set_once(phydev, PHY_SHARED_F_PROBE_DONE);
-}
+bool phy_package_init_once(struct phy_device *phydev);
+bool phy_package_probe_once(struct phy_device *phydev);
extern const struct bus_type mdio_bus_type;
--
2.48.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 3/8] net: phy: add getters for public members of struct phy_package_shared
2025-02-19 21:01 [PATCH net-next 0/8] net: phy: move PHY package code to its own source file Heiner Kallweit
2025-02-19 21:03 ` [PATCH net-next 1/8] net: phy: move PHY package code from phy_device.c to " Heiner Kallweit
2025-02-19 21:03 ` [PATCH net-next 2/8] net: phy: move PHY package related code from phy.h to phy_package.c Heiner Kallweit
@ 2025-02-19 21:04 ` Heiner Kallweit
2025-02-25 2:01 ` Jakub Kicinski
2025-02-19 21:05 ` [PATCH net-next 4/8] net: phy: qca807x: use new phy_package_shared getters Heiner Kallweit
` (4 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Heiner Kallweit @ 2025-02-19 21:04 UTC (permalink / raw)
To: Andrew Lunn, Russell King - ARM Linux, Paolo Abeni,
Jakub Kicinski, Eric Dumazet, David Miller, Daniel Golle,
Qingfang Deng, SkyLake Huang, Matthias Brugger,
AngeloGioacchino Del Regno, Richard Cochran
Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek, linux-arm-msm
Add getters for public members, this prepares for making struct
phy_package_shared private to phylib.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/phy_package.c | 12 ++++++++++++
include/linux/phy.h | 3 +++
2 files changed, 15 insertions(+)
diff --git a/drivers/net/phy/phy_package.c b/drivers/net/phy/phy_package.c
index 9b9c200ae..6955b4132 100644
--- a/drivers/net/phy/phy_package.c
+++ b/drivers/net/phy/phy_package.c
@@ -6,6 +6,18 @@
#include <linux/of.h>
#include <linux/phy.h>
+struct device_node *phy_package_shared_get_node(struct phy_device *phydev)
+{
+ return phydev->shared->np;
+}
+EXPORT_SYMBOL_GPL(phy_package_shared_get_node);
+
+void *phy_package_shared_get_priv(struct phy_device *phydev)
+{
+ return phydev->shared->priv;
+}
+EXPORT_SYMBOL_GPL(phy_package_shared_get_priv);
+
int phy_package_address(struct phy_device *phydev, unsigned int addr_offset)
{
struct phy_package_shared *shared = phydev->shared;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index a8f39e817..ce591307a 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -2095,6 +2095,9 @@ int phy_ethtool_get_link_ksettings(struct net_device *ndev,
int phy_ethtool_set_link_ksettings(struct net_device *ndev,
const struct ethtool_link_ksettings *cmd);
int phy_ethtool_nway_reset(struct net_device *ndev);
+
+struct device_node *phy_package_shared_get_node(struct phy_device *phydev);
+void *phy_package_shared_get_priv(struct phy_device *phydev);
int phy_package_join(struct phy_device *phydev, int base_addr, size_t priv_size);
int of_phy_package_join(struct phy_device *phydev, size_t priv_size);
void phy_package_leave(struct phy_device *phydev);
--
2.48.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 4/8] net: phy: qca807x: use new phy_package_shared getters
2025-02-19 21:01 [PATCH net-next 0/8] net: phy: move PHY package code to its own source file Heiner Kallweit
` (2 preceding siblings ...)
2025-02-19 21:04 ` [PATCH net-next 3/8] net: phy: add getters for public members of struct phy_package_shared Heiner Kallweit
@ 2025-02-19 21:05 ` Heiner Kallweit
2025-02-19 21:06 ` [PATCH net-next 5/8] net: phy: micrel: " Heiner Kallweit
` (3 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Heiner Kallweit @ 2025-02-19 21:05 UTC (permalink / raw)
To: Andrew Lunn, Russell King - ARM Linux, Paolo Abeni,
Jakub Kicinski, Eric Dumazet, David Miller, Daniel Golle,
Qingfang Deng, SkyLake Huang, Matthias Brugger,
AngeloGioacchino Del Regno, Richard Cochran
Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek, linux-arm-msm
Use the new getters for members of struct phy_package_shared.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/qcom/qca807x.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/drivers/net/phy/qcom/qca807x.c b/drivers/net/phy/qcom/qca807x.c
index 3279de857..297086828 100644
--- a/drivers/net/phy/qcom/qca807x.c
+++ b/drivers/net/phy/qcom/qca807x.c
@@ -486,13 +486,16 @@ static int qca807x_read_status(struct phy_device *phydev)
static int qca807x_phy_package_probe_once(struct phy_device *phydev)
{
- struct phy_package_shared *shared = phydev->shared;
- struct qca807x_shared_priv *priv = shared->priv;
+ struct qca807x_shared_priv *priv;
unsigned int tx_drive_strength;
const char *package_mode_name;
+ struct device_node *np;
+
+ priv = phy_package_shared_get_priv(phydev);
+ np = phy_package_shared_get_node(phydev);
/* Default to 600mw if not defined */
- if (of_property_read_u32(shared->np, "qcom,tx-drive-strength-milliwatt",
+ if (of_property_read_u32(np, "qcom,tx-drive-strength-milliwatt",
&tx_drive_strength))
tx_drive_strength = 600;
@@ -541,7 +544,7 @@ static int qca807x_phy_package_probe_once(struct phy_device *phydev)
}
priv->package_mode = PHY_INTERFACE_MODE_NA;
- if (!of_property_read_string(shared->np, "qcom,package-mode",
+ if (!of_property_read_string(np, "qcom,package-mode",
&package_mode_name)) {
if (!strcasecmp(package_mode_name,
phy_modes(PHY_INTERFACE_MODE_PSGMII)))
@@ -558,10 +561,11 @@ static int qca807x_phy_package_probe_once(struct phy_device *phydev)
static int qca807x_phy_package_config_init_once(struct phy_device *phydev)
{
- struct phy_package_shared *shared = phydev->shared;
- struct qca807x_shared_priv *priv = shared->priv;
+ struct qca807x_shared_priv *priv;
int val, ret;
+ priv = phy_package_shared_get_priv(phydev);
+
/* Make sure PHY follow PHY package mode if enforced */
if (priv->package_mode != PHY_INTERFACE_MODE_NA &&
phydev->interface != priv->package_mode)
@@ -708,7 +712,6 @@ static int qca807x_probe(struct phy_device *phydev)
struct device_node *node = phydev->mdio.dev.of_node;
struct qca807x_shared_priv *shared_priv;
struct device *dev = &phydev->mdio.dev;
- struct phy_package_shared *shared;
struct qca807x_priv *priv;
int ret;
@@ -722,8 +725,7 @@ static int qca807x_probe(struct phy_device *phydev)
return ret;
}
- shared = phydev->shared;
- shared_priv = shared->priv;
+ shared_priv = phy_package_shared_get_priv(phydev);
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
--
2.48.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 5/8] net: phy: micrel: use new phy_package_shared getters
2025-02-19 21:01 [PATCH net-next 0/8] net: phy: move PHY package code to its own source file Heiner Kallweit
` (3 preceding siblings ...)
2025-02-19 21:05 ` [PATCH net-next 4/8] net: phy: qca807x: use new phy_package_shared getters Heiner Kallweit
@ 2025-02-19 21:06 ` Heiner Kallweit
2025-02-19 21:06 ` [PATCH net-next 6/8] net: phy: mtk-ge-soc: " Heiner Kallweit
` (2 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Heiner Kallweit @ 2025-02-19 21:06 UTC (permalink / raw)
To: Andrew Lunn, Russell King - ARM Linux, Paolo Abeni,
Jakub Kicinski, Eric Dumazet, David Miller, Daniel Golle,
Qingfang Deng, SkyLake Huang, Matthias Brugger,
AngeloGioacchino Del Regno, Richard Cochran
Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek, linux-arm-msm
Use the new getters for members of struct phy_package_shared.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/micrel.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 9c0b1c229..1705e043a 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -2632,7 +2632,9 @@ static int lan8814_ts_info(struct mii_timestamper *mii_ts, struct kernel_ethtool
{
struct kszphy_ptp_priv *ptp_priv = container_of(mii_ts, struct kszphy_ptp_priv, mii_ts);
struct phy_device *phydev = ptp_priv->phydev;
- struct lan8814_shared_priv *shared = phydev->shared->priv;
+ struct lan8814_shared_priv *shared;
+
+ shared = phy_package_shared_get_priv(phydev);
info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
SOF_TIMESTAMPING_RX_HARDWARE |
@@ -3653,9 +3655,11 @@ static int lan8814_gpio_process_cap(struct lan8814_shared_priv *shared)
static int lan8814_handle_gpio_interrupt(struct phy_device *phydev, u16 status)
{
- struct lan8814_shared_priv *shared = phydev->shared->priv;
+ struct lan8814_shared_priv *shared;
int ret;
+ shared = phy_package_shared_get_priv(phydev);
+
mutex_lock(&shared->shared_lock);
ret = lan8814_gpio_process_cap(shared);
mutex_unlock(&shared->shared_lock);
@@ -3864,7 +3868,9 @@ static void lan8814_ptp_init(struct phy_device *phydev)
static int lan8814_ptp_probe_once(struct phy_device *phydev)
{
- struct lan8814_shared_priv *shared = phydev->shared->priv;
+ struct lan8814_shared_priv *shared;
+
+ shared = phy_package_shared_get_priv(phydev);
/* Initialise shared lock for clock*/
mutex_init(&shared->shared_lock);
--
2.48.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 6/8] net: phy: mtk-ge-soc: use new phy_package_shared getters
2025-02-19 21:01 [PATCH net-next 0/8] net: phy: move PHY package code to its own source file Heiner Kallweit
` (4 preceding siblings ...)
2025-02-19 21:06 ` [PATCH net-next 5/8] net: phy: micrel: " Heiner Kallweit
@ 2025-02-19 21:06 ` Heiner Kallweit
2025-02-19 21:07 ` [PATCH net-next 7/8] net: phy: mscc: " Heiner Kallweit
2025-02-19 21:08 ` [PATCH net-next 8/8] net: phy: make struct phy_package_shared private to phylib Heiner Kallweit
7 siblings, 0 replies; 15+ messages in thread
From: Heiner Kallweit @ 2025-02-19 21:06 UTC (permalink / raw)
To: Andrew Lunn, Russell King - ARM Linux, Paolo Abeni,
Jakub Kicinski, Eric Dumazet, David Miller, Daniel Golle,
Qingfang Deng, SkyLake Huang, Matthias Brugger,
AngeloGioacchino Del Regno, Richard Cochran
Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek, linux-arm-msm
Use the new getters for members of struct phy_package_shared.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/mediatek/mtk-ge-soc.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/net/phy/mediatek/mtk-ge-soc.c b/drivers/net/phy/mediatek/mtk-ge-soc.c
index bdf99b327..c3ed97937 100644
--- a/drivers/net/phy/mediatek/mtk-ge-soc.c
+++ b/drivers/net/phy/mediatek/mtk-ge-soc.c
@@ -1190,9 +1190,11 @@ static int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index,
static bool mt7988_phy_led_get_polarity(struct phy_device *phydev, int led_num)
{
- struct mtk_socphy_shared *priv = phydev->shared->priv;
+ struct mtk_socphy_shared *priv;
u32 polarities;
+ priv = phy_package_shared_get_priv(phydev);
+
if (led_num == 0)
polarities = ~(priv->boottrap);
else
@@ -1229,11 +1231,13 @@ static int mt7988_phy_fix_leds_polarities(struct phy_device *phydev)
static int mt7988_phy_probe_shared(struct phy_device *phydev)
{
struct device_node *np = dev_of_node(&phydev->mdio.bus->dev);
- struct mtk_socphy_shared *shared = phydev->shared->priv;
+ struct mtk_socphy_shared *shared;
struct regmap *regmap;
u32 reg;
int ret;
+ shared = phy_package_shared_get_priv(phydev);
+
/* The LED0 of the 4 PHYs in MT7988 are wired to SoC pins LED_A, LED_B,
* LED_C and LED_D respectively. At the same time those pins are used to
* bootstrap configuration of the reference clock source (LED_A),
@@ -1280,7 +1284,7 @@ static int mt7988_phy_probe(struct phy_device *phydev)
return err;
}
- shared = phydev->shared->priv;
+ shared = phy_package_shared_get_priv(phydev);
priv = &shared->priv[phydev->mdio.addr];
phydev->priv = priv;
--
2.48.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 7/8] net: phy: mscc: use new phy_package_shared getters
2025-02-19 21:01 [PATCH net-next 0/8] net: phy: move PHY package code to its own source file Heiner Kallweit
` (5 preceding siblings ...)
2025-02-19 21:06 ` [PATCH net-next 6/8] net: phy: mtk-ge-soc: " Heiner Kallweit
@ 2025-02-19 21:07 ` Heiner Kallweit
2025-02-19 21:08 ` [PATCH net-next 8/8] net: phy: make struct phy_package_shared private to phylib Heiner Kallweit
7 siblings, 0 replies; 15+ messages in thread
From: Heiner Kallweit @ 2025-02-19 21:07 UTC (permalink / raw)
To: Andrew Lunn, Russell King - ARM Linux, Paolo Abeni,
Jakub Kicinski, Eric Dumazet, David Miller, Daniel Golle,
Qingfang Deng, SkyLake Huang, Matthias Brugger,
AngeloGioacchino Del Regno, Richard Cochran
Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek, linux-arm-msm
Use the new getters for members of struct phy_package_shared.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/mscc/mscc_ptp.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/net/phy/mscc/mscc_ptp.c b/drivers/net/phy/mscc/mscc_ptp.c
index 738a8822f..ca4203d6a 100644
--- a/drivers/net/phy/mscc/mscc_ptp.c
+++ b/drivers/net/phy/mscc/mscc_ptp.c
@@ -645,11 +645,12 @@ static int __vsc85xx_gettime(struct ptp_clock_info *info, struct timespec64 *ts)
{
struct vsc85xx_ptp *ptp = container_of(info, struct vsc85xx_ptp, caps);
struct phy_device *phydev = ptp->phydev;
- struct vsc85xx_shared_private *shared =
- (struct vsc85xx_shared_private *)phydev->shared->priv;
struct vsc8531_private *priv = phydev->priv;
+ struct vsc85xx_shared_private *shared;
u32 val;
+ shared = phy_package_shared_get_priv(phydev);
+
val = vsc85xx_ts_read_csr(phydev, PROCESSOR, MSCC_PHY_PTP_LTC_CTRL);
val |= PTP_LTC_CTRL_SAVE_ENA;
vsc85xx_ts_write_csr(phydev, PROCESSOR, MSCC_PHY_PTP_LTC_CTRL, val);
@@ -696,11 +697,12 @@ static int __vsc85xx_settime(struct ptp_clock_info *info,
{
struct vsc85xx_ptp *ptp = container_of(info, struct vsc85xx_ptp, caps);
struct phy_device *phydev = ptp->phydev;
- struct vsc85xx_shared_private *shared =
- (struct vsc85xx_shared_private *)phydev->shared->priv;
struct vsc8531_private *priv = phydev->priv;
+ struct vsc85xx_shared_private *shared;
u32 val;
+ shared = phy_package_shared_get_priv(phydev);
+
vsc85xx_ts_write_csr(phydev, PROCESSOR, MSCC_PHY_PTP_LTC_LOAD_SEC_MSB,
PTP_LTC_LOAD_SEC_MSB(ts->tv_sec));
vsc85xx_ts_write_csr(phydev, PROCESSOR, MSCC_PHY_PTP_LTC_LOAD_SEC_LSB,
@@ -1580,8 +1582,9 @@ int vsc8584_ptp_probe(struct phy_device *phydev)
int vsc8584_ptp_probe_once(struct phy_device *phydev)
{
- struct vsc85xx_shared_private *shared =
- (struct vsc85xx_shared_private *)phydev->shared->priv;
+ struct vsc85xx_shared_private *shared;
+
+ shared = phy_package_shared_get_priv(phydev);
/* Initialize shared GPIO lock */
mutex_init(&shared->gpio_lock);
--
2.48.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 8/8] net: phy: make struct phy_package_shared private to phylib
2025-02-19 21:01 [PATCH net-next 0/8] net: phy: move PHY package code to its own source file Heiner Kallweit
` (6 preceding siblings ...)
2025-02-19 21:07 ` [PATCH net-next 7/8] net: phy: mscc: " Heiner Kallweit
@ 2025-02-19 21:08 ` Heiner Kallweit
7 siblings, 0 replies; 15+ messages in thread
From: Heiner Kallweit @ 2025-02-19 21:08 UTC (permalink / raw)
To: Andrew Lunn, Russell King - ARM Linux, Paolo Abeni,
Jakub Kicinski, Eric Dumazet, David Miller, Daniel Golle,
Qingfang Deng, SkyLake Huang, Matthias Brugger,
AngeloGioacchino Del Regno, Richard Cochran
Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek, linux-arm-msm
Move definition of struct phy_package_shared to phy_package.c to
make it private to phylib.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/phy_package.c | 31 +++++++++++++++++++++++++++++++
include/linux/phy.h | 31 -------------------------------
2 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/drivers/net/phy/phy_package.c b/drivers/net/phy/phy_package.c
index 6955b4132..a8c3f26d2 100644
--- a/drivers/net/phy/phy_package.c
+++ b/drivers/net/phy/phy_package.c
@@ -6,6 +6,37 @@
#include <linux/of.h>
#include <linux/phy.h>
+/**
+ * struct phy_package_shared - Shared information in PHY packages
+ * @base_addr: Base PHY address of PHY package used to combine PHYs
+ * in one package and for offset calculation of phy_package_read/write
+ * @np: Pointer to the Device Node if PHY package defined in DT
+ * @refcnt: Number of PHYs connected to this shared data
+ * @flags: Initialization of PHY package
+ * @priv_size: Size of the shared private data @priv
+ * @priv: Driver private data shared across a PHY package
+ *
+ * Represents a shared structure between different phydev's in the same
+ * package, for example a quad PHY. See phy_package_join() and
+ * phy_package_leave().
+ */
+struct phy_package_shared {
+ u8 base_addr;
+ /* With PHY package defined in DT this points to the PHY package node */
+ struct device_node *np;
+ refcount_t refcnt;
+ unsigned long flags;
+ size_t priv_size;
+
+ /* private data pointer */
+ /* note that this pointer is shared between different phydevs and
+ * the user has to take care of appropriate locking. It is allocated
+ * and freed automatically by phy_package_join() and
+ * phy_package_leave().
+ */
+ void *priv;
+};
+
struct device_node *phy_package_shared_get_node(struct phy_device *phydev)
{
return phydev->shared->np;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index ce591307a..3008f31de 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -322,37 +322,6 @@ struct mdio_bus_stats {
struct u64_stats_sync syncp;
};
-/**
- * struct phy_package_shared - Shared information in PHY packages
- * @base_addr: Base PHY address of PHY package used to combine PHYs
- * in one package and for offset calculation of phy_package_read/write
- * @np: Pointer to the Device Node if PHY package defined in DT
- * @refcnt: Number of PHYs connected to this shared data
- * @flags: Initialization of PHY package
- * @priv_size: Size of the shared private data @priv
- * @priv: Driver private data shared across a PHY package
- *
- * Represents a shared structure between different phydev's in the same
- * package, for example a quad PHY. See phy_package_join() and
- * phy_package_leave().
- */
-struct phy_package_shared {
- u8 base_addr;
- /* With PHY package defined in DT this points to the PHY package node */
- struct device_node *np;
- refcount_t refcnt;
- unsigned long flags;
- size_t priv_size;
-
- /* private data pointer */
- /* note that this pointer is shared between different phydevs and
- * the user has to take care of appropriate locking. It is allocated
- * and freed automatically by phy_package_join() and
- * phy_package_leave().
- */
- void *priv;
-};
-
/**
* struct mii_bus - Represents an MDIO bus
*
--
2.48.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH net-next 2/8] net: phy: move PHY package related code from phy.h to phy_package.c
2025-02-19 21:03 ` [PATCH net-next 2/8] net: phy: move PHY package related code from phy.h to phy_package.c Heiner Kallweit
@ 2025-02-21 1:56 ` Andrew Lunn
2025-02-21 7:21 ` Heiner Kallweit
0 siblings, 1 reply; 15+ messages in thread
From: Andrew Lunn @ 2025-02-21 1:56 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Russell King - ARM Linux, Paolo Abeni, Jakub Kicinski,
Eric Dumazet, David Miller, Daniel Golle, Qingfang Deng,
SkyLake Huang, Matthias Brugger, AngeloGioacchino Del Regno,
Richard Cochran, netdev@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-mediatek,
linux-arm-msm
On Wed, Feb 19, 2025 at 10:03:50PM +0100, Heiner Kallweit wrote:
> Move PHY package related inline functions from phy.h to phy_package.c.
> While doing so remove locked versions phy_package_read() and
> phy_package_write() which have no user.
What combination of builtin and modules have you tried? Code like this
is often in the header because we get linker errors in some
configurations. It might be worth checking the versions of the
original patches from Christian to see if there was such issues.
Andrew
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next 2/8] net: phy: move PHY package related code from phy.h to phy_package.c
2025-02-21 1:56 ` Andrew Lunn
@ 2025-02-21 7:21 ` Heiner Kallweit
2025-02-25 9:05 ` Paolo Abeni
0 siblings, 1 reply; 15+ messages in thread
From: Heiner Kallweit @ 2025-02-21 7:21 UTC (permalink / raw)
To: Andrew Lunn
Cc: Russell King - ARM Linux, Paolo Abeni, Jakub Kicinski,
Eric Dumazet, David Miller, Daniel Golle, Qingfang Deng,
SkyLake Huang, Matthias Brugger, AngeloGioacchino Del Regno,
Richard Cochran, netdev@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-mediatek,
linux-arm-msm
On 21.02.2025 02:56, Andrew Lunn wrote:
> On Wed, Feb 19, 2025 at 10:03:50PM +0100, Heiner Kallweit wrote:
>> Move PHY package related inline functions from phy.h to phy_package.c.
>> While doing so remove locked versions phy_package_read() and
>> phy_package_write() which have no user.
>
> What combination of builtin and modules have you tried? Code like this
> is often in the header because we get linker errors in some
> configurations. It might be worth checking the versions of the
> original patches from Christian to see if there was such issues.
>
The PHY package functions are used by PHY drivers only, all of them
have a Kconfig dependency on PHYLIB. I don't see a scenario where we
could have the problem you're mentioning. But right, the PHY package
function declarations are a candidate for a new header file not to
be used outside drivers/net/phy.
> Andrew
Heiner
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next 3/8] net: phy: add getters for public members of struct phy_package_shared
2025-02-19 21:04 ` [PATCH net-next 3/8] net: phy: add getters for public members of struct phy_package_shared Heiner Kallweit
@ 2025-02-25 2:01 ` Jakub Kicinski
2025-02-25 9:12 ` Paolo Abeni
0 siblings, 1 reply; 15+ messages in thread
From: Jakub Kicinski @ 2025-02-25 2:01 UTC (permalink / raw)
To: Heiner Kallweit, Andrew Lunn, Russell King - ARM Linux
Cc: Paolo Abeni, Eric Dumazet, David Miller, Daniel Golle,
Qingfang Deng, SkyLake Huang, Matthias Brugger,
AngeloGioacchino Del Regno, Richard Cochran,
netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek, linux-arm-msm
On Wed, 19 Feb 2025 22:04:47 +0100 Heiner Kallweit wrote:
> +struct device_node *phy_package_shared_get_node(struct phy_device *phydev);
> +void *phy_package_shared_get_priv(struct phy_device *phydev);
A bit sad that none of the users can fit in a line with this naming.
Isn't "shared" implied by "package" here ?
How would you feel about phy_package_get_priv() ?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next 2/8] net: phy: move PHY package related code from phy.h to phy_package.c
2025-02-21 7:21 ` Heiner Kallweit
@ 2025-02-25 9:05 ` Paolo Abeni
0 siblings, 0 replies; 15+ messages in thread
From: Paolo Abeni @ 2025-02-25 9:05 UTC (permalink / raw)
To: Heiner Kallweit, Andrew Lunn
Cc: Russell King - ARM Linux, Jakub Kicinski, Eric Dumazet,
David Miller, Daniel Golle, Qingfang Deng, SkyLake Huang,
Matthias Brugger, AngeloGioacchino Del Regno, Richard Cochran,
netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek, linux-arm-msm
On 2/21/25 8:21 AM, Heiner Kallweit wrote:
> On 21.02.2025 02:56, Andrew Lunn wrote:
>> On Wed, Feb 19, 2025 at 10:03:50PM +0100, Heiner Kallweit wrote:
>>> Move PHY package related inline functions from phy.h to phy_package.c.
>>> While doing so remove locked versions phy_package_read() and
>>> phy_package_write() which have no user.
>>
>> What combination of builtin and modules have you tried? Code like this
>> is often in the header because we get linker errors in some
>> configurations. It might be worth checking the versions of the
>> original patches from Christian to see if there was such issues.
>>
> The PHY package functions are used by PHY drivers only, all of them
> have a Kconfig dependency on PHYLIB. I don't see a scenario where we
> could have the problem you're mentioning. But right, the PHY package
> function declarations are a candidate for a new header file not to
> be used outside drivers/net/phy.
IMHO it's easy that some corner case will pass unnoticed until some
build breakage is reported. I suggest to keep such functions in a
(private) header from the start.
Thanks,
Paolo
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next 3/8] net: phy: add getters for public members of struct phy_package_shared
2025-02-25 2:01 ` Jakub Kicinski
@ 2025-02-25 9:12 ` Paolo Abeni
2025-02-27 21:06 ` Heiner Kallweit
0 siblings, 1 reply; 15+ messages in thread
From: Paolo Abeni @ 2025-02-25 9:12 UTC (permalink / raw)
To: Jakub Kicinski, Heiner Kallweit, Andrew Lunn,
Russell King - ARM Linux
Cc: Eric Dumazet, David Miller, Daniel Golle, Qingfang Deng,
SkyLake Huang, Matthias Brugger, AngeloGioacchino Del Regno,
Richard Cochran, netdev@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-mediatek,
linux-arm-msm
On 2/25/25 3:01 AM, Jakub Kicinski wrote:
> On Wed, 19 Feb 2025 22:04:47 +0100 Heiner Kallweit wrote:
>> +struct device_node *phy_package_shared_get_node(struct phy_device *phydev);
>> +void *phy_package_shared_get_priv(struct phy_device *phydev);
>
> A bit sad that none of the users can fit in a line with this naming.
> Isn't "shared" implied by "package" here ?
> How would you feel about phy_package_get_priv() ?
FWIW I personally agree the latter would be a better name.
@Heiner: could you please give that naming schema a shot here?
/P
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next 3/8] net: phy: add getters for public members of struct phy_package_shared
2025-02-25 9:12 ` Paolo Abeni
@ 2025-02-27 21:06 ` Heiner Kallweit
0 siblings, 0 replies; 15+ messages in thread
From: Heiner Kallweit @ 2025-02-27 21:06 UTC (permalink / raw)
To: Paolo Abeni, Jakub Kicinski, Andrew Lunn,
Russell King - ARM Linux
Cc: Eric Dumazet, David Miller, Daniel Golle, Qingfang Deng,
SkyLake Huang, Matthias Brugger, AngeloGioacchino Del Regno,
Richard Cochran, netdev@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-mediatek,
linux-arm-msm
On 25.02.2025 10:12, Paolo Abeni wrote:
> On 2/25/25 3:01 AM, Jakub Kicinski wrote:
>> On Wed, 19 Feb 2025 22:04:47 +0100 Heiner Kallweit wrote:
>>> +struct device_node *phy_package_shared_get_node(struct phy_device *phydev);
>>> +void *phy_package_shared_get_priv(struct phy_device *phydev);
>>
>> A bit sad that none of the users can fit in a line with this naming.
>> Isn't "shared" implied by "package" here ?
>> How would you feel about phy_package_get_priv() ?
>
> FWIW I personally agree the latter would be a better name.
>
> @Heiner: could you please give that naming schema a shot here?
>
> /P
>
Sure. I'll submit a v2 with the suggested changes.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2025-02-27 21:05 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-19 21:01 [PATCH net-next 0/8] net: phy: move PHY package code to its own source file Heiner Kallweit
2025-02-19 21:03 ` [PATCH net-next 1/8] net: phy: move PHY package code from phy_device.c to " Heiner Kallweit
2025-02-19 21:03 ` [PATCH net-next 2/8] net: phy: move PHY package related code from phy.h to phy_package.c Heiner Kallweit
2025-02-21 1:56 ` Andrew Lunn
2025-02-21 7:21 ` Heiner Kallweit
2025-02-25 9:05 ` Paolo Abeni
2025-02-19 21:04 ` [PATCH net-next 3/8] net: phy: add getters for public members of struct phy_package_shared Heiner Kallweit
2025-02-25 2:01 ` Jakub Kicinski
2025-02-25 9:12 ` Paolo Abeni
2025-02-27 21:06 ` Heiner Kallweit
2025-02-19 21:05 ` [PATCH net-next 4/8] net: phy: qca807x: use new phy_package_shared getters Heiner Kallweit
2025-02-19 21:06 ` [PATCH net-next 5/8] net: phy: micrel: " Heiner Kallweit
2025-02-19 21:06 ` [PATCH net-next 6/8] net: phy: mtk-ge-soc: " Heiner Kallweit
2025-02-19 21:07 ` [PATCH net-next 7/8] net: phy: mscc: " Heiner Kallweit
2025-02-19 21:08 ` [PATCH net-next 8/8] net: phy: make struct phy_package_shared private to phylib Heiner Kallweit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).