Re: [PATCH 1/2] i2c: Multiplexed I2C bus core support.

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

 



One thing I forgot:

On Thu, 15 Apr 2010 14:49:06 +0200, Jean Delvare wrote:
> On Mon, 25 Jan 2010 13:13:48 +0100, Michael Lawnick wrote:
> > +static int i2c_check_clients(struct i2c_adapter *adapter, int addr)
> > +{
> > +	int result = 0;
> 
> Useless initialization.
> 
> > +
> > +	result = device_for_each_child(&adapter->dev, &addr, __i2c_check_addr);
> > +
> > +	if (!result && (adapter->dev.parent->bus == &i2c_bus_type))
> 
> All devices don't have a parent, so you should first check that
> adapter->dev.parent isn't NULL. Try your code with i2c-stub for
> example, it would crash.
> 
> > +		result = i2c_check_clients(to_i2c_adapter(adapter->dev.parent), addr);
> > +	
> > +	return result;
> > +}

As discussed some weeks ago, this isn't actually sufficient. You don't
only need to check the parent segments for address business, you also
need to check all child segments, recursively. If any child segment has
a device using the address in question, then you can't use it.

This may be more difficult to implement. In particular, you'll have to
pay attention to locking.

-- 
Jean Delvare
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux