Re: [PATCH] net: phy: dp83822: Add optional external PHY clock
From: Andrew Lunn
Date: Wed May 27 2026 - 12:24:36 EST
> @@ -203,6 +204,7 @@ struct dp83822_private {
> u8 cfg_dac_minus;
> u8 cfg_dac_plus;
> struct ethtool_wolinfo wol;
> + struct clk *clk;
> bool set_gpio2_clk_out;
> u32 gpio2_clk_out;
> bool led_pin_enable[DP83822_MAX_LED_PINS];
> @@ -984,13 +986,19 @@ static int dp83822_attach_mdi_port(struct phy_device *phydev,
>
> static int dp8382x_probe(struct phy_device *phydev)
> {
> + struct device *dev = &phydev->mdio.dev;
> struct dp83822_private *dp83822;
>
> - dp83822 = devm_kzalloc(&phydev->mdio.dev, sizeof(*dp83822),
> + dp83822 = devm_kzalloc(dev, sizeof(*dp83822),
> GFP_KERNEL);
Logically, these two changes have nothing to do with clocks. So they
should be in a different patch.
> if (!dp83822)
> return -ENOMEM;
>
> + dp83822->clk = devm_clk_get_optional_enabled(dev, NULL);
> + if (IS_ERR(dp83822->clk))
> + return dev_err_probe(dev, PTR_ERR(dp83822->clk),
> + "Failed to request ref clock\n");
There is no use of dp83822->clk other than here. So there is no need
to store it in the private structure. You can use a local variable.
Andrew
---
pw-bot: cr