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>
This commit is contained in:
parent
39ce342c3a
commit
147e9d3af3
@ -170,7 +170,9 @@ struct outbound_transaction_event {
|
|||||||
struct event event;
|
struct event event;
|
||||||
struct client *client;
|
struct client *client;
|
||||||
struct outbound_transaction_resource r;
|
struct outbound_transaction_resource r;
|
||||||
struct fw_cdev_event_response response;
|
union {
|
||||||
|
struct fw_cdev_event_response without_tstamp;
|
||||||
|
} rsp;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct inbound_transaction_event {
|
struct inbound_transaction_event {
|
||||||
@ -540,7 +542,7 @@ static void complete_transaction(struct fw_card *card, int rcode,
|
|||||||
void *payload, size_t length, void *data)
|
void *payload, size_t length, void *data)
|
||||||
{
|
{
|
||||||
struct outbound_transaction_event *e = data;
|
struct outbound_transaction_event *e = data;
|
||||||
struct fw_cdev_event_response *rsp = &e->response;
|
struct fw_cdev_event_response *rsp = &e->rsp.without_tstamp;
|
||||||
struct client *client = e->client;
|
struct client *client = e->client;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
@ -581,6 +583,8 @@ static int init_request(struct client *client,
|
|||||||
int destination_id, int speed)
|
int destination_id, int speed)
|
||||||
{
|
{
|
||||||
struct outbound_transaction_event *e;
|
struct outbound_transaction_event *e;
|
||||||
|
struct fw_cdev_event_response *rsp;
|
||||||
|
void *payload;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (request->tcode != TCODE_STREAM_DATA &&
|
if (request->tcode != TCODE_STREAM_DATA &&
|
||||||
@ -594,14 +598,14 @@ static int init_request(struct client *client,
|
|||||||
e = kmalloc(sizeof(*e) + request->length, GFP_KERNEL);
|
e = kmalloc(sizeof(*e) + request->length, GFP_KERNEL);
|
||||||
if (e == NULL)
|
if (e == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
e->client = client;
|
e->client = client;
|
||||||
e->response.length = request->length;
|
|
||||||
e->response.closure = request->closure;
|
|
||||||
|
|
||||||
if (request->data &&
|
rsp = &e->rsp.without_tstamp;
|
||||||
copy_from_user(e->response.data,
|
rsp->length = request->length;
|
||||||
u64_to_uptr(request->data), request->length)) {
|
rsp->closure = request->closure;
|
||||||
|
payload = rsp->data;
|
||||||
|
|
||||||
|
if (request->data && copy_from_user(payload, u64_to_uptr(request->data), request->length)) {
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@ -611,10 +615,9 @@ static int init_request(struct client *client,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
fw_send_request(client->device->card, &e->r.transaction,
|
fw_send_request(client->device->card, &e->r.transaction, request->tcode, destination_id,
|
||||||
request->tcode, destination_id, request->generation,
|
request->generation, speed, request->offset, payload, request->length,
|
||||||
speed, request->offset, e->response.data,
|
complete_transaction, e);
|
||||||
request->length, complete_transaction, e);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
|
Loading…
Reference in New Issue
Block a user