Re: [PATCH] firewire: reread config ROM when device reset the bus

From: Stefan Richter
Date: Mon Mar 03 2008 - 11:51:52 EST


Kristian Høgsberg wrote:
I would just add a

case REREAD_BIB_CHANGED:
break;

to the switch to make that clear,

Yes, that's nicer.

but otherwise

Signed-off-by: Kristian Høgsberg <krh@xxxxxxxxxx>

Thanks.

...
--- linux.orig/drivers/firewire/fw-cdev.c
+++ linux/drivers/firewire/fw-cdev.c
@@ -269,20 +270,25 @@ static int ioctl_get_info(struct client
{
struct fw_cdev_get_info *get_info = buffer;
struct fw_cdev_event_bus_reset bus_reset;
+ struct fw_device *device = client->device;
+ unsigned long ret = 0;

client->version = get_info->version;
get_info->version = FW_CDEV_VERSION;

+ down(&device->device.sem);
if (get_info->rom != 0) {
void __user *uptr = u64_to_uptr(get_info->rom);
size_t want = get_info->rom_length;
- size_t have = client->device->config_rom_length * 4;
+ size_t have;

- if (copy_to_user(uptr, client->device->config_rom,
- min(want, have)))
- return -EFAULT;
+ have = device->config_rom_length * 4;
+ ret = copy_to_user(uptr, device->config_rom, min(want, have));
}
- get_info->rom_length = client->device->config_rom_length * 4;
+ get_info->rom_length = device->config_rom_length * 4;
+ up(&device->device.sem);
+ if (ret != 0)
+ return -EFAULT;

client->bus_reset_closure = get_info->bus_reset_closure;
if (get_info->bus_reset != 0) {

Maybe I should rather use fw-device.c::idr_rwsem instead of device.sem, to have better control over who takes the mutex when. Could also be a new dedicated mutex but we don't want to end up with too many of them... Do you have an opinion?
--
Stefan Richter
-=====-==--- --== ---==
http://arcgraph.de/sr/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/