diff options
Diffstat (limited to 'drivers/firewire/core-device.c')
-rw-r--r-- | drivers/firewire/core-device.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 8038311e1737..f9f782afedf2 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c | |||
@@ -1069,31 +1069,30 @@ static void fw_device_init(struct work_struct *work) | |||
1069 | put_device(&device->device); /* our reference */ | 1069 | put_device(&device->device); /* our reference */ |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | enum { | ||
1073 | REREAD_BIB_ERROR, | ||
1074 | REREAD_BIB_UNCHANGED, | ||
1075 | REREAD_BIB_CHANGED, | ||
1076 | }; | ||
1077 | |||
1078 | /* Reread and compare bus info block and header of root directory */ | 1072 | /* Reread and compare bus info block and header of root directory */ |
1079 | static int reread_config_rom(struct fw_device *device, int generation) | 1073 | static int reread_config_rom(struct fw_device *device, int generation, |
1074 | bool *changed) | ||
1080 | { | 1075 | { |
1081 | u32 q; | 1076 | u32 q; |
1082 | int i; | 1077 | int i, rcode; |
1083 | 1078 | ||
1084 | for (i = 0; i < 6; i++) { | 1079 | for (i = 0; i < 6; i++) { |
1085 | if (read_rom(device, generation, i, &q) != RCODE_COMPLETE) | 1080 | rcode = read_rom(device, generation, i, &q); |
1086 | return REREAD_BIB_ERROR; | 1081 | if (rcode != RCODE_COMPLETE) |
1082 | return rcode; | ||
1087 | 1083 | ||
1088 | if (i == 0 && q == 0) | 1084 | if (i == 0 && q == 0) |
1089 | /* inaccessible (see read_config_rom); retry later */ | 1085 | /* inaccessible (see read_config_rom); retry later */ |
1090 | return REREAD_BIB_ERROR; | 1086 | return RCODE_BUSY; |
1091 | 1087 | ||
1092 | if (q != device->config_rom[i]) | 1088 | if (q != device->config_rom[i]) { |
1093 | return REREAD_BIB_CHANGED; | 1089 | *changed = true; |
1090 | return RCODE_COMPLETE; | ||
1091 | } | ||
1094 | } | 1092 | } |
1095 | 1093 | ||
1096 | return REREAD_BIB_UNCHANGED; | 1094 | *changed = false; |
1095 | return RCODE_COMPLETE; | ||
1097 | } | 1096 | } |
1098 | 1097 | ||
1099 | static void fw_device_refresh(struct work_struct *work) | 1098 | static void fw_device_refresh(struct work_struct *work) |
@@ -1101,10 +1100,11 @@ static void fw_device_refresh(struct work_struct *work) | |||
1101 | struct fw_device *device = | 1100 | struct fw_device *device = |
1102 | container_of(work, struct fw_device, work.work); | 1101 | container_of(work, struct fw_device, work.work); |
1103 | struct fw_card *card = device->card; | 1102 | struct fw_card *card = device->card; |
1104 | int node_id = device->node_id; | 1103 | int ret, node_id = device->node_id; |
1104 | bool changed; | ||
1105 | 1105 | ||
1106 | switch (reread_config_rom(device, device->generation)) { | 1106 | ret = reread_config_rom(device, device->generation, &changed); |
1107 | case REREAD_BIB_ERROR: | 1107 | if (ret != RCODE_COMPLETE) { |
1108 | if (device->config_rom_retries < MAX_RETRIES / 2 && | 1108 | if (device->config_rom_retries < MAX_RETRIES / 2 && |
1109 | atomic_read(&device->state) == FW_DEVICE_INITIALIZING) { | 1109 | atomic_read(&device->state) == FW_DEVICE_INITIALIZING) { |
1110 | device->config_rom_retries++; | 1110 | device->config_rom_retries++; |
@@ -1113,8 +1113,9 @@ static void fw_device_refresh(struct work_struct *work) | |||
1113 | return; | 1113 | return; |
1114 | } | 1114 | } |
1115 | goto give_up; | 1115 | goto give_up; |
1116 | } | ||
1116 | 1117 | ||
1117 | case REREAD_BIB_UNCHANGED: | 1118 | if (!changed) { |
1118 | if (atomic_cmpxchg(&device->state, | 1119 | if (atomic_cmpxchg(&device->state, |
1119 | FW_DEVICE_INITIALIZING, | 1120 | FW_DEVICE_INITIALIZING, |
1120 | FW_DEVICE_RUNNING) == FW_DEVICE_GONE) | 1121 | FW_DEVICE_RUNNING) == FW_DEVICE_GONE) |
@@ -1123,9 +1124,6 @@ static void fw_device_refresh(struct work_struct *work) | |||
1123 | fw_device_update(work); | 1124 | fw_device_update(work); |
1124 | device->config_rom_retries = 0; | 1125 | device->config_rom_retries = 0; |
1125 | goto out; | 1126 | goto out; |
1126 | |||
1127 | case REREAD_BIB_CHANGED: | ||
1128 | break; | ||
1129 | } | 1127 | } |
1130 | 1128 | ||
1131 | /* | 1129 | /* |