mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Ard Biesheuvel <ardb+git@google.com>
Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Ard Biesheuvel <ardb@kernel.org>
Subject: Re: [PATCH] efi: Constify sysfs attributes
Date: Wed, 7 Oct 2026 18:05:57 +0200	[thread overview]
Message-ID: <939a7bbd-a082-4cab-b4b7-2640d3d47cdd@t-8ch.de> (raw)
In-Reply-To: <20261007155130.2112665-2-ardb+git@google.com>

On 2026-10-07 17:51:31+0200, Ard Biesheuvel wrote:
> From: Ard Biesheuvel <ardb@kernel.org>
> 
> Implement Thomas's suggestions to constify sysfs kobject attributes.
> 
> Cc: Thomas Weißschuh <linux@weissschuh.net>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

Thanks! But some remarks.

> ---
>  arch/x86/platform/efi/efi.c | 11 ++++---
>  drivers/firmware/efi/efi.c  | 34 +++++++++++---------
>  include/linux/efi.h         |  3 +-
>  3 files changed, 27 insertions(+), 21 deletions(-)
> 
> diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
> index 0c39adb96b91..d8fe93770c2a 100644
> --- a/arch/x86/platform/efi/efi.c
> +++ b/arch/x86/platform/efi/efi.c
> @@ -891,7 +891,7 @@ bool efi_is_table_address(unsigned long phys_addr)
>  
>  #define EFI_ATTR_SHOW(name) \
>  static ssize_t name##_show(struct kobject *kobj, \
> -				struct kobj_attribute *attr, char *buf) \
> +			   const struct kobj_attribute *attr, char *buf) \
>  { \
>  	return sprintf(buf, "0x%lx\n", EFI_FIELD(name)); \
>  }
> @@ -900,11 +900,12 @@ EFI_ATTR_SHOW(fw_vendor);
>  EFI_ATTR_SHOW(runtime);
>  EFI_ATTR_SHOW(config_table);
>  
> -struct kobj_attribute efi_attr_fw_vendor = __ATTR_RO(fw_vendor);
> -struct kobj_attribute efi_attr_runtime = __ATTR_RO(runtime);
> -struct kobj_attribute efi_attr_config_table = __ATTR_RO(config_table);
> +const struct kobj_attribute efi_attr_fw_vendor = __KOBJ_ATTR_RO(fw_vendor);
> +const struct kobj_attribute efi_attr_runtime = __KOBJ_ATTR_RO(runtime);
> +const struct kobj_attribute efi_attr_config_table = __KOBJ_ATTR_RO(config_table);
>  
> -umode_t efi_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n)
> +umode_t efi_attr_is_visible(struct kobject *kobj, const struct attribute *attr,
> +			    int n)

The break looks unnecessary.

>  {
>  	if (attr == &efi_attr_fw_vendor.attr) {
>  		if (efi_enabled(EFI_PARAVIRT) ||
> diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> index e08ce813a3d4..93d6ffd9bc0d 100644
> --- a/drivers/firmware/efi/efi.c
> +++ b/drivers/firmware/efi/efi.c
> @@ -155,21 +155,21 @@ static ssize_t systab_show(struct kobject *kobj,
>  	return str - buf;
>  }
>  
> -static struct kobj_attribute efi_attr_systab = __ATTR_RO_MODE(systab, 0400);
> +static const struct kobj_attribute efi_attr_systab = __ATTR_RO_MODE(systab, 0400);

__KOBJ_ATTR_RO_MODE()

(and the callback prototype)

>  static ssize_t fw_platform_size_show(struct kobject *kobj,
> -				     struct kobj_attribute *attr, char *buf)
> +				     const struct kobj_attribute *attr, char *buf)
>  {
>  	return sprintf(buf, "%d\n", efi_enabled(EFI_64BIT) ? 64 : 32);

This should switch to sysfs_emit() at some point.

>  }

(...)

      reply	other threads:[~2026-10-07 16:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07 15:51 Ard Biesheuvel
2026-10-07 16:05 ` Thomas Weißschuh [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=939a7bbd-a082-4cab-b4b7-2640d3d47cdd@t-8ch.de \
    --to=linux@weissschuh.net \
    --cc=ardb+git@google.com \
    --cc=ardb@kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®