[PATCH v14 09/18] media: i2c: ds90ub960: Fix use of UB960_SR_FWD_CTL1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The driver does not update the forwarding bits in the UB960_SR_FWD_CTL1
register for ports that won't be used. This might leave port forwardings
enabled for unused ports, which might cause issues.

Fix this by making sure all the port forwardings are disabled by
default, and only enable the ones that are used.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@xxxxxxxxxxxxxxxx>
Reported-by: Ludwig Zenz <lzenz@xxxxxxxxxxxxxxxxxx>
Link: https://lore.kernel.org/all/20230516123549.3120-1-lzenz@xxxxxxxxxxxxxxxxxx/
---
 drivers/media/i2c/ds90ub960.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c
index ff939300c918..e101bcf2356a 100644
--- a/drivers/media/i2c/ds90ub960.c
+++ b/drivers/media/i2c/ds90ub960.c
@@ -2330,7 +2330,8 @@ static int ub960_enable_rx_port(struct ub960_data *priv, unsigned int nport)
 	dev_dbg(dev, "enable RX port %u\n", nport);
 
 	/* Enable forwarding */
-	return ub960_update_bits(priv, UB960_SR_FWD_CTL1, BIT(4 + nport), 0);
+	return ub960_update_bits(priv, UB960_SR_FWD_CTL1,
+				 UB960_SR_FWD_CTL1_PORT_DIS(nport), 0);
 }
 
 static void ub960_disable_rx_port(struct ub960_data *priv, unsigned int nport)
@@ -2340,8 +2341,9 @@ static void ub960_disable_rx_port(struct ub960_data *priv, unsigned int nport)
 	dev_dbg(dev, "disable RX port %u\n", nport);
 
 	/* Disable forwarding */
-	ub960_update_bits(priv, UB960_SR_FWD_CTL1, BIT(4 + nport),
-			  BIT(4 + nport));
+	ub960_update_bits(priv, UB960_SR_FWD_CTL1,
+			  UB960_SR_FWD_CTL1_PORT_DIS(nport),
+			  UB960_SR_FWD_CTL1_PORT_DIS(nport));
 }
 
 /*
@@ -2467,7 +2469,11 @@ static int ub960_configure_ports_for_streaming(struct ub960_data *priv,
 
 	/* Configure RX ports */
 
-	fwd_ctl = 0;
+	/*
+	 * Keep all port forwardings disabled by default. Forwarding will be
+	 * enabled in ub960_enable_rx_port.
+	 */
+	fwd_ctl = GENMASK(7, 4);
 
 	for (nport = 0; nport < priv->hw_data->num_rxports; nport++) {
 		struct ub960_rxport *rxport = priv->rxports[nport];
@@ -2515,10 +2521,6 @@ static int ub960_configure_ports_for_streaming(struct ub960_data *priv,
 			break;
 		}
 
-		/* Forwarding */
-
-		fwd_ctl |= BIT(4 + nport); /* forward disable */
-
 		if (rx_data[nport].tx_port == 1)
 			fwd_ctl |= BIT(nport); /* forward to TX1 */
 		else
-- 
2.34.1




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux