On Fri, Jul 10, 2020 at 7:32 PM Calvin Johnson
<[email protected]> wrote:
>
> Define phylink_fwnode_phy_connect() to connect phy specified by
> a fwnode to a phylink instance.
...
> +int phylink_fwnode_phy_connect(struct phylink *pl,
> + struct fwnode_handle *fwnode,
> + u32 flags)
> +{
> + struct phy_device *phy_dev;
> + int ret = 0;
This assignment is redundant and actually entire var is not needed.
> + if (is_of_node(fwnode)) {
> + ret = phylink_of_phy_connect(pl, to_of_node(fwnode), flags);
> + } else if (is_acpi_device_node(fwnode)) {
> + phy_dev = phy_find_by_mdio_handle(fwnode);
> + if (!phy_dev)
> + return -ENODEV;
> + ret = phylink_connect_phy(pl, phy_dev);
> + } else {
> + ret = -EINVAL;
> + }
> +
> + return ret;
You may refactor in the similar way, i.e.
if (is_of_node(...))
return phy...
if (is_acpi_device_node(...)) {
... return phylink_connect_phy();
}
return -EINVAL;
> +}
--
With Best Regards,
Andy Shevchenko