Re: [PATCH 5/7] net: of_mdio: parse "max-speed" property to set PHY supported features

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Thu, 5 Dec 2013 14:52:14 -0800, Florian Fainelli <florian@xxxxxxxxxxx> wrote:
> From: Florian Fainelli <f.fainelli@xxxxxxxxx>
> 
> The "max-speed" property is defined per the ePAPR specification to
> express the maximum speed a PHY supports. Use that property, if present
> to set the phydev->supported features which properly restricts the PHY
> within the range of defined speeds.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@xxxxxxxxx>
> ---
>  drivers/of/of_mdio.c | 25 ++++++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
> index 4923ab2..e1e19e5 100644
> --- a/drivers/of/of_mdio.c
> +++ b/drivers/of/of_mdio.c
> @@ -22,12 +22,30 @@
>  MODULE_AUTHOR("Grant Likely <grant.likely@xxxxxxxxxxxx>");
>  MODULE_LICENSE("GPL");
>  
> +static void of_set_phy_supported(struct phy_device *phydev, u32 max_speed)
> +{
> +	phydev->supported |= PHY_DEFAULT_FEATURES;
> +
> +	switch (max_speed) {
> +	default:
> +		return;

No need for a default clause.

> +
> +	case SPEED_1000:
> +		phydev->supported |= PHY_1000BT_FEATURES;
> +	case SPEED_100:
> +		phydev->supported |= PHY_100BT_FEATURES;
> +	case SPEED_10:
> +		phydev->supported |= PHY_10BT_FEATURES;
> +	}
> +}
> +
>  static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *child,
>  				   u32 addr)
>  {
>  	struct phy_device *phy;
>  	bool is_c45;
>  	int rc, prev_irq;
> +	u32 max_speed = 0;
>  
>  	is_c45 = of_device_is_compatible(child,
>  					 "ethernet-phy-ieee802.3-c45");
> @@ -58,8 +76,13 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi
>  		return 1;
>  	}
>  
> +	/* Set phydev->supported based on the "max-speed" property
> +	 * if present */
> +	if (!of_property_read_u32(child, "max-speed", &max_speed))
> +		of_set_phy_supported(phy, max_speed);
> +

Why the separate function? There is no need since there is only one
caller and the block is very short. Just do this:

	if (!of_property_read_u32(child, "max-speed", &max_speed)) {
		phydev->supported |= PHY_DEFAULT_FEATURES;
		switch (max_speed) {
		case SPEED_1000:
			phydev->supported |= PHY_1000BT_FEATURES;
		case SPEED_100:
			phydev->supported |= PHY_100BT_FEATURES;
		case SPEED_10:
			phydev->supported |= PHY_10BT_FEATURES;
		}
	}

>  	dev_dbg(&mdio->dev, "registered phy %s at address %i\n",
> -		 child->name, addr);
> +		child->name, addr);

Unrelated whitespace change. I wouldn't even bother with changing this.
It adds noise.

However, those are style concerns. The content looks fine.

Acked-by: Grant Likely <grant.likely@xxxxxxxxxx>

g.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux