Skip to content

Commit 0b56751

Browse files
kmaincentPaolo Abeni
authored andcommitted
net: pse-pd: tps23881: Simplify function returns by removing redundant checks
Cleaned up several functions in tps23881 by removing redundant checks on return values at the end of functions. These check has been removed, and the return statement now directly returns the function result, reducing the code's complexity and making it more concise. Reviewed-by: Andrew Lunn <[email protected]> Acked-by: Oleksij Rempel <[email protected]> Reviewed-by: Kyle Swenson <[email protected]> Signed-off-by: Kory Maincent <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 6e56a6d commit 0b56751

File tree

1 file changed

+6
-28
lines changed

1 file changed

+6
-28
lines changed

drivers/net/pse-pd/tps23881.c

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ static int tps23881_pi_enable(struct pse_controller_dev *pcdev, int id)
5959
struct i2c_client *client = priv->client;
6060
u8 chan;
6161
u16 val;
62-
int ret;
6362

6463
if (id >= TPS23881_MAX_CHANS)
6564
return -ERANGE;
@@ -78,11 +77,7 @@ static int tps23881_pi_enable(struct pse_controller_dev *pcdev, int id)
7877
val |= BIT(chan + 4);
7978
}
8079

81-
ret = i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val);
82-
if (ret)
83-
return ret;
84-
85-
return 0;
80+
return i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val);
8681
}
8782

8883
static int tps23881_pi_disable(struct pse_controller_dev *pcdev, int id)
@@ -91,7 +86,6 @@ static int tps23881_pi_disable(struct pse_controller_dev *pcdev, int id)
9186
struct i2c_client *client = priv->client;
9287
u8 chan;
9388
u16 val;
94-
int ret;
9589

9690
if (id >= TPS23881_MAX_CHANS)
9791
return -ERANGE;
@@ -110,11 +104,7 @@ static int tps23881_pi_disable(struct pse_controller_dev *pcdev, int id)
110104
val |= BIT(chan + 8);
111105
}
112106

113-
ret = i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val);
114-
if (ret)
115-
return ret;
116-
117-
return 0;
107+
return i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val);
118108
}
119109

120110
static int tps23881_pi_is_enabled(struct pse_controller_dev *pcdev, int id)
@@ -480,7 +470,7 @@ tps23881_write_port_matrix(struct tps23881_priv *priv,
480470
struct i2c_client *client = priv->client;
481471
u8 pi_id, lgcl_chan, hw_chan;
482472
u16 val = 0;
483-
int i, ret;
473+
int i;
484474

485475
for (i = 0; i < port_cnt; i++) {
486476
pi_id = port_matrix[i].pi_id;
@@ -511,11 +501,7 @@ tps23881_write_port_matrix(struct tps23881_priv *priv,
511501
}
512502

513503
/* Write hardware ports matrix */
514-
ret = i2c_smbus_write_word_data(client, TPS23881_REG_PORT_MAP, val);
515-
if (ret)
516-
return ret;
517-
518-
return 0;
504+
return i2c_smbus_write_word_data(client, TPS23881_REG_PORT_MAP, val);
519505
}
520506

521507
static int
@@ -564,11 +550,7 @@ tps23881_set_ports_conf(struct tps23881_priv *priv,
564550
val |= BIT(port_matrix[i].lgcl_chan[1]) |
565551
BIT(port_matrix[i].lgcl_chan[1] + 4);
566552
}
567-
ret = i2c_smbus_write_word_data(client, TPS23881_REG_DET_CLA_EN, val);
568-
if (ret)
569-
return ret;
570-
571-
return 0;
553+
return i2c_smbus_write_word_data(client, TPS23881_REG_DET_CLA_EN, val);
572554
}
573555

574556
static int
@@ -594,11 +576,7 @@ tps23881_set_ports_matrix(struct tps23881_priv *priv,
594576
if (ret)
595577
return ret;
596578

597-
ret = tps23881_set_ports_conf(priv, port_matrix);
598-
if (ret)
599-
return ret;
600-
601-
return 0;
579+
return tps23881_set_ports_conf(priv, port_matrix);
602580
}
603581

604582
static int tps23881_setup_pi_matrix(struct pse_controller_dev *pcdev)

0 commit comments

Comments
 (0)