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]
Date:   Sat, 17 Oct 2020 22:39:38 +0200
From:   Andrew Lunn <andrew@...n.ch>
To:     Ivan Mikhaylov <i.mikhaylov@...ro.com>
Cc:     "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Po-Yu Chuang <ratbert@...aday-tech.com>,
        Joel Stanley <joel@....id.au>, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org, openbmc@...ts.ozlabs.org
Subject: Re: [PATCH v1 2/2] net: ftgmac100: add handling of mdio/phy nodes
 for ast2400/2500

> -	err = mdiobus_register(priv->mii_bus);
> +	mdio_np = of_get_child_by_name(np, "mdio");
> +	if (mdio_np)
> +		err = of_mdiobus_register(priv->mii_bus, mdio_np);
> +	else
> +		err = mdiobus_register(priv->mii_bus);

of_mdiobus_register() will do the right thing if passed a NULL pointer
for mdio_np.

> +
>  	if (err) {
>  		dev_err(priv->dev, "Cannot register MDIO bus!\n");
>  		goto err_register_mdiobus;
>  	}
>  
> +	if (mdio_np)
> +		of_node_put(mdio_np);

of_node_put() is also happy with a NULL pointer.

> +
>  	return 0;
>  
>  err_register_mdiobus:
> @@ -1830,10 +1839,23 @@ static int ftgmac100_probe(struct platform_device *pdev)
>  	} else if (np && of_get_property(np, "phy-handle", NULL)) {
>  		struct phy_device *phy;
>  
> +		/* Support "mdio"/"phy" child nodes for ast2400/2500 with
> +		 * an embedded MDIO controller. Automatically scan the DTS for
> +		 * available PHYs and register them.
> +		 */
> +		if (of_device_is_compatible(np, "aspeed,ast2400-mac") ||
> +		    of_device_is_compatible(np, "aspeed,ast2500-mac")) {
> +			err = ftgmac100_setup_mdio(netdev);
> +			if (err)
> +				goto err_setup_mdio;
> +		}
> +
>  		phy = of_phy_get_and_connect(priv->netdev, np,
>  					     &ftgmac100_adjust_link);
>  		if (!phy) {
>  			dev_err(&pdev->dev, "Failed to connect to phy\n");
> +			if (priv->mii_bus)
> +				mdiobus_unregister(priv->mii_bus);
>  			goto err_setup_mdio;

It would be nice if the tear down was symmetric to the setup. Add an
ftgmac100_remove_mdio(), and call it on the same condition as
ftgmac100_setup_mdio().

	 Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ