drivers/net/phy/microchip_rds_ptp.c | 10 ++-------- drivers/net/phy/microchip_rds_ptp.h | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-)
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 <rosenp@gmail.com>
---
drivers/net/phy/microchip_rds_ptp.c | 10 ++--------
drivers/net/phy/microchip_rds_ptp.h | 2 +-
2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/net/phy/microchip_rds_ptp.c b/drivers/net/phy/microchip_rds_ptp.c
index 2ad95d5c9d86..4e6ed11f9334 100644
--- a/drivers/net/phy/microchip_rds_ptp.c
+++ b/drivers/net/phy/microchip_rds_ptp.c
@@ -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;
diff --git a/drivers/net/phy/microchip_rds_ptp.h b/drivers/net/phy/microchip_rds_ptp.h
index 25af68337b94..f5c6ab585fff 100644
--- a/drivers/net/phy/microchip_rds_ptp.h
+++ b/drivers/net/phy/microchip_rds_ptp.h
@@ -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
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 -- pw-bot: reject
© 2016 - 2026 Red Hat, Inc.