From: Russ Weight <russell.h.weight@intel.com>
To: mcgrof@kernel.org, gregkh@linuxfoundation.org, rafael@kernel.org,
linux-kernel@vger.kernel.org
Cc: trix@redhat.com, lgoncalv@redhat.com, yilun.xu@intel.com,
hao.wu@intel.com, matthew.gerlach@intel.com,
basheer.ahmed.muddebihal@intel.com, tianfei.zhang@intel.com,
Russ Weight <russell.h.weight@intel.com>
Subject: [RFC PATCH 2/5] firmware_loader: Check fw_state_is_done in loading_store
Date: Thu, 3 Feb 2022 14:30:49 -0700 [thread overview]
Message-ID: <20220203213053.360190-3-russell.h.weight@intel.com> (raw)
In-Reply-To: <20220203213053.360190-1-russell.h.weight@intel.com>
Add the fw_state_is_done() function and exit early from
firmware_loading_store() if the state is already "done". This is being done
in preparation for supporting persistent sysfs nodes to allow userspace to
upload firmware to a device, potentially reusing the sysfs loading and data
files multiple times.
Signed-off-by: Russ Weight <russell.h.weight@intel.com>
---
drivers/base/firmware_loader/fallback.c | 2 +-
drivers/base/firmware_loader/firmware.h | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/base/firmware_loader/fallback.c b/drivers/base/firmware_loader/fallback.c
index 4afb0e9312c0..d82e055a4297 100644
--- a/drivers/base/firmware_loader/fallback.c
+++ b/drivers/base/firmware_loader/fallback.c
@@ -250,7 +250,7 @@ static ssize_t firmware_loading_store(struct device *dev,
mutex_lock(&fw_lock);
fw_priv = fw_sysfs->fw_priv;
- if (fw_state_is_aborted(fw_priv))
+ if (fw_state_is_aborted(fw_priv) || fw_state_is_done(fw_priv))
goto out;
switch (loading) {
diff --git a/drivers/base/firmware_loader/firmware.h b/drivers/base/firmware_loader/firmware.h
index 2889f446ad41..58768d16f8df 100644
--- a/drivers/base/firmware_loader/firmware.h
+++ b/drivers/base/firmware_loader/firmware.h
@@ -149,6 +149,11 @@ static inline void fw_state_done(struct fw_priv *fw_priv)
__fw_state_set(fw_priv, FW_STATUS_DONE);
}
+static inline bool fw_state_is_done(struct fw_priv *fw_priv)
+{
+ return __fw_state_check(fw_priv, FW_STATUS_DONE);
+}
+
int assign_fw(struct firmware *fw, struct device *device);
#ifdef CONFIG_FW_LOADER
--
2.25.1
next prev parent reply other threads:[~2022-02-03 21:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-03 21:30 [RFC PATCH 0/5] Extend FW framework for user FW uploads Russ Weight
2022-02-03 21:30 ` [RFC PATCH 1/5] firmware_loader: Clear data and size in fw_free_paged_buf Russ Weight
2022-02-03 21:30 ` Russ Weight [this message]
2022-02-03 21:30 ` [RFC PATCH 3/5] firmware_loader: Split fw_sysfs support from fallback Russ Weight
2022-02-03 22:51 ` Luis Chamberlain
2022-02-11 1:50 ` Russ Weight
2022-02-06 15:43 ` Tom Rix
2022-02-11 2:24 ` Russ Weight
2022-02-03 21:30 ` [RFC PATCH 4/5] firmware_loader: Add firmware-upload support Russ Weight
2022-02-03 22:59 ` Luis Chamberlain
2022-02-11 2:29 ` Russ Weight
2022-02-03 21:30 ` [RFC PATCH 5/5] firmware_loader: Add sysfs nodes to monitor fw_upload Russ Weight
2022-02-03 23:00 ` [RFC PATCH 0/5] Extend FW framework for user FW uploads Luis Chamberlain
2022-02-11 2:30 ` Russ Weight
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=20220203213053.360190-3-russell.h.weight@intel.com \
--to=russell.h.weight@intel.com \
--cc=basheer.ahmed.muddebihal@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hao.wu@intel.com \
--cc=lgoncalv@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.gerlach@intel.com \
--cc=mcgrof@kernel.org \
--cc=rafael@kernel.org \
--cc=tianfei.zhang@intel.com \
--cc=trix@redhat.com \
--cc=yilun.xu@intel.com \
/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
all inboxes | Powered by JetHome®