Thread (12 messages) 12 messages, 3 authors, 2020-07-10

Re: [net-next PATCH v4 5/6] phylink: introduce phylink_fwnode_phy_connect()

From: Calvin Johnson <hidden>
Date: 2020-07-10 14:08:23
Also in: linux-acpi

On Thu, Jul 09, 2020 at 11:48:03PM +0300, Andy Shevchenko wrote:
On Thu, Jul 9, 2020 at 8:58 PM Calvin Johnson
[off-list ref] wrote:
quoted
Define phylink_fwnode_phy_connect() to connect phy specified by
a fwnode to a phylink instance.
...
quoted
+       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_fwnode(fwnode);
+               if (!phy_dev)
+                       return -ENODEV;
+               ret = phylink_connect_phy(pl, phy_dev);
+       }
Looking at this more I really don't like how this if-else-if looks like.

I would rather expect something like

               phy_dev = phy_find_by_fwnode(fwnode);
               if (!phy_dev)
                       return -ENODEV;
               ret = phylink_connect_phy(pl, phy_dev);

Where phy_find_by_fwnode() will take care about OF or any other
possible fwnode cases.
phy_find_by_fwnode() has a different purpose from that of
phylink_fwnode_phy_connect(). Current implementation looks good to me as it
clearly takes different paths for DT and ACPI cases.

Thanks
Calvin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help