Thread (33 messages) 33 messages, 3 authors, 2020-12-18

Re: [net-next PATCH v2 02/14] net: phy: Introduce phy related fwnode functions

From: Andy Shevchenko <hidden>
Date: 2020-12-15 17:24:51
Also in: linux-acpi, linux-arm-kernel, lkml

On Tue, Dec 15, 2020 at 6:44 PM Calvin Johnson
[off-list ref] wrote:
Define fwnode_phy_find_device() to iterate an mdiobus and find the
phy device of the provided phy fwnode. Additionally define
device_phy_find_device() to find phy device of provided device.

Define fwnode_get_phy_node() to get phy_node using named reference.
...
+#include <linux/acpi.h>
Not sure we need this. See below.

...
+/**
+ * fwnode_phy_find_device - Find phy_device on the mdiobus for the provided
+ * phy_fwnode.
Can we keep a summary on one line?
+ * @phy_fwnode: Pointer to the phy's fwnode.
+ *
+ * If successful, returns a pointer to the phy_device with the embedded
+ * struct device refcount incremented by one, or NULL on failure.
+ */
+struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode)
+{
+       struct mdio_device *mdiodev;
+       struct device *d;
+       if (!phy_fwnode)
+               return NULL;
Why is this needed?
Perhaps a comment to the function description explains a case when
@phy_fwnode == NULL.
+       d = bus_find_device_by_fwnode(&mdio_bus_type, phy_fwnode);
+       if (d) {
+               mdiodev = to_mdio_device(d);
+               if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY)
+                       return to_phy_device(d);
+               put_device(d);
+       }
+
+       return NULL;
+}
...
+ * For ACPI, only "phy-handle" is supported. DT supports all the three
+ * named references to the phy node.
...
+       /* Only phy-handle is used for ACPI */
+       phy_node = fwnode_find_reference(fwnode, "phy-handle", 0);
+       if (is_acpi_node(fwnode) || !IS_ERR(phy_node))
+               return phy_node;
So, what is the problem with going through the rest on ACPI?
Usually we describe the restrictions in the documentation.

-- 
With Best Regards,
Andy Shevchenko
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help