From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: jikos@kernel.org
Cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org, Even Xu <even.xu@intel.com>
Subject: [PATCH 3/9] hid: intel-ish-hid: ishtp: add helper functions for client buffer operation
Date: Tue, 11 Sep 2018 16:44:15 -0700 [thread overview]
Message-ID: <20180911234421.10691-4-srinivas.pandruvada@linux.intel.com> (raw)
In-Reply-To: <20180911234421.10691-1-srinivas.pandruvada@linux.intel.com>
From: Even Xu <even.xu@intel.com>
Add helper ishtp_cl_tx_empty() and ishtp_cl_rx_get_rb() to hide internal
details from callers, who needs this functionality.
Signed-off-by: Even Xu <even.xu@intel.com>
Reviewed-by: Andriy Shevchenko <andriy.shevchenko@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
.../hid/intel-ish-hid/ishtp/client-buffers.c | 45 +++++++++++++++++++
drivers/hid/intel-ish-hid/ishtp/client.h | 2 +
2 files changed, 47 insertions(+)
diff --git a/drivers/hid/intel-ish-hid/ishtp/client-buffers.c b/drivers/hid/intel-ish-hid/ishtp/client-buffers.c
index b9b917d2d50d..12d61305e83d 100644
--- a/drivers/hid/intel-ish-hid/ishtp/client-buffers.c
+++ b/drivers/hid/intel-ish-hid/ishtp/client-buffers.c
@@ -255,3 +255,48 @@ int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb)
return rets;
}
EXPORT_SYMBOL(ishtp_cl_io_rb_recycle);
+
+/**
+ * ishtp_cl_tx_empty() -test whether client device tx buffer is empty
+ * @cl: Pointer to client device instance
+ *
+ * Look client device tx buffer list, and check whether this list is empty
+ *
+ * Return: true if client tx buffer list is empty else false
+ */
+bool ishtp_cl_tx_empty(struct ishtp_cl *cl)
+{
+ int tx_list_empty;
+ unsigned long tx_flags;
+
+ spin_lock_irqsave(&cl->tx_list_spinlock, tx_flags);
+ tx_list_empty = list_empty(&cl->tx_list.list);
+ spin_unlock_irqrestore(&cl->tx_list_spinlock, tx_flags);
+
+ return !!tx_list_empty;
+}
+EXPORT_SYMBOL(ishtp_cl_tx_empty);
+
+/**
+ * ishtp_cl_rx_get_rb() -Get a rb from client device rx buffer list
+ * @cl: Pointer to client device instance
+ *
+ * Check client device in-processing buffer list and get a rb from it.
+ *
+ * Return: rb pointer if buffer list isn't empty else NULL
+ */
+struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl)
+{
+ unsigned long rx_flags;
+ struct ishtp_cl_rb *rb;
+
+ spin_lock_irqsave(&cl->in_process_spinlock, rx_flags);
+ rb = list_first_entry_or_null(&cl->in_process_list.list,
+ struct ishtp_cl_rb, list);
+ if (rb)
+ list_del_init(&rb->list);
+ spin_unlock_irqrestore(&cl->in_process_spinlock, rx_flags);
+
+ return rb;
+}
+EXPORT_SYMBOL(ishtp_cl_rx_get_rb);
diff --git a/drivers/hid/intel-ish-hid/ishtp/client.h b/drivers/hid/intel-ish-hid/ishtp/client.h
index 79eade547f5d..a82ee4d82cdb 100644
--- a/drivers/hid/intel-ish-hid/ishtp/client.h
+++ b/drivers/hid/intel-ish-hid/ishtp/client.h
@@ -178,5 +178,7 @@ int ishtp_cl_flush_queues(struct ishtp_cl *cl);
/* exported functions from ISHTP client buffer management scope */
int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb);
+bool ishtp_cl_tx_empty(struct ishtp_cl *cl);
+struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl);
#endif /* _ISHTP_CLIENT_H_ */
--
2.17.1
next prev parent reply other threads:[~2018-09-11 23:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-11 23:44 [PATCH 0/9] HID: intel ISH: Cleanup patches Srinivas Pandruvada
2018-09-11 23:44 ` [PATCH 1/9] hid: intel-ish-hid: ishtp: add helper function for driver data get/set Srinivas Pandruvada
2018-09-11 23:44 ` [PATCH 2/9] hid: intel-ish-hid: use helper function for private driver data set/get Srinivas Pandruvada
2018-09-11 23:44 ` Srinivas Pandruvada [this message]
2018-09-11 23:44 ` [PATCH 4/9] hid: intel-ish-hid: use helper function to access client buffer Srinivas Pandruvada
2018-09-11 23:44 ` [PATCH 5/9] hid: intel-ish-hid: ishtp: add helper function for client search Srinivas Pandruvada
2018-09-11 23:44 ` [PATCH 6/9] hid: intel-ish-hid: use helper function to search client id Srinivas Pandruvada
2018-09-11 23:44 ` [PATCH 7/9] HID: intel_ish-hid: Enhance API to get ring buffer sizes Srinivas Pandruvada
2018-09-11 23:44 ` [PATCH 8/9] HID: intel-ish-hid: use resource-managed api Srinivas Pandruvada
2018-09-11 23:44 ` [PATCH 9/9] HID: intel-ish-hid: using list_head for ipc write queue Srinivas Pandruvada
2018-09-24 9:21 ` [PATCH 0/9] HID: intel ISH: Cleanup patches Jiri Kosina
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=20180911234421.10691-4-srinivas.pandruvada@linux.intel.com \
--to=srinivas.pandruvada@linux.intel.com \
--cc=benjamin.tissoires@redhat.com \
--cc=even.xu@intel.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).