Subject: Re: linux-next: manual merge of the v4l-dvb tree with the i2c tree

From: Stephen Rothwell <[email-masked]>
Date: Thu, 29 May 2025 12:49:29 +1000

Hi all,

On Mon, 28 Apr 2025 11:30:52 +1000 Stephen Rothwell <[email-masked]> wrote:
> 
> On Mon, 28 Apr 2025 11:22:00 +1000 Stephen Rothwell <[email-masked]> wrote:
> >
> > On Mon, 28 Apr 2025 10:49:05 +1000 Stephen Rothwell <[email-masked]> wrote:  
> > >
> > > Today's linux-next merge of the v4l-dvb tree got a conflict in:
> > > 
> > >   drivers/media/i2c/ds90ub960.c
> > > 
> > > between commits:
> > > 
> > >   3ec29d51b546 ("media: i2c: ds90ub960: Protect alias_use_mask with a mutex")
> > >   818bd489f137 ("i2c: use client addresses directly in ATR interface")
> > > 
> > > from the i2c tree and commits:
> > > 
> > >   24868501a744 ("media: i2c: ds90ub9xx: Add err parameter to read/write funcs")
> > >   2ca499384e98 ("media: i2c: ds90ub960: Add RX port iteration support")
> > > 
> > > from the v4l-dvb tree.
> > > 
> > > I fixed it up (see below) and can carry the fix as necessary. This
> > > is now fixed as far as linux-next is concerned, but any non trivial
> > > conflicts should be mentioned to your upstream maintainer when your tree
> > > is submitted for merging.  You may also want to consider cooperating
> > > with the maintainer of the conflicting tree to minimise any particularly
> > > complex conflicts.    
> > 
> > The actual resolution is below ...  
> 
> I hit the wrong key :-(   Resolution below.
> -- 
> Cheers,
> Stephen Rothwell
> 
> diff --cc drivers/media/i2c/ds90ub960.c
> index 5a4d5de110bd,1877eb735cc7..000000000000
> --- a/drivers/media/i2c/ds90ub960.c
> +++ b/drivers/media/i2c/ds90ub960.c
> @@@ -1056,11 -1271,10 +1274,12 @@@ static int ub960_atr_attach_addr(struc
>   	struct ub960_rxport *rxport = priv->rxports[chan_id];
>   	struct device *dev = &priv->client->dev;
>   	unsigned int reg_idx;
> + 	int ret = 0;
>   
>  -	for (reg_idx = 0; reg_idx < ARRAY_SIZE(rxport->aliased_clients); reg_idx++) {
>  -		if (!rxport->aliased_clients[reg_idx])
>  +	guard(mutex)(&rxport->aliased_addrs_lock);
>  +
>  +	for (reg_idx = 0; reg_idx < ARRAY_SIZE(rxport->aliased_addrs); reg_idx++) {
>  +		if (!rxport->aliased_addrs[reg_idx])
>   			break;
>   	}
>   
> @@@ -1069,15 -1283,18 +1288,18 @@@
>   		return -EADDRNOTAVAIL;
>   	}
>   
>  -	rxport->aliased_clients[reg_idx] = client;
>  +	rxport->aliased_addrs[reg_idx] = addr;
>   
>   	ub960_rxport_write(priv, chan_id, UB960_RR_SLAVE_ID(reg_idx),
> - 			   addr << 1);
>  -			   client->addr << 1, &ret);
> ++			   addr << 1, &ret);
>   	ub960_rxport_write(priv, chan_id, UB960_RR_SLAVE_ALIAS(reg_idx),
> - 			   alias << 1);
> + 			   alias << 1, &ret);
> + 
> + 	if (ret)
> + 		return ret;
>   
>   	dev_dbg(dev, "rx%u: client 0x%02x assigned alias 0x%02x at slot %u\n",
>  -		rxport->nport, client->addr, alias, reg_idx);
>  +		rxport->nport, addr, alias, reg_idx);
>   
>   	return 0;
>   }
> @@@ -1089,11 -1306,10 +1311,12 @@@ static void ub960_atr_detach_addr(struc
>   	struct ub960_rxport *rxport = priv->rxports[chan_id];
>   	struct device *dev = &priv->client->dev;
>   	unsigned int reg_idx;
> + 	int ret;
>   
>  -	for (reg_idx = 0; reg_idx < ARRAY_SIZE(rxport->aliased_clients); reg_idx++) {
>  -		if (rxport->aliased_clients[reg_idx] == client)
>  +	guard(mutex)(&rxport->aliased_addrs_lock);
>  +
>  +	for (reg_idx = 0; reg_idx < ARRAY_SIZE(rxport->aliased_addrs); reg_idx++) {
>  +		if (rxport->aliased_addrs[reg_idx] == addr)
>   			break;
>   	}
>   
> @@@ -1103,12 -1319,18 +1326,18 @@@
>   		return;
>   	}
>   
>  -	rxport->aliased_clients[reg_idx] = NULL;
>  +	rxport->aliased_addrs[reg_idx] = 0;
>   
> - 	ub960_rxport_write(priv, chan_id, UB960_RR_SLAVE_ALIAS(reg_idx), 0);
> + 	ret = ub960_rxport_write(priv, chan_id, UB960_RR_SLAVE_ALIAS(reg_idx),
> + 				 0, NULL);
> + 	if (ret) {
> + 		dev_err(dev, "rx%u: unable to fully unmap client 0x%02x: %d\n",
>  -			rxport->nport, client->addr, ret);
> ++			rxport->nport, addr, ret);
> + 		return;
> + 	}
>   
>   	dev_dbg(dev, "rx%u: client 0x%02x released at slot %u\n", rxport->nport,
>  -		client->addr, reg_idx);
>  +		addr, reg_idx);
>   }
>   
>   static const struct i2c_atr_ops ub960_atr_ops = {
> @@@ -3231,21 -4370,12 +4376,14 @@@ static void ub960_txport_free_ports(str
>   
>   static void ub960_rxport_free_ports(struct ub960_data *priv)
>   {
> - 	unsigned int nport;
> + 	for_each_active_rxport(priv, it) {
> + 		fwnode_handle_put(it.rxport->source.ep_fwnode);
> + 		fwnode_handle_put(it.rxport->ser.fwnode);
>   
> - 	for (nport = 0; nport < priv->hw_data->num_rxports; nport++) {
> - 		struct ub960_rxport *rxport = priv->rxports[nport];
> ++		mutex_destroy(&it.rxport->aliased_addrs_lock);
>  +
> - 		if (!rxport)
> - 			continue;
> - 
> - 		fwnode_handle_put(rxport->source.ep_fwnode);
> - 		fwnode_handle_put(rxport->ser.fwnode);
> - 
> - 		mutex_destroy(&rxport->aliased_addrs_lock);
> - 
> - 		kfree(rxport);
> - 		priv->rxports[nport] = NULL;
> + 		kfree(it.rxport);
> + 		priv->rxports[it.nport] = NULL;
>   	}
>   }

This is now a conflict between the i2c tree and Linus' tree.

-- 
Cheers,
Stephen Rothwell