eeprom.c (02b17a41ad102934a3772ffc82f345345c232ee4) | eeprom.c (72ee33907b629355d8fd1980140a467041a9f519) |
---|---|
1/* 2 * Thunderbolt Cactus Ridge driver - eeprom access 3 * 4 * Copyright (c) 2014 Andreas Noever <andreas.noever@gmail.com> 5 */ 6 7#include <linux/crc32.h> 8#include <linux/property.h> --- 190 unchanged lines hidden (view full) --- 199 200struct tb_drom_entry_header { 201 u8 len; 202 u8 index:6; 203 bool port_disabled:1; /* only valid if type is TB_DROM_ENTRY_PORT */ 204 enum tb_drom_entry_type type:1; 205} __packed; 206 | 1/* 2 * Thunderbolt Cactus Ridge driver - eeprom access 3 * 4 * Copyright (c) 2014 Andreas Noever <andreas.noever@gmail.com> 5 */ 6 7#include <linux/crc32.h> 8#include <linux/property.h> --- 190 unchanged lines hidden (view full) --- 199 200struct tb_drom_entry_header { 201 u8 len; 202 u8 index:6; 203 bool port_disabled:1; /* only valid if type is TB_DROM_ENTRY_PORT */ 204 enum tb_drom_entry_type type:1; 205} __packed; 206 |
207struct tb_drom_entry_generic { 208 struct tb_drom_entry_header header; 209 u8 data[0]; 210} __packed; 211 |
|
207struct tb_drom_entry_port { 208 /* BYTES 0-1 */ 209 struct tb_drom_entry_header header; 210 /* BYTE 2 */ 211 u8 dual_link_port_rid:4; 212 u8 link_nr:1; 213 u8 unknown1:2; 214 bool has_dual_link_port:1; --- 75 unchanged lines hidden (view full) --- 290 data[0], crc); 291 return -EIO; 292 } 293 294 *uid = *(u64 *)(data+1); 295 return 0; 296} 297 | 212struct tb_drom_entry_port { 213 /* BYTES 0-1 */ 214 struct tb_drom_entry_header header; 215 /* BYTE 2 */ 216 u8 dual_link_port_rid:4; 217 u8 link_nr:1; 218 u8 unknown1:2; 219 bool has_dual_link_port:1; --- 75 unchanged lines hidden (view full) --- 295 data[0], crc); 296 return -EIO; 297 } 298 299 *uid = *(u64 *)(data+1); 300 return 0; 301} 302 |
303static int tb_drom_parse_entry_generic(struct tb_switch *sw, 304 struct tb_drom_entry_header *header) 305{ 306 const struct tb_drom_entry_generic *entry = 307 (const struct tb_drom_entry_generic *)header; 308 309 switch (header->index) { 310 case 1: 311 /* Length includes 2 bytes header so remove it before copy */ 312 sw->vendor_name = kstrndup(entry->data, 313 header->len - sizeof(*header), GFP_KERNEL); 314 if (!sw->vendor_name) 315 return -ENOMEM; 316 break; 317 318 case 2: 319 sw->device_name = kstrndup(entry->data, 320 header->len - sizeof(*header), GFP_KERNEL); 321 if (!sw->device_name) 322 return -ENOMEM; 323 break; 324 } 325 326 return 0; 327} 328 |
|
298static int tb_drom_parse_entry_port(struct tb_switch *sw, 299 struct tb_drom_entry_header *header) 300{ 301 struct tb_port *port; 302 int res; 303 enum tb_port_type type; 304 305 port = &sw->ports[header->index]; --- 39 unchanged lines hidden (view full) --- 345 if (pos + 1 == drom_size || pos + entry->len > drom_size 346 || !entry->len) { 347 tb_sw_warn(sw, "drom buffer overrun, aborting\n"); 348 return -EIO; 349 } 350 351 switch (entry->type) { 352 case TB_DROM_ENTRY_GENERIC: | 329static int tb_drom_parse_entry_port(struct tb_switch *sw, 330 struct tb_drom_entry_header *header) 331{ 332 struct tb_port *port; 333 int res; 334 enum tb_port_type type; 335 336 port = &sw->ports[header->index]; --- 39 unchanged lines hidden (view full) --- 376 if (pos + 1 == drom_size || pos + entry->len > drom_size 377 || !entry->len) { 378 tb_sw_warn(sw, "drom buffer overrun, aborting\n"); 379 return -EIO; 380 } 381 382 switch (entry->type) { 383 case TB_DROM_ENTRY_GENERIC: |
384 res = tb_drom_parse_entry_generic(sw, entry); |
|
353 break; 354 case TB_DROM_ENTRY_PORT: 355 res = tb_drom_parse_entry_port(sw, entry); 356 break; 357 } 358 if (res) 359 return res; 360 --- 142 unchanged lines hidden --- | 385 break; 386 case TB_DROM_ENTRY_PORT: 387 res = tb_drom_parse_entry_port(sw, entry); 388 break; 389 } 390 if (res) 391 return res; 392 --- 142 unchanged lines hidden --- |