Commit da8ecffa authored by Kristian Høgsberg's avatar Kristian Høgsberg Committed by Stefan Richter

firewire: Streamline userspace interface structs.

Make event struct layout common part include the closure and add a
union for all event types; provide a mechanism for setting the
bus reset event closure.

Shuffle struct fw_cdev_queue_iso fields around to be 64-bit safe.
Signed-off-by: default avatarKristian Høgsberg <krh@redhat.com>
Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
parent 20d11673
...@@ -79,6 +79,7 @@ struct client { ...@@ -79,6 +79,7 @@ struct client {
u32 request_serial; u32 request_serial;
struct list_head event_list; struct list_head event_list;
wait_queue_head_t wait; wait_queue_head_t wait;
u64 bus_reset_closure;
struct fw_iso_context *iso_context; struct fw_iso_context *iso_context;
struct fw_iso_buffer buffer; struct fw_iso_buffer buffer;
...@@ -199,12 +200,13 @@ fw_device_op_read(struct file *file, ...@@ -199,12 +200,13 @@ fw_device_op_read(struct file *file,
static void static void
fill_bus_reset_event(struct fw_cdev_event_bus_reset *event, fill_bus_reset_event(struct fw_cdev_event_bus_reset *event,
struct fw_device *device) struct client *client)
{ {
struct fw_card *card = device->card; struct fw_card *card = client->device->card;
event->closure = client->bus_reset_closure;
event->type = FW_CDEV_EVENT_BUS_RESET; event->type = FW_CDEV_EVENT_BUS_RESET;
event->node_id = device->node_id; event->node_id = client->device->node_id;
event->local_node_id = card->local_node->node_id; event->local_node_id = card->local_node->node_id;
event->bm_node_id = 0; /* FIXME: We don't track the BM. */ event->bm_node_id = 0; /* FIXME: We don't track the BM. */
event->irm_node_id = card->irm_node->node_id; event->irm_node_id = card->irm_node->node_id;
...@@ -232,7 +234,6 @@ static void ...@@ -232,7 +234,6 @@ static void
queue_bus_reset_event(struct client *client) queue_bus_reset_event(struct client *client)
{ {
struct bus_reset *bus_reset; struct bus_reset *bus_reset;
struct fw_device *device = client->device;
bus_reset = kzalloc(sizeof *bus_reset, GFP_ATOMIC); bus_reset = kzalloc(sizeof *bus_reset, GFP_ATOMIC);
if (bus_reset == NULL) { if (bus_reset == NULL) {
...@@ -240,7 +241,7 @@ queue_bus_reset_event(struct client *client) ...@@ -240,7 +241,7 @@ queue_bus_reset_event(struct client *client)
return; return;
} }
fill_bus_reset_event(&bus_reset->reset, device); fill_bus_reset_event(&bus_reset->reset, client);
queue_event(client, &bus_reset->event, queue_event(client, &bus_reset->event,
&bus_reset->reset, sizeof bus_reset->reset, NULL, 0); &bus_reset->reset, sizeof bus_reset->reset, NULL, 0);
...@@ -283,10 +284,11 @@ static int ioctl_get_info(struct client *client, void __user *arg) ...@@ -283,10 +284,11 @@ static int ioctl_get_info(struct client *client, void __user *arg)
} }
get_info.rom_length = client->device->config_rom_length * 4; get_info.rom_length = client->device->config_rom_length * 4;
client->bus_reset_closure = get_info.bus_reset_closure;
if (get_info.bus_reset != 0) { if (get_info.bus_reset != 0) {
void __user *uptr = u64_to_uptr(get_info.bus_reset); void __user *uptr = u64_to_uptr(get_info.bus_reset);
fill_bus_reset_event(&bus_reset, client->device); fill_bus_reset_event(&bus_reset, client);
if (copy_to_user(uptr, &bus_reset, sizeof bus_reset)) if (copy_to_user(uptr, &bus_reset, sizeof bus_reset))
return -EFAULT; return -EFAULT;
} }
......
...@@ -74,7 +74,13 @@ ...@@ -74,7 +74,13 @@
* event. It's a 64-bit type so that it's a fixed size type big * event. It's a 64-bit type so that it's a fixed size type big
* enough to hold a pointer on all platforms. */ * enough to hold a pointer on all platforms. */
struct fw_cdev_event_common {
__u64 closure;
__u32 type;
};
struct fw_cdev_event_bus_reset { struct fw_cdev_event_bus_reset {
__u64 closure;
__u32 type; __u32 type;
__u32 node_id; __u32 node_id;
__u32 local_node_id; __u32 local_node_id;
...@@ -85,31 +91,39 @@ struct fw_cdev_event_bus_reset { ...@@ -85,31 +91,39 @@ struct fw_cdev_event_bus_reset {
}; };
struct fw_cdev_event_response { struct fw_cdev_event_response {
__u64 closure;
__u32 type; __u32 type;
__u32 rcode; __u32 rcode;
__u64 closure;
__u32 length; __u32 length;
__u32 data[0]; __u32 data[0];
}; };
struct fw_cdev_event_request { struct fw_cdev_event_request {
__u64 closure;
__u32 type; __u32 type;
__u32 tcode; __u32 tcode;
__u64 offset; __u64 offset;
__u64 closure;
__u32 serial; __u32 serial;
__u32 length; __u32 length;
__u32 data[0]; __u32 data[0];
}; };
struct fw_cdev_event_iso_interrupt { struct fw_cdev_event_iso_interrupt {
__u64 closure;
__u32 type; __u32 type;
__u32 cycle; __u32 cycle;
__u64 closure;
__u32 header_length; /* Length in bytes of following headers. */ __u32 header_length; /* Length in bytes of following headers. */
__u32 header[0]; __u32 header[0];
}; };
union fw_cdev_event {
struct fw_cdev_event_common common;
struct fw_cdev_event_bus_reset bus_reset;
struct fw_cdev_event_response response;
struct fw_cdev_event_request request;
struct fw_cdev_event_iso_interrupt iso_interrupt;
};
#define FW_CDEV_IOC_GET_INFO _IO('#', 0x00) #define FW_CDEV_IOC_GET_INFO _IO('#', 0x00)
#define FW_CDEV_IOC_SEND_REQUEST _IO('#', 0x01) #define FW_CDEV_IOC_SEND_REQUEST _IO('#', 0x01)
#define FW_CDEV_IOC_ALLOCATE _IO('#', 0x02) #define FW_CDEV_IOC_ALLOCATE _IO('#', 0x02)
...@@ -145,8 +159,12 @@ struct fw_cdev_get_info { ...@@ -145,8 +159,12 @@ struct fw_cdev_get_info {
__u64 rom; __u64 rom;
/* If non-zero, a fw_cdev_event_bus_reset struct will be /* If non-zero, a fw_cdev_event_bus_reset struct will be
* copied here with the current state of the bus. */ * copied here with the current state of the bus. This does
* not cause a bus reset to happen. The value of closure in
* this and sub-sequent bus reset events is set to
* bus_reset_closure. */
__u64 bus_reset; __u64 bus_reset;
__u64 bus_reset_closure;
/* The index of the card this devices belongs to. */ /* The index of the card this devices belongs to. */
__u32 card; __u32 card;
...@@ -212,9 +230,9 @@ struct fw_cdev_iso_packet { ...@@ -212,9 +230,9 @@ struct fw_cdev_iso_packet {
}; };
struct fw_cdev_queue_iso { struct fw_cdev_queue_iso {
__u32 size;
__u64 packets; __u64 packets;
__u64 data; __u64 data;
__u32 size;
}; };
struct fw_cdev_start_iso { struct fw_cdev_start_iso {
......
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