aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2012-04-11 11:39:59 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2012-04-17 16:57:10 -0400
commit8527f8e2934683e53405fbe876a4e6f4a0c46eb8 (patch)
treeac62e400e7e901256657cb131017d2efcd48f6d9 /drivers/firewire
parent94fba9fbeac44462c498e848496ba088198d78d1 (diff)
firewire: core: fw_device_refresh(): clean up error handling
In fw_device_init() and fw_device_refresh(), if a call to read_cofig_rom() fails, the operation is retried a few times, with these retries being controlled by the MAX_RETRIES and RETRY_DELAY symbols. fw_device_refresh() also reads part of the config rom by calling reread_config_rom(). Any errors from this call resulted in retries with MAX_RETRIES/2 and RETRY_DELAY/2. There is no reason to require that a device that has initiated a bus reset must react faster to read requests than a device that has just been plugged in. Furthermore, if the config rom has changed, any errors from the following read_config_rom() call are then handled with the normal retry count and delay. Remove this inconsistency by always using the normal retry count and delay. (This also makes the two error handlers identical and allows merging them.) Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire')
-rw-r--r--drivers/firewire/core-device.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index a3f486fbd7b7..4d460ef87161 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -1115,16 +1115,8 @@ static void fw_device_refresh(struct work_struct *work)
1115 bool changed; 1115 bool changed;
1116 1116
1117 ret = reread_config_rom(device, device->generation, &changed); 1117 ret = reread_config_rom(device, device->generation, &changed);
1118 if (ret != RCODE_COMPLETE) { 1118 if (ret != RCODE_COMPLETE)
1119 if (device->config_rom_retries < MAX_RETRIES / 2 && 1119 goto failed_config_rom;
1120 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) {
1121 device->config_rom_retries++;
1122 fw_schedule_device_work(device, RETRY_DELAY / 2);
1123
1124 return;
1125 }
1126 goto give_up;
1127 }
1128 1120
1129 if (!changed) { 1121 if (!changed) {
1130 if (atomic_cmpxchg(&device->state, 1122 if (atomic_cmpxchg(&device->state,
@@ -1144,16 +1136,8 @@ static void fw_device_refresh(struct work_struct *work)
1144 device_for_each_child(&device->device, NULL, shutdown_unit); 1136 device_for_each_child(&device->device, NULL, shutdown_unit);
1145 1137
1146 ret = read_config_rom(device, device->generation); 1138 ret = read_config_rom(device, device->generation);
1147 if (ret != RCODE_COMPLETE) { 1139 if (ret != RCODE_COMPLETE)
1148 if (device->config_rom_retries < MAX_RETRIES && 1140 goto failed_config_rom;
1149 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) {
1150 device->config_rom_retries++;
1151 fw_schedule_device_work(device, RETRY_DELAY);
1152
1153 return;
1154 }
1155 goto give_up;
1156 }
1157 1141
1158 fw_device_cdev_update(device); 1142 fw_device_cdev_update(device);
1159 create_units(device); 1143 create_units(device);
@@ -1170,7 +1154,14 @@ static void fw_device_refresh(struct work_struct *work)
1170 device->config_rom_retries = 0; 1154 device->config_rom_retries = 0;
1171 goto out; 1155 goto out;
1172 1156
1173 give_up: 1157 failed_config_rom:
1158 if (device->config_rom_retries < MAX_RETRIES &&
1159 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) {
1160 device->config_rom_retries++;
1161 fw_schedule_device_work(device, RETRY_DELAY);
1162 return;
1163 }
1164
1174 fw_notice(card, "giving up on refresh of device %s: %s\n", 1165 fw_notice(card, "giving up on refresh of device %s: %s\n",
1175 dev_name(&device->device), fw_rcode_string(ret)); 1166 dev_name(&device->device), fw_rcode_string(ret));
1176 gone: 1167 gone: