net: phy: microchip_rds_ptp: simplify allocation
Subsystems (3)
PATCH 1/1 net: phy: microchip_rds_ptp: simplify allocation
Simplifies allocations by using a flexible array member in this struct.
Remove memset as it's now allocated by kzalloc.
Signed-off-by Rosen Penev <[email protected]>
--- drivers/net/phy/microchip_rds_ptp.c | 10 ++-------- drivers/net/phy/microchip_rds_ptp.h | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/net/phy/microchip_rds_ptp.c +2 -8
@@ -1246,7 +1246,8 @@ struct mchp_rds_ptp_clock *mchp_rds_ptp_probe(struct phy_device *phydev, u8 mmd,struct mchp_rds_ptp_clock *clock;int rc; - clock =devm_kzalloc (&phydev->mdio.dev,sizeof (*clock),GFP_KERNEL ); + clock =devm_kzalloc (&phydev->mdio.dev, +struct_size (clock, pin_config,MCHP_RDS_PTP_N_PIN ),GFP_KERNEL );if (!clock)return ERR_PTR (-ENOMEM );
@@ -1255,17 +1256,10 @@ struct mchp_rds_ptp_clock *mchp_rds_ptp_probe(struct phy_device *phydev, u8 mmd, clock->mmd = mmd;mutex_init (&clock->ptp_lock); - clock->pin_config =devm_kmalloc_array (&phydev->mdio.dev, -MCHP_RDS_PTP_N_PIN , -sizeof (*clock->pin_config), -GFP_KERNEL ); -if (!clock->pin_config) -return ERR_PTR (-ENOMEM );for (int i =0 ; i <MCHP_RDS_PTP_N_PIN ; ++i) {struct ptp_pin_desc *p = &clock->pin_config[i]; -memset (p,0 ,sizeof (*p));snprintf (p->name,sizeof (p->name),"pin%d" , i); p->index = i; p->func =PTP_PF_NONE ;
drivers/net/phy/microchip_rds_ptp.h +1 -1
@@ -199,7 +199,7 @@ struct mchp_rds_ptp_clock {u8 mmd;int mchp_rds_ptp_event;int event_pin; -struct ptp_pin_desc *pin_config; +struct ptp_pin_desc pin_config[]; };struct mchp_rds_ptp_rx_ts {
--
2.53.0
Jakub Kicinski
maintainerQuoted 3 lines · On Sun, 15 Mar 2026 14:45:27 -0700 Rosen Penev wrote:
Simplifies allocations by using a flexible array member in this struct.
Remove memset as it's now allocated by kzalloc.
Quoting documentation:
Clean-up patches
~~~~~~~~~~~~~~~~
Netdev discourages patches which perform simple clean-ups, which are not in the context of other work.
This is because it is felt that the churn that such changes produce comes at a greater cost than the value of such clean-ups.
See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#clean-up-patches
Signature · 1 line
pw-bot: reject