12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #include <linux/etherdevice.h>
- #include <linux/kernel.h>
- #include <linux/of_net.h>
- #include <linux/phy.h>
- #include <linux/export.h>
- int of_get_phy_mode(struct device_node *np)
- {
- const char *pm;
- int err, i;
- err = of_property_read_string(np, "phy-mode", &pm);
- if (err < 0)
- err = of_property_read_string(np, "phy-connection-type", &pm);
- if (err < 0)
- return err;
- for (i = 0; i < PHY_INTERFACE_MODE_MAX; i++)
- if (!strcasecmp(pm, phy_modes(i)))
- return i;
- return -ENODEV;
- }
- EXPORT_SYMBOL_GPL(of_get_phy_mode);
- static const void *of_get_mac_addr(struct device_node *np, const char *name)
- {
- struct property *pp = of_find_property(np, name, NULL);
- if (pp && pp->length == ETH_ALEN && is_valid_ether_addr(pp->value))
- return pp->value;
- return NULL;
- }
- const void *of_get_mac_address(struct device_node *np)
- {
- const void *addr;
- addr = of_get_mac_addr(np, "mac-address");
- if (addr)
- return addr;
- addr = of_get_mac_addr(np, "local-mac-address");
- if (addr)
- return addr;
- return of_get_mac_addr(np, "address");
- }
- EXPORT_SYMBOL(of_get_mac_address);
|