Skip to content

Commit 147e9d3

Browse files
committed
firewire: cdev: code refactoring to operate event of response
This commit is a preparation to handle time stamp of asynchronous transaction for user space application. Link: https://lore.kernel.org/r/20230529113406.986289-8-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
1 parent 39ce342 commit 147e9d3

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

drivers/firewire/core-cdev.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ struct outbound_transaction_event {
170170
struct event event;
171171
struct client *client;
172172
struct outbound_transaction_resource r;
173-
struct fw_cdev_event_response response;
173+
union {
174+
struct fw_cdev_event_response without_tstamp;
175+
} rsp;
174176
};
175177

176178
struct inbound_transaction_event {
@@ -540,7 +542,7 @@ static void complete_transaction(struct fw_card *card, int rcode,
540542
void *payload, size_t length, void *data)
541543
{
542544
struct outbound_transaction_event *e = data;
543-
struct fw_cdev_event_response *rsp = &e->response;
545+
struct fw_cdev_event_response *rsp = &e->rsp.without_tstamp;
544546
struct client *client = e->client;
545547
unsigned long flags;
546548

@@ -581,6 +583,8 @@ static int init_request(struct client *client,
581583
int destination_id, int speed)
582584
{
583585
struct outbound_transaction_event *e;
586+
struct fw_cdev_event_response *rsp;
587+
void *payload;
584588
int ret;
585589

586590
if (request->tcode != TCODE_STREAM_DATA &&
@@ -594,14 +598,14 @@ static int init_request(struct client *client,
594598
e = kmalloc(sizeof(*e) + request->length, GFP_KERNEL);
595599
if (e == NULL)
596600
return -ENOMEM;
597-
598601
e->client = client;
599-
e->response.length = request->length;
600-
e->response.closure = request->closure;
601602

602-
if (request->data &&
603-
copy_from_user(e->response.data,
604-
u64_to_uptr(request->data), request->length)) {
603+
rsp = &e->rsp.without_tstamp;
604+
rsp->length = request->length;
605+
rsp->closure = request->closure;
606+
payload = rsp->data;
607+
608+
if (request->data && copy_from_user(payload, u64_to_uptr(request->data), request->length)) {
605609
ret = -EFAULT;
606610
goto failed;
607611
}
@@ -611,10 +615,9 @@ static int init_request(struct client *client,
611615
if (ret < 0)
612616
goto failed;
613617

614-
fw_send_request(client->device->card, &e->r.transaction,
615-
request->tcode, destination_id, request->generation,
616-
speed, request->offset, e->response.data,
617-
request->length, complete_transaction, e);
618+
fw_send_request(client->device->card, &e->r.transaction, request->tcode, destination_id,
619+
request->generation, speed, request->offset, payload, request->length,
620+
complete_transaction, e);
618621
return 0;
619622

620623
failed:

0 commit comments

Comments
 (0)