]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mv88e6xxx: Use cached config3 in 6352 has_serdes
authorFidan Aliyeva <fidan.aliyeva.ext@ericsson.com>
Thu, 21 May 2026 20:29:23 +0000 (22:29 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 26 May 2026 10:11:32 +0000 (12:11 +0200)
1. Refactor mv88e6352_g2_scratch_port_has_serdes to use the cached
scratch config3 value instead of reading it everytime.
2. Remove err<0 check from mv88e6352_phylink_get_caps as it is never
true anymore

Co-developed-by: Thomas Eckerman <thomas.eckerman.ext@ericsson.com>
Signed-off-by: Thomas Eckerman <thomas.eckerman.ext@ericsson.com>
Signed-off-by: Fidan Aliyeva <fidan.aliyeva.ext@ericsson.com>
Link: https://patch.msgid.link/20260521202924.727929-4-fidan.aliyeva.ext@ericsson.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/dsa/mv88e6xxx/chip.c
drivers/net/dsa/mv88e6xxx/global2_scratch.c

index 703421069cf897ea77d8ab382e27af11c3eec03b..c30e4c13565a5050189d42b3ffffbfb403489d4a 100644 (file)
@@ -685,9 +685,6 @@ static void mv88e6352_phylink_get_caps(struct mv88e6xxx_chip *chip, int port,
        /* Port 4 supports automedia if the serdes is associated with it. */
        if (port == 4) {
                err = mv88e6352_g2_scratch_port_has_serdes(chip, port);
-               if (err < 0)
-                       dev_err(chip->dev, "p%d: failed to read scratch\n",
-                               port);
                if (err <= 0)
                        return;
 
index f2f9e7dce1aadb2013791e61ae05d6cebd66ec07..f292ee4db113c9f18f90a96393f854b9bf79bc19 100644 (file)
@@ -348,26 +348,20 @@ int mv88e6352_g2_cache_global_scratch_config3(struct mv88e6xxx_chip *chip)
 }
 
 /**
- * mv88e6352_g2_scratch_port_has_serdes - indicate if a port can have a serdes
+ * mv88e6352_g2_scratch_port_has_serdes - indicate if a port has serdes
  * @chip: chip private data
  * @port: port number to check for serdes
  *
  * Indicates whether the port may have a serdes attached according to the
- * pin strapping. Returns negative error number, 0 if the port is not
- * configured to have a serdes, and 1 if the port is configured to have a
- * serdes attached.
+ * pin strapping, which is cached at reset (scratch config3). Returns 0 if
+ * the port is not configured to have a serdes, and 1 if the port is
+ * configured to have a serdes attached.
  */
 int mv88e6352_g2_scratch_port_has_serdes(struct mv88e6xxx_chip *chip, int port)
 {
-       u8 config3, p;
-       int err;
-
-       err = mv88e6xxx_g2_scratch_read(chip, MV88E6352_G2_SCRATCH_CONFIG_DATA3,
-                                       &config3);
-       if (err)
-               return err;
+       u8 p;
 
-       if (config3 & MV88E6352_G2_SCRATCH_CONFIG_DATA3_S_SEL)
+       if (chip->g2_scratch_config3 & MV88E6352_G2_SCRATCH_CONFIG_DATA3_S_SEL)
                p = 5;
        else
                p = 4;