lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <521C5C19.5070905@atmel.com>
Date:	Tue, 27 Aug 2013 09:58:17 +0200
From:	Nicolas Ferre <nicolas.ferre@...el.com>
To:	Boris BREZILLON <b.brezillon@...rkiz.com>
CC:	Rob Herring <rob.herring@...xeda.com>,
	Pawel Moll <pawel.moll@....com>,
	Mark Rutland <mark.rutland@....com>,
	Stephen Warren <swarren@...dotorg.org>,
	Ian Campbell <ian.campbell@...rix.com>,
	Russell King <linux@....linux.org.uk>,
	<devicetree@...r.kernel.org>,
	<linux-arm-kernel@...ts.infradead.org>,
	<linux-kernel@...r.kernel.org>, <netdev@...r.kernel.org>
Subject: Re: [PATCH v3 1/2] net/cadence/macb: add support for dt phy definition

On 27/08/2013 09:37, Boris BREZILLON :
> The macb driver only handle PHY description through platform_data
> (macb_platform_data).
> Thus, when using dt you cannot define phy properties like phy address or
> phy irq pin.
>
> This patch makes use of the of_mdiobus_register to add support for
> phy device definition using dt.
> A fallback to the autoscan procedure is added in case there is no phy
> devices defined in dt.
>
> Signed-off-by: Boris BREZILLON <b.brezillon@...rkiz.com>

Acked-by: Nicolas Ferre <nicolas.ferre@...el.com>

> ---
>   drivers/net/ethernet/cadence/macb.c |   48 +++++++++++++++++++++++++++--------
>   1 file changed, 38 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index e866608..393afeb 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -27,6 +27,7 @@
>   #include <linux/phy.h>
>   #include <linux/of.h>
>   #include <linux/of_device.h>
> +#include <linux/of_mdio.h>
>   #include <linux/of_net.h>
>   #include <linux/pinctrl/consumer.h>
>
> @@ -275,7 +276,7 @@ static int macb_mii_probe(struct net_device *dev)
>   	phydev = phy_find_first(bp->mii_bus);
>   	if (!phydev) {
>   		netdev_err(dev, "no PHY found\n");
> -		return -1;
> +		return -ENXIO;
>   	}
>
>   	pdata = dev_get_platdata(&bp->pdev->dev);
> @@ -314,6 +315,7 @@ static int macb_mii_probe(struct net_device *dev)
>   int macb_mii_init(struct macb *bp)
>   {
>   	struct macb_platform_data *pdata;
> +	struct device_node *np;
>   	int err = -ENXIO, i;
>
>   	/* Enable management port */
> @@ -335,26 +337,52 @@ int macb_mii_init(struct macb *bp)
>   	bp->mii_bus->parent = &bp->dev->dev;
>   	pdata = bp->pdev->dev.platform_data;
>
> -	if (pdata)
> -		bp->mii_bus->phy_mask = pdata->phy_mask;
> -
>   	bp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
>   	if (!bp->mii_bus->irq) {
>   		err = -ENOMEM;
>   		goto err_out_free_mdiobus;
>   	}
>
> -	for (i = 0; i < PHY_MAX_ADDR; i++)
> -		bp->mii_bus->irq[i] = PHY_POLL;
> -
>   	dev_set_drvdata(&bp->dev->dev, bp->mii_bus);
>
> -	if (mdiobus_register(bp->mii_bus))
> +	np = bp->pdev->dev.of_node;
> +	if (np) {
> +		/* try dt phy registration */
> +		err = of_mdiobus_register(bp->mii_bus, np);
> +
> +		/* fallback to standard phy registration if no phy were
> +		 * found during dt phy registration
> +		 */
> +		if (!err && !phy_find_first(bp->mii_bus)) {
> +			for (i = 0; i < PHY_MAX_ADDR; i++) {
> +				struct phy_device *phydev;
> +
> +				phydev = mdiobus_scan(bp->mii_bus, i);
> +				if (IS_ERR(phydev)) {
> +					err = PTR_ERR(phydev);
> +					break;
> +				}
> +			}
> +
> +			if (err)
> +				goto err_out_unregister_bus;
> +		}
> +	} else {
> +		for (i = 0; i < PHY_MAX_ADDR; i++)
> +			bp->mii_bus->irq[i] = PHY_POLL;
> +
> +		if (pdata)
> +			bp->mii_bus->phy_mask = pdata->phy_mask;
> +
> +		err = mdiobus_register(bp->mii_bus);
> +	}
> +
> +	if (err)
>   		goto err_out_free_mdio_irq;
>
> -	if (macb_mii_probe(bp->dev) != 0) {
> +	err = macb_mii_probe(bp->dev);
> +	if (err)
>   		goto err_out_unregister_bus;
> -	}
>
>   	return 0;
>
>


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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ