aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2008-07-14 16:38:36 -0400
committerJean Delvare <khali@mahadeva.delvare>2008-07-14 16:38:36 -0400
commitf741f673298b03b92d46e30b0b6fd0e960423665 (patch)
tree73a48fc17a8022b50d0da55fb3fd6f2d686582e6 /drivers/i2c
parentb1204e6ec16468ebf89d9d818bfe425ca7adcdf3 (diff)
i2c: Clean up old chip drivers
Clean up old i2c chip drivers: * Name the i2c_client "client" instead of "new_client". * Drop useless initializations to 0. Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/chips/eeprom.c32
-rw-r--r--drivers/i2c/chips/max6875.c4
-rw-r--r--drivers/i2c/chips/pca9539.c25
-rw-r--r--drivers/i2c/chips/pcf8574.c23
-rw-r--r--drivers/i2c/chips/pcf8591.c31
5 files changed, 54 insertions, 61 deletions
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
index e22ec3b3aedf..373ea8d8fe8f 100644
--- a/drivers/i2c/chips/eeprom.c
+++ b/drivers/i2c/chips/eeprom.c
@@ -158,7 +158,7 @@ static int eeprom_attach_adapter(struct i2c_adapter *adapter)
158/* This function is called by i2c_probe */ 158/* This function is called by i2c_probe */
159static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) 159static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
160{ 160{
161 struct i2c_client *new_client; 161 struct i2c_client *client;
162 struct eeprom_data *data; 162 struct eeprom_data *data;
163 int err = 0; 163 int err = 0;
164 164
@@ -184,22 +184,20 @@ static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
184 goto exit; 184 goto exit;
185 } 185 }
186 186
187 new_client = &data->client; 187 client = &data->client;
188 memset(data->data, 0xff, EEPROM_SIZE); 188 memset(data->data, 0xff, EEPROM_SIZE);
189 i2c_set_clientdata(new_client, data); 189 i2c_set_clientdata(client, data);
190 new_client->addr = address; 190 client->addr = address;
191 new_client->adapter = adapter; 191 client->adapter = adapter;
192 new_client->driver = &eeprom_driver; 192 client->driver = &eeprom_driver;
193 new_client->flags = 0;
194 193
195 /* Fill in the remaining client fields */ 194 /* Fill in the remaining client fields */
196 strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE); 195 strlcpy(client->name, "eeprom", I2C_NAME_SIZE);
197 data->valid = 0;
198 mutex_init(&data->update_lock); 196 mutex_init(&data->update_lock);
199 data->nature = UNKNOWN; 197 data->nature = UNKNOWN;
200 198
201 /* Tell the I2C layer a new client has arrived */ 199 /* Tell the I2C layer a new client has arrived */
202 if ((err = i2c_attach_client(new_client))) 200 if ((err = i2c_attach_client(client)))
203 goto exit_kfree; 201 goto exit_kfree;
204 202
205 /* Detect the Vaio nature of EEPROMs. 203 /* Detect the Vaio nature of EEPROMs.
@@ -208,27 +206,27 @@ static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
208 && i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA)) { 206 && i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
209 char name[4]; 207 char name[4];
210 208
211 name[0] = i2c_smbus_read_byte_data(new_client, 0x80); 209 name[0] = i2c_smbus_read_byte_data(client, 0x80);
212 name[1] = i2c_smbus_read_byte_data(new_client, 0x81); 210 name[1] = i2c_smbus_read_byte_data(client, 0x81);
213 name[2] = i2c_smbus_read_byte_data(new_client, 0x82); 211 name[2] = i2c_smbus_read_byte_data(client, 0x82);
214 name[3] = i2c_smbus_read_byte_data(new_client, 0x83); 212 name[3] = i2c_smbus_read_byte_data(client, 0x83);
215 213
216 if (!memcmp(name, "PCG-", 4) || !memcmp(name, "VGN-", 4)) { 214 if (!memcmp(name, "PCG-", 4) || !memcmp(name, "VGN-", 4)) {
217 dev_info(&new_client->dev, "Vaio EEPROM detected, " 215 dev_info(&client->dev, "Vaio EEPROM detected, "
218 "enabling privacy protection\n"); 216 "enabling privacy protection\n");
219 data->nature = VAIO; 217 data->nature = VAIO;
220 } 218 }
221 } 219 }
222 220
223 /* create the sysfs eeprom file */ 221 /* create the sysfs eeprom file */
224 err = sysfs_create_bin_file(&new_client->dev.kobj, &eeprom_attr); 222 err = sysfs_create_bin_file(&client->dev.kobj, &eeprom_attr);
225 if (err) 223 if (err)
226 goto exit_detach; 224 goto exit_detach;
227 225
228 return 0; 226 return 0;
229 227
230exit_detach: 228exit_detach:
231 i2c_detach_client(new_client); 229 i2c_detach_client(client);
232exit_kfree: 230exit_kfree:
233 kfree(data); 231 kfree(data);
234exit: 232exit:
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c
index cf507b3f60f3..5a0285d8b6f9 100644
--- a/drivers/i2c/chips/max6875.c
+++ b/drivers/i2c/chips/max6875.c
@@ -170,7 +170,7 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
170 struct i2c_client *real_client; 170 struct i2c_client *real_client;
171 struct i2c_client *fake_client; 171 struct i2c_client *fake_client;
172 struct max6875_data *data; 172 struct max6875_data *data;
173 int err = 0; 173 int err;
174 174
175 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA 175 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA
176 | I2C_FUNC_SMBUS_READ_BYTE)) 176 | I2C_FUNC_SMBUS_READ_BYTE))
@@ -195,7 +195,6 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
195 real_client->addr = address; 195 real_client->addr = address;
196 real_client->adapter = adapter; 196 real_client->adapter = adapter;
197 real_client->driver = &max6875_driver; 197 real_client->driver = &max6875_driver;
198 real_client->flags = 0;
199 strlcpy(real_client->name, "max6875", I2C_NAME_SIZE); 198 strlcpy(real_client->name, "max6875", I2C_NAME_SIZE);
200 mutex_init(&data->update_lock); 199 mutex_init(&data->update_lock);
201 200
@@ -204,7 +203,6 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
204 fake_client->addr = address | 1; 203 fake_client->addr = address | 1;
205 fake_client->adapter = adapter; 204 fake_client->adapter = adapter;
206 fake_client->driver = &max6875_driver; 205 fake_client->driver = &max6875_driver;
207 fake_client->flags = 0;
208 strlcpy(fake_client->name, "max6875 subclient", I2C_NAME_SIZE); 206 strlcpy(fake_client->name, "max6875 subclient", I2C_NAME_SIZE);
209 207
210 if ((err = i2c_attach_client(real_client)) != 0) 208 if ((err = i2c_attach_client(real_client)) != 0)
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c
index f43c4e79b55e..58ab7f26be26 100644
--- a/drivers/i2c/chips/pca9539.c
+++ b/drivers/i2c/chips/pca9539.c
@@ -113,7 +113,7 @@ static int pca9539_attach_adapter(struct i2c_adapter *adapter)
113/* This function is called by i2c_probe */ 113/* This function is called by i2c_probe */
114static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind) 114static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
115{ 115{
116 struct i2c_client *new_client; 116 struct i2c_client *client;
117 struct pca9539_data *data; 117 struct pca9539_data *data;
118 int err = 0; 118 int err = 0;
119 119
@@ -127,29 +127,28 @@ static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
127 goto exit; 127 goto exit;
128 } 128 }
129 129
130 new_client = &data->client; 130 client = &data->client;
131 i2c_set_clientdata(new_client, data); 131 i2c_set_clientdata(client, data);
132 new_client->addr = address; 132 client->addr = address;
133 new_client->adapter = adapter; 133 client->adapter = adapter;
134 new_client->driver = &pca9539_driver; 134 client->driver = &pca9539_driver;
135 new_client->flags = 0;
136 135
137 if (kind < 0) { 136 if (kind < 0) {
138 /* Detection: the pca9539 only has 8 registers (0-7). 137 /* Detection: the pca9539 only has 8 registers (0-7).
139 A read of 7 should succeed, but a read of 8 should fail. */ 138 A read of 7 should succeed, but a read of 8 should fail. */
140 if ((i2c_smbus_read_byte_data(new_client, 7) < 0) || 139 if ((i2c_smbus_read_byte_data(client, 7) < 0) ||
141 (i2c_smbus_read_byte_data(new_client, 8) >= 0)) 140 (i2c_smbus_read_byte_data(client, 8) >= 0))
142 goto exit_kfree; 141 goto exit_kfree;
143 } 142 }
144 143
145 strlcpy(new_client->name, "pca9539", I2C_NAME_SIZE); 144 strlcpy(client->name, "pca9539", I2C_NAME_SIZE);
146 145
147 /* Tell the I2C layer a new client has arrived */ 146 /* Tell the I2C layer a new client has arrived */
148 if ((err = i2c_attach_client(new_client))) 147 if ((err = i2c_attach_client(client)))
149 goto exit_kfree; 148 goto exit_kfree;
150 149
151 /* Register sysfs hooks */ 150 /* Register sysfs hooks */
152 err = sysfs_create_group(&new_client->dev.kobj, 151 err = sysfs_create_group(&client->dev.kobj,
153 &pca9539_defattr_group); 152 &pca9539_defattr_group);
154 if (err) 153 if (err)
155 goto exit_detach; 154 goto exit_detach;
@@ -157,7 +156,7 @@ static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
157 return 0; 156 return 0;
158 157
159exit_detach: 158exit_detach:
160 i2c_detach_client(new_client); 159 i2c_detach_client(client);
161exit_kfree: 160exit_kfree:
162 kfree(data); 161 kfree(data);
163exit: 162exit:
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c
index ad2f7901a8c9..1b3db2b3ada9 100644
--- a/drivers/i2c/chips/pcf8574.c
+++ b/drivers/i2c/chips/pcf8574.c
@@ -127,7 +127,7 @@ static int pcf8574_attach_adapter(struct i2c_adapter *adapter)
127/* This function is called by i2c_probe */ 127/* This function is called by i2c_probe */
128static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind) 128static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind)
129{ 129{
130 struct i2c_client *new_client; 130 struct i2c_client *client;
131 struct pcf8574_data *data; 131 struct pcf8574_data *data;
132 int err = 0; 132 int err = 0;
133 const char *client_name = ""; 133 const char *client_name = "";
@@ -142,12 +142,11 @@ static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind)
142 goto exit; 142 goto exit;
143 } 143 }
144 144
145 new_client = &data->client; 145 client = &data->client;
146 i2c_set_clientdata(new_client, data); 146 i2c_set_clientdata(client, data);
147 new_client->addr = address; 147 client->addr = address;
148 new_client->adapter = adapter; 148 client->adapter = adapter;
149 new_client->driver = &pcf8574_driver; 149 client->driver = &pcf8574_driver;
150 new_client->flags = 0;
151 150
152 /* Now, we would do the remaining detection. But the PCF8574 is plainly 151 /* Now, we would do the remaining detection. But the PCF8574 is plainly
153 impossible to detect! Stupid chip. */ 152 impossible to detect! Stupid chip. */
@@ -166,23 +165,23 @@ static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind)
166 client_name = "pcf8574"; 165 client_name = "pcf8574";
167 166
168 /* Fill in the remaining client fields and put it into the global list */ 167 /* Fill in the remaining client fields and put it into the global list */
169 strlcpy(new_client->name, client_name, I2C_NAME_SIZE); 168 strlcpy(client->name, client_name, I2C_NAME_SIZE);
170 169
171 /* Tell the I2C layer a new client has arrived */ 170 /* Tell the I2C layer a new client has arrived */
172 if ((err = i2c_attach_client(new_client))) 171 if ((err = i2c_attach_client(client)))
173 goto exit_free; 172 goto exit_free;
174 173
175 /* Initialize the PCF8574 chip */ 174 /* Initialize the PCF8574 chip */
176 pcf8574_init_client(new_client); 175 pcf8574_init_client(client);
177 176
178 /* Register sysfs hooks */ 177 /* Register sysfs hooks */
179 err = sysfs_create_group(&new_client->dev.kobj, &pcf8574_attr_group); 178 err = sysfs_create_group(&client->dev.kobj, &pcf8574_attr_group);
180 if (err) 179 if (err)
181 goto exit_detach; 180 goto exit_detach;
182 return 0; 181 return 0;
183 182
184 exit_detach: 183 exit_detach:
185 i2c_detach_client(new_client); 184 i2c_detach_client(client);
186 exit_free: 185 exit_free:
187 kfree(data); 186 kfree(data);
188 exit: 187 exit:
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c
index d3a24524817a..db735379f22f 100644
--- a/drivers/i2c/chips/pcf8591.c
+++ b/drivers/i2c/chips/pcf8591.c
@@ -188,7 +188,7 @@ static int pcf8591_attach_adapter(struct i2c_adapter *adapter)
188/* This function is called by i2c_probe */ 188/* This function is called by i2c_probe */
189static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) 189static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
190{ 190{
191 struct i2c_client *new_client; 191 struct i2c_client *client;
192 struct pcf8591_data *data; 192 struct pcf8591_data *data;
193 int err = 0; 193 int err = 0;
194 194
@@ -203,12 +203,11 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
203 goto exit; 203 goto exit;
204 } 204 }
205 205
206 new_client = &data->client; 206 client = &data->client;
207 i2c_set_clientdata(new_client, data); 207 i2c_set_clientdata(client, data);
208 new_client->addr = address; 208 client->addr = address;
209 new_client->adapter = adapter; 209 client->adapter = adapter;
210 new_client->driver = &pcf8591_driver; 210 client->driver = &pcf8591_driver;
211 new_client->flags = 0;
212 211
213 /* Now, we would do the remaining detection. But the PCF8591 is plainly 212 /* Now, we would do the remaining detection. But the PCF8591 is plainly
214 impossible to detect! Stupid chip. */ 213 impossible to detect! Stupid chip. */
@@ -219,31 +218,31 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
219 218
220 /* Fill in the remaining client fields and put it into the global 219 /* Fill in the remaining client fields and put it into the global
221 list */ 220 list */
222 strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE); 221 strlcpy(client->name, "pcf8591", I2C_NAME_SIZE);
223 mutex_init(&data->update_lock); 222 mutex_init(&data->update_lock);
224 223
225 /* Tell the I2C layer a new client has arrived */ 224 /* Tell the I2C layer a new client has arrived */
226 if ((err = i2c_attach_client(new_client))) 225 if ((err = i2c_attach_client(client)))
227 goto exit_kfree; 226 goto exit_kfree;
228 227
229 /* Initialize the PCF8591 chip */ 228 /* Initialize the PCF8591 chip */
230 pcf8591_init_client(new_client); 229 pcf8591_init_client(client);
231 230
232 /* Register sysfs hooks */ 231 /* Register sysfs hooks */
233 err = sysfs_create_group(&new_client->dev.kobj, &pcf8591_attr_group); 232 err = sysfs_create_group(&client->dev.kobj, &pcf8591_attr_group);
234 if (err) 233 if (err)
235 goto exit_detach; 234 goto exit_detach;
236 235
237 /* Register input2 if not in "two differential inputs" mode */ 236 /* Register input2 if not in "two differential inputs" mode */
238 if (input_mode != 3) { 237 if (input_mode != 3) {
239 if ((err = device_create_file(&new_client->dev, 238 if ((err = device_create_file(&client->dev,
240 &dev_attr_in2_input))) 239 &dev_attr_in2_input)))
241 goto exit_sysfs_remove; 240 goto exit_sysfs_remove;
242 } 241 }
243 242
244 /* Register input3 only in "four single ended inputs" mode */ 243 /* Register input3 only in "four single ended inputs" mode */
245 if (input_mode == 0) { 244 if (input_mode == 0) {
246 if ((err = device_create_file(&new_client->dev, 245 if ((err = device_create_file(&client->dev,
247 &dev_attr_in3_input))) 246 &dev_attr_in3_input)))
248 goto exit_sysfs_remove; 247 goto exit_sysfs_remove;
249 } 248 }
@@ -251,10 +250,10 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
251 return 0; 250 return 0;
252 251
253exit_sysfs_remove: 252exit_sysfs_remove:
254 sysfs_remove_group(&new_client->dev.kobj, &pcf8591_attr_group_opt); 253 sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt);
255 sysfs_remove_group(&new_client->dev.kobj, &pcf8591_attr_group); 254 sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group);
256exit_detach: 255exit_detach:
257 i2c_detach_client(new_client); 256 i2c_detach_client(client);
258exit_kfree: 257exit_kfree:
259 kfree(data); 258 kfree(data);
260exit: 259exit: