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
This commit is contained in:
bencollins 2003-07-22 14:54:19 +00:00
parent ce14ef3b9e
commit ec749d4a02
7 changed files with 199 additions and 200 deletions

View File

@ -50,25 +50,25 @@ int raw1394_arm_register(struct raw1394_handle *handle, nodeaddr_t start,
arm_options_t client_transactions) arm_options_t client_transactions)
{ {
int retval=0; int retval=0;
struct raw1394_request *req = &(handle->req); struct raw1394_request req;
if (((start & ~(0xFFFFFFFFFFFF)) != 0) || if (((start & ~(0xFFFFFFFFFFFF)) != 0) ||
(((start + length) & ~(0xFFFFFFFFFFFF)) != 0)) { (((start + length) & ~(0xFFFFFFFFFFFF)) != 0)) {
errno = EINVAL; errno = EINVAL;
return (-1); return (-1);
} }
CLEAR_REQ(req); CLEAR_REQ(&req);
req->type = RAW1394_REQ_ARM_REGISTER; req.type = RAW1394_REQ_ARM_REGISTER;
req->generation = handle->generation; /* not necessary */ req.generation = handle->generation; /* not necessary */
req->address = start; req.address = start;
req->length = length; req.length = length;
req->tag = arm_tag; req.tag = arm_tag;
req->recvb = ptr2int(handle->buffer); /* arm_handle on success */ req.recvb = ptr2int(handle->buffer); /* arm_handle on success */
req->misc = ((client_transactions & 0x0f) << 8)|((notification_options & 0x0F) << 4)|(access_rights & 0x0F) req.misc = ((client_transactions & 0x0f) << 8)|((notification_options & 0x0F) << 4)|(access_rights & 0x0F)
|((ARM_REC_LENGTH & 0xFFFF) << 16); |((ARM_REC_LENGTH & 0xFFFF) << 16);
req->sendb = ptr2int(initial_value); req.sendb = ptr2int(initial_value);
retval = (int) write(handle->fd, req, sizeof(*req)); retval = (int) write(handle->fd, &req, sizeof(req));
return (retval == sizeof(*req)) ? 0:-1; 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 raw1394_arm_unregister (struct raw1394_handle *handle, nodeaddr_t start)
{ {
int retval; int retval;
struct raw1394_request *req = &(handle->req); struct raw1394_request req;
CLEAR_REQ(req); CLEAR_REQ(&req);
req->type = RAW1394_REQ_ARM_UNREGISTER; req.type = RAW1394_REQ_ARM_UNREGISTER;
req->generation = handle->generation; /* not necessary */ req.generation = handle->generation; /* not necessary */
req->address = start; req.address = start;
retval = write(handle->fd, req, sizeof(*req)); retval = write(handle->fd, &req, sizeof(req));
return (retval == sizeof(*req)) ? 0:-1; return (retval == sizeof(req)) ? 0:-1;
} }

View File

@ -40,27 +40,27 @@
**/ **/
int raw1394_loop_iterate(struct raw1394_handle *handle) int raw1394_loop_iterate(struct raw1394_handle *handle)
{ {
struct raw1394_request *req = &handle->req; struct raw1394_request req;
int retval = 0, channel; int retval = 0, channel;
if (read(handle->fd, req, sizeof(*req)) < 0) { if (read(handle->fd, &req, sizeof(req)) < 0) {
return -1; return -1;
} }
switch (req->type) { switch (req.type) {
case RAW1394_REQ_BUS_RESET: case RAW1394_REQ_BUS_RESET:
if (handle->protocol_version == 3) { if (handle->protocol_version == 3) {
handle->num_of_nodes = req->misc & 0xffff; handle->num_of_nodes = req.misc & 0xffff;
handle->local_id = req->misc >> 16; handle->local_id = req.misc >> 16;
} else { } else {
handle->num_of_nodes = req->misc & 0xff; handle->num_of_nodes = req.misc & 0xff;
handle->irm_id = ((req->misc >> 8) & 0xff) | 0xffc0; handle->irm_id = ((req.misc >> 8) & 0xff) | 0xffc0;
handle->local_id = req->misc >> 16; handle->local_id = req.misc >> 16;
} }
if (handle->bus_reset_handler) { if (handle->bus_reset_handler) {
retval = handle->bus_reset_handler(handle, retval = handle->bus_reset_handler(handle,
req->generation); req.generation);
} }
break; break;
@ -72,31 +72,31 @@ int raw1394_loop_iterate(struct raw1394_handle *handle)
if (handle->iso_handler[channel]) { if (handle->iso_handler[channel]) {
retval = handle->iso_handler[channel](handle, channel, retval = handle->iso_handler[channel](handle, channel,
req->length, req.length,
handle->buffer); handle->buffer);
} }
break; break;
case RAW1394_REQ_FCP_REQUEST: case RAW1394_REQ_FCP_REQUEST:
if (handle->fcp_handler) { if (handle->fcp_handler) {
retval = handle->fcp_handler(handle, req->misc & 0xffff, retval = handle->fcp_handler(handle, req.misc & 0xffff,
req->misc >> 16, req.misc >> 16,
req->length, req.length,
(char *)handle->buffer); (char *)handle->buffer);
} }
break; break;
case RAW1394_REQ_ARM: case RAW1394_REQ_ARM:
if (handle->arm_tag_handler) { if (handle->arm_tag_handler) {
retval = handle->arm_tag_handler(handle, req->tag, retval = handle->arm_tag_handler(handle, req.tag,
(req->misc & (0xFF)), (req.misc & (0xFF)),
((req->misc >> 16) & (0xFFFF)), ((req.misc >> 16) & (0xFFFF)),
int2ptr(req->recvb)); int2ptr(req.recvb));
} }
break; break;
case RAW1394_REQ_ECHO: case RAW1394_REQ_ECHO:
retval=req->misc; retval=req.misc;
break; break;
case RAW1394_REQ_RAWISO_ACTIVITY: case RAW1394_REQ_RAWISO_ACTIVITY:
@ -105,8 +105,8 @@ int raw1394_loop_iterate(struct raw1394_handle *handle)
default: default:
if (handle->tag_handler) { if (handle->tag_handler) {
retval = handle->tag_handler(handle, req->tag, retval = handle->tag_handler(handle, req.tag,
req->error); req.error);
} }
break; break;
} }

View File

@ -22,17 +22,17 @@ static int do_fcp_listen(struct raw1394_handle *handle, int startstop)
struct sync_cb_data sd = { 0, 0 }; struct sync_cb_data sd = { 0, 0 };
struct raw1394_reqhandle rh = { (req_callback_t)_raw1394_sync_cb, &sd }; struct raw1394_reqhandle rh = { (req_callback_t)_raw1394_sync_cb, &sd };
int err; int err;
struct raw1394_request *req = &handle->req; struct raw1394_request req;
CLEAR_REQ(req); CLEAR_REQ(&req);
req->type = RAW1394_REQ_FCP_LISTEN; req.type = RAW1394_REQ_FCP_LISTEN;
req->generation = handle->generation; req.generation = handle->generation;
req->misc = startstop; req.misc = startstop;
req->tag = ptr2int(&rh); req.tag = ptr2int(&rh);
req->recvb = ptr2int(handle->buffer); req.recvb = ptr2int(handle->buffer);
req->length = 512; req.length = 512;
err = write(handle->fd, req, sizeof(*req)); err = write(handle->fd, &req, sizeof(req));
while (!sd.done) { while (!sd.done) {
if (err < 0) return err; if (err < 0) return err;
err = raw1394_loop_iterate(handle); err = raw1394_loop_iterate(handle);

View File

@ -29,17 +29,17 @@ static int do_iso_listen(struct raw1394_handle *handle, int channel)
struct sync_cb_data sd = { 0, 0 }; struct sync_cb_data sd = { 0, 0 };
struct raw1394_reqhandle rh = { (req_callback_t)_raw1394_sync_cb, &sd }; struct raw1394_reqhandle rh = { (req_callback_t)_raw1394_sync_cb, &sd };
int err; int err;
struct raw1394_request *req = &handle->req; struct raw1394_request req;
CLEAR_REQ(req); CLEAR_REQ(&req);
req->type = RAW1394_REQ_ISO_LISTEN; req.type = RAW1394_REQ_ISO_LISTEN;
req->generation = handle->generation; req.generation = handle->generation;
req->misc = channel; req.misc = channel;
req->tag = ptr2int(&rh); req.tag = ptr2int(&rh);
req->recvb = ptr2int(handle->buffer); req.recvb = ptr2int(handle->buffer);
req->length = HBUF_SIZE; req.length = HBUF_SIZE;
err = write(handle->fd, req, sizeof(*req)); err = write(handle->fd, &req, sizeof(req));
while (!sd.done) { while (!sd.done) {
if (err < 0) return err; if (err < 0) return err;
err = raw1394_loop_iterate(handle); err = raw1394_loop_iterate(handle);

View File

@ -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) static unsigned int init_rawdevice(struct raw1394_handle *h)
{ {
struct raw1394_request *req = &h->req; struct raw1394_request req;
CLEAR_REQ(req); CLEAR_REQ(&req);
req->type = RAW1394_REQ_INITIALIZE; req.type = RAW1394_REQ_INITIALIZE;
req->misc = RAW1394_KERNELAPI_VERSION; req.misc = RAW1394_KERNELAPI_VERSION;
h->protocol_version = RAW1394_KERNELAPI_VERSION; h->protocol_version = RAW1394_KERNELAPI_VERSION;
if (write(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 (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; h->protocol_version = 3;
if (write(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 (read(h->fd, &req, sizeof(req)) < 0) return -1;
} }
if (req->error) { if (req.error) {
errno = 0; errno = 0;
return -1; 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) struct raw1394_portinfo *pinf, int maxports)
{ {
int num; int num;
struct raw1394_request *req = &handle->req; struct raw1394_request req;
struct raw1394_khost_list *khl; struct raw1394_khost_list *khl;
CLEAR_REQ(req); CLEAR_REQ(&req);
req->type = RAW1394_REQ_LIST_CARDS; req.type = RAW1394_REQ_LIST_CARDS;
req->generation = handle->generation; req.generation = handle->generation;
req->recvb = ptr2int(handle->buffer); req.recvb = ptr2int(pinf);
req->length = HBUF_SIZE; req.length = sizeof(struct raw1394_portinfo) * maxports;
while (1) { while (1) {
if (write(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 (read(handle->fd, &req, sizeof(req)) < 0) return -1;
if (!req->error) break; if (!req.error) break;
if (req->error == RAW1394_ERROR_GENERATION) { if (req.error == RAW1394_ERROR_GENERATION) {
handle->generation = req->generation; handle->generation = req.generation;
continue; continue;
} }
return -1; 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++) { num && maxports; num--, maxports--, pinf++, khl++) {
pinf->nodes = khl->nodes; pinf->nodes = khl->nodes;
strcpy(pinf->name, khl->name); 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) 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.type = RAW1394_REQ_SET_CARD;
req->generation = handle->generation; req.generation = handle->generation;
req->misc = port; req.misc = port;
if (write(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 (read(handle->fd, &req, sizeof(req)) < 0) return -1;
switch (req->error) { switch (req.error) {
case RAW1394_ERROR_GENERATION: case RAW1394_ERROR_GENERATION:
handle->generation = req->generation; handle->generation = req.generation;
errno = ESTALE; errno = ESTALE;
return -1; return -1;
case RAW1394_ERROR_INVALID_ARG: case RAW1394_ERROR_INVALID_ARG:
@ -379,14 +379,14 @@ int raw1394_set_port(struct raw1394_handle *handle, int port)
return -1; return -1;
case RAW1394_ERROR_NONE: case RAW1394_ERROR_NONE:
if (handle->protocol_version == 3) { if (handle->protocol_version == 3) {
handle->num_of_nodes = req->misc & 0xffff; handle->num_of_nodes = req.misc & 0xffff;
handle->local_id = req->misc >> 16; handle->local_id = req.misc >> 16;
} else { } else {
handle->num_of_nodes = req->misc & 0xff; handle->num_of_nodes = req.misc & 0xff;
handle->irm_id = ((req->misc >> 8) & 0xff) | 0xffc0; handle->irm_id = ((req.misc >> 8) & 0xff) | 0xffc0;
handle->local_id = req->misc >> 16; handle->local_id = req.misc >> 16;
} }
handle->generation = req->generation; handle->generation = req.generation;
return 0; return 0;
default: default:
errno = 0; errno = 0;
@ -430,15 +430,15 @@ tryagain:
int raw1394_reset_bus_new(struct raw1394_handle *handle, int type) 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.type = RAW1394_REQ_RESET_BUS;
req->generation = handle->generation; req.generation = handle->generation;
req->misc = type; 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 */ return 0; /* success */
} }
@ -461,15 +461,15 @@ int raw1394_reset_bus(struct raw1394_handle *handle)
int raw1394_busreset_notify (struct raw1394_handle *handle, int raw1394_busreset_notify (struct raw1394_handle *handle,
int off_on_switch) 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.type = RAW1394_REQ_RESET_NOTIFY;
req->generation = handle->generation; req.generation = handle->generation;
req->misc = off_on_switch; 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 */ 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 int raw1394_update_config_rom(raw1394handle_t handle, const quadlet_t
*new_rom, size_t size, unsigned char rom_version) *new_rom, size_t size, unsigned char rom_version)
{ {
struct raw1394_request *req = &handle->req; struct raw1394_request req;
int status; int status;
CLEAR_REQ(req); CLEAR_REQ(&req);
req->type = RAW1394_REQ_UPDATE_ROM; req.type = RAW1394_REQ_UPDATE_ROM;
req->sendb = (unsigned long) new_rom; req.sendb = (unsigned long) new_rom;
req->length = size; req.length = size;
req->misc = rom_version; req.misc = rom_version;
req->recvb = (unsigned long) &status; 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; 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, int raw1394_get_config_rom(raw1394handle_t handle, quadlet_t *buffer,
size_t buffersize, size_t *rom_size, unsigned char *rom_version) size_t buffersize, size_t *rom_size, unsigned char *rom_version)
{ {
struct raw1394_request *req = &handle->req; struct raw1394_request req;
int status; int status;
CLEAR_REQ(req); CLEAR_REQ(&req);
req->type = RAW1394_REQ_GET_ROM; req.type = RAW1394_REQ_GET_ROM;
req->recvb = (unsigned long) buffer; req.recvb = (unsigned long) buffer;
req->length = buffersize; req.length = buffersize;
req->tag = (unsigned long) rom_size; req.tag = (unsigned long) rom_size;
req->address = (unsigned long) rom_version; req.address = (unsigned long) rom_version;
req->sendb = (unsigned long) &status; 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; return status;
} }

View File

@ -42,7 +42,6 @@ struct raw1394_handle {
raw1394_iso_xmit_handler_t iso_xmit_handler; raw1394_iso_xmit_handler_t iso_xmit_handler;
raw1394_iso_recv_handler_t iso_recv_handler; raw1394_iso_recv_handler_t iso_recv_handler;
struct raw1394_request req;
quadlet_t buffer[HBUF_SIZE/4]; /* 2048 */ quadlet_t buffer[HBUF_SIZE/4]; /* 2048 */
}; };

View File

@ -54,19 +54,19 @@ int raw1394_start_read(struct raw1394_handle *handle, nodeid_t node,
nodeaddr_t addr, size_t length, quadlet_t *buffer, nodeaddr_t addr, size_t length, quadlet_t *buffer,
unsigned long tag) 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.type = RAW1394_REQ_ASYNC_READ;
req->generation = handle->generation; req.generation = handle->generation;
req->tag = tag; req.tag = tag;
req->address = ((__u64)node << 48) | addr; req.address = ((__u64)node << 48) | addr;
req->length = length; req.length = length;
req->recvb = ptr2int(buffer); 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, nodeaddr_t addr, size_t length, quadlet_t *data,
unsigned long tag) 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.type = RAW1394_REQ_ASYNC_WRITE;
req->generation = handle->generation; req.generation = handle->generation;
req->tag = tag; req.tag = tag;
req->address = ((__u64)node << 48) | addr; req.address = ((__u64)node << 48) | addr;
req->length = length; req.length = length;
req->sendb = ptr2int(data); 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, nodeaddr_t addr, unsigned int extcode, quadlet_t data,
quadlet_t arg, quadlet_t *result, unsigned long tag) quadlet_t arg, quadlet_t *result, unsigned long tag)
{ {
struct raw1394_request *req = &handle->req; struct raw1394_request req;
quadlet_t sendbuf[2]; quadlet_t sendbuf[2];
if ((extcode > 7) || (extcode == 0)) { if ((extcode > 7) || (extcode == 0)) {
@ -141,37 +141,37 @@ int raw1394_start_lock(struct raw1394_handle *handle, nodeid_t node,
return -1; return -1;
} }
CLEAR_REQ(req); CLEAR_REQ(&req);
req->type = RAW1394_REQ_LOCK; req.type = RAW1394_REQ_LOCK;
req->generation = handle->generation; req.generation = handle->generation;
req->tag = tag; req.tag = tag;
req->address = ((__u64)node << 48) | addr; req.address = ((__u64)node << 48) | addr;
req->sendb = ptr2int(sendbuf); req.sendb = ptr2int(sendbuf);
req->recvb = ptr2int(result); req.recvb = ptr2int(result);
req->misc = extcode; req.misc = extcode;
switch (extcode) { switch (extcode) {
case 3: /* EXTCODE_FETCH_ADD */ case 3: /* EXTCODE_FETCH_ADD */
case 4: /* EXTCODE_LITTLE_ADD */ case 4: /* EXTCODE_LITTLE_ADD */
sendbuf[0] = data; sendbuf[0] = data;
req->length = 4; req.length = 4;
break; break;
default: default:
sendbuf[0] = arg; sendbuf[0] = arg;
sendbuf[1] = data; sendbuf[1] = data;
req->length = 8; req.length = 8;
break; 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, int raw1394_start_lock64(struct raw1394_handle *handle, nodeid_t node,
nodeaddr_t addr, unsigned int extcode, octlet_t data, nodeaddr_t addr, unsigned int extcode, octlet_t data,
octlet_t arg, octlet_t *result, unsigned long tag) octlet_t arg, octlet_t *result, unsigned long tag)
{ {
struct raw1394_request *req = &handle->req; struct raw1394_request req;
octlet_t sendbuf[2]; octlet_t sendbuf[2];
if ((extcode > 7) || (extcode == 0)) { if ((extcode > 7) || (extcode == 0)) {
@ -179,31 +179,31 @@ int raw1394_start_lock64(struct raw1394_handle *handle, nodeid_t node,
return -1; return -1;
} }
CLEAR_REQ(req); CLEAR_REQ(&req);
req->type = RAW1394_REQ_LOCK64; req.type = RAW1394_REQ_LOCK64;
req->generation = handle->generation; req.generation = handle->generation;
req->tag = tag; req.tag = tag;
req->address = ((__u64)node << 48) | addr; req.address = ((__u64)node << 48) | addr;
req->sendb = ptr2int(sendbuf); req.sendb = ptr2int(sendbuf);
req->recvb = ptr2int(result); req.recvb = ptr2int(result);
req->misc = extcode; req.misc = extcode;
switch (extcode) { switch (extcode) {
case 3: /* EXTCODE_FETCH_ADD */ case 3: /* EXTCODE_FETCH_ADD */
case 4: /* EXTCODE_LITTLE_ADD */ case 4: /* EXTCODE_LITTLE_ADD */
sendbuf[0] = data; sendbuf[0] = data;
req->length = 8; req.length = 8;
break; break;
default: default:
sendbuf[0] = arg; sendbuf[0] = arg;
sendbuf[1] = data; sendbuf[1] = data;
req->length = 16; req.length = 16;
break; 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 int speed, size_t length, quadlet_t *data,
unsigned long rawtag) 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.type = RAW1394_REQ_ISO_SEND;
req->generation = handle->generation; req.generation = handle->generation;
req->tag = rawtag; req.tag = rawtag;
req->address = ((__u64)channel << 48) | speed; req.address = ((__u64)channel << 48) | speed;
req->misc = (tag << 16) | sy; req.misc = (tag << 16) | sy;
req->length = length; req.length = length;
req->sendb = ptr2int(data); 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, int raw1394_start_async_send(struct raw1394_handle *handle,
size_t length, size_t header_length, unsigned int expect_response, size_t length, size_t header_length, unsigned int expect_response,
quadlet_t *data, unsigned long rawtag) 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.type = RAW1394_REQ_ASYNC_SEND;
req->generation = handle->generation; req.generation = handle->generation;
req->tag = rawtag; req.tag = rawtag;
req->length = length; req.length = length;
req->misc = (expect_response << 16) | (header_length & 0xffff); req.misc = (expect_response << 16) | (header_length & 0xffff);
req->sendb = ptr2int(data); 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, int raw1394_start_phy_packet_write(struct raw1394_handle *handle,
quadlet_t data, unsigned long tag) 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.type = RAW1394_REQ_PHYPACKET;
req->generation = handle->generation; req.generation = handle->generation;
req->tag = tag; 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) 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) int raw1394_echo_request(struct raw1394_handle *handle, quadlet_t data)
{ {
struct raw1394_request *req = &handle->req; struct raw1394_request req;
int retval=0; int retval=0;
CLEAR_REQ(req); CLEAR_REQ(&req);
req->type = RAW1394_REQ_ECHO; req.type = RAW1394_REQ_ECHO;
req->misc = data; req.misc = data;
retval = (int)write(handle->fd, req, sizeof(*req)); retval = (int)write(handle->fd, &req, sizeof(req));
if (retval == sizeof(*req)) { if (retval == sizeof(req)) {
return 0; /* succcess */ return 0; /* succcess */
} }
return -1; return -1;