Received: by 10.223.185.116 with SMTP id b49csp1421787wrg; Fri, 23 Feb 2018 18:51:12 -0800 (PST) X-Google-Smtp-Source: AH8x226DYLavoVrOuMEquv0S2zC13LjrwgtREzZNC7RafIVHcArIgeh6J7iTdjnGZGPzwzPsdofS X-Received: by 2002:a17:902:9898:: with SMTP id s24-v6mr3394654plp.382.1519440672071; Fri, 23 Feb 2018 18:51:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519440672; cv=none; d=google.com; s=arc-20160816; b=WdJXaiZfkKse6wxTxBU99bwn+5m2kh7TUyZcCB+w/sEhDSz6DNMGVFW3eh/GLfb0hR 4dTZvx3I8LqVjmHSg2TPmLuz+BFmkJFjb4R8sRHDGidmmXx9yP+aDkwCBJYhtUGiIBnz cjwOK+/fO66F5XCpUHLp7Czso+soXPPDgUqJdhyAdqlfZfKIX5Fwsh0wKyti1HzXZ5aY ybFdYVp0E7zH96W8DnrrAZUezU/3Z2Bt3JSrUU25R6EzW3CUbctqG7SOZlZbZNNWWyYi AwUtyQ78Q+GBO7ikwRwBnJt0RitX497Je79IDNCfXkCyRfeBIixdkiSNUG9HRHkxaaso 6l6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:arc-authentication-results; bh=RNhLbiS7ZLjmJmLH9CTIoXCMxpvpQALZUwZbmjVOTkQ=; b=KMzfhNygVCokzGy46IZH5R4VYxE0qrL1eR5Bk53ffU/6S8gRcf2z4SBNGlgXFoxSMJ qRosqj9Z234ZMdN4o9PlB1S3JJhOhdkEemfRJk1cXxw3YdeV7vEttns+Kb2p7093NN79 jqWXELFWnXQmlfRmbnmZERI7cXD03pDaze8+5WqLbmWF8YbGqLW43I/ULtOfDOoyfhJs IfYq/s6OKQabO8u1GGdALKRE/KCW03y8G8dSbn2uUiMSh4ITMao6cPR+2Gpq8fq9YUXU IIxlDi4CMdO4BDHRE7jm4KkD46yjb77X6rcIeODzBCgvCx+AaOekTNlCAJk4/4ZwauGJ Ofww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t11-v6si2789188plr.411.2018.02.23.18.50.57; Fri, 23 Feb 2018 18:51:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753218AbeBXCsz (ORCPT + 99 others); Fri, 23 Feb 2018 21:48:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:48606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752733AbeBXCqU (ORCPT ); Fri, 23 Feb 2018 21:46:20 -0500 Received: from garbanzo.do-not-panic.com (c-73-15-241-2.hsd1.ca.comcast.net [73.15.241.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9C6A2217C0; Sat, 24 Feb 2018 02:46:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C6A2217C0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mcgrof@kernel.org From: "Luis R. Rodriguez" To: gregkh@linuxfoundation.org Cc: akpm@linux-foundation.org, keescook@chromium.org, shuah@kernel.org, mfuzzey@parkeon.com, zohar@linux.vnet.ibm.com, dhowells@redhat.com, pali.rohar@gmail.com, tiwai@suse.de, arend.vanspriel@broadcom.com, zajec5@gmail.com, nbroeking@me.com, markivx@codeaurora.org, stephen.boyd@linaro.org, broonie@kernel.org, dmitry.torokhov@gmail.com, dwmw2@infradead.org, torvalds@linux-foundation.org, Abhay_Salunke@dell.com, bjorn.andersson@linaro.org, jewalt@lgsinnovations.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, "Luis R. Rodriguez" Subject: [PATCH v2 04/11] firmware: simplify CONFIG_FW_LOADER_USER_HELPER_FALLBACK further Date: Fri, 23 Feb 2018 18:46:06 -0800 Message-Id: <20180224024613.24078-5-mcgrof@kernel.org> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20180224024613.24078-1-mcgrof@kernel.org> References: <20180224024613.24078-1-mcgrof@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All CONFIG_FW_LOADER_USER_HELPER_FALLBACK really is, is just a bool, initailized at build time. Define it as such. This simplifies the logic even further, removing now all explicit #ifdefs around the code. Signed-off-by: Luis R. Rodriguez --- drivers/base/firmware_loader.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/base/firmware_loader.c b/drivers/base/firmware_loader.c index 7dd36ace6152..59dba794ce1a 100644 --- a/drivers/base/firmware_loader.c +++ b/drivers/base/firmware_loader.c @@ -266,6 +266,22 @@ static inline bool fw_state_is_aborted(struct fw_priv *fw_priv) #ifdef CONFIG_FW_LOADER_USER_HELPER +/** + * struct firmware_fallback_config - firmware fallback configuratioon settings + * + * Helps describe and fine tune the fallback mechanism. + * + * @force_sysfs_fallback: force the sysfs fallback mechanism to be used + * as if one had enabled CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y. + */ +struct firmware_fallback_config { + bool force_sysfs_fallback; +}; + +static const struct firmware_fallback_config fw_fallback_config = { + .force_sysfs_fallback = IS_ENABLED(CONFIG_FW_LOADER_USER_HELPER_FALLBACK), +}; + static inline bool fw_sysfs_done(struct fw_priv *fw_priv) { return __fw_state_check(fw_priv, FW_STATUS_DONE); @@ -1151,19 +1167,14 @@ static int fw_load_from_user_helper(struct firmware *firmware, return ret; } -#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK -static bool fw_force_sysfs_fallback(unsigned int opt_flags) -{ - return true; -} -#else static bool fw_force_sysfs_fallback(unsigned int opt_flags) { + if (fw_fallback_config.force_sysfs_fallback) + return true; if (!(opt_flags & FW_OPT_USERHELPER)) return false; return true; } -#endif static bool fw_run_sysfs_fallback(unsigned int opt_flags) { -- 2.16.2