Netdev List
 help / color / mirror / Atom feed
From: Fidan Aliyeva <fidan.aliyeva.ext@ericsson.com>
To: <andrew@lunn.ch>, <olteanv@gmail.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<marek.behun@nic.cz>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<fidan.aliyeva.ext@ericsson.com>,
	Thomas Eckerman <thomas.eckerman.ext@ericsson.com>
Subject: [PATCH net-next 3/4] mv88e6xxx: Use cached config3 in 6352 has_serdes
Date: Sat, 16 May 2026 00:37:06 +0200	[thread overview]
Message-ID: <20260515223707.1026325-4-fidan.aliyeva.ext@ericsson.com> (raw)
In-Reply-To: <20260515223707.1026325-1-fidan.aliyeva.ext@ericsson.com>

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>
---
 drivers/net/dsa/mv88e6xxx/chip.c            |  3 ---
 drivers/net/dsa/mv88e6xxx/global2_scratch.c | 18 ++++++------------
 2 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 4ed6f880e02c..63cdcce3d8c7 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -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;

diff --git a/drivers/net/dsa/mv88e6xxx/global2_scratch.c b/drivers/net/dsa/mv88e6xxx/global2_scratch.c
index a2c09bbdde17..7caf3d45177d 100644
--- a/drivers/net/dsa/mv88e6xxx/global2_scratch.c
+++ b/drivers/net/dsa/mv88e6xxx/global2_scratch.c
@@ -347,26 +347,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;
--
2.36.0


  parent reply	other threads:[~2026-05-15 22:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-10 21:34 [RFC PATCH 1/1] mv88e6xxx: Cache scratch config of 6352 in setup Fidan Aliyeva
2026-05-10 21:45 ` Fidan Aliyeva
2026-05-10 23:06   ` Andrew Lunn
2026-05-10 23:13 ` Andrew Lunn
2026-05-15 14:50   ` Fidan Aliyeva
2026-05-15 15:35     ` Andrew Lunn
2026-05-15 22:37 ` [PATCH net-next 0/4] mv88e6xxx: Cache scratch config3 of 6352 Fidan Aliyeva
2026-05-15 22:37   ` [PATCH net-next 1/4] mv88e6xxx: Add mv88e6352_reset for 6352 family Fidan Aliyeva
2026-05-15 22:37   ` [PATCH net-next 2/4] mv88e6xxx: Cache scratch config3 of 6352 Fidan Aliyeva
2026-05-15 22:37   ` Fidan Aliyeva [this message]
2026-05-15 22:37   ` [PATCH net-next 4/4] mv88e6xxx: Remove locks for 6352's has_serdes Fidan Aliyeva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260515223707.1026325-4-fidan.aliyeva.ext@ericsson.com \
    --to=fidan.aliyeva.ext@ericsson.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marek.behun@nic.cz \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=thomas.eckerman.ext@ericsson.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox