Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Kishon Vijay Abraham I" <kishon@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>
Subject: Re: [PATCH] PCI: endpoint: make pci_epc_class constant
Date: Wed, 12 Jun 2024 15:20:43 -0500	[thread overview]
Message-ID: <20240612202043.GA1036897@bhelgaas> (raw)
In-Reply-To: <2024061011-citable-herbicide-1095@gregkh>

On Mon, Jun 10, 2024 at 10:20:12AM +0200, Greg Kroah-Hartman wrote:
> Now that the driver core allows for struct class to be in read-only
> memory, we should make all 'class' structures declared at build time
> placing them into read-only memory, instead of having to be dynamically
> allocated at runtime.
> 
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: "Krzysztof Wilczyński" <kw@linux.com>
> Cc: Manivannan Sadhasivam <mani@kernel.org>
> Cc: Kishon Vijay Abraham I <kishon@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: linux-pci@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Applied to pci/endpoint for v6.11, thanks!

> ---
>  drivers/pci/endpoint/pci-epc-core.c | 19 +++++++------------
>  1 file changed, 7 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c
> index 47d27ec7439d..ed038dd77f83 100644
> --- a/drivers/pci/endpoint/pci-epc-core.c
> +++ b/drivers/pci/endpoint/pci-epc-core.c
> @@ -14,7 +14,9 @@
>  #include <linux/pci-epf.h>
>  #include <linux/pci-ep-cfs.h>
>  
> -static struct class *pci_epc_class;
> +static const struct class pci_epc_class = {
> +	.name = "pci_epc",
> +};
>  
>  static void devm_pci_epc_release(struct device *dev, void *res)
>  {
> @@ -60,7 +62,7 @@ struct pci_epc *pci_epc_get(const char *epc_name)
>  	struct device *dev;
>  	struct class_dev_iter iter;
>  
> -	class_dev_iter_init(&iter, pci_epc_class, NULL, NULL);
> +	class_dev_iter_init(&iter, &pci_epc_class, NULL, NULL);
>  	while ((dev = class_dev_iter_next(&iter))) {
>  		if (strcmp(epc_name, dev_name(dev)))
>  			continue;
> @@ -867,7 +869,7 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops,
>  	INIT_LIST_HEAD(&epc->pci_epf);
>  
>  	device_initialize(&epc->dev);
> -	epc->dev.class = pci_epc_class;
> +	epc->dev.class = &pci_epc_class;
>  	epc->dev.parent = dev;
>  	epc->dev.release = pci_epc_release;
>  	epc->ops = ops;
> @@ -927,20 +929,13 @@ EXPORT_SYMBOL_GPL(__devm_pci_epc_create);
>  
>  static int __init pci_epc_init(void)
>  {
> -	pci_epc_class = class_create("pci_epc");
> -	if (IS_ERR(pci_epc_class)) {
> -		pr_err("failed to create pci epc class --> %ld\n",
> -		       PTR_ERR(pci_epc_class));
> -		return PTR_ERR(pci_epc_class);
> -	}
> -
> -	return 0;
> +	return class_register(&pci_epc_class);
>  }
>  module_init(pci_epc_init);
>  
>  static void __exit pci_epc_exit(void)
>  {
> -	class_destroy(pci_epc_class);
> +	class_unregister(&pci_epc_class);
>  }
>  module_exit(pci_epc_exit);
>  
> -- 
> 2.45.2
> 

      reply	other threads:[~2024-06-12 20:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-10  8:20 [PATCH] PCI: endpoint: make pci_epc_class constant Greg Kroah-Hartman
2024-06-12 20:20 ` Bjorn Helgaas [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=20240612202043.GA1036897@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kishon@kernel.org \
    --cc=kw@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mani@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