All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: [PATCH v3 07/12] firewire: cdev: code refactoring to operate event of response
Date: Mon, 29 May 2023 20:34:01 +0900	[thread overview]
Message-ID: <20230529113406.986289-8-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <20230529113406.986289-1-o-takashi@sakamocchi.jp>

This commit is a preparation to handle time stamp of asynchronous
transaction for user space application.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 drivers/firewire/core-cdev.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index 5a9446d30447..315ebc8c545d 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -170,7 +170,9 @@ struct outbound_transaction_event {
 	struct event event;
 	struct client *client;
 	struct outbound_transaction_resource r;
-	struct fw_cdev_event_response response;
+	union {
+		struct fw_cdev_event_response without_tstamp;
+	} rsp;
 };
 
 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)
 {
 	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;
 	unsigned long flags;
 
@@ -581,6 +583,8 @@ static int init_request(struct client *client,
 			int destination_id, int speed)
 {
 	struct outbound_transaction_event *e;
+	struct fw_cdev_event_response *rsp;
+	void *payload;
 	int ret;
 
 	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);
 	if (e == NULL)
 		return -ENOMEM;
-
 	e->client = client;
-	e->response.length = request->length;
-	e->response.closure = request->closure;
 
-	if (request->data &&
-	    copy_from_user(e->response.data,
-			   u64_to_uptr(request->data), request->length)) {
+	rsp = &e->rsp.without_tstamp;
+	rsp->length = 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;
 		goto failed;
 	}
@@ -611,10 +615,9 @@ static int init_request(struct client *client,
 	if (ret < 0)
 		goto failed;
 
-	fw_send_request(client->device->card, &e->r.transaction,
-			request->tcode, destination_id, request->generation,
-			speed, request->offset, e->response.data,
-			request->length, complete_transaction, e);
+	fw_send_request(client->device->card, &e->r.transaction, request->tcode, destination_id,
+			request->generation, speed, request->offset, payload, request->length,
+			complete_transaction, e);
 	return 0;
 
  failed:
-- 
2.39.2


  parent reply	other threads:[~2023-05-29 11:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-29 11:33 [PATCH v3 00/12] firewire: deliver hardware time stamp for asynchronous transaction Takashi Sakamoto
2023-05-29 11:33 ` [PATCH v3 01/12] firewire: add KUnit test to check layout of UAPI structures Takashi Sakamoto
2023-05-29 11:33 ` [PATCH v3 02/12] firewire: cdev: add new version of ABI to notify time stamp at request/response subaction of transaction Takashi Sakamoto
2023-05-29 11:33 ` [PATCH v3 03/12] firewire: cdev: add new event to notify request subaction with time stamp Takashi Sakamoto
2023-05-29 11:33 ` [PATCH v3 04/12] firewire: cdev: implement " Takashi Sakamoto
2023-05-29 11:33 ` [PATCH v3 05/12] firewire: core: use union for callback of transaction completion Takashi Sakamoto
2023-05-29 11:34 ` [PATCH v3 06/12] firewire: core: implement variations to send request and wait for response with time stamp Takashi Sakamoto
2023-05-29 11:34 ` Takashi Sakamoto [this message]
2023-05-29 11:34 ` [PATCH v3 08/12] firewire: cdev: add new event to notify response subaction " Takashi Sakamoto
2023-05-29 11:34 ` [PATCH v3 09/12] firewire: cdev: implement " Takashi Sakamoto
2023-05-29 11:34 ` [PATCH v3 10/12] firewire: cdev: code refactoring to dispatch event for phy packet Takashi Sakamoto
2023-05-29 11:34 ` [PATCH v3 11/12] firewire: cdev: add new event to notify phy packet with time stamp Takashi Sakamoto
2023-05-29 11:34 ` [PATCH v3 12/12] firewire: cdev: implement new event relevant to " Takashi Sakamoto
2023-05-29 23:15 ` [PATCH v3 00/12] firewire: deliver hardware time stamp for asynchronous transaction Takashi Sakamoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230529113406.986289-8-o-takashi@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux1394-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.