aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/firewire/core-device.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index f61211977d33..014cabd3afda 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -492,29 +492,29 @@ static int read_rom(struct fw_device *device,
492 return rcode; 492 return rcode;
493} 493}
494 494
495#define READ_BIB_ROM_SIZE 256 495#define MAX_CONFIG_ROM_SIZE 256
496 496
497/* 497/*
498 * Read the bus info block, perform a speed probe, and read all of the rest of 498 * Read the bus info block, perform a speed probe, and read all of the rest of
499 * the config ROM. We do all this with a cached bus generation. If the bus 499 * the config ROM. We do all this with a cached bus generation. If the bus
500 * generation changes under us, read_bus_info_block will fail and get retried. 500 * generation changes under us, read_config_rom will fail and get retried.
501 * It's better to start all over in this case because the node from which we 501 * It's better to start all over in this case because the node from which we
502 * are reading the ROM may have changed the ROM during the reset. 502 * are reading the ROM may have changed the ROM during the reset.
503 */ 503 */
504static int read_bus_info_block(struct fw_device *device, int generation) 504static int read_config_rom(struct fw_device *device, int generation)
505{ 505{
506 const u32 *old_rom, *new_rom; 506 const u32 *old_rom, *new_rom;
507 u32 *rom, *stack; 507 u32 *rom, *stack;
508 u32 sp, key; 508 u32 sp, key;
509 int i, end, length, ret = -1; 509 int i, end, length, ret = -1;
510 510
511 rom = kmalloc(sizeof(*rom) * READ_BIB_ROM_SIZE + 511 rom = kmalloc(sizeof(*rom) * MAX_CONFIG_ROM_SIZE +
512 sizeof(*stack) * READ_BIB_ROM_SIZE, GFP_KERNEL); 512 sizeof(*stack) * MAX_CONFIG_ROM_SIZE, GFP_KERNEL);
513 if (rom == NULL) 513 if (rom == NULL)
514 return -ENOMEM; 514 return -ENOMEM;
515 515
516 stack = &rom[READ_BIB_ROM_SIZE]; 516 stack = &rom[MAX_CONFIG_ROM_SIZE];
517 memset(rom, 0, sizeof(*rom) * READ_BIB_ROM_SIZE); 517 memset(rom, 0, sizeof(*rom) * MAX_CONFIG_ROM_SIZE);
518 518
519 device->max_speed = SCODE_100; 519 device->max_speed = SCODE_100;
520 520
@@ -581,14 +581,14 @@ static int read_bus_info_block(struct fw_device *device, int generation)
581 */ 581 */
582 key = stack[--sp]; 582 key = stack[--sp];
583 i = key & 0xffffff; 583 i = key & 0xffffff;
584 if (WARN_ON(i >= READ_BIB_ROM_SIZE)) 584 if (WARN_ON(i >= MAX_CONFIG_ROM_SIZE))
585 goto out; 585 goto out;
586 586
587 /* Read header quadlet for the block to get the length. */ 587 /* Read header quadlet for the block to get the length. */
588 if (read_rom(device, generation, i, &rom[i]) != RCODE_COMPLETE) 588 if (read_rom(device, generation, i, &rom[i]) != RCODE_COMPLETE)
589 goto out; 589 goto out;
590 end = i + (rom[i] >> 16) + 1; 590 end = i + (rom[i] >> 16) + 1;
591 if (end > READ_BIB_ROM_SIZE) { 591 if (end > MAX_CONFIG_ROM_SIZE) {
592 /* 592 /*
593 * This block extends outside the config ROM which is 593 * This block extends outside the config ROM which is
594 * a firmware bug. Ignore this whole block, i.e. 594 * a firmware bug. Ignore this whole block, i.e.
@@ -621,7 +621,7 @@ static int read_bus_info_block(struct fw_device *device, int generation)
621 * fake immediate entry so that later iterators over 621 * fake immediate entry so that later iterators over
622 * the ROM don't have to check offsets all the time. 622 * the ROM don't have to check offsets all the time.
623 */ 623 */
624 if (i + (rom[i] & 0xffffff) >= READ_BIB_ROM_SIZE) { 624 if (i + (rom[i] & 0xffffff) >= MAX_CONFIG_ROM_SIZE) {
625 fw_error("skipped unsupported ROM entry %x at %llx\n", 625 fw_error("skipped unsupported ROM entry %x at %llx\n",
626 rom[i], 626 rom[i],
627 i * 4 | CSR_REGISTER_BASE | CSR_CONFIG_ROM); 627 i * 4 | CSR_REGISTER_BASE | CSR_CONFIG_ROM);
@@ -971,7 +971,7 @@ static void fw_device_init(struct work_struct *work)
971 * device. 971 * device.
972 */ 972 */
973 973
974 if (read_bus_info_block(device, device->generation) < 0) { 974 if (read_config_rom(device, device->generation) < 0) {
975 if (device->config_rom_retries < MAX_RETRIES && 975 if (device->config_rom_retries < MAX_RETRIES &&
976 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) { 976 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) {
977 device->config_rom_retries++; 977 device->config_rom_retries++;
@@ -1088,7 +1088,7 @@ enum {
1088}; 1088};
1089 1089
1090/* Reread and compare bus info block and header of root directory */ 1090/* Reread and compare bus info block and header of root directory */
1091static int reread_bus_info_block(struct fw_device *device, int generation) 1091static int reread_config_rom(struct fw_device *device, int generation)
1092{ 1092{
1093 u32 q; 1093 u32 q;
1094 int i; 1094 int i;
@@ -1114,7 +1114,7 @@ static void fw_device_refresh(struct work_struct *work)
1114 struct fw_card *card = device->card; 1114 struct fw_card *card = device->card;
1115 int node_id = device->node_id; 1115 int node_id = device->node_id;
1116 1116
1117 switch (reread_bus_info_block(device, device->generation)) { 1117 switch (reread_config_rom(device, device->generation)) {
1118 case REREAD_BIB_ERROR: 1118 case REREAD_BIB_ERROR:
1119 if (device->config_rom_retries < MAX_RETRIES / 2 && 1119 if (device->config_rom_retries < MAX_RETRIES / 2 &&
1120 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) { 1120 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) {
@@ -1148,7 +1148,7 @@ static void fw_device_refresh(struct work_struct *work)
1148 */ 1148 */
1149 device_for_each_child(&device->device, NULL, shutdown_unit); 1149 device_for_each_child(&device->device, NULL, shutdown_unit);
1150 1150
1151 if (read_bus_info_block(device, device->generation) < 0) { 1151 if (read_config_rom(device, device->generation) < 0) {
1152 if (device->config_rom_retries < MAX_RETRIES && 1152 if (device->config_rom_retries < MAX_RETRIES &&
1153 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) { 1153 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) {
1154 device->config_rom_retries++; 1154 device->config_rom_retries++;