From ec749d4a021095ff680a927d4a996b051468bc6a Mon Sep 17 00:00:00 2001 From: bencollins Date: Tue, 22 Jul 2003 14:54:19 +0000 Subject: [PATCH] Patch from Stephen Tiedemann to allow reentrancy in raw1394's usage of raw1394_request's. git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@128 53a565d1-3bb7-0310-b661-cf11e63c67ab --- src/arm.c | 38 +++++------ src/eventloop.c | 40 ++++++------ src/fcp.c | 18 ++--- src/iso.c | 18 ++--- src/main.c | 136 +++++++++++++++++++------------------- src/raw1394_private.h | 1 - src/readwrite.c | 148 +++++++++++++++++++++--------------------- 7 files changed, 199 insertions(+), 200 deletions(-) diff --git a/src/arm.c b/src/arm.c index 669b8ab..546374b 100644 --- a/src/arm.c +++ b/src/arm.c @@ -50,25 +50,25 @@ int raw1394_arm_register(struct raw1394_handle *handle, nodeaddr_t start, arm_options_t client_transactions) { int retval=0; - struct raw1394_request *req = &(handle->req); + struct raw1394_request req; if (((start & ~(0xFFFFFFFFFFFF)) != 0) || (((start + length) & ~(0xFFFFFFFFFFFF)) != 0)) { errno = EINVAL; return (-1); } - CLEAR_REQ(req); - req->type = RAW1394_REQ_ARM_REGISTER; - req->generation = handle->generation; /* not necessary */ - req->address = start; - req->length = length; - req->tag = arm_tag; - req->recvb = ptr2int(handle->buffer); /* arm_handle on success */ - req->misc = ((client_transactions & 0x0f) << 8)|((notification_options & 0x0F) << 4)|(access_rights & 0x0F) + CLEAR_REQ(&req); + req.type = RAW1394_REQ_ARM_REGISTER; + req.generation = handle->generation; /* not necessary */ + req.address = start; + req.length = length; + req.tag = arm_tag; + req.recvb = ptr2int(handle->buffer); /* arm_handle on success */ + req.misc = ((client_transactions & 0x0f) << 8)|((notification_options & 0x0F) << 4)|(access_rights & 0x0F) |((ARM_REC_LENGTH & 0xFFFF) << 16); - req->sendb = ptr2int(initial_value); - retval = (int) write(handle->fd, req, sizeof(*req)); - return (retval == sizeof(*req)) ? 0:-1; + req.sendb = ptr2int(initial_value); + retval = (int) write(handle->fd, &req, sizeof(req)); + return (retval == sizeof(req)) ? 0:-1; } /* @@ -82,12 +82,12 @@ int raw1394_arm_register(struct raw1394_handle *handle, nodeaddr_t start, int raw1394_arm_unregister (struct raw1394_handle *handle, nodeaddr_t start) { int retval; - struct raw1394_request *req = &(handle->req); + struct raw1394_request req; - CLEAR_REQ(req); - req->type = RAW1394_REQ_ARM_UNREGISTER; - req->generation = handle->generation; /* not necessary */ - req->address = start; - retval = write(handle->fd, req, sizeof(*req)); - return (retval == sizeof(*req)) ? 0:-1; + CLEAR_REQ(&req); + req.type = RAW1394_REQ_ARM_UNREGISTER; + req.generation = handle->generation; /* not necessary */ + req.address = start; + retval = write(handle->fd, &req, sizeof(req)); + return (retval == sizeof(req)) ? 0:-1; } diff --git a/src/eventloop.c b/src/eventloop.c index c360a63..982f700 100644 --- a/src/eventloop.c +++ b/src/eventloop.c @@ -40,27 +40,27 @@ **/ int raw1394_loop_iterate(struct raw1394_handle *handle) { - struct raw1394_request *req = &handle->req; + struct raw1394_request req; int retval = 0, channel; - if (read(handle->fd, req, sizeof(*req)) < 0) { + if (read(handle->fd, &req, sizeof(req)) < 0) { return -1; } - switch (req->type) { + switch (req.type) { case RAW1394_REQ_BUS_RESET: if (handle->protocol_version == 3) { - handle->num_of_nodes = req->misc & 0xffff; - handle->local_id = req->misc >> 16; + handle->num_of_nodes = req.misc & 0xffff; + handle->local_id = req.misc >> 16; } else { - handle->num_of_nodes = req->misc & 0xff; - handle->irm_id = ((req->misc >> 8) & 0xff) | 0xffc0; - handle->local_id = req->misc >> 16; + handle->num_of_nodes = req.misc & 0xff; + handle->irm_id = ((req.misc >> 8) & 0xff) | 0xffc0; + handle->local_id = req.misc >> 16; } if (handle->bus_reset_handler) { retval = handle->bus_reset_handler(handle, - req->generation); + req.generation); } break; @@ -72,31 +72,31 @@ int raw1394_loop_iterate(struct raw1394_handle *handle) if (handle->iso_handler[channel]) { retval = handle->iso_handler[channel](handle, channel, - req->length, + req.length, handle->buffer); } break; case RAW1394_REQ_FCP_REQUEST: if (handle->fcp_handler) { - retval = handle->fcp_handler(handle, req->misc & 0xffff, - req->misc >> 16, - req->length, + retval = handle->fcp_handler(handle, req.misc & 0xffff, + req.misc >> 16, + req.length, (char *)handle->buffer); } break; case RAW1394_REQ_ARM: if (handle->arm_tag_handler) { - retval = handle->arm_tag_handler(handle, req->tag, - (req->misc & (0xFF)), - ((req->misc >> 16) & (0xFFFF)), - int2ptr(req->recvb)); + retval = handle->arm_tag_handler(handle, req.tag, + (req.misc & (0xFF)), + ((req.misc >> 16) & (0xFFFF)), + int2ptr(req.recvb)); } break; case RAW1394_REQ_ECHO: - retval=req->misc; + retval=req.misc; break; case RAW1394_REQ_RAWISO_ACTIVITY: @@ -105,8 +105,8 @@ int raw1394_loop_iterate(struct raw1394_handle *handle) default: if (handle->tag_handler) { - retval = handle->tag_handler(handle, req->tag, - req->error); + retval = handle->tag_handler(handle, req.tag, + req.error); } break; } diff --git a/src/fcp.c b/src/fcp.c index e5d98d5..da05b03 100644 --- a/src/fcp.c +++ b/src/fcp.c @@ -22,17 +22,17 @@ static int do_fcp_listen(struct raw1394_handle *handle, int startstop) struct sync_cb_data sd = { 0, 0 }; struct raw1394_reqhandle rh = { (req_callback_t)_raw1394_sync_cb, &sd }; int err; - struct raw1394_request *req = &handle->req; + struct raw1394_request req; - CLEAR_REQ(req); - req->type = RAW1394_REQ_FCP_LISTEN; - req->generation = handle->generation; - req->misc = startstop; - req->tag = ptr2int(&rh); - req->recvb = ptr2int(handle->buffer); - req->length = 512; + CLEAR_REQ(&req); + req.type = RAW1394_REQ_FCP_LISTEN; + req.generation = handle->generation; + req.misc = startstop; + req.tag = ptr2int(&rh); + req.recvb = ptr2int(handle->buffer); + req.length = 512; - err = write(handle->fd, req, sizeof(*req)); + err = write(handle->fd, &req, sizeof(req)); while (!sd.done) { if (err < 0) return err; err = raw1394_loop_iterate(handle); diff --git a/src/iso.c b/src/iso.c index f6f18c7..9702ea6 100644 --- a/src/iso.c +++ b/src/iso.c @@ -29,17 +29,17 @@ static int do_iso_listen(struct raw1394_handle *handle, int channel) struct sync_cb_data sd = { 0, 0 }; struct raw1394_reqhandle rh = { (req_callback_t)_raw1394_sync_cb, &sd }; int err; - struct raw1394_request *req = &handle->req; + struct raw1394_request req; - CLEAR_REQ(req); - req->type = RAW1394_REQ_ISO_LISTEN; - req->generation = handle->generation; - req->misc = channel; - req->tag = ptr2int(&rh); - req->recvb = ptr2int(handle->buffer); - req->length = HBUF_SIZE; + CLEAR_REQ(&req); + req.type = RAW1394_REQ_ISO_LISTEN; + req.generation = handle->generation; + req.misc = channel; + req.tag = ptr2int(&rh); + req.recvb = ptr2int(handle->buffer); + req.length = HBUF_SIZE; - err = write(handle->fd, req, sizeof(*req)); + err = write(handle->fd, &req, sizeof(req)); while (!sd.done) { if (err < 0) return err; err = raw1394_loop_iterate(handle); diff --git a/src/main.c b/src/main.c index 3d611bc..39d93a6 100644 --- a/src/main.c +++ b/src/main.c @@ -84,28 +84,28 @@ int _raw1394_sync_cb(struct raw1394_handle *unused, struct sync_cb_data *data, static unsigned int init_rawdevice(struct raw1394_handle *h) { - struct raw1394_request *req = &h->req; + struct raw1394_request req; - CLEAR_REQ(req); - req->type = RAW1394_REQ_INITIALIZE; - req->misc = RAW1394_KERNELAPI_VERSION; + CLEAR_REQ(&req); + req.type = RAW1394_REQ_INITIALIZE; + req.misc = RAW1394_KERNELAPI_VERSION; h->protocol_version = RAW1394_KERNELAPI_VERSION; - if (write(h->fd, req, sizeof(*req)) < 0) return -1; - if (read(h->fd, req, sizeof(*req)) < 0) return -1; + if (write(h->fd, &req, sizeof(req)) < 0) return -1; + if (read(h->fd, &req, sizeof(req)) < 0) return -1; - if (req->error == RAW1394_ERROR_COMPAT && req->misc == 3) { + if (req.error == RAW1394_ERROR_COMPAT && req.misc == 3) { h->protocol_version = 3; - if (write(h->fd, req, sizeof(*req)) < 0) return -1; - if (read(h->fd, req, sizeof(*req)) < 0) return -1; + if (write(h->fd, &req, sizeof(req)) < 0) return -1; + if (read(h->fd, &req, sizeof(req)) < 0) return -1; } - if (req->error) { + if (req.error) { errno = 0; return -1; } - return req->generation; + return req.generation; } @@ -308,36 +308,36 @@ int raw1394_get_port_info(struct raw1394_handle *handle, struct raw1394_portinfo *pinf, int maxports) { int num; - struct raw1394_request *req = &handle->req; + struct raw1394_request req; struct raw1394_khost_list *khl; - CLEAR_REQ(req); - req->type = RAW1394_REQ_LIST_CARDS; - req->generation = handle->generation; - req->recvb = ptr2int(handle->buffer); - req->length = HBUF_SIZE; + CLEAR_REQ(&req); + req.type = RAW1394_REQ_LIST_CARDS; + req.generation = handle->generation; + req.recvb = ptr2int(pinf); + req.length = sizeof(struct raw1394_portinfo) * maxports; while (1) { - if (write(handle->fd, req, sizeof(*req)) < 0) return -1; - if (read(handle->fd, req, sizeof(*req)) < 0) return -1; + if (write(handle->fd, &req, sizeof(req)) < 0) return -1; + if (read(handle->fd, &req, sizeof(req)) < 0) return -1; - if (!req->error) break; + if (!req.error) break; - if (req->error == RAW1394_ERROR_GENERATION) { - handle->generation = req->generation; + if (req.error == RAW1394_ERROR_GENERATION) { + handle->generation = req.generation; continue; } return -1; } - for (num = req->misc, khl = (struct raw1394_khost_list *)handle->buffer; + for (num = req.misc, khl = (struct raw1394_khost_list *) int2ptr(req.recvb); num && maxports; num--, maxports--, pinf++, khl++) { pinf->nodes = khl->nodes; strcpy(pinf->name, khl->name); } - return req->misc; + return req.misc; } @@ -358,20 +358,20 @@ int raw1394_get_port_info(struct raw1394_handle *handle, **/ int raw1394_set_port(struct raw1394_handle *handle, int port) { - struct raw1394_request *req = &handle->req; + struct raw1394_request req; - CLEAR_REQ(req); + CLEAR_REQ(&req); - req->type = RAW1394_REQ_SET_CARD; - req->generation = handle->generation; - req->misc = port; + req.type = RAW1394_REQ_SET_CARD; + req.generation = handle->generation; + req.misc = port; - if (write(handle->fd, req, sizeof(*req)) < 0) return -1; - if (read(handle->fd, req, sizeof(*req)) < 0) return -1; + if (write(handle->fd, &req, sizeof(req)) < 0) return -1; + if (read(handle->fd, &req, sizeof(req)) < 0) return -1; - switch (req->error) { + switch (req.error) { case RAW1394_ERROR_GENERATION: - handle->generation = req->generation; + handle->generation = req.generation; errno = ESTALE; return -1; case RAW1394_ERROR_INVALID_ARG: @@ -379,14 +379,14 @@ int raw1394_set_port(struct raw1394_handle *handle, int port) return -1; case RAW1394_ERROR_NONE: if (handle->protocol_version == 3) { - handle->num_of_nodes = req->misc & 0xffff; - handle->local_id = req->misc >> 16; + handle->num_of_nodes = req.misc & 0xffff; + handle->local_id = req.misc >> 16; } else { - handle->num_of_nodes = req->misc & 0xff; - handle->irm_id = ((req->misc >> 8) & 0xff) | 0xffc0; - handle->local_id = req->misc >> 16; + handle->num_of_nodes = req.misc & 0xff; + handle->irm_id = ((req.misc >> 8) & 0xff) | 0xffc0; + handle->local_id = req.misc >> 16; } - handle->generation = req->generation; + handle->generation = req.generation; return 0; default: errno = 0; @@ -430,15 +430,15 @@ tryagain: int raw1394_reset_bus_new(struct raw1394_handle *handle, int type) { - struct raw1394_request *req = &handle->req; + struct raw1394_request req; - CLEAR_REQ(req); + CLEAR_REQ(&req); - req->type = RAW1394_REQ_RESET_BUS; - req->generation = handle->generation; - req->misc = type; + req.type = RAW1394_REQ_RESET_BUS; + req.generation = handle->generation; + req.misc = type; - if (write(handle->fd, req, sizeof(*req)) < 0) return -1; + if (write(handle->fd, &req, sizeof(req)) < 0) return -1; return 0; /* success */ } @@ -461,15 +461,15 @@ int raw1394_reset_bus(struct raw1394_handle *handle) int raw1394_busreset_notify (struct raw1394_handle *handle, int off_on_switch) { - struct raw1394_request *req = &handle->req; + struct raw1394_request req; - CLEAR_REQ(req); + CLEAR_REQ(&req); - req->type = RAW1394_REQ_RESET_NOTIFY; - req->generation = handle->generation; - req->misc = off_on_switch; + req.type = RAW1394_REQ_RESET_NOTIFY; + req.generation = handle->generation; + req.misc = off_on_switch; - if (write(handle->fd, req, sizeof(*req)) < 0) return -1; + if (write(handle->fd, &req, sizeof(req)) < 0) return -1; return 0; /* success */ } @@ -477,18 +477,18 @@ int raw1394_busreset_notify (struct raw1394_handle *handle, int raw1394_update_config_rom(raw1394handle_t handle, const quadlet_t *new_rom, size_t size, unsigned char rom_version) { - struct raw1394_request *req = &handle->req; + struct raw1394_request req; int status; - CLEAR_REQ(req); + CLEAR_REQ(&req); - req->type = RAW1394_REQ_UPDATE_ROM; - req->sendb = (unsigned long) new_rom; - req->length = size; - req->misc = rom_version; - req->recvb = (unsigned long) &status; + req.type = RAW1394_REQ_UPDATE_ROM; + req.sendb = (unsigned long) new_rom; + req.length = size; + req.misc = rom_version; + req.recvb = (unsigned long) &status; - if (write(handle->fd, req, sizeof(*req)) < 0) return -8; + if (write(handle->fd, &req, sizeof(req)) < 0) return -8; return status; } @@ -496,19 +496,19 @@ int raw1394_update_config_rom(raw1394handle_t handle, const quadlet_t int raw1394_get_config_rom(raw1394handle_t handle, quadlet_t *buffer, size_t buffersize, size_t *rom_size, unsigned char *rom_version) { - struct raw1394_request *req = &handle->req; + struct raw1394_request req; int status; - CLEAR_REQ(req); + CLEAR_REQ(&req); - req->type = RAW1394_REQ_GET_ROM; - req->recvb = (unsigned long) buffer; - req->length = buffersize; - req->tag = (unsigned long) rom_size; - req->address = (unsigned long) rom_version; - req->sendb = (unsigned long) &status; + req.type = RAW1394_REQ_GET_ROM; + req.recvb = (unsigned long) buffer; + req.length = buffersize; + req.tag = (unsigned long) rom_size; + req.address = (unsigned long) rom_version; + req.sendb = (unsigned long) &status; - if (write(handle->fd, req, sizeof(*req)) < 0) return -8; + if (write(handle->fd, &req, sizeof(req)) < 0) return -8; return status; } diff --git a/src/raw1394_private.h b/src/raw1394_private.h index c873a80..2a72dda 100644 --- a/src/raw1394_private.h +++ b/src/raw1394_private.h @@ -42,7 +42,6 @@ struct raw1394_handle { raw1394_iso_xmit_handler_t iso_xmit_handler; raw1394_iso_recv_handler_t iso_recv_handler; - struct raw1394_request req; quadlet_t buffer[HBUF_SIZE/4]; /* 2048 */ }; diff --git a/src/readwrite.c b/src/readwrite.c index a0608b7..b3127d3 100644 --- a/src/readwrite.c +++ b/src/readwrite.c @@ -54,19 +54,19 @@ int raw1394_start_read(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr, size_t length, quadlet_t *buffer, unsigned long tag) { - struct raw1394_request *req = &handle->req; + struct raw1394_request req; - CLEAR_REQ(req); + CLEAR_REQ(&req); - req->type = RAW1394_REQ_ASYNC_READ; - req->generation = handle->generation; - req->tag = tag; + req.type = RAW1394_REQ_ASYNC_READ; + req.generation = handle->generation; + req.tag = tag; - req->address = ((__u64)node << 48) | addr; - req->length = length; - req->recvb = ptr2int(buffer); + req.address = ((__u64)node << 48) | addr; + req.length = length; + req.recvb = ptr2int(buffer); - return (int)write(handle->fd, req, sizeof(*req)); + return (int)write(handle->fd, &req, sizeof(req)); } @@ -93,19 +93,19 @@ int raw1394_start_write(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr, size_t length, quadlet_t *data, unsigned long tag) { - struct raw1394_request *req = &handle->req; + struct raw1394_request req; - CLEAR_REQ(req); + CLEAR_REQ(&req); - req->type = RAW1394_REQ_ASYNC_WRITE; - req->generation = handle->generation; - req->tag = tag; + req.type = RAW1394_REQ_ASYNC_WRITE; + req.generation = handle->generation; + req.tag = tag; - req->address = ((__u64)node << 48) | addr; - req->length = length; - req->sendb = ptr2int(data); + req.address = ((__u64)node << 48) | addr; + req.length = length; + req.sendb = ptr2int(data); - return (int)write(handle->fd, req, sizeof(*req)); + return (int)write(handle->fd, &req, sizeof(req)); } @@ -133,7 +133,7 @@ int raw1394_start_lock(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr, unsigned int extcode, quadlet_t data, quadlet_t arg, quadlet_t *result, unsigned long tag) { - struct raw1394_request *req = &handle->req; + struct raw1394_request req; quadlet_t sendbuf[2]; if ((extcode > 7) || (extcode == 0)) { @@ -141,37 +141,37 @@ int raw1394_start_lock(struct raw1394_handle *handle, nodeid_t node, return -1; } - CLEAR_REQ(req); + CLEAR_REQ(&req); - req->type = RAW1394_REQ_LOCK; - req->generation = handle->generation; - req->tag = tag; + req.type = RAW1394_REQ_LOCK; + req.generation = handle->generation; + req.tag = tag; - req->address = ((__u64)node << 48) | addr; - req->sendb = ptr2int(sendbuf); - req->recvb = ptr2int(result); - req->misc = extcode; + req.address = ((__u64)node << 48) | addr; + req.sendb = ptr2int(sendbuf); + req.recvb = ptr2int(result); + req.misc = extcode; switch (extcode) { case 3: /* EXTCODE_FETCH_ADD */ case 4: /* EXTCODE_LITTLE_ADD */ sendbuf[0] = data; - req->length = 4; + req.length = 4; break; default: sendbuf[0] = arg; sendbuf[1] = data; - req->length = 8; + req.length = 8; break; } - return (int)write(handle->fd, req, sizeof(*req)); + return (int)write(handle->fd, &req, sizeof(req)); } int raw1394_start_lock64(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr, unsigned int extcode, octlet_t data, octlet_t arg, octlet_t *result, unsigned long tag) { - struct raw1394_request *req = &handle->req; + struct raw1394_request req; octlet_t sendbuf[2]; if ((extcode > 7) || (extcode == 0)) { @@ -179,31 +179,31 @@ int raw1394_start_lock64(struct raw1394_handle *handle, nodeid_t node, return -1; } - CLEAR_REQ(req); + CLEAR_REQ(&req); - req->type = RAW1394_REQ_LOCK64; - req->generation = handle->generation; - req->tag = tag; + req.type = RAW1394_REQ_LOCK64; + req.generation = handle->generation; + req.tag = tag; - req->address = ((__u64)node << 48) | addr; - req->sendb = ptr2int(sendbuf); - req->recvb = ptr2int(result); - req->misc = extcode; + req.address = ((__u64)node << 48) | addr; + req.sendb = ptr2int(sendbuf); + req.recvb = ptr2int(result); + req.misc = extcode; switch (extcode) { case 3: /* EXTCODE_FETCH_ADD */ case 4: /* EXTCODE_LITTLE_ADD */ sendbuf[0] = data; - req->length = 8; + req.length = 8; break; default: sendbuf[0] = arg; sendbuf[1] = data; - req->length = 16; + req.length = 16; break; } - return (int)write(handle->fd, req, sizeof(*req)); + return (int)write(handle->fd, &req, sizeof(req)); } @@ -233,39 +233,39 @@ int raw1394_start_iso_write(struct raw1394_handle *handle, unsigned int channel, unsigned int speed, size_t length, quadlet_t *data, unsigned long rawtag) { - struct raw1394_request *req = &handle->req; + struct raw1394_request req; - CLEAR_REQ(req); + CLEAR_REQ(&req); - req->type = RAW1394_REQ_ISO_SEND; - req->generation = handle->generation; - req->tag = rawtag; + req.type = RAW1394_REQ_ISO_SEND; + req.generation = handle->generation; + req.tag = rawtag; - req->address = ((__u64)channel << 48) | speed; - req->misc = (tag << 16) | sy; - req->length = length; - req->sendb = ptr2int(data); + req.address = ((__u64)channel << 48) | speed; + req.misc = (tag << 16) | sy; + req.length = length; + req.sendb = ptr2int(data); - return (int)write(handle->fd, req, sizeof(*req)); + return (int)write(handle->fd, &req, sizeof(req)); } int raw1394_start_async_send(struct raw1394_handle *handle, size_t length, size_t header_length, unsigned int expect_response, quadlet_t *data, unsigned long rawtag) { - struct raw1394_request *req = &handle->req; + struct raw1394_request req; - CLEAR_REQ(req); + CLEAR_REQ(&req); - req->type = RAW1394_REQ_ASYNC_SEND; - req->generation = handle->generation; - req->tag = rawtag; + req.type = RAW1394_REQ_ASYNC_SEND; + req.generation = handle->generation; + req.tag = rawtag; - req->length = length; - req->misc = (expect_response << 16) | (header_length & 0xffff); - req->sendb = ptr2int(data); + req.length = length; + req.misc = (expect_response << 16) | (header_length & 0xffff); + req.sendb = ptr2int(data); - return (int)write(handle->fd, req, sizeof(*req)); + return (int)write(handle->fd, &req, sizeof(req)); } @@ -360,17 +360,17 @@ int raw1394_async_send(struct raw1394_handle *handle , int raw1394_start_phy_packet_write(struct raw1394_handle *handle, quadlet_t data, unsigned long tag) { - struct raw1394_request *req = &handle->req; + struct raw1394_request req; - CLEAR_REQ(req); + CLEAR_REQ(&req); - req->type = RAW1394_REQ_PHYPACKET; - req->generation = handle->generation; - req->tag = tag; + req.type = RAW1394_REQ_PHYPACKET; + req.generation = handle->generation; + req.tag = tag; - req->sendb = data; + req.sendb = data; - return (int)write(handle->fd, req, sizeof(*req)); + return (int)write(handle->fd, &req, sizeof(req)); } int raw1394_phy_packet_write (struct raw1394_handle *handle, quadlet_t data) @@ -384,16 +384,16 @@ int raw1394_phy_packet_write (struct raw1394_handle *handle, quadlet_t data) int raw1394_echo_request(struct raw1394_handle *handle, quadlet_t data) { - struct raw1394_request *req = &handle->req; + struct raw1394_request req; int retval=0; - CLEAR_REQ(req); + CLEAR_REQ(&req); - req->type = RAW1394_REQ_ECHO; - req->misc = data; + req.type = RAW1394_REQ_ECHO; + req.misc = data; - retval = (int)write(handle->fd, req, sizeof(*req)); - if (retval == sizeof(*req)) { + retval = (int)write(handle->fd, &req, sizeof(req)); + if (retval == sizeof(req)) { return 0; /* succcess */ } return -1;