[PATCH v1 5/7] device property: Introduce fwnode_phy_is_fixed_link()
From: Calvin Johnson
Date: Fri Jan 31 2020 - 10:35:52 EST
From: Calvin Johnson <calvin.johnson@xxxxxxxxxxx>
Introduce fwnode_phy_is_fixed_link() function that an Ethernet driver
can call on its PHY phandle to find out whether it's a fixed link PHY
or not.
Signed-off-by: Calvin Johnson <calvin.johnson@xxxxxxxxxxx>
---
drivers/base/property.c | 21 +++++++++++++++++++++
include/linux/property.h | 1 +
2 files changed, 22 insertions(+)
diff --git a/drivers/base/property.c b/drivers/base/property.c
index fdb79033d58f..a0f69fae82cd 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -827,6 +827,27 @@ enum dev_dma_attr device_get_dma_attr(struct device *dev)
}
EXPORT_SYMBOL_GPL(device_get_dma_attr);
+/*
+ * fwnode_phy_is_fixed_link()
+ */
+bool fwnode_phy_is_fixed_link(struct fwnode_handle *fwnode)
+{
+ struct fwnode_handle *fixed_node;
+ int len, err;
+ const char *managed;
+
+ fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link");
+ if (fixed_node)
+ return fixed_node;
+
+ err = fwnode_property_read_string(fixed_node, "managed", &managed);
+ if (err == 0 && strcmp(managed, "auto") != 0)
+ return true;
+
+ return false;
+}
+EXPORT_SYMBOL(fwnode_phy_is_fixed_link);
+
/**
* fwnode_get_phy_mode - Get phy mode for given firmware node
* @fwnode: Pointer to the given node
diff --git a/include/linux/property.h b/include/linux/property.h
index 1998f502d2ed..ba89fcf091c8 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -333,6 +333,7 @@ int device_get_phy_mode(struct device *dev);
void *device_get_mac_address(struct device *dev, char *addr, int alen);
+bool fwnode_phy_is_fixed_link(struct fwnode_handle *fwnode);
int fwnode_get_phy_mode(struct fwnode_handle *fwnode,
phy_interface_t *interface);
void *fwnode_get_mac_address(struct fwnode_handle *fwnode,
--
2.17.1