aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2008-06-18 08:46:27 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-07-21 18:16:38 -0400
commit64b3d6d11948cc71ff12124dcb693392a32f1bf4 (patch)
treed13757608f2bc1ad90ce7bfa99784546c499225e /drivers/usb/host
parent71be4f81e97fe1f42c48a6dfc411dc6d3c18687f (diff)
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>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/ohci-pnx4008.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
index 7062ab5feecd..6ad8f2fc57b9 100644
--- a/drivers/usb/host/ohci-pnx4008.c
+++ b/drivers/usb/host/ohci-pnx4008.c
@@ -109,8 +109,6 @@ static struct clk *usb_clk;
109 109
110static int isp1301_probe(struct i2c_adapter *adap); 110static int isp1301_probe(struct i2c_adapter *adap);
111static int isp1301_detach(struct i2c_client *client); 111static int isp1301_detach(struct i2c_client *client);
112static int isp1301_command(struct i2c_client *client, unsigned int cmd,
113 void *arg);
114 112
115static const unsigned short normal_i2c[] = 113static const unsigned short normal_i2c[] =
116 { ISP1301_I2C_ADDR, ISP1301_I2C_ADDR + 1, I2C_CLIENT_END }; 114 { ISP1301_I2C_ADDR, ISP1301_I2C_ADDR + 1, I2C_CLIENT_END };
@@ -123,30 +121,37 @@ static struct i2c_client_address_data addr_data = {
123}; 121};
124 122
125struct i2c_driver isp1301_driver = { 123struct i2c_driver isp1301_driver = {
126 .class = I2C_CLASS_HWMON, 124 .driver = {
125 .name = "isp1301_pnx",
126 },
127 .attach_adapter = isp1301_probe, 127 .attach_adapter = isp1301_probe,
128 .detach_client = isp1301_detach, 128 .detach_client = isp1301_detach,
129 .command = isp1301_command
130}; 129};
131 130
132static int isp1301_attach(struct i2c_adapter *adap, int addr, int kind) 131static int isp1301_attach(struct i2c_adapter *adap, int addr, int kind)
133{ 132{
134 struct i2c_client *c; 133 struct i2c_client *c;
134 int err;
135 135
136 c = kzalloc(sizeof(*c), GFP_KERNEL); 136 c = kzalloc(sizeof(*c), GFP_KERNEL);
137
138 if (!c) 137 if (!c)
139 return -ENOMEM; 138 return -ENOMEM;
140 139
141 strcpy(c->name, "isp1301"); 140 strlcpy(c->name, "isp1301_pnx", I2C_NAME_SIZE);
142 c->flags = 0; 141 c->flags = 0;
143 c->addr = addr; 142 c->addr = addr;
144 c->adapter = adap; 143 c->adapter = adap;
145 c->driver = &isp1301_driver; 144 c->driver = &isp1301_driver;
146 145
146 err = i2c_attach_client(c);
147 if (err) {
148 kfree(c);
149 return err;
150 }
151
147 isp1301_i2c_client = c; 152 isp1301_i2c_client = c;
148 153
149 return i2c_attach_client(c); 154 return 0;
150} 155}
151 156
152static int isp1301_probe(struct i2c_adapter *adap) 157static int isp1301_probe(struct i2c_adapter *adap)
@@ -161,13 +166,6 @@ static int isp1301_detach(struct i2c_client *client)
161 return 0; 166 return 0;
162} 167}
163 168
164/* No commands defined */
165static int isp1301_command(struct i2c_client *client, unsigned int cmd,
166 void *arg)
167{
168 return 0;
169}
170
171static void i2c_write(u8 buf, u8 subaddr) 169static void i2c_write(u8 buf, u8 subaddr)
172{ 170{
173 char tmpbuf[2]; 171 char tmpbuf[2];