From patchwork Tue Jan 17 12:43:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44655 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1734921wrn; Tue, 17 Jan 2023 04:49:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXvDaVbgYp320IcetrB4qpuaeu65DcbokmczOuhn+tvdkb5nHLOfSOFUMTa1mWtCxRHKo3U1 X-Received: by 2002:a17:90a:f409:b0:226:f7f6:ad2f with SMTP id ch9-20020a17090af40900b00226f7f6ad2fmr3160614pjb.38.1673959740473; Tue, 17 Jan 2023 04:49:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673959740; cv=none; d=google.com; s=arc-20160816; b=hcHfQH2EydmEpaV4cHnkfV4wZnsCrB15fptG6f4rjeAL0yk+Av6GsamYvHRrY8YiGI /HvJ6g20rCX43DyvJZn4ri/+uKdZKGPkvOYyAivuqQrVTnCm8zR3HAvQL6Qji3HW77gE 7dnZI9J8odXEywW0O6ho2XV/MAkjIa7/EoM6ckLl3c3IBN47zxnAnmMDg6KwhEp+L+p1 wVrg6T+pe8eldGj3V2HQhGY8hgv/a4Rqnex7y+q7qm7qJPJyrnFa3nI2VqjEkyZHzw5v CJrtCJr4RiQMstnXQQW8y24Z+yJISj0NkTqb59pSNZ61VPtVmHL5pdpgT4kZmV48g22H viMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qK6sol1rHaVBA3qP1szUgYICxKEojpkO+GBqfovIurE=; b=d9uR5edGMHsJYKezejVoa7QGY9LPBSSa8VvjJ0c23G95nMEIYvR+ZgMkVeLtsn/QQi gr2Vz6bxhDwGr56pYANbDO6006W9+HXjuoo1NsqeRfbPoeal3r/KyIlQ7oO9eJOXSxzp UK5MKympojiLGwt1WrJk3p/10/lhvrwyI2n3k2Sa36pk+cTFw1nhjChlTqKkUlHfkizM YiueQzdYVqP+b623nxlmWp696d7Q0TjWqfY8L/Q7irld0Xkyl9gGoiw1hnD0D1oCqQjD SUTnWeMn2mxUaUjOQNM1GhSVZoQb+A7bU8qfStYrnqjKnUjdKi/hRs9ide6nGOgdX/Ug 7Zuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=s33xb2oj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z15-20020a17090acb0f00b002270b129b0fsi26773271pjt.82.2023.01.17.04.48.43; Tue, 17 Jan 2023 04:49:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=s33xb2oj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236541AbjAQMqQ (ORCPT + 99 others); Tue, 17 Jan 2023 07:46:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236871AbjAQMqC (ORCPT ); Tue, 17 Jan 2023 07:46:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95707BB86; Tue, 17 Jan 2023 04:46:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2B3BE6130E; Tue, 17 Jan 2023 12:46:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87980C433D2; Tue, 17 Jan 2023 12:45:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673959559; bh=nfaUQ9f/qaL/KRjoDGEKTPz6nI6/U2ME9FXRoaJ2ljE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s33xb2oj34xuXbqCthHoT3wFRhsIC/zlVgWFXku7b5BS855uVKD/knDzdGTfLIqsa pysxNMosSNqykDag6j662+HcUI38mXOwcjj0QCWCCvOCCqn1IJBG+16mAp97W+bB90 0WRkiJmq/MU3Po6+WYd2XSOBpfZAycR4hvRJRUYDmMjeMp9PPgSCK1bKvSzMrqY/9M QYATjO5tTqFGBpgV8KVT/7MoaS9/tAiR5nBvRIUr+6RUeOi/5/W/GPdSZJYkoIPGhQ lNS8dzDwETK3tK9YSom04joN++cWhTE/f21uWzqgSZPzoqtGeBgEJMyRhVBqrq2oy9 1qwd7YtNAdsBQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHlM5-0004Mn-GG; Tue, 17 Jan 2023 13:46:21 +0100 From: Johan Hovold To: Ard Biesheuvel Cc: Matthew Garrett , Jeremy Kerr , Maximilian Luz , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 1/2] efi: efivars: drop kobject from efivars_register() Date: Tue, 17 Jan 2023 13:43:09 +0100 Message-Id: <20230117124310.16594-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230117124310.16594-1-johan+linaro@kernel.org> References: <20230117124310.16594-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755274005336488998?= X-GMAIL-MSGID: =?utf-8?q?1755274009162929065?= Since commit 0f5b2c69a4cb ("efi: vars: Remove deprecated 'efivars' sysfs interface") and the removal of the sysfs interface there are no users of the efivars kobject. Drop the kobject argument from efivars_register() and add a new efivar_is_available() helper in favour of the old efivars_kobject(). Note that the new helper uses the prefix 'efivar' (i.e. without an 's') for consistency with efivar_supports_writes() and the rest of the interface (except the registration functions). For the benefit of drivers with optional EFI support, also provide a dummy implementation of efivar_is_available(). Signed-off-by: Johan Hovold --- drivers/firmware/efi/efi.c | 2 +- drivers/firmware/efi/vars.c | 19 ++++++------------- drivers/firmware/google/gsmi.c | 2 +- fs/efivarfs/super.c | 2 +- include/linux/efi.h | 11 +++++++---- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 5aa8cd510bc0..a7f1a32537f1 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -197,7 +197,7 @@ static int generic_ops_register(void) generic_ops.set_variable = efi.set_variable; generic_ops.set_variable_nonblocking = efi.set_variable_nonblocking; } - return efivars_register(&generic_efivars, &generic_ops, efi_kobj); + return efivars_register(&generic_efivars, &generic_ops); } static void generic_ops_unregister(void) diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c index 0ba9f18312f5..d6b2c4f9a575 100644 --- a/drivers/firmware/efi/vars.c +++ b/drivers/firmware/efi/vars.c @@ -40,37 +40,30 @@ static efi_status_t check_var_size(bool nonblocking, u32 attributes, } /** - * efivars_kobject - get the kobject for the registered efivars + * efivar_is_available - check if efivars is available * - * If efivars_register() has not been called we return NULL, - * otherwise return the kobject used at registration time. + * @return true iff evivars is currently registered */ -struct kobject *efivars_kobject(void) +bool efivar_is_available(void) { - if (!__efivars) - return NULL; - - return __efivars->kobject; + return __efivars != NULL; } -EXPORT_SYMBOL_GPL(efivars_kobject); +EXPORT_SYMBOL_GPL(efivar_is_available); /** * efivars_register - register an efivars * @efivars: efivars to register * @ops: efivars operations - * @kobject: @efivars-specific kobject * * Only a single efivars can be registered at any time. */ int efivars_register(struct efivars *efivars, - const struct efivar_operations *ops, - struct kobject *kobject) + const struct efivar_operations *ops) { if (down_interruptible(&efivars_lock)) return -EINTR; efivars->ops = ops; - efivars->kobject = kobject; __efivars = efivars; diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c index 4e2575dfeb90..60054a5d5de7 100644 --- a/drivers/firmware/google/gsmi.c +++ b/drivers/firmware/google/gsmi.c @@ -1029,7 +1029,7 @@ static __init int gsmi_init(void) } #ifdef CONFIG_EFI - ret = efivars_register(&efivars, &efivar_ops, gsmi_kobj); + ret = efivars_register(&efivars, &efivar_ops); if (ret) { printk(KERN_INFO "gsmi: Failed to register efivars\n"); sysfs_remove_files(gsmi_kobj, gsmi_attrs); diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c index 07e82e246666..f72c529c8ec3 100644 --- a/fs/efivarfs/super.c +++ b/fs/efivarfs/super.c @@ -256,7 +256,7 @@ static struct file_system_type efivarfs_type = { static __init int efivarfs_init(void) { - if (!efivars_kobject()) + if (!efivar_is_available()) return -ENODEV; return register_filesystem(&efivarfs_type); diff --git a/include/linux/efi.h b/include/linux/efi.h index 4b27519143f5..2124e55c02d6 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1039,7 +1039,6 @@ struct efivar_operations { struct efivars { struct kset *kset; - struct kobject *kobject; const struct efivar_operations *ops; }; @@ -1053,10 +1052,14 @@ struct efivars { #define EFI_VAR_NAME_LEN 1024 int efivars_register(struct efivars *efivars, - const struct efivar_operations *ops, - struct kobject *kobject); + const struct efivar_operations *ops); int efivars_unregister(struct efivars *efivars); -struct kobject *efivars_kobject(void); + +#ifdef CONFIG_EFI +bool efivar_is_available(void); +#else +static inline bool efivar_is_available(void) { return false; } +#endif int efivar_supports_writes(void); From patchwork Tue Jan 17 12:43:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44656 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1734980wrn; Tue, 17 Jan 2023 04:49:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXtlJAyOc51YkZ2zB+pO6LKqxX7iiiV6op7NClJyFGb7m79IyElyX0GraWImwBlzOPGZefaQ X-Received: by 2002:a17:903:31d5:b0:194:62d9:9a81 with SMTP id v21-20020a17090331d500b0019462d99a81mr3180694ple.64.1673959748009; Tue, 17 Jan 2023 04:49:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673959747; cv=none; d=google.com; s=arc-20160816; b=KDHO1Zp1ElovEQMqDPzd5a/jjFD6pO0DPY9ML4iF//4S2n1mQq+B9AJvMag6mXguNO DJqeU2daacHvUYGrosrR2AS0iDK4BCeda1heTD8fxjInafshk3eJlft3S+WsDtdfqKsv +lWL36VhAj31UP+lxgYjzIy1jgS6a4GIlAIRa5zCkg5MxNLcX/yQlushPe5FWFAtSdTQ rHDRWNVfCkCEcinNUmnYFhaTNZhbG4ceSMCyf+VRjPwKdBSChtolngCLj/Tfx0f14D+Z ryyN9oBP4y8wKa3BAvqlb65WE7CdUSS3MLGz+eG1smrmpdbpH5Qg4U7xE+zSXZEPM2y9 Cqmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zZnP5i2IbDZWR96z3Aa/r0fI/XRgWDSDX+Jea7YQ+t4=; b=w2Myk7JEBVg1m28TKS9auOBpDLsZYMnki7QFQN7HyU45Ev3udRnaEowrwimmFgAfM2 9OdcHsyAWsTlbSBCC57mEv0voyfpxunvCU8JBqvR3o8waleC+R5NnyhslWpKRXY8wt0g qLISNdawBtT0ztu0/f3MNRq3KGAgDb/oxKhoG7vNmMzZ36Fy1ICUUmOJZan2aGds4NLG lI7YiLBRL5jVCpA8kQLbR7ZCGGkKNJ2HFjC4LFtf66GZeV77f9mnpDj4YJbVc9Tueoh+ NQZRWesZ7lAvQ/jHIEYdvTW+EYQZK/x2A25M045Z3d51RrdsgtP1xaBhMnhfdCbzUhKO R6tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dIzQDTNa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg17-20020a17090326d100b0019317aff5f1si29005245plb.603.2023.01.17.04.48.55; Tue, 17 Jan 2023 04:49:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dIzQDTNa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236398AbjAQMq1 (ORCPT + 99 others); Tue, 17 Jan 2023 07:46:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236744AbjAQMqK (ORCPT ); Tue, 17 Jan 2023 07:46:10 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A37321207F; Tue, 17 Jan 2023 04:46:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3E9A061333; Tue, 17 Jan 2023 12:46:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C23AC433F1; Tue, 17 Jan 2023 12:45:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673959559; bh=R4MUqRfYUuD7hD15Z2VAffe0lvOKWbQwgywpMdRQ0Y8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dIzQDTNa2+d8GV2wAYso+GyeWBDaiFO4GQ8XNuZOAN7CC2NlmKSz+Dgy0ITBFYGso oN+yWT3CYO3ELix6rt/nMBT+zBiFu3Qc/sUwWbPJY3mRs3xmqxpDjtw463FH8ild2d Rvit2N5RRjsRH16lsnWge6QOvTAwgMgrtJQPaW3k/z4KgKBHcZ6mrpleIul8liwbVO KK5QPL5vsk75Va/Hm8idpXY32nYLKMEMwSsra4fbq7O1b2EszayTZDGvQseiZIqebW Hyqdwovkz1V803neN10xbWWrbC/GrNoeyLjqRFOdU+T7oCBpphDePF8Jvw3zGVwoGI VCX9qWuxlDX0g== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHlM5-0004Mp-JV; Tue, 17 Jan 2023 13:46:21 +0100 From: Johan Hovold To: Ard Biesheuvel Cc: Matthew Garrett , Jeremy Kerr , Maximilian Luz , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 2/2] efi: efivars: make efivar_supports_writes() return bool Date: Tue, 17 Jan 2023 13:43:10 +0100 Message-Id: <20230117124310.16594-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230117124310.16594-1-johan+linaro@kernel.org> References: <20230117124310.16594-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755274016543563879?= X-GMAIL-MSGID: =?utf-8?q?1755274016543563879?= For consistency with the new efivar_is_available() function, change the return type of efivar_supports_writes() to bool. Signed-off-by: Johan Hovold --- drivers/firmware/efi/vars.c | 2 +- include/linux/efi.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c index d6b2c4f9a575..aa5ba38f81ff 100644 --- a/drivers/firmware/efi/vars.c +++ b/drivers/firmware/efi/vars.c @@ -110,7 +110,7 @@ int efivars_unregister(struct efivars *efivars) } EXPORT_SYMBOL_GPL(efivars_unregister); -int efivar_supports_writes(void) +bool efivar_supports_writes(void) { return __efivars && __efivars->ops->set_variable; } diff --git a/include/linux/efi.h b/include/linux/efi.h index 2124e55c02d6..f6b107da1cbc 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1061,7 +1061,7 @@ bool efivar_is_available(void); static inline bool efivar_is_available(void) { return false; } #endif -int efivar_supports_writes(void); +bool efivar_supports_writes(void); int efivar_lock(void); int efivar_trylock(void);