[PATCHv2 1/3] firmware_class: move NO_CACHE from private to driver_data_req_params

From: yi1 . li
Date: Sat May 20 2017 - 02:52:22 EST


From: Yi Li <yi1.li@xxxxxxxxxxxxxxx>

This adds DRIVER_DATA_REQ_NO_CACHE flag with .req flag under struct
driver_data_req_params. When this flag is set, the driver_data driver
will bypass the internal caching mechanism, its used by streaming
case and other drivers which implement their own cache thing.

Signed-off-by: Yi Li <yi1.li@xxxxxxxxxxxxxxx>
---
drivers/base/firmware_class.c | 16 +++++++---------
include/linux/driver_data.h | 4 ++++
2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 7af430a..444c9a8 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -72,14 +72,10 @@ enum driver_data_mode {
* issue a uevent to userspace. Userspace in turn is expected to be
* monitoring for uevents for the firmware_class and will use the
* exposted sysfs interface to upload the driver data for the caller.
- * @DRIVER_DATA_PRIV_REQ_NO_CACHE: indicates that the driver data request
- * should not set up and use the internal caching mechanism to assist
- * drivers from fetching driver data at resume time after suspend.
*/
enum driver_data_priv_reqs {
DRIVER_DATA_PRIV_REQ_FALLBACK = 1 << 0,
DRIVER_DATA_PRIV_REQ_FALLBACK_UEVENT = 1 << 1,
- DRIVER_DATA_PRIV_REQ_NO_CACHE = 1 << 2,
};

/**
@@ -151,10 +147,12 @@ struct driver_data_params {
}

#define __DATA_REQ_FIRMWARE_BUF(buf, size) \
+ .req_params = { \
+ .reqs = DRIVER_DATA_REQ_NO_CACHE, \
+ }, \
.priv_params = { \
.priv_reqs = DRIVER_DATA_PRIV_REQ_FALLBACK | \
- DRIVER_DATA_PRIV_REQ_FALLBACK_UEVENT | \
- DRIVER_DATA_PRIV_REQ_NO_CACHE, \
+ DRIVER_DATA_PRIV_REQ_FALLBACK_UEVENT, \
.alloc_buf = buf, \
.alloc_buf_size = size, \
}
@@ -186,7 +184,7 @@ struct driver_data_params {
#define driver_data_param_uevent(params) \
(!!((params)->priv_reqs & DRIVER_DATA_PRIV_REQ_FALLBACK_UEVENT))
#define driver_data_param_nocache(params) \
- (!!((params)->priv_reqs & DRIVER_DATA_PRIV_REQ_NO_CACHE))
+ (!!((params)->reqs & DRIVER_DATA_REQ_NO_CACHE))

#define driver_data_param_optional(params) \
(!!((params)->reqs & DRIVER_DATA_REQ_OPTIONAL))
@@ -793,14 +791,14 @@ static int assign_firmware_buf(struct firmware *fw, struct device *device,
/* don't cache firmware handled without uevent */
if (device &&
driver_data_param_uevent(&data_params->priv_params) &&
- !driver_data_param_nocache(&data_params->priv_params))
+ !driver_data_param_nocache(&data_params->req_params))
fw_add_devm_name(device, buf->fw_id);

/*
* After caching firmware image is started, let it piggyback
* on request firmware.
*/
- if (!driver_data_param_nocache(&data_params->priv_params) &&
+ if (!driver_data_param_nocache(&data_params->req_params) &&
buf->fwc->state == FW_LOADER_START_CACHE) {
if (fw_cache_piggyback_on_request(buf->fw_id))
kref_get(&buf->ref);
diff --git a/include/linux/driver_data.h b/include/linux/driver_data.h
index bf51e0b..b6ef5ee 100644
--- a/include/linux/driver_data.h
+++ b/include/linux/driver_data.h
@@ -117,11 +117,15 @@ union driver_data_cbs {
* file to be present given the API range, it is only required for one
* file in the API range to be present. If the %DRIVER_DATA_REQ_OPTIONAL
* flag is also enabled then all files are treated as optional.
+ * @DRIVER_DATA_REQ_NO_CACHE: indicates that the driver data request
+ * should not set up and use the internal caching mechanism to assist
+ * drivers from fetching driver data at resume time after suspend.
*/
enum driver_data_reqs {
DRIVER_DATA_REQ_OPTIONAL = 1 << 0,
DRIVER_DATA_REQ_KEEP = 1 << 1,
DRIVER_DATA_REQ_USE_API_VERSIONING = 1 << 2,
+ DRIVER_DATA_REQ_NO_CACHE = 1 << 3,
};

/**
--
2.7.4