Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934576AbcJTJwo (ORCPT ); Thu, 20 Oct 2016 05:52:44 -0400 Received: from atlantic540.startdedicated.de ([188.138.9.77]:47022 "EHLO atlantic540.startdedicated.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933907AbcJTJw3 (ORCPT ); Thu, 20 Oct 2016 05:52:29 -0400 From: Daniel Wagner To: linux-kernel@vger.kernel.org Cc: Ming Lei , "Luis R . Rodriguez" , Greg Kroah-Hartman , "Srivatsa S . Bhat" , "Rafael J . Wysocki" , Daniel Vetter , Takashi Iwai , Bjorn Andersson , Arend van Spriel , Daniel Wagner Subject: [PATCH v6 6/6] firmware: move fw_state_is_{aborted|done}() into UHM section Date: Thu, 20 Oct 2016 11:52:12 +0200 Message-Id: <1476957132-27818-7-git-send-email-wagi@monom.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476957132-27818-1-git-send-email-wagi@monom.org> References: <1476957132-27818-1-git-send-email-wagi@monom.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2736 Lines: 80 From: Daniel Wagner 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 Cc: Ming Lei Cc: Luis R. Rodriguez Cc: Greg Kroah-Hartman --- 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