public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: phy: microchip_rds_ptp: simplify allocation
@ 2026-03-15 21:45 Rosen Penev
  2026-03-19  1:29 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-03-15 21:45 UTC (permalink / raw)
  To: netdev
  Cc: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Richard Cochran,
	open list

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] net: phy: microchip_rds_ptp: simplify allocation
  2026-03-15 21:45 [PATCH net-next] net: phy: microchip_rds_ptp: simplify allocation Rosen Penev
@ 2026-03-19  1:29 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2026-03-19  1:29 UTC (permalink / raw)
  To: Rosen Penev
  Cc: netdev, Andrew Lunn, Heiner Kallweit, Russell King,
	David S. Miller, Eric Dumazet, Paolo Abeni, Richard Cochran,
	open list

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-19  1:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-15 21:45 [PATCH net-next] net: phy: microchip_rds_ptp: simplify allocation Rosen Penev
2026-03-19  1:29 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox