mirror of https://gitee.com/openkylin/linux.git
USB: ohci-pnx4008: I2C cleanups and fixes
Various cleanups and fixes to the i2c code in ohci-pnx4008: * Delete empty isp1301_command. The i2c driver command implementation is optional, so there's no point in providing an empty implementation. * Give a name to isp1301_driver. I'm surprised that i2c-core accepted to register this driver at all. I've chosen "isp1301_pnx" as the name, because it's not a generic ISP1301 driver (much like the isp1301_omap driver.) We might want to make the name even more specific (but "isp1301_ohci_pnx4008" doesn't fit.) * The ISP1301 is definitely not a hardware monitoring device. * Fix a memory leak on failure in isp1301_attach. If i2c_attach_client fails, the client is not registered so isp1301_detach is never called and the i2c_client memory is lost. * Use strlcpy instead of strcpy. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Vitaly Wool <vitalywool@gmail.com> Cc: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
71be4f81e9
commit
64b3d6d119
|
@ -109,8 +109,6 @@ static struct clk *usb_clk;
|
|||
|
||||
static int isp1301_probe(struct i2c_adapter *adap);
|
||||
static int isp1301_detach(struct i2c_client *client);
|
||||
static int isp1301_command(struct i2c_client *client, unsigned int cmd,
|
||||
void *arg);
|
||||
|
||||
static const unsigned short normal_i2c[] =
|
||||
{ ISP1301_I2C_ADDR, ISP1301_I2C_ADDR + 1, I2C_CLIENT_END };
|
||||
|
@ -123,30 +121,37 @@ static struct i2c_client_address_data addr_data = {
|
|||
};
|
||||
|
||||
struct i2c_driver isp1301_driver = {
|
||||
.class = I2C_CLASS_HWMON,
|
||||
.driver = {
|
||||
.name = "isp1301_pnx",
|
||||
},
|
||||
.attach_adapter = isp1301_probe,
|
||||
.detach_client = isp1301_detach,
|
||||
.command = isp1301_command
|
||||
};
|
||||
|
||||
static int isp1301_attach(struct i2c_adapter *adap, int addr, int kind)
|
||||
{
|
||||
struct i2c_client *c;
|
||||
int err;
|
||||
|
||||
c = kzalloc(sizeof(*c), GFP_KERNEL);
|
||||
|
||||
if (!c)
|
||||
return -ENOMEM;
|
||||
|
||||
strcpy(c->name, "isp1301");
|
||||
strlcpy(c->name, "isp1301_pnx", I2C_NAME_SIZE);
|
||||
c->flags = 0;
|
||||
c->addr = addr;
|
||||
c->adapter = adap;
|
||||
c->driver = &isp1301_driver;
|
||||
|
||||
err = i2c_attach_client(c);
|
||||
if (err) {
|
||||
kfree(c);
|
||||
return err;
|
||||
}
|
||||
|
||||
isp1301_i2c_client = c;
|
||||
|
||||
return i2c_attach_client(c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int isp1301_probe(struct i2c_adapter *adap)
|
||||
|
@ -161,13 +166,6 @@ static int isp1301_detach(struct i2c_client *client)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* No commands defined */
|
||||
static int isp1301_command(struct i2c_client *client, unsigned int cmd,
|
||||
void *arg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void i2c_write(u8 buf, u8 subaddr)
|
||||
{
|
||||
char tmpbuf[2];
|
||||
|
|
Loading…
Reference in New Issue