net: dsa: mv88e6xxx: Add support for EEPROM via platform data
authorAndrew Lunn <andrew@lunn.ch>
Sat, 19 May 2018 20:31:35 +0000 (22:31 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 20 May 2018 22:58:27 +0000 (18:58 -0400)
Add the size of the EEPROM to the platform data, so it can also be
instantiated by a platform device.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/mv88e6xxx/chip.c
drivers/net/dsa/mv88e6xxx/chip.h
include/linux/platform_data/mv88e6xxx.h

index 5b40382036eabbd9f74b34a19aaf699a5834d584..1fa1f820a437f5416254a11946aa10a2334de5cc 100644 (file)
@@ -4386,7 +4386,6 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)
        struct device_node *np = dev->of_node;
        const struct mv88e6xxx_info *compat_info;
        struct mv88e6xxx_chip *chip;
-       u32 eeprom_len;
        int port;
        int err;
 
@@ -4436,9 +4435,13 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)
 
        mv88e6xxx_phy_init(chip);
 
-       if (chip->info->ops->get_eeprom &&
-           !of_property_read_u32(np, "eeprom-length", &eeprom_len))
-               chip->eeprom_len = eeprom_len;
+       if (chip->info->ops->get_eeprom) {
+               if (np)
+                       of_property_read_u32(np, "eeprom-length",
+                                            &chip->eeprom_len);
+               else
+                       chip->eeprom_len = pdata->eeprom_len;
+       }
 
        mutex_lock(&chip->reg_lock);
        err = mv88e6xxx_switch_reset(chip);
index 012268046442e65ce3ba9bae220cd9fda1ed139a..8ac3fbb15352d85f3f38ee4ffa30d551d34bc337 100644 (file)
@@ -238,7 +238,7 @@ struct mv88e6xxx_chip {
        struct gpio_desc *reset;
 
        /* set to size of eeprom if supported by the switch */
-       int             eeprom_len;
+       u32 eeprom_len;
 
        /* List of mdio busses */
        struct list_head mdios;
index 88e91e05f48f25ed4e675a7a28217c8d43a51af5..f63af2955ea070504983f5d6c438798ea016a75a 100644 (file)
@@ -12,6 +12,7 @@ struct dsa_mv88e6xxx_pdata {
        const char *compatible;
        unsigned int enabled_ports;
        struct net_device *netdev;
+       u32 eeprom_len;
 };
 
 #endif