From patchwork Mon Nov 20 18:23:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 10066929 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 89EE26038F for ; Mon, 20 Nov 2017 18:28:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FF1C2937A for ; Mon, 20 Nov 2017 18:28:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74C24293E1; Mon, 20 Nov 2017 18:28:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DF882937A for ; Mon, 20 Nov 2017 18:28:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752533AbdKTS2K (ORCPT ); Mon, 20 Nov 2017 13:28:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:57388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752204AbdKTSYZ (ORCPT ); Mon, 20 Nov 2017 13:24:25 -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 910C22199D; Mon, 20 Nov 2017 18:24:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 910C22199D 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, 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 11/23] firmware: provide helper for FW_OPT_USERHELPER Date: Mon, 20 Nov 2017 10:23:57 -0800 Message-Id: <20171120182409.27348-12-mcgrof@kernel.org> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20171120182409.27348-1-mcgrof@kernel.org> References: <20171120182409.27348-1-mcgrof@kernel.org> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The macro FW_OPT_USERHELPER is only currently defined when CONFIG_FW_LOADER_USER_HELPER is set. This is handled via an ifdef around CONFIG_FW_LOADER_USER_HELPER. This makes reading and understanding use FW_OPT_USERHELPER a bit convoluted. Instead wrap the functionality implemented behind CONFIG_FW_LOADER_USER_HELPER as we typically do in the kernel. Now when CONFIG_FW_LOADER_USER_HELPER is *not set*, then simply the helper fw_sysfs_fallback() will not do anything. Signed-off-by: Luis R. Rodriguez --- drivers/base/firmware_class.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index aba3f2cbe2f4..316991429032 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -61,11 +61,7 @@ struct fw_state { /* firmware behavior options */ #define FW_OPT_UEVENT (1U << 0) #define FW_OPT_NOWAIT (1U << 1) -#ifdef CONFIG_FW_LOADER_USER_HELPER #define FW_OPT_USERHELPER (1U << 2) -#else -#define FW_OPT_USERHELPER 0 -#endif #ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK #define FW_OPT_FALLBACK FW_OPT_USERHELPER #else @@ -1158,12 +1154,25 @@ static int fw_load_from_user_helper(struct firmware *firmware, return ret; } +static int fw_sysfs_fallback(struct firmware *fw, const char *name, + struct device *device, + unsigned int opt_flags, + int ret) +{ + if (!(opt_flags & FW_OPT_USERHELPER)) + return ret; + + dev_warn(device, "Falling back to user helper\n"); + return fw_load_from_user_helper(fw, name, device, opt_flags); +} #else /* CONFIG_FW_LOADER_USER_HELPER */ -static inline int -fw_load_from_user_helper(struct firmware *firmware, const char *name, - struct device *device, unsigned int opt_flags) +static int fw_sysfs_fallback(struct firmware *fw, const char *name, + struct device *device, + unsigned int opt_flags, + int ret) { - return -ENOENT; + /* Keep carrying over the same error */ + return ret; } static inline void kill_pending_fw_fallback_reqs(bool only_kill_custom) { } @@ -1273,11 +1282,7 @@ _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) { - dev_warn(device, "Falling back to user helper\n"); - ret = fw_load_from_user_helper(fw, name, device, - opt_flags); - } + ret = fw_sysfs_fallback(fw, name, device, opt_flags, ret); } else ret = assign_fw(fw, device, opt_flags);