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.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
index d3da1fb05b9b..1a7eeebac506 100644
--- a/drivers/i2c/chips/eeprom.c
+++ b/drivers/i2c/chips/eeprom.c
@@ -128,13 +128,20 @@ static ssize_t eeprom_read(struct kobject *kobj, struct bin_attribute *bin_attr,
128 for (slice = off >> 5; slice <= (off + count - 1) >> 5; slice++) 128 for (slice = off >> 5; slice <= (off + count - 1) >> 5; slice++)
129 eeprom_update_client(client, slice); 129 eeprom_update_client(client, slice);
130 130
131 /* Hide Vaio security settings to regular users (16 first bytes) */ 131 /* Hide Vaio private settings to regular users:
132 if (data->nature == VAIO && off < 16 && !capable(CAP_SYS_ADMIN)) { 132 - BIOS passwords: bytes 0x00 to 0x0f
133 size_t in_row1 = 16 - off; 133 - UUID: bytes 0x10 to 0x1f
134 in_row1 = min(in_row1, count); 134 - Serial number: 0xc0 to 0xdf */
135 memset(buf, 0, in_row1); 135 if (data->nature == VAIO && !capable(CAP_SYS_ADMIN)) {
136 if (count - in_row1 > 0) 136 int i;
137 memcpy(buf + in_row1, &data->data[16], count - in_row1); 137
138 for (i = 0; i < count; i++) {
139 if ((off + i <= 0x1f) ||
140 (off + i >= 0xc0 && off + i <= 0xdf))
141 buf[i] = 0;
142 else
143 buf[i] = data->data[off + i];
144 }
138 } else { 145 } else {
139 memcpy(buf, &data->data[off], count); 146 memcpy(buf, &data->data[off], count);
140 } 147 }
@@ -197,14 +204,18 @@ static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
197 goto exit_kfree; 204 goto exit_kfree;
198 205
199 /* Detect the Vaio nature of EEPROMs. 206 /* Detect the Vaio nature of EEPROMs.
200 We use the "PCG-" prefix as the signature. */ 207 We use the "PCG-" or "VGN-" prefix as the signature. */
201 if (address == 0x57) { 208 if (address == 0x57) {
202 if (i2c_smbus_read_byte_data(new_client, 0x80) == 'P' 209 char name[4];
203 && i2c_smbus_read_byte(new_client) == 'C' 210
204 && i2c_smbus_read_byte(new_client) == 'G' 211 name[0] = i2c_smbus_read_byte_data(new_client, 0x80);
205 && i2c_smbus_read_byte(new_client) == '-') { 212 name[1] = i2c_smbus_read_byte(new_client);
213 name[2] = i2c_smbus_read_byte(new_client);
214 name[3] = i2c_smbus_read_byte(new_client);
215
216 if (!memcmp(name, "PCG-", 4) || !memcmp(name, "VGN-", 4)) {
206 dev_info(&new_client->dev, "Vaio EEPROM detected, " 217 dev_info(&new_client->dev, "Vaio EEPROM detected, "
207 "enabling password protection\n"); 218 "enabling privacy protection\n");
208 data->nature = VAIO; 219 data->nature = VAIO;
209 } 220 }
210 } 221 }