aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/chips/eeprom.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/chips/eeprom.c')
-rw-r--r--drivers/i2c/chips/eeprom.c32
1 files changed, 15 insertions, 17 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: