diff options
Diffstat (limited to 'drivers/firewire/core-device.c')
-rw-r--r-- | drivers/firewire/core-device.c | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index f3b890da1e87..afa7c83bd114 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c | |||
@@ -485,6 +485,7 @@ static int read_rom(struct fw_device *device, | |||
485 | */ | 485 | */ |
486 | static int read_config_rom(struct fw_device *device, int generation) | 486 | static int read_config_rom(struct fw_device *device, int generation) |
487 | { | 487 | { |
488 | struct fw_card *card = device->card; | ||
488 | const u32 *old_rom, *new_rom; | 489 | const u32 *old_rom, *new_rom; |
489 | u32 *rom, *stack; | 490 | u32 *rom, *stack; |
490 | u32 sp, key; | 491 | u32 sp, key; |
@@ -529,12 +530,12 @@ static int read_config_rom(struct fw_device *device, int generation) | |||
529 | */ | 530 | */ |
530 | if ((rom[2] & 0x7) < device->max_speed || | 531 | if ((rom[2] & 0x7) < device->max_speed || |
531 | device->max_speed == SCODE_BETA || | 532 | device->max_speed == SCODE_BETA || |
532 | device->card->beta_repeaters_present) { | 533 | card->beta_repeaters_present) { |
533 | u32 dummy; | 534 | u32 dummy; |
534 | 535 | ||
535 | /* for S1600 and S3200 */ | 536 | /* for S1600 and S3200 */ |
536 | if (device->max_speed == SCODE_BETA) | 537 | if (device->max_speed == SCODE_BETA) |
537 | device->max_speed = device->card->link_speed; | 538 | device->max_speed = card->link_speed; |
538 | 539 | ||
539 | while (device->max_speed > SCODE_100) { | 540 | while (device->max_speed > SCODE_100) { |
540 | if (read_rom(device, generation, 0, &dummy) == | 541 | if (read_rom(device, generation, 0, &dummy) == |
@@ -576,9 +577,9 @@ static int read_config_rom(struct fw_device *device, int generation) | |||
576 | * a firmware bug. Ignore this whole block, i.e. | 577 | * a firmware bug. Ignore this whole block, i.e. |
577 | * simply set a fake block length of 0. | 578 | * simply set a fake block length of 0. |
578 | */ | 579 | */ |
579 | fw_error("skipped invalid ROM block %x at %llx\n", | 580 | fw_err(card, "skipped invalid ROM block %x at %llx\n", |
580 | rom[i], | 581 | rom[i], |
581 | i * 4 | CSR_REGISTER_BASE | CSR_CONFIG_ROM); | 582 | i * 4 | CSR_REGISTER_BASE | CSR_CONFIG_ROM); |
582 | rom[i] = 0; | 583 | rom[i] = 0; |
583 | end = i; | 584 | end = i; |
584 | } | 585 | } |
@@ -604,9 +605,10 @@ static int read_config_rom(struct fw_device *device, int generation) | |||
604 | * the ROM don't have to check offsets all the time. | 605 | * the ROM don't have to check offsets all the time. |
605 | */ | 606 | */ |
606 | if (i + (rom[i] & 0xffffff) >= MAX_CONFIG_ROM_SIZE) { | 607 | if (i + (rom[i] & 0xffffff) >= MAX_CONFIG_ROM_SIZE) { |
607 | fw_error("skipped unsupported ROM entry %x at %llx\n", | 608 | fw_err(card, |
608 | rom[i], | 609 | "skipped unsupported ROM entry %x at %llx\n", |
609 | i * 4 | CSR_REGISTER_BASE | CSR_CONFIG_ROM); | 610 | rom[i], |
611 | i * 4 | CSR_REGISTER_BASE | CSR_CONFIG_ROM); | ||
610 | rom[i] = 0; | 612 | rom[i] = 0; |
611 | continue; | 613 | continue; |
612 | } | 614 | } |
@@ -641,6 +643,7 @@ static void fw_unit_release(struct device *dev) | |||
641 | { | 643 | { |
642 | struct fw_unit *unit = fw_unit(dev); | 644 | struct fw_unit *unit = fw_unit(dev); |
643 | 645 | ||
646 | fw_device_put(fw_parent_device(unit)); | ||
644 | kfree(unit); | 647 | kfree(unit); |
645 | } | 648 | } |
646 | 649 | ||
@@ -672,7 +675,7 @@ static void create_units(struct fw_device *device) | |||
672 | */ | 675 | */ |
673 | unit = kzalloc(sizeof(*unit), GFP_KERNEL); | 676 | unit = kzalloc(sizeof(*unit), GFP_KERNEL); |
674 | if (unit == NULL) { | 677 | if (unit == NULL) { |
675 | fw_error("failed to allocate memory for unit\n"); | 678 | fw_err(device->card, "out of memory for unit\n"); |
676 | continue; | 679 | continue; |
677 | } | 680 | } |
678 | 681 | ||
@@ -692,6 +695,7 @@ static void create_units(struct fw_device *device) | |||
692 | if (device_register(&unit->device) < 0) | 695 | if (device_register(&unit->device) < 0) |
693 | goto skip_unit; | 696 | goto skip_unit; |
694 | 697 | ||
698 | fw_device_get(device); | ||
695 | continue; | 699 | continue; |
696 | 700 | ||
697 | skip_unit: | 701 | skip_unit: |
@@ -873,7 +877,7 @@ static int lookup_existing_device(struct device *dev, void *data) | |||
873 | smp_wmb(); /* update node_id before generation */ | 877 | smp_wmb(); /* update node_id before generation */ |
874 | old->generation = card->generation; | 878 | old->generation = card->generation; |
875 | old->config_rom_retries = 0; | 879 | old->config_rom_retries = 0; |
876 | fw_notify("rediscovered device %s\n", dev_name(dev)); | 880 | fw_notice(card, "rediscovered device %s\n", dev_name(dev)); |
877 | 881 | ||
878 | PREPARE_DELAYED_WORK(&old->work, fw_device_update); | 882 | PREPARE_DELAYED_WORK(&old->work, fw_device_update); |
879 | fw_schedule_device_work(old, 0); | 883 | fw_schedule_device_work(old, 0); |
@@ -954,6 +958,7 @@ static void fw_device_init(struct work_struct *work) | |||
954 | { | 958 | { |
955 | struct fw_device *device = | 959 | struct fw_device *device = |
956 | container_of(work, struct fw_device, work.work); | 960 | container_of(work, struct fw_device, work.work); |
961 | struct fw_card *card = device->card; | ||
957 | struct device *revived_dev; | 962 | struct device *revived_dev; |
958 | int minor, ret; | 963 | int minor, ret; |
959 | 964 | ||
@@ -970,16 +975,16 @@ static void fw_device_init(struct work_struct *work) | |||
970 | fw_schedule_device_work(device, RETRY_DELAY); | 975 | fw_schedule_device_work(device, RETRY_DELAY); |
971 | } else { | 976 | } else { |
972 | if (device->node->link_on) | 977 | if (device->node->link_on) |
973 | fw_notify("giving up on config rom for node id %x\n", | 978 | fw_notice(card, "giving up on Config ROM for node id %x\n", |
974 | device->node_id); | 979 | device->node_id); |
975 | if (device->node == device->card->root_node) | 980 | if (device->node == card->root_node) |
976 | fw_schedule_bm_work(device->card, 0); | 981 | fw_schedule_bm_work(card, 0); |
977 | fw_device_release(&device->device); | 982 | fw_device_release(&device->device); |
978 | } | 983 | } |
979 | return; | 984 | return; |
980 | } | 985 | } |
981 | 986 | ||
982 | revived_dev = device_find_child(device->card->device, | 987 | revived_dev = device_find_child(card->device, |
983 | device, lookup_existing_device); | 988 | device, lookup_existing_device); |
984 | if (revived_dev) { | 989 | if (revived_dev) { |
985 | put_device(revived_dev); | 990 | put_device(revived_dev); |
@@ -1002,7 +1007,7 @@ static void fw_device_init(struct work_struct *work) | |||
1002 | 1007 | ||
1003 | device->device.bus = &fw_bus_type; | 1008 | device->device.bus = &fw_bus_type; |
1004 | device->device.type = &fw_device_type; | 1009 | device->device.type = &fw_device_type; |
1005 | device->device.parent = device->card->device; | 1010 | device->device.parent = card->device; |
1006 | device->device.devt = MKDEV(fw_cdev_major, minor); | 1011 | device->device.devt = MKDEV(fw_cdev_major, minor); |
1007 | dev_set_name(&device->device, "fw%d", minor); | 1012 | dev_set_name(&device->device, "fw%d", minor); |
1008 | 1013 | ||
@@ -1014,7 +1019,7 @@ static void fw_device_init(struct work_struct *work) | |||
1014 | &device->attribute_group); | 1019 | &device->attribute_group); |
1015 | 1020 | ||
1016 | if (device_add(&device->device)) { | 1021 | if (device_add(&device->device)) { |
1017 | fw_error("Failed to add device.\n"); | 1022 | fw_err(card, "failed to add device\n"); |
1018 | goto error_with_cdev; | 1023 | goto error_with_cdev; |
1019 | } | 1024 | } |
1020 | 1025 | ||
@@ -1035,18 +1040,10 @@ static void fw_device_init(struct work_struct *work) | |||
1035 | PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); | 1040 | PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); |
1036 | fw_schedule_device_work(device, SHUTDOWN_DELAY); | 1041 | fw_schedule_device_work(device, SHUTDOWN_DELAY); |
1037 | } else { | 1042 | } else { |
1038 | if (device->config_rom_retries) | 1043 | fw_notice(card, "created device %s: GUID %08x%08x, S%d00\n", |
1039 | fw_notify("created device %s: GUID %08x%08x, S%d00, " | 1044 | dev_name(&device->device), |
1040 | "%d config ROM retries\n", | 1045 | device->config_rom[3], device->config_rom[4], |
1041 | dev_name(&device->device), | 1046 | 1 << device->max_speed); |
1042 | device->config_rom[3], device->config_rom[4], | ||
1043 | 1 << device->max_speed, | ||
1044 | device->config_rom_retries); | ||
1045 | else | ||
1046 | fw_notify("created device %s: GUID %08x%08x, S%d00\n", | ||
1047 | dev_name(&device->device), | ||
1048 | device->config_rom[3], device->config_rom[4], | ||
1049 | 1 << device->max_speed); | ||
1050 | device->config_rom_retries = 0; | 1047 | device->config_rom_retries = 0; |
1051 | 1048 | ||
1052 | set_broadcast_channel(device, device->generation); | 1049 | set_broadcast_channel(device, device->generation); |
@@ -1058,8 +1055,8 @@ static void fw_device_init(struct work_struct *work) | |||
1058 | * just end up running the IRM work a couple of extra times - | 1055 | * just end up running the IRM work a couple of extra times - |
1059 | * pretty harmless. | 1056 | * pretty harmless. |
1060 | */ | 1057 | */ |
1061 | if (device->node == device->card->root_node) | 1058 | if (device->node == card->root_node) |
1062 | fw_schedule_bm_work(device->card, 0); | 1059 | fw_schedule_bm_work(card, 0); |
1063 | 1060 | ||
1064 | return; | 1061 | return; |
1065 | 1062 | ||
@@ -1163,12 +1160,13 @@ static void fw_device_refresh(struct work_struct *work) | |||
1163 | FW_DEVICE_RUNNING) == FW_DEVICE_GONE) | 1160 | FW_DEVICE_RUNNING) == FW_DEVICE_GONE) |
1164 | goto gone; | 1161 | goto gone; |
1165 | 1162 | ||
1166 | fw_notify("refreshed device %s\n", dev_name(&device->device)); | 1163 | fw_notice(card, "refreshed device %s\n", dev_name(&device->device)); |
1167 | device->config_rom_retries = 0; | 1164 | device->config_rom_retries = 0; |
1168 | goto out; | 1165 | goto out; |
1169 | 1166 | ||
1170 | give_up: | 1167 | give_up: |
1171 | fw_notify("giving up on refresh of device %s\n", dev_name(&device->device)); | 1168 | fw_notice(card, "giving up on refresh of device %s\n", |
1169 | dev_name(&device->device)); | ||
1172 | gone: | 1170 | gone: |
1173 | atomic_set(&device->state, FW_DEVICE_GONE); | 1171 | atomic_set(&device->state, FW_DEVICE_GONE); |
1174 | PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); | 1172 | PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); |