[i2c] [PATCH] i2c: Simplify i2c_device_probe

Ben Dooks ben-linux at fluff.org
Wed Jun 4 01:43:59 CEST 2008


On Tue, Jun 03, 2008 at 08:29:54PM +0200, Jean Delvare wrote:
> i2c_driver.id_table is mandatory now, so we can simplify
> i2c_device_probe() a bit.
> 
> Signed-off-by: Jean Delvare <khali at linux-fr.org>
> ---
>  drivers/i2c/i2c-core.c |    9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> --- linux-2.6.26-rc4.orig/drivers/i2c/i2c-core.c	2008-06-03 10:57:55.000000000 +0200
> +++ linux-2.6.26-rc4/drivers/i2c/i2c-core.c	2008-06-03 16:38:37.000000000 +0200
> @@ -101,19 +101,14 @@ static int i2c_device_probe(struct devic
>  {
>  	struct i2c_client	*client = to_i2c_client(dev);
>  	struct i2c_driver	*driver = to_i2c_driver(dev->driver);
> -	const struct i2c_device_id *id;
>  	int status;
>  
> -	if (!driver->probe)
> +	if (!driver->probe || !driver->id_table)
>  		return -ENODEV;
>  	client->driver = driver;
>  	dev_dbg(dev, "probe\n");
>  
> -	if (driver->id_table)
> -		id = i2c_match_id(driver->id_table, client);
> -	else
> -		id = NULL;
> -	status = driver->probe(client, id);
> +	status = driver->probe(client, i2c_match_id(driver->id_table, client));
>  	if (status)
>  		client->driver = NULL;
>  	return status;

Looks ok, will give it a test tommorow if possible.
 
> 
> -- 
> Jean Delvare

-- 
-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.




More information about the i2c mailing list