Re: [PATCH] net/phy: micrel: Add clock support for KSZ8021/KSZ8031

From: Sascha Hauer
Date: Fri Oct 10 2014 - 03:45:18 EST


On Thu, Oct 09, 2014 at 10:01:15AM -0700, Florian Fainelli wrote:
> On 10/09/2014 05:32 AM, Sascha Hauer wrote:
> > static int ksz8021_config_init(struct phy_device *phydev)
> > {
> > + struct clk *clk;
> > const u16 val = KSZPHY_OMSO_B_CAST_OFF | KSZPHY_OMSO_RMII_OVERRIDE;
> > int rc;
> >
> > + clk = devm_clk_get(&phydev->dev, "rmii-ref");
> > + if (!IS_ERR(clk)) {
> > + unsigned long rate = clk_get_rate(clk);
> > +
> > + if (rate > 24500000 && rate < 25500000)
> > + phydev->dev_flags |= MICREL_PHY_25MHZ_CLK;
> > + else if (rate > 49500000 && rate < 50500000)
> > + phydev->dev_flags |= MICREL_PHY_50MHZ_CLK;
> > + }
>
> I suppose that you could move this to the PHY driver probe() callback,
> and perform the rate checking from here, rejecting a clock whose rate is
> out of the acceptable range, and return an error to prevent the PHY
> driver registration? It is really up to you though.

Oh, it seems doing this in config_init is really wrong as it can be
called multiple times, even as a response to the SIOCSMIIREG ioctl.
We would request the clock each time then without ever releasing it.
I'll send an updated version with clock handling in probe().

Sascha

--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/