Thread (101 messages) flat view 101 messages, 8 authors, 2021-01-09

Re: [PATCH v8 3/4] net: dsa: mv88e6xxx: Change serdes lane parameter from u8 type to int

From: Jakub Kicinski <kuba@kernel.org>
Date: 2020-11-06 01:40:27
Also in: lkml

On Tue,  3 Nov 2020 18:50:02 +1000 Pavana Sharma wrote:
Returning 0 is no more an error case with MV88E6393 family
which has serdes lane numbers 0, 9 or 10.
So with this change .serdes_get_lane will return lane number
or error (-ENODEV).

Signed-off-by: Pavana Sharma <redacted>
 	mv88e6xxx_reg_lock(chip);
 	lane = mv88e6xxx_serdes_get_lane(chip, port);
-	if (lane && chip->info->ops->serdes_pcs_get_state)
+	if ((lane >= 0) && chip->info->ops->serdes_pcs_get_state)
unnecessary parenthesis, checkpatch even warns about this
 		err = chip->info->ops->serdes_pcs_get_state(chip, port, lane,
 							    state);
 	else
quoted hunk ↗ jump to hunk
@@ -522,15 +522,15 @@ static void mv88e6xxx_serdes_pcs_an_restart(struct dsa_switch *ds, int port)
 {
 	struct mv88e6xxx_chip *chip = ds->priv;
 	const struct mv88e6xxx_ops *ops;
+	int lane;
 	int err = 0;
Please keep the reverse xmas tree order of variables

int lane; should be after int err = 0; 

We're ordering full lines, not just the type and name.
-	u8 lane;
 
 	ops = chip->info->ops;
 
 	if (ops->serdes_pcs_an_restart) {
 		mv88e6xxx_reg_lock(chip);
 		lane = mv88e6xxx_serdes_get_lane(chip, port);
-		if (lane)
+		if (lane >= 0)
 			err = ops->serdes_pcs_an_restart(chip, port, lane);
 		mv88e6xxx_reg_unlock(chip);
 void mv88e6390_serdes_get_regs(struct mv88e6xxx_chip *chip, int port, void *_p)
 {
-	u16 *p = _p;
 	int lane;
+	u16 *p = _p;
 	u16 reg;
 	int i;
ditto
quoted hunk ↗ jump to hunk
@@ -129,18 +129,18 @@ void mv88e6352_serdes_get_regs(struct mv88e6xxx_chip *chip, int port, void *_p);
 int mv88e6390_serdes_get_regs_len(struct mv88e6xxx_chip *chip, int port);
 void mv88e6390_serdes_get_regs(struct mv88e6xxx_chip *chip, int port, void *_p);
 
-/* Return the (first) SERDES lane address a port is using, 0 otherwise. */
+/* Return the (first) SERDES lane address a port is using, ERROR otherwise. */
The usual notation is -errno, instead of ERROR.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help