mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Wagner <wagi@monom.org>
To: linux-kernel@vger.kernel.org
Cc: Ming Lei <ming.lei@canonical.com>,
	"Luis R . Rodriguez" <mcgrof@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Srivatsa S . Bhat" <srivatsa.bhat@linux.vnet.ibm.com>,
	"Rafael J . Wysocki" <rjw@sisk.pl>,
	Daniel Vetter <daniel.vetter@intel.com>,
	Takashi Iwai <tiwai@suse.com>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Arend van Spriel <arend.vanspriel@broadcom.com>,
	Daniel Wagner <daniel.wagner@bmw-carit.de>
Subject: [PATCH v6 6/6] firmware: move fw_state_is_{aborted|done}() into UHM section
Date: Thu, 20 Oct 2016 11:52:12 +0200	[thread overview]
Message-ID: <1476957132-27818-7-git-send-email-wagi@monom.org> (raw)
In-Reply-To: <1476957132-27818-1-git-send-email-wagi@monom.org>

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

For direct firmware loading we do not need to read the status after
fw_state_wait() returns. It either returns success or the error
code. Also assign_firmware_buf() is only called if there was no
error (especially ABORTED has been detected by
fw_get_umh_firmware()).

So we are allowed to move the remaining fw_state_is_{aborted|done}()
defintion into the !CONFIG_FW_LOADER_USER_HELPER section.

Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Cc: Ming Lei <ming.lei@canonical.com>
Cc: Luis R. Rodriguez <mcgrof@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/base/firmware_class.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 4f1755537314..813587f2ccbe 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -116,11 +116,6 @@ static void fw_state_init(struct fw_state *fw_st)
 	fw_st->status = FW_STATUS_UNKNOWN;
 }
 
-static int __fw_state_check(struct fw_state *fw_st, enum fw_status status)
-{
-	return fw_st->status == status;
-}
-
 static inline bool __fw_state_is_done(enum fw_status status)
 {
 	return status == FW_STATUS_DONE || status == FW_STATUS_ABORTED;
@@ -152,16 +147,10 @@ static void __fw_state_set(struct fw_state *fw_st,
 	__fw_state_set(fw_st, FW_STATUS_LOADING)
 #define fw_state_done(fw_st)					\
 	__fw_state_set(fw_st, FW_STATUS_DONE)
-#define fw_state_is_done(fw_st)					\
-	__fw_state_check(fw_st, FW_STATUS_DONE)
 #define fw_state_wait(fw_st)					\
 	__fw_state_wait_common(fw_st, MAX_SCHEDULE_TIMEOUT)
 
-#ifndef CONFIG_FW_LOADER_USER_HELPER
-
-#define fw_state_is_aborted(fw_st)	false
-
-#else /* CONFIG_FW_LOADER_USER_HELPER */
+#ifdef CONFIG_FW_LOADER_USER_HELPER
 
 static int loading_timeout = 60;	/* In seconds */
 
@@ -170,8 +159,15 @@ static inline long firmware_loading_timeout(void)
 	return loading_timeout > 0 ? loading_timeout * HZ : MAX_JIFFY_OFFSET;
 }
 
+static int __fw_state_check(struct fw_state *fw_st, enum fw_status status)
+{
+	return fw_st->status == status;
+}
+
 #define fw_state_aborted(fw_st)					\
 	__fw_state_set(fw_st, FW_STATUS_ABORTED)
+#define fw_state_is_done(fw_st)					\
+	__fw_state_check(fw_st, FW_STATUS_DONE)
 #define fw_state_is_loading(fw_st)				\
 	__fw_state_check(fw_st, FW_STATUS_LOADING)
 #define fw_state_is_aborted(fw_st)				\
@@ -1156,7 +1152,7 @@ static int assign_firmware_buf(struct firmware *fw, struct device *device,
 	struct firmware_buf *buf = fw->priv;
 
 	mutex_lock(&fw_lock);
-	if (!buf->size || fw_state_is_aborted(&buf->fw_st)) {
+	if (!buf->size) {
 		mutex_unlock(&fw_lock);
 		return -ENOENT;
 	}
-- 
2.7.4

      parent reply	other threads:[~2016-10-20  9:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-20  9:52 [PATCH v6 0/6] firmware: encapsulate firmware loading status Daniel Wagner
2016-10-20  9:52 ` [PATCH v6 1/6] firmware: move umh locking code into fw_load_from_user_helper() Daniel Wagner
2016-11-09 21:17   ` Luis R. Rodriguez
2016-10-20  9:52 ` [PATCH v6 2/6] firmware: encapsulate firmware loading status Daniel Wagner
2016-10-20  9:52 ` [PATCH v6 3/6] firmware: rename fw_load_from_user_helper() and _request_firmware_load() Daniel Wagner
2016-10-20  9:52 ` [PATCH v6 4/6] firmware: drop bit ops in favor of simple state machine Daniel Wagner
2016-10-20  9:52 ` [PATCH v6 5/6] firmware: do not use fw_lock for fw_state protection Daniel Wagner
2016-10-20  9:52 ` Daniel Wagner [this message]

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=1476957132-27818-7-git-send-email-wagi@monom.org \
    --to=wagi@monom.org \
    --cc=arend.vanspriel@broadcom.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=daniel.vetter@intel.com \
    --cc=daniel.wagner@bmw-carit.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=ming.lei@canonical.com \
    --cc=rjw@sisk.pl \
    --cc=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=tiwai@suse.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®