Commit 8527f8e2 authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Stefan Richter

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: default avatarClemens Ladisch <clemens@ladisch.de>
Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
parent 94fba9fb
...@@ -1115,16 +1115,8 @@ static void fw_device_refresh(struct work_struct *work) ...@@ -1115,16 +1115,8 @@ static void fw_device_refresh(struct work_struct *work)
bool changed; bool changed;
ret = reread_config_rom(device, device->generation, &changed); ret = reread_config_rom(device, device->generation, &changed);
if (ret != RCODE_COMPLETE) { if (ret != RCODE_COMPLETE)
if (device->config_rom_retries < MAX_RETRIES / 2 && goto failed_config_rom;
atomic_read(&device->state) == FW_DEVICE_INITIALIZING) {
device->config_rom_retries++;
fw_schedule_device_work(device, RETRY_DELAY / 2);
return;
}
goto give_up;
}
if (!changed) { if (!changed) {
if (atomic_cmpxchg(&device->state, if (atomic_cmpxchg(&device->state,
...@@ -1144,16 +1136,8 @@ static void fw_device_refresh(struct work_struct *work) ...@@ -1144,16 +1136,8 @@ static void fw_device_refresh(struct work_struct *work)
device_for_each_child(&device->device, NULL, shutdown_unit); device_for_each_child(&device->device, NULL, shutdown_unit);
ret = read_config_rom(device, device->generation); ret = read_config_rom(device, device->generation);
if (ret != RCODE_COMPLETE) { if (ret != RCODE_COMPLETE)
if (device->config_rom_retries < MAX_RETRIES && goto failed_config_rom;
atomic_read(&device->state) == FW_DEVICE_INITIALIZING) {
device->config_rom_retries++;
fw_schedule_device_work(device, RETRY_DELAY);
return;
}
goto give_up;
}
fw_device_cdev_update(device); fw_device_cdev_update(device);
create_units(device); create_units(device);
...@@ -1170,7 +1154,14 @@ static void fw_device_refresh(struct work_struct *work) ...@@ -1170,7 +1154,14 @@ static void fw_device_refresh(struct work_struct *work)
device->config_rom_retries = 0; device->config_rom_retries = 0;
goto out; goto out;
give_up: failed_config_rom:
if (device->config_rom_retries < MAX_RETRIES &&
atomic_read(&device->state) == FW_DEVICE_INITIALIZING) {
device->config_rom_retries++;
fw_schedule_device_work(device, RETRY_DELAY);
return;
}
fw_notice(card, "giving up on refresh of device %s: %s\n", fw_notice(card, "giving up on refresh of device %s: %s\n",
dev_name(&device->device), fw_rcode_string(ret)); dev_name(&device->device), fw_rcode_string(ret));
gone: gone:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment