From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751860AbdBOPFY (ORCPT ); Wed, 15 Feb 2017 10:05:24 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:33191 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751140AbdBOPFX (ORCPT ); Wed, 15 Feb 2017 10:05:23 -0500 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Ming Lei , "Luis R . Rodriguez" , Linux Kernel Mailing List , Greg KH Cc: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Subject: [PATCH V2 RESEND] firmware: simplify defining and handling FW_OPT_FALLBACK Date: Wed, 15 Feb 2017 16:05:13 +0100 Message-Id: <20170215150513.3703-1-zajec5@gmail.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafał Miłecki I found handling of FW_OPT_FALLBACK a bit complex. It was defined using another option and their values were dependent on kernel config. It was also non-trivial to follow the code. Some callers were using FW_OPT_FALLBACK which was confusing since the _request_firmware function was always checking for FW_OPT_USERHELPER (the same bit in a relevant configuration). With this patch FW_OPT_USERHELPER gets its own bit and is explicitly checked in the _request_firmware which hopefully makes code easier to understand. Signed-off-by: Rafał Miłecki --- V2: s/config_enabled/IS_ENABLED/ to compile since c0a0aba8e47 ("kconfig.h: remove config_enabled() macro") RESEND: I was suggested to resend this patch (thanks Greg!) Ming/Luis/Greg: could someone accept this patch, please? I hope this trivial cleanup isn't too big deal. --- drivers/base/firmware_class.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index ac350c518e0c..d05be1732c8b 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -190,13 +190,9 @@ static int __fw_state_check(struct fw_state *fw_st, enum fw_status status) #else #define FW_OPT_USERHELPER 0 #endif -#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK -#define FW_OPT_FALLBACK FW_OPT_USERHELPER -#else -#define FW_OPT_FALLBACK 0 -#endif #define FW_OPT_NO_WARN (1U << 3) #define FW_OPT_NOCACHE (1U << 4) +#define FW_OPT_FALLBACK (1U << 5) struct firmware_cache { /* firmware_buf instance will be added into the below list */ @@ -1210,8 +1206,12 @@ _request_firmware(const struct firmware **firmware_p, const char *name, dev_warn(device, "Direct firmware load for %s failed with error %d\n", name, ret); - if (opt_flags & FW_OPT_USERHELPER) { + if (IS_ENABLED(CONFIG_FW_LOADER_USER_HELPER_FALLBACK) && + opt_flags & FW_OPT_FALLBACK) { dev_warn(device, "Falling back to user helper\n"); + opt_flags |= FW_OPT_USERHELPER; + } + if (opt_flags & FW_OPT_USERHELPER) { ret = fw_load_from_user_helper(fw, name, device, opt_flags, timeout); } -- 2.11.0