Skip to content

Commit

Permalink
[PATCH] i2c: Handle i2c_add_adapter failure in i2c algorithm drivers
Browse files Browse the repository at this point in the history
Content-Disposition: inline; filename=i2c-algo-error-handling-fix.patch

It is possible for i2c_add_adapter() to fail.  Several I2C algorithm
drivers ignore that fact.  This (compile-tested only) patch fixes them.

Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Mark M. Hoffman authored and Greg Kroah-Hartman committed Jul 12, 2006
1 parent 5d925fe commit b39ad0c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
3 changes: 1 addition & 2 deletions drivers/i2c/algos/i2c-algo-bit.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,7 @@ int i2c_bit_add_bus(struct i2c_adapter *adap)
adap->timeout = 100; /* default values, should */
adap->retries = 3; /* be replaced by defines */

i2c_add_adapter(adap);
return 0;
return i2c_add_adapter(adap);
}


Expand Down
4 changes: 1 addition & 3 deletions drivers/i2c/algos/i2c-algo-ite.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,10 +742,8 @@ int i2c_iic_add_bus(struct i2c_adapter *adap)
adap->retries = 3; /* be replaced by defines */
adap->flags = 0;

i2c_add_adapter(adap);
iic_init(iic_adap);

return 0;
return i2c_add_adapter(adap);
}


Expand Down
6 changes: 3 additions & 3 deletions drivers/i2c/algos/i2c-algo-pca.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,10 @@ int i2c_pca_add_bus(struct i2c_adapter *adap)
adap->timeout = 100; /* default values, should */
adap->retries = 3; /* be replaced by defines */

rval = pca_init(pca_adap);
if ((rval = pca_init(pca_adap)))
return rval;

if (!rval)
i2c_add_adapter(adap);
rval = i2c_add_adapter(adap);

return rval;
}
Expand Down
8 changes: 5 additions & 3 deletions drivers/i2c/algos/i2c-algo-pcf.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,11 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
adap->timeout = 100; /* default values, should */
adap->retries = 3; /* be replaced by defines */

rval = pcf_init_8584(pcf_adap);
if (!rval)
i2c_add_adapter(adap);
if ((rval = pcf_init_8584(pcf_adap)))
return rval;

rval = i2c_add_adapter(adap);

return rval;
}

Expand Down
4 changes: 1 addition & 3 deletions drivers/i2c/algos/i2c-algo-sibyte.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@ int i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed)
printk("\n");
}

i2c_add_adapter(i2c_adap);

return 0;
return i2c_add_adapter(i2c_adap);
}


Expand Down

0 comments on commit b39ad0c

Please sign in to comment.