public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: pse-pd: tps23881: Fix power on/off issue
@ 2024-12-20 17:04 Kory Maincent
  2024-12-23  6:23 ` Oleksij Rempel
  2024-12-23 18:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Kory Maincent @ 2024-12-20 17:04 UTC (permalink / raw)
  To: Kory Maincent (Dent Project), Jakub Kicinski, netdev,
	linux-kernel
  Cc: thomas.petazzoni, Oleksij Rempel, Andrew Lunn, David S. Miller,
	Eric Dumazet, Paolo Abeni

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: 20e6d190ffe1 ("net: pse-pd: Add TI TPS23881 PSE controller driver")
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---
 drivers/net/pse-pd/tps23881.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/net/pse-pd/tps23881.c b/drivers/net/pse-pd/tps23881.c
index 5c4e88be46ee..8797ca1a8a21 100644
--- a/drivers/net/pse-pd/tps23881.c
+++ b/drivers/net/pse-pd/tps23881.c
@@ -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];
@@ -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];
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: pse-pd: tps23881: Fix power on/off issue
  2024-12-20 17:04 [PATCH net] net: pse-pd: tps23881: Fix power on/off issue Kory Maincent
@ 2024-12-23  6:23 ` Oleksij Rempel
  2024-12-23 18:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Oleksij Rempel @ 2024-12-23  6:23 UTC (permalink / raw)
  To: Kory Maincent
  Cc: Jakub Kicinski, netdev, linux-kernel, thomas.petazzoni,
	Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni

On Fri, Dec 20, 2024 at 06:04:00PM +0100, Kory Maincent wrote:
> 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: 20e6d190ffe1 ("net: pse-pd: Add TI TPS23881 PSE controller driver")
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>

Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>

Thank you!
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: pse-pd: tps23881: Fix power on/off issue
  2024-12-20 17:04 [PATCH net] net: pse-pd: tps23881: Fix power on/off issue Kory Maincent
  2024-12-23  6:23 ` Oleksij Rempel
@ 2024-12-23 18:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-12-23 18:50 UTC (permalink / raw)
  To: Kory Maincent
  Cc: kuba, netdev, linux-kernel, thomas.petazzoni, o.rempel,
	andrew+netdev, davem, edumazet, pabeni

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 20 Dec 2024 18:04:00 +0100 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [net] net: pse-pd: tps23881: Fix power on/off issue
    https://git.kernel.org/netdev/net/c/75221e96101f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-12-23 18:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-20 17:04 [PATCH net] net: pse-pd: tps23881: Fix power on/off issue Kory Maincent
2024-12-23  6:23 ` Oleksij Rempel
2024-12-23 18:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox