diff options
author | Lukas Wunner <lukas@wunner.de> | 2017-06-06 08:25:04 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-06-09 05:42:42 -0400 |
commit | 02b17a41ad102934a3772ffc82f345345c232ee4 (patch) | |
tree | 450c50597bdf621d2ad82556b92de67bae46ad55 /drivers/thunderbolt | |
parent | 390229455535d75a9bdd19437054413d677fc7b0 (diff) |
thunderbolt: Refactor and fix parsing of port drom entries
Currently tb_drom_parse_entry() is only able to parse drom entries of
type TB_DROM_ENTRY_PORT. Rename it to tb_drom_parse_entry_port().
Fold tb_drom_parse_port_entry() into it.
Its return value is currently ignored. Evaluate it and abort parsing on
error.
Change tb_drom_parse_entries() to accommodate for parsing of other entry
types than TB_DROM_ENTRY_PORT.
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/thunderbolt')
-rw-r--r-- | drivers/thunderbolt/eeprom.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/drivers/thunderbolt/eeprom.c b/drivers/thunderbolt/eeprom.c index e2c1f8a45522..5c7d80a109b1 100644 --- a/drivers/thunderbolt/eeprom.c +++ b/drivers/thunderbolt/eeprom.c | |||
@@ -295,25 +295,13 @@ int tb_drom_read_uid_only(struct tb_switch *sw, u64 *uid) | |||
295 | return 0; | 295 | return 0; |
296 | } | 296 | } |
297 | 297 | ||
298 | static void tb_drom_parse_port_entry(struct tb_port *port, | 298 | static int tb_drom_parse_entry_port(struct tb_switch *sw, |
299 | struct tb_drom_entry_port *entry) | 299 | struct tb_drom_entry_header *header) |
300 | { | ||
301 | port->link_nr = entry->link_nr; | ||
302 | if (entry->has_dual_link_port) | ||
303 | port->dual_link_port = | ||
304 | &port->sw->ports[entry->dual_link_port_nr]; | ||
305 | } | ||
306 | |||
307 | static int tb_drom_parse_entry(struct tb_switch *sw, | ||
308 | struct tb_drom_entry_header *header) | ||
309 | { | 300 | { |
310 | struct tb_port *port; | 301 | struct tb_port *port; |
311 | int res; | 302 | int res; |
312 | enum tb_port_type type; | 303 | enum tb_port_type type; |
313 | 304 | ||
314 | if (header->type != TB_DROM_ENTRY_PORT) | ||
315 | return 0; | ||
316 | |||
317 | port = &sw->ports[header->index]; | 305 | port = &sw->ports[header->index]; |
318 | port->disabled = header->port_disabled; | 306 | port->disabled = header->port_disabled; |
319 | if (port->disabled) | 307 | if (port->disabled) |
@@ -332,7 +320,10 @@ static int tb_drom_parse_entry(struct tb_switch *sw, | |||
332 | header->len, sizeof(struct tb_drom_entry_port)); | 320 | header->len, sizeof(struct tb_drom_entry_port)); |
333 | return -EIO; | 321 | return -EIO; |
334 | } | 322 | } |
335 | tb_drom_parse_port_entry(port, entry); | 323 | port->link_nr = entry->link_nr; |
324 | if (entry->has_dual_link_port) | ||
325 | port->dual_link_port = | ||
326 | &port->sw->ports[entry->dual_link_port_nr]; | ||
336 | } | 327 | } |
337 | return 0; | 328 | return 0; |
338 | } | 329 | } |
@@ -347,6 +338,7 @@ static int tb_drom_parse_entries(struct tb_switch *sw) | |||
347 | struct tb_drom_header *header = (void *) sw->drom; | 338 | struct tb_drom_header *header = (void *) sw->drom; |
348 | u16 pos = sizeof(*header); | 339 | u16 pos = sizeof(*header); |
349 | u16 drom_size = header->data_len + TB_DROM_DATA_START; | 340 | u16 drom_size = header->data_len + TB_DROM_DATA_START; |
341 | int res; | ||
350 | 342 | ||
351 | while (pos < drom_size) { | 343 | while (pos < drom_size) { |
352 | struct tb_drom_entry_header *entry = (void *) (sw->drom + pos); | 344 | struct tb_drom_entry_header *entry = (void *) (sw->drom + pos); |
@@ -356,7 +348,15 @@ static int tb_drom_parse_entries(struct tb_switch *sw) | |||
356 | return -EIO; | 348 | return -EIO; |
357 | } | 349 | } |
358 | 350 | ||
359 | tb_drom_parse_entry(sw, entry); | 351 | switch (entry->type) { |
352 | case TB_DROM_ENTRY_GENERIC: | ||
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 | 360 | ||
361 | pos += entry->len; | 361 | pos += entry->len; |
362 | } | 362 | } |