From: yi1.li@linux.intel.com
To: mcgrof@kernel.org, atull@kernel.org, gregkh@linuxfoundation.org,
wagi@monom.org, dwmw2@infradead.org, rafal@milecki.pl,
arend.vanspriel@broadcom.com, rjw@rjwysocki.net,
moritz.fischer@ettus.com, pmladek@suse.com,
johannes.berg@intel.com, emmanuel.grumbach@intel.com,
luciano.coelho@intel.com, kvalo@codeaurora.org, luto@kernel.org,
takahiro.akashi@linaro.org, dhowells@redhat.com,
pjones@redhat.com
Cc: linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org,
Yi Li <yi1.li@linux.intel.com>
Subject: [PATCHv2 1/2] firmware: Enable pre-allocated buffer support in driver_data
Date: Sat, 20 May 2017 01:48:05 -0500 [thread overview]
Message-ID: <1495262886-1045-2-git-send-email-yi1.li@linux.intel.com> (raw)
In-Reply-To: <1495262886-1045-1-git-send-email-yi1.li@linux.intel.com>
From: Yi Li <yi1.li@linux.intel.com>
This enables the equivalent feature of the legacy request_firmware_into_buf
to driver_data, so caller can allocate and manage the firmware buffer
instead of by driver_data class internally. The caller need to setup
alloc_buf and alloc_buf_size in the @driver_data_req_params structure.
Signed-off-by: Yi Li <yi1.li@linux.intel.com>
---
drivers/base/firmware_class.c | 21 ++++++++-------------
include/linux/driver_data.h | 5 +++++
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 444c9a8..461c7c2 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -83,9 +83,6 @@ enum driver_data_priv_reqs {
* @mode: mode of operation
* @priv_reqs: private set of &enum driver_data_reqs, private requirements for
* the driver data request
- * @alloc_buf: buffer area allocated by the caller so we can place the
- * respective driver data
- * @alloc_buf_size: size of the @alloc_buf
* @old_async_cb: used only for request_firmware_nowait() since we won't change
* all async callbacks to get the return value on failure
* @api: used internally for keeping track of the currently evaluated API
@@ -98,8 +95,6 @@ enum driver_data_priv_reqs {
struct driver_data_priv_params {
enum driver_data_mode mode;
u64 priv_reqs;
- void *alloc_buf;
- size_t alloc_buf_size;
void (*old_async_cb)(const struct firmware *driver_data, void *context);
u8 api;
bool retry_api;
@@ -149,12 +144,12 @@ struct driver_data_params {
#define __DATA_REQ_FIRMWARE_BUF(buf, size) \
.req_params = { \
.reqs = DRIVER_DATA_REQ_NO_CACHE, \
+ .alloc_buf = &buf, \
+ .alloc_buf_size = size, \
}, \
.priv_params = { \
.priv_reqs = DRIVER_DATA_PRIV_REQ_FALLBACK | \
DRIVER_DATA_PRIV_REQ_FALLBACK_UEVENT, \
- .alloc_buf = buf, \
- .alloc_buf_size = size, \
}
#define __DATA_REQ_FIRMWARE_NOWAIT(module, uevent, gfp, async_cb, async_ctx) \
@@ -265,9 +260,9 @@ static bool fw_get_builtin_firmware(struct firmware *fw, const char *name,
void *buf;
size_t size;
- if (data_params) {
- buf = data_params->priv_params.alloc_buf;
- size = data_params->priv_params.alloc_buf_size;
+ if (data_params && data_params->req_params.alloc_buf) {
+ buf = *data_params->req_params.alloc_buf;
+ size = data_params->req_params.alloc_buf_size;
} else {
buf = NULL;
size = 0;
@@ -507,9 +502,9 @@ static struct firmware_buf *__allocate_fw_buf(const char *fw_name,
void *dbuf;
size_t size;
- if (data_params) {
- dbuf = data_params->priv_params.alloc_buf;
- size = data_params->priv_params.alloc_buf_size;
+ if (data_params && data_params->req_params.alloc_buf) {
+ dbuf = *data_params->req_params.alloc_buf;
+ size = data_params->req_params.alloc_buf_size;
} else {
dbuf = NULL;
size = 0;
diff --git a/include/linux/driver_data.h b/include/linux/driver_data.h
index b6ef5ee..a3a5fbe 100644
--- a/include/linux/driver_data.h
+++ b/include/linux/driver_data.h
@@ -144,6 +144,9 @@ enum driver_data_reqs {
* highest version of API supported by the caller.
* @api_name_postfix: optional, indicates to use this as the driver data name
* postfix when %DRIVER_DATA_REQ_USE_API_VERSIONING is enabled.
+ * @alloc_buf: pointer of pointer to the buffer area allocated by the caller
+ * so we can place the respective driver data
+ * @alloc_buf_size: size of the @alloc_buf
*
* This data structure is intended to carry all requirements and specifications
* required to complete the task to get the requested driver date file to the
@@ -157,6 +160,8 @@ struct driver_data_req_params {
u8 api_max;
const char *api_name_postfix;
const union driver_data_cbs cbs;
+ void **alloc_buf;
+ size_t alloc_buf_size;
};
/*
--
2.7.4
next prev parent reply other threads:[~2017-05-20 6:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-20 6:48 [PATCHv2 0/2] Enable pre-allocated buffer support for driver_data yi1.li
2017-05-20 6:48 ` yi1.li [this message]
2017-05-20 6:48 ` [PATCHv2 2/2] test: add pre-allocated buffer to driver_data tester yi1.li
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=1495262886-1045-2-git-send-email-yi1.li@linux.intel.com \
--to=yi1.li@linux.intel.com \
--cc=arend.vanspriel@broadcom.com \
--cc=atull@kernel.org \
--cc=dhowells@redhat.com \
--cc=dwmw2@infradead.org \
--cc=emmanuel.grumbach@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=johannes.berg@intel.com \
--cc=kvalo@codeaurora.org \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luciano.coelho@intel.com \
--cc=luto@kernel.org \
--cc=mcgrof@kernel.org \
--cc=moritz.fischer@ettus.com \
--cc=pjones@redhat.com \
--cc=pmladek@suse.com \
--cc=rafal@milecki.pl \
--cc=rjw@rjwysocki.net \
--cc=takahiro.akashi@linaro.org \
--cc=wagi@monom.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
Powered by JetHome