]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/of/of_mdio.c
Merge tag 'devicetree-for-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git...
[mirror_ubuntu-bionic-kernel.git] / drivers / of / of_mdio.c
index 754b9d6cd1cd8e64a80a2bc2bce5d77bdf99657b..d94dd8b77abd5140d52c6dfbdff249409225cbec 100644 (file)
@@ -421,19 +421,14 @@ int of_phy_register_fixed_link(struct device_node *np)
 {
        struct fixed_phy_status status = {};
        struct device_node *fixed_link_node;
-       const __be32 *fixed_link_prop;
-       int link_gpio;
-       int len, err;
-       struct phy_device *phy;
+       u32 fixed_link_prop[5];
        const char *managed;
+       int link_gpio = -1;
 
-       err = of_property_read_string(np, "managed", &managed);
-       if (err == 0) {
-               if (strcmp(managed, "in-band-status") == 0) {
-                       /* status is zeroed, namely its .link member */
-                       phy = fixed_phy_register(PHY_POLL, &status, -1, np);
-                       return PTR_ERR_OR_ZERO(phy);
-               }
+       if (of_property_read_string(np, "managed", &managed) == 0 &&
+           strcmp(managed, "in-band-status") == 0) {
+               /* status is zeroed, namely its .link member */
+               goto register_phy;
        }
 
        /* New binding */
@@ -456,23 +451,25 @@ int of_phy_register_fixed_link(struct device_node *np)
                if (link_gpio == -EPROBE_DEFER)
                        return -EPROBE_DEFER;
 
-               phy = fixed_phy_register(PHY_POLL, &status, link_gpio, np);
-               return PTR_ERR_OR_ZERO(phy);
+               goto register_phy;
        }
 
        /* Old binding */
-       fixed_link_prop = of_get_property(np, "fixed-link", &len);
-       if (fixed_link_prop && len == (5 * sizeof(__be32))) {
+       if (of_property_read_u32_array(np, "fixed-link", fixed_link_prop,
+                                      ARRAY_SIZE(fixed_link_prop)) == 0) {
                status.link = 1;
-               status.duplex = be32_to_cpu(fixed_link_prop[1]);
-               status.speed = be32_to_cpu(fixed_link_prop[2]);
-               status.pause = be32_to_cpu(fixed_link_prop[3]);
-               status.asym_pause = be32_to_cpu(fixed_link_prop[4]);
-               phy = fixed_phy_register(PHY_POLL, &status, -1, np);
-               return PTR_ERR_OR_ZERO(phy);
+               status.duplex = fixed_link_prop[1];
+               status.speed  = fixed_link_prop[2];
+               status.pause  = fixed_link_prop[3];
+               status.asym_pause = fixed_link_prop[4];
+               goto register_phy;
        }
 
        return -ENODEV;
+
+register_phy:
+       return PTR_ERR_OR_ZERO(fixed_phy_register(PHY_POLL, &status, link_gpio,
+                                                 np));
 }
 EXPORT_SYMBOL(of_phy_register_fixed_link);