Skip to content

Commit

Permalink
net: pse-pd: tps23881: Fix power on/off issue
Browse files Browse the repository at this point in the history
An issue was present in the initial driver implementation. The driver
read the power status of all channels before toggling the bit of the
desired one. Using the power status register as a base value introduced
a problem, because only the bit corresponding to the concerned channel ID
should be set in the write-only power enable register. This led to cases
where disabling power for one channel also powered off other channels.

This patch removes the power status read and ensures the value is
limited to the bit matching the channel index of the PI.

Fixes: 20e6d19 ("net: pse-pd: Add TI TPS23881 PSE controller driver")
Signed-off-by: Kory Maincent <[email protected]>
Acked-by: Oleksij Rempel <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
kmaincent authored and kuba-moo committed Dec 23, 2024
1 parent 4a4d38a commit 75221e9
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions drivers/net/pse-pd/tps23881.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,11 @@ static int tps23881_pi_enable(struct pse_controller_dev *pcdev, int id)
if (id >= TPS23881_MAX_CHANS)
return -ERANGE;

ret = i2c_smbus_read_word_data(client, TPS23881_REG_PW_STATUS);
if (ret < 0)
return ret;

chan = priv->port[id].chan[0];
if (chan < 4)
val = (u16)(ret | BIT(chan));
val = BIT(chan);
else
val = (u16)(ret | BIT(chan + 4));
val = BIT(chan + 4);

if (priv->port[id].is_4p) {
chan = priv->port[id].chan[1];
Expand Down Expand Up @@ -100,15 +96,11 @@ static int tps23881_pi_disable(struct pse_controller_dev *pcdev, int id)
if (id >= TPS23881_MAX_CHANS)
return -ERANGE;

ret = i2c_smbus_read_word_data(client, TPS23881_REG_PW_STATUS);
if (ret < 0)
return ret;

chan = priv->port[id].chan[0];
if (chan < 4)
val = (u16)(ret | BIT(chan + 4));
val = BIT(chan + 4);
else
val = (u16)(ret | BIT(chan + 8));
val = BIT(chan + 8);

if (priv->port[id].is_4p) {
chan = priv->port[id].chan[1];
Expand Down

0 comments on commit 75221e9

Please sign in to comment.