Re: [PATCH v2 2/2] i2c: Add i2c_device_get_match_data() callback

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

 



On Wed, Jul 26, 2023 at 02:08:04PM +0100, Biju Das wrote:
> Add i2c_device_get_match_data() callback to struct bus_type().
> 
> While at it, introduced i2c_get_match_data_helper() to avoid code
> duplication with i2c_get_match_data().

I have not been Cc'ed to this...

...

> +static const void *i2c_device_get_match_data(const struct device *dev)
> +{
> +	const struct i2c_client *client = (dev->type == &i2c_client_type) ?
> +					  to_i2c_client(dev) : NULL;

There is an API i2c_verify_client() or something like this, I don't remember
by heart.

> +	if (!dev->driver)
> +		return NULL;
> +
> +	return i2c_get_match_data_helper(to_i2c_driver(dev->driver), client);
> +}

...

> +const void *i2c_get_match_data(const struct i2c_client *client)
> +{
> +	const struct i2c_driver *driver = to_i2c_driver(client->dev.driver);
>  	const void *data;
>  
>  	data = device_get_match_data(&client->dev);
> -	if (!data) {
> -		match = i2c_match_id(driver->id_table, client);
> -		if (!match)
> -			return NULL;
> -
> -		data = (const void *)match->driver_data;
> -	}
> +	if (!data)
> +		data = i2c_get_match_data_helper(driver, client);

	if (data)
		return data;

	return i2c_...;

>  
>  	return data;
>  }

...

Side question, what is the idea for i2c_of_match_device()? Shouldn't you also
take it into consideration?

-- 
With Best Regards,
Andy Shevchenko





[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