net: phy: move PHY package code to its own source file
Subsystems (6)
Heiner Kallweit
maintainerv2 cover net: phy: move PHY package code to its own source file
This series contributes to cleaning up phylib by moving PHY package related code to its own source file.
v2:
- rename the getters
- add a new header file phylib.h, which is used by PHY drivers only
Heiner Kallweit (8):
net: phy: move PHY package code from phy_device.c to own source file
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: mediatek: use new phy_package_shared getters
net: phy: mscc: use new phy_package_shared getters
net: phy: move PHY package related code from phy.h to phy_package.c
net: phy: remove remaining PHY package related definitions from phy.h
drivers/net/phy/Makefile | 3 +- drivers/net/phy/mediatek/mtk-ge-soc.c | 7 +- drivers/net/phy/micrel.c | 9 +- drivers/net/phy/mscc/mscc_main.c | 2 + drivers/net/phy/mscc/mscc_ptp.c | 14 +- drivers/net/phy/phy-core.c | 1 + drivers/net/phy/phy_device.c | 237 ----------------- drivers/net/phy/phy_package.c | 350 ++++++++++++++++++++++++++ drivers/net/phy/phylib-internal.h | 2 + drivers/net/phy/phylib.h | 28 +++ drivers/net/phy/qcom/qca807x.c | 16 +- include/linux/phy.h | 124 --------- 12 files changed, 409 insertions(+), 384 deletions(-) create mode 100644 drivers/net/phy/phy_package.c create mode 100644 drivers/net/phy/phylib.h
Signature · 1 line
2.48.1
Heiner Kallweit
maintainerPATCH v2 1/8 net: phy: move PHY package code from phy_device.c to own source file
This patch is the first step in moving the PHY package related code to its own source file. No functional change intended.
--- 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
drivers/net/phy/Makefile +2 -1
@@ -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
drivers/net/phy/phy_device.c +0 -237
243 lines not on this page · raw message
drivers/net/phy/phy_package.c new file +244 -0
244 lines not on this page · raw message
Signature · 1 line
2.48.1
Heiner Kallweit
maintainerPATCH v2 2/8 net: phy: add getters for public members in struct phy_package_shared
In reply to Heiner KallweitAdd getters for public members, this prepares for making struct phy_package_shared private to phylib. Declare the getters in a new header file phylib.h, which will be used by PHY drivers only.
---
v2:
- rename the getters, making the names shorter
- add header phylib.h
--- drivers/net/phy/phy_package.c | 14 ++++++++++++++ drivers/net/phy/phylib.h | 15 +++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 drivers/net/phy/phylib.h
drivers/net/phy/phy_package.c +14 -0
@@ -6,6 +6,20 @@#include <linux/of.h> #include <linux/phy.h> +#include "phylib.h" + +struct device_node *phy_package_get_node (struct phy_device *phydev) +{ +return phydev->shared->np; +} +EXPORT_SYMBOL_GPL (phy_package_get_node); + +void *phy_package_get_priv (struct phy_device *phydev) +{ +return phydev->shared->priv; +} +EXPORT_SYMBOL_GPL (phy_package_get_priv); +/** * phy_package_join - join a common PHY group * @phydev: target phy_device struct
drivers/net/phy/phylib.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* phylib header +*/ + +#ifndef __PHYLIB_H +#define __PHYLIB_H + +struct device_node ; +struct phy_device ; + +struct device_node *phy_package_get_node (struct phy_device *phydev); +void *phy_package_get_priv (struct phy_device *phydev); + +#endif /* __PHYLIB_H */
Signature · 1 line
2.48.1
Heiner Kallweit
maintainerPATCH v2 3/8 net: phy: qca807x: use new phy_package_shared getters
In reply to Heiner KallweitUse the new getters for members of struct phy_package_shared.
--- drivers/net/phy/qcom/qca807x.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/net/phy/qcom/qca807x.c +7 -9
@@ -15,6 +15,7 @@#include <linux/gpio/driver.h> #include <linux/sfp.h> +#include "../phylib.h" #include "qcom.h" #define QCA807X_CHIP_CONFIGURATION 0x1f
@@ -486,13 +487,13 @@ 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 =phy_package_get_priv (phydev); +struct device_node *np =phy_package_get_node (phydev);unsigned int tx_drive_strength;const char *package_mode_name;/* 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 +542,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,8 +559,7 @@ 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 =phy_package_get_priv (phydev);int val, ret;/* Make sure PHY follow PHY package mode if enforced */
@@ -708,7 +708,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 +721,7 @@ static int qca807x_probe(struct phy_device *phydev)return ret; } - shared = phydev->shared; - shared_priv = shared->priv; + shared_priv =phy_package_get_priv (phydev); priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );if (!priv)
Signature · 1 line
2.48.1
Heiner Kallweit
maintainerPATCH v2 4/8 net: phy: micrel: use new phy_package_shared getters
In reply to Heiner KallweitUse the new getters for members of struct phy_package_shared.
--- drivers/net/phy/micrel.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/phy/micrel.c +5 -4
@@ -34,6 +34,8 @@#include <linux/net_tstamp.h> #include <linux/gpio/consumer.h> +#include "phylib.h" +/* Operation Mode Strap Override */ #define MII_KSZPHY_OMSO 0x16#define KSZPHY_OMSO_FACTORY_TEST BIT(15)
@@ -2631,8 +2633,7 @@ static void lan8814_ptp_tx_ts_get(struct phy_device *phydev,static int lan8814_ts_info (struct mii_timestamper *mii_ts,struct kernel_ethtool_ts_info *info) { 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 =phy_package_get_priv (ptp_priv->phydev); info->so_timestamping =SOF_TIMESTAMPING_TX_HARDWARE | SOF_TIMESTAMPING_RX_HARDWARE |
@@ -3653,7 +3654,7 @@ 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 =phy_package_get_priv (phydev);int ret;mutex_lock (&shared->shared_lock);
@@ -3864,7 +3865,7 @@ 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 =phy_package_get_priv (phydev);/* Initialise shared lock for clock*/ mutex_init (&shared->shared_lock);
Signature · 1 line
2.48.1
Heiner Kallweit
maintainerPATCH v2 5/8 net: phy: mediatek: use new phy_package_shared getters
In reply to Heiner KallweitUse the new getters for members of struct phy_package_shared.
--- drivers/net/phy/mediatek/mtk-ge-soc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/phy/mediatek/mtk-ge-soc.c +4 -3
@@ -8,6 +8,7 @@#include <linux/phy.h> #include <linux/regmap.h> +#include "../phylib.h" #include "mtk.h" #define MTK_GPHY_ID_MT7981 0x03a29461
@@ -1278,7 +1279,7 @@ 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 =phy_package_get_priv (phydev);u32 polarities;if (led_num ==0 )
@@ -1317,7 +1318,7 @@ 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 =phy_package_get_priv (phydev);struct regmap *regmap;u32 reg;int ret;
@@ -1368,7 +1369,7 @@ static int mt7988_phy_probe(struct phy_device *phydev)return err; } - shared = phydev->shared->priv; + shared =phy_package_get_priv (phydev); priv = &shared->priv[phydev->mdio.addr]; phydev->priv = priv;
Signature · 1 line
2.48.1
Heiner Kallweit
maintainerPATCH v2 6/8 net: phy: mscc: use new phy_package_shared getters
In reply to Heiner KallweitUse the new getters for members of struct phy_package_shared.
--- drivers/net/phy/mscc/mscc_ptp.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/phy/mscc/mscc_ptp.c +8 -6
@@ -17,6 +17,7 @@#include <linux/udp.h> #include <linux/unaligned.h> +#include "../phylib.h" #include "mscc.h" #include "mscc_ptp.h"
@@ -645,11 +646,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_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 +698,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_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 +1583,7 @@ 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 =phy_package_get_priv (phydev);/* Initialize shared GPIO lock */ mutex_init (&shared->gpio_lock);
Signature · 1 line
2.48.1
Heiner Kallweit
maintainerPATCH v2 7/8 net: phy: move PHY package related code from phy.h to phy_package.c
In reply to Heiner KallweitMove 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.
--- drivers/net/phy/mscc/mscc_main.c | 2 + drivers/net/phy/phy-core.c | 1 + drivers/net/phy/phy_package.c | 61 ++++++++++++++++++++++ drivers/net/phy/phylib-internal.h | 2 + drivers/net/phy/phylib.h | 6 +++ include/linux/phy.h | 86 ------------------------------- 6 files changed, 72 insertions(+), 86 deletions(-)
drivers/net/phy/mscc/mscc_main.c +2 -0
@@ -17,6 +17,8 @@#include <linux/of.h> #include <linux/netdevice.h> #include <dt-bindings/net/mscc-phy-vsc8531.h> + +#include "../phylib.h" #include "mscc_serdes.h" #include "mscc.h"
drivers/net/phy/phy-core.c +1 -0
@@ -6,6 +6,7 @@#include <linux/phy.h> #include <linux/of.h> +#include "phylib.h" #include "phylib-internal.h" /**
drivers/net/phy/phy_package.c +61 -0
73 lines not on this page · raw message
drivers/net/phy/phylib-internal.h +2 -0
@@ -20,6 +20,8 @@ void of_set_phy_timing_role(struct phy_device *phydev);int phy_speed_down_core (struct phy_device *phydev);void phy_check_downshift (struct phy_device *phydev); +int phy_package_address (struct phy_device *phydev,unsigned int addr_offset); +int genphy_c45_read_eee_adv (struct phy_device *phydev,unsigned long *adv);#endif /* __PHYLIB_INTERNAL_H */
drivers/net/phy/phylib.h +6 -0
@@ -11,5 +11,11 @@ struct phy_device;struct device_node *phy_package_get_node (struct phy_device *phydev);void *phy_package_get_priv (struct phy_device *phydev); +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); +bool phy_package_init_once (struct phy_device *phydev); +bool phy_package_probe_once (struct phy_device *phydev);#endif /* __PHYLIB_H */
include/linux/phy.h +0 -86
104 lines not on this page · raw message
Signature · 1 line
2.48.1
kernel test robot
build botRe: [PATCH net-next v2 7/8] net: phy: move PHY package related code from phy.h to phy_package.c
kernel test robot noticed the following build errors:
Hi Heiner,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Heiner-Kallweit/net-phy-move-PHY-package-code-from-phy_device-c-to-own-source-file/20250301-055302 base: net-next/main patch link: https://lore.kernel.org/r/edba99c5-0f95-40bd-8398-98d811068369%40gmail.com patch subject: [PATCH net-next v2 7/8] net: phy: move PHY package related code from phy.h to phy_package.c config: arc-randconfig-001-20250302 (https://download.01.org/0day-ci/archive/20250302/[email protected]/config) compiler: arceb-elf-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250302/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/net/phy/bcm54140.c: In function 'bcm54140_base_read_rdb':
>> drivers/net/phy/bcm54140.c:436:15: error: implicit declaration of function '__phy_package_write'; did you mean '__phy_package_write_mmd'? [-Werror=implicit-function-declaration]
436 | ret = __phy_package_write(phydev, BCM54140_BASE_ADDR,
| ^~~~~~~~~~~~~~~~~~~
| __phy_package_write_mmd
>> drivers/net/phy/bcm54140.c:441:15: error: implicit declaration of function '__phy_package_read'; did you mean '__phy_package_read_mmd'? [-Werror=implicit-function-declaration]
441 | ret = __phy_package_read(phydev, BCM54140_BASE_ADDR,
| ^~~~~~~~~~~~~~~~~~
| __phy_package_read_mmdcc1: some warnings being treated as errors
vim +436 drivers/net/phy/bcm54140.c
4406d36dfdf1fb Michael Walle 2020-04-20 430
6937602ed3f9eb Michael Walle 2020-04-20 431 static int bcm54140_base_read_rdb(struct phy_device *phydev, u16 rdb)
6937602ed3f9eb Michael Walle 2020-04-20 432 {
6937602ed3f9eb Michael Walle 2020-04-20 433 int ret;
6937602ed3f9eb Michael Walle 2020-04-20 434
dc9989f173289f Michael Walle 2020-05-06 435 phy_lock_mdio_bus(phydev);
9eea577eb1155f Christian Marangi 2023-12-15 @436 ret = __phy_package_write(phydev, BCM54140_BASE_ADDR,
9eea577eb1155f Christian Marangi 2023-12-15 437 MII_BCM54XX_RDB_ADDR, rdb);
6937602ed3f9eb Michael Walle 2020-04-20 438 if (ret < 0)
6937602ed3f9eb Michael Walle 2020-04-20 439 goto out;
6937602ed3f9eb Michael Walle 2020-04-20 440
9eea577eb1155f Christian Marangi 2023-12-15 @441 ret = __phy_package_read(phydev, BCM54140_BASE_ADDR,
9eea577eb1155f Christian Marangi 2023-12-15 442 MII_BCM54XX_RDB_DATA);
6937602ed3f9eb Michael Walle 2020-04-20 443
6937602ed3f9eb Michael Walle 2020-04-20 444 out:
dc9989f173289f Michael Walle 2020-05-06 445 phy_unlock_mdio_bus(phydev);
6937602ed3f9eb Michael Walle 2020-04-20 446 return ret;
6937602ed3f9eb Michael Walle 2020-04-20 447 }
6937602ed3f9eb Michael Walle 2020-04-20 448 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH net-next v2 7/8] net: phy: move PHY package related code from phy.h to phy_package.c
In reply to Heiner Kallweitkernel test robot noticed the following build errors:
Hi Heiner,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Heiner-Kallweit/net-phy-move-PHY-package-code-from-phy_device-c-to-own-source-file/20250301-055302 base: net-next/main patch link: https://lore.kernel.org/r/edba99c5-0f95-40bd-8398-98d811068369%40gmail.com patch subject: [PATCH net-next v2 7/8] net: phy: move PHY package related code from phy.h to phy_package.c config: loongarch-randconfig-001-20250302 (https://download.01.org/0day-ci/archive/20250302/[email protected]/config) compiler: loongarch64-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250302/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/net/phy/bcm54140.c: In function 'bcm54140_base_read_rdb':
drivers/net/phy/bcm54140.c:436:15: error: implicit declaration of function '__phy_package_write'; did you mean '__phy_package_write_mmd'? [-Wimplicit-function-declaration]
436 | ret = __phy_package_write(phydev, BCM54140_BASE_ADDR,
| ^~~~~~~~~~~~~~~~~~~
| __phy_package_write_mmd
drivers/net/phy/bcm54140.c:441:15: error: implicit declaration of function '__phy_package_read'; did you mean '__phy_package_read_mmd'? [-Wimplicit-function-declaration]
441 | ret = __phy_package_read(phydev, BCM54140_BASE_ADDR,
| ^~~~~~~~~~~~~~~~~~
| __phy_package_read_mmd
drivers/net/phy/bcm54140.c: In function 'bcm54140_probe':
>> drivers/net/phy/bcm54140.c:599:13: error: implicit declaration of function 'phy_package_init_once'; did you mean 'phy_package_write_mmd'? [-Wimplicit-function-declaration]
599 | if (phy_package_init_once(phydev)) {
| ^~~~~~~~~~~~~~~~~~~~~
| phy_package_write_mmdvim +599 drivers/net/phy/bcm54140.c
6937602ed3f9ebd Michael Walle 2020-04-20 578
6937602ed3f9ebd Michael Walle 2020-04-20 579 static int bcm54140_probe(struct phy_device *phydev)
6937602ed3f9ebd Michael Walle 2020-04-20 580 {
6937602ed3f9ebd Michael Walle 2020-04-20 581 struct bcm54140_priv *priv;
6937602ed3f9ebd Michael Walle 2020-04-20 582 int ret;
6937602ed3f9ebd Michael Walle 2020-04-20 583
6937602ed3f9ebd Michael Walle 2020-04-20 584 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
6937602ed3f9ebd Michael Walle 2020-04-20 585 if (!priv)
6937602ed3f9ebd Michael Walle 2020-04-20 586 return -ENOMEM;
6937602ed3f9ebd Michael Walle 2020-04-20 587
6937602ed3f9ebd Michael Walle 2020-04-20 588 phydev->priv = priv;
6937602ed3f9ebd Michael Walle 2020-04-20 589
6937602ed3f9ebd Michael Walle 2020-04-20 590 ret = bcm54140_get_base_addr_and_port(phydev);
6937602ed3f9ebd Michael Walle 2020-04-20 591 if (ret)
6937602ed3f9ebd Michael Walle 2020-04-20 592 return ret;
6937602ed3f9ebd Michael Walle 2020-04-20 593
dc9989f173289f3 Michael Walle 2020-05-06 594 devm_phy_package_join(&phydev->mdio.dev, phydev, priv->base_addr, 0);
dc9989f173289f3 Michael Walle 2020-05-06 595
4406d36dfdf1fbd Michael Walle 2020-04-20 596 #if IS_ENABLED(CONFIG_HWMON)
4406d36dfdf1fbd Michael Walle 2020-04-20 597 mutex_init(&priv->alarm_lock);
4406d36dfdf1fbd Michael Walle 2020-04-20 598
dc9989f173289f3 Michael Walle 2020-05-06 @599 if (phy_package_init_once(phydev)) {
4406d36dfdf1fbd Michael Walle 2020-04-20 600 ret = bcm54140_probe_once(phydev);
4406d36dfdf1fbd Michael Walle 2020-04-20 601 if (ret)
4406d36dfdf1fbd Michael Walle 2020-04-20 602 return ret;
4406d36dfdf1fbd Michael Walle 2020-04-20 603 }
4406d36dfdf1fbd Michael Walle 2020-04-20 604 #endif
4406d36dfdf1fbd Michael Walle 2020-04-20 605
6937602ed3f9ebd Michael Walle 2020-04-20 606 phydev_dbg(phydev, "probed (port %d, base PHY address %d)\n",
6937602ed3f9ebd Michael Walle 2020-04-20 607 priv->port, priv->base_addr);
6937602ed3f9ebd Michael Walle 2020-04-20 608
6937602ed3f9ebd Michael Walle 2020-04-20 609 return 0;
6937602ed3f9ebd Michael Walle 2020-04-20 610 }
6937602ed3f9ebd Michael Walle 2020-04-20 611 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Heiner Kallweit
maintainerPATCH v2 8/8 net: phy: remove remaining PHY package related definitions from phy.h
In reply to Heiner KallweitMove definition of struct phy_package_shared to phy_package.c, and move remaining PHY package related declarations from phy.h to phylib.h, thus making them accessible for PHY drivers only.
--- drivers/net/phy/phy_package.c | 31 ++++++++++++++++++++++++++++ drivers/net/phy/phylib.h | 7 +++++++ include/linux/phy.h | 38 ----------------------------------- 3 files changed, 38 insertions(+), 38 deletions(-)
drivers/net/phy/phy_package.c +31 -0
@@ -9,6 +9,37 @@#include "phylib.h" #include "phylib-internal.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_get_node (struct phy_device *phydev) {return phydev->shared->np;
drivers/net/phy/phylib.h +7 -0
@@ -17,5 +17,12 @@ int __phy_package_write(struct phy_device *phydev, unsigned int addr_offset, u32 regnum, u16 val);bool phy_package_init_once (struct phy_device *phydev);bool phy_package_probe_once (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); +int devm_phy_package_join (struct device *dev,struct phy_device *phydev, +int base_addr,size_t priv_size); +int devm_of_phy_package_join (struct device *dev,struct phy_device *phydev, +size_t priv_size);#endif /* __PHYLIB_H */
include/linux/phy.h +0 -38
@@ -319,37 +319,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 *
@@ -2109,13 +2078,6 @@ 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); -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); -int devm_phy_package_join (struct device *dev,struct phy_device *phydev, -int base_addr,size_t priv_size); -int devm_of_phy_package_join (struct device *dev,struct phy_device *phydev, -size_t priv_size);int __init mdio_bus_init (void );void mdio_bus_exit (void );
Signature · 1 line
2.48.1
kernel test robot
build botRe: [PATCH net-next v2 8/8] net: phy: remove remaining PHY package related definitions from phy.h
kernel test robot noticed the following build errors:
Hi Heiner,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Heiner-Kallweit/net-phy-move-PHY-package-code-from-phy_device-c-to-own-source-file/20250301-055302 base: net-next/main patch link: https://lore.kernel.org/r/6ad490fa-61ad-48b8-9660-bb525f756f41%40gmail.com patch subject: [PATCH net-next v2 8/8] net: phy: remove remaining PHY package related definitions from phy.h config: arc-randconfig-001-20250302 (https://download.01.org/0day-ci/archive/20250302/[email protected]/config) compiler: arceb-elf-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250302/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/net/phy/bcm54140.c: In function 'bcm54140_base_read_rdb':
drivers/net/phy/bcm54140.c:436:15: error: implicit declaration of function '__phy_package_write'; did you mean '__phy_package_write_mmd'? [-Werror=implicit-function-declaration]
436 | ret = __phy_package_write(phydev, BCM54140_BASE_ADDR,
| ^~~~~~~~~~~~~~~~~~~
| __phy_package_write_mmd
drivers/net/phy/bcm54140.c:441:15: error: implicit declaration of function '__phy_package_read'; did you mean '__phy_package_read_mmd'? [-Werror=implicit-function-declaration]
441 | ret = __phy_package_read(phydev, BCM54140_BASE_ADDR,
| ^~~~~~~~~~~~~~~~~~
| __phy_package_read_mmd
drivers/net/phy/bcm54140.c: In function 'bcm54140_probe':
>> drivers/net/phy/bcm54140.c:594:9: error: implicit declaration of function 'devm_phy_package_join' [-Werror=implicit-function-declaration]
594 | devm_phy_package_join(&phydev->mdio.dev, phydev, priv->base_addr, 0);
| ^~~~~~~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +/devm_phy_package_join +594 drivers/net/phy/bcm54140.c
6937602ed3f9eb Michael Walle 2020-04-20 578
6937602ed3f9eb Michael Walle 2020-04-20 579 static int bcm54140_probe(struct phy_device *phydev)
6937602ed3f9eb Michael Walle 2020-04-20 580 {
6937602ed3f9eb Michael Walle 2020-04-20 581 struct bcm54140_priv *priv;
6937602ed3f9eb Michael Walle 2020-04-20 582 int ret;
6937602ed3f9eb Michael Walle 2020-04-20 583
6937602ed3f9eb Michael Walle 2020-04-20 584 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
6937602ed3f9eb Michael Walle 2020-04-20 585 if (!priv)
6937602ed3f9eb Michael Walle 2020-04-20 586 return -ENOMEM;
6937602ed3f9eb Michael Walle 2020-04-20 587
6937602ed3f9eb Michael Walle 2020-04-20 588 phydev->priv = priv;
6937602ed3f9eb Michael Walle 2020-04-20 589
6937602ed3f9eb Michael Walle 2020-04-20 590 ret = bcm54140_get_base_addr_and_port(phydev);
6937602ed3f9eb Michael Walle 2020-04-20 591 if (ret)
6937602ed3f9eb Michael Walle 2020-04-20 592 return ret;
6937602ed3f9eb Michael Walle 2020-04-20 593 dc9989f173289f Michael Walle 2020-05-06 @594 devm_phy_package_join(&phydev->mdio.dev, phydev, priv->base_addr, 0);dc9989f173289f Michael Walle 2020-05-06 595
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Heiner Kallweit
maintainerQuoted 17 lines · Heiner Kallweit
This series contributes to cleaning up phylib by moving PHY package related code to its own source file.
v2:
- rename the getters
- add a new header filephylib.h, which is used by PHY drivers onlyHeiner Kallweit (8):
net: phy: move PHY package code fromphy_device.cto own source file
net: phy: add getters for public members in structphy_package_shared
net: phy: qca807x: use newphy_package_sharedgetters
net: phy: micrel: use newphy_package_sharedgetters
net: phy: mediatek: use newphy_package_sharedgetters
net: phy: mscc: use newphy_package_sharedgetters
net: phy: move PHY package related code fromphy.htophy_package.c
net: phy: remove remaining PHY package related definitions fromphy.h
Quoted 16 lines
drivers/net/phy/Makefile | 3 +- drivers/net/phy/mediatek/mtk-ge-soc.c | 7 +- drivers/net/phy/micrel.c | 9 +- drivers/net/phy/mscc/mscc_main.c | 2 + drivers/net/phy/mscc/mscc_ptp.c | 14 +- drivers/net/phy/phy-core.c | 1 + drivers/net/phy/phy_device.c | 237 ----------------- drivers/net/phy/phy_package.c | 350 ++++++++++++++++++++++++++ drivers/net/phy/phylib-internal.h | 2 + drivers/net/phy/phylib.h | 28 +++ drivers/net/phy/qcom/qca807x.c | 16 +- include/linux/phy.h | 124 --------- 12 files changed, 409 insertions(+), 384 deletions(-) create mode 100644 drivers/net/phy/phy_package.c create mode 100644 drivers/net/phy/phylib.h
CI is complaining about one issue in patch 7 which I have to correct. Will wait for other feedback before resubmitting.
--
pw-bot: cr