lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 4 Mar 2024 17:52:16 +0000
From: Simon Horman <horms@...nel.org>
To: "Ricardo B. Marliere" <ricardo@...liere.net>
Cc: Yisen Zhuang <yisen.zhuang@...wei.com>,
	Salil Mehta <salil.mehta@...wei.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Loic Poulain <loic.poulain@...aro.org>,
	Sergey Ryazanov <ryazanov.s.a@...il.com>,
	Johannes Berg <johannes@...solutions.net>,
	Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-ppp@...r.kernel.org,
	Benjamin Tissoires <benjamin.tissoires@...hat.com>
Subject: Re: [PATCH net-next 1/6] net: hns: make hnae_class constant

+ Benjamin Tissoires <benjamin.tissoires@...hat.com>

On Sat, Mar 02, 2024 at 02:05:57PM -0300, Ricardo B. Marliere wrote:
> Since commit 43a7206b0963 ("driver core: class: make class_register() take
> a const *"), the driver core allows for struct class to be in read-only
> memory, so move the hnae_class structure to be declared at build time
> placing it into read-only memory, instead of having to be dynamically
> allocated at boot time.
> 
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Suggested-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Signed-off-by: Ricardo B. Marliere <ricardo@...liere.net>

Reviewed-by: Simon Horman <horms@...nel.org>

> ---
>  drivers/net/ethernet/hisilicon/hns/hnae.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
> index 8a1027ad340d..d4293f76d69d 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hnae.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
> @@ -12,7 +12,9 @@
>  
>  #define cls_to_ae_dev(dev) container_of(dev, struct hnae_ae_dev, cls_dev)
>  
> -static struct class *hnae_class;
> +static const struct class hnae_class = {
> +	.name = "hnae",
> +};
>  
>  static void
>  hnae_list_add(spinlock_t *lock, struct list_head *node, struct list_head *head)
> @@ -111,7 +113,7 @@ static struct hnae_ae_dev *find_ae(const struct fwnode_handle *fwnode)
>  
>  	WARN_ON(!fwnode);
>  
> -	dev = class_find_device(hnae_class, NULL, fwnode, __ae_match);
> +	dev = class_find_device(&hnae_class, NULL, fwnode, __ae_match);
>  
>  	return dev ? cls_to_ae_dev(dev) : NULL;
>  }
> @@ -415,7 +417,7 @@ int hnae_ae_register(struct hnae_ae_dev *hdev, struct module *owner)
>  	hdev->owner = owner;
>  	hdev->id = (int)atomic_inc_return(&id);
>  	hdev->cls_dev.parent = hdev->dev;
> -	hdev->cls_dev.class = hnae_class;
> +	hdev->cls_dev.class = &hnae_class;
>  	hdev->cls_dev.release = hnae_release;
>  	(void)dev_set_name(&hdev->cls_dev, "hnae%d", hdev->id);
>  	ret = device_register(&hdev->cls_dev);
> @@ -448,13 +450,12 @@ EXPORT_SYMBOL(hnae_ae_unregister);
>  
>  static int __init hnae_init(void)
>  {
> -	hnae_class = class_create("hnae");
> -	return PTR_ERR_OR_ZERO(hnae_class);
> +	return class_register(&hnae_class);
>  }
>  
>  static void __exit hnae_exit(void)
>  {
> -	class_destroy(hnae_class);
> +	class_unregister(&hnae_class);
>  }
>  
>  subsys_initcall(hnae_init);
> 
> -- 
> 2.43.0
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ