From: Bjorn Helgaas <helgaas@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Kurt Schwemmer <kurt.schwemmer@microsemi.com>,
Logan Gunthorpe <logang@deltatee.com>,
Jon Mason <jdmason@kudzu.us>, Dave Jiang <dave.jiang@intel.com>,
Allen Hubbe <allenbh@gmail.com>,
Bjorn Helgaas <bhelgaas@google.com>,
ntb@lists.linux.dev
Subject: Re: [PATCH] PCI: switchtec: make switchtec_class constant
Date: Mon, 10 Jun 2024 15:04:34 -0500 [thread overview]
Message-ID: <20240610200434.GA958238@bhelgaas> (raw)
In-Reply-To: <2024061053-online-unwound-b173@gregkh>
On Mon, Jun 10, 2024 at 10:20:53AM +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: Kurt Schwemmer <kurt.schwemmer@microsemi.com>
> Cc: Logan Gunthorpe <logang@deltatee.com>
> Cc: Jon Mason <jdmason@kudzu.us>
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Allen Hubbe <allenbh@gmail.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: linux-pci@vger.kernel.org
> Cc: ntb@lists.linux.dev
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Applied with reviewed-by from Dave and Logan to pci/switchtec for
v6.11, thanks!
> ---
> drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 2 +-
> drivers/pci/switch/switchtec.c | 16 ++++++++--------
> include/linux/switchtec.h | 2 +-
> 3 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> index d6bbcc7b5b90..31946387badf 100644
> --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> @@ -1565,7 +1565,7 @@ static struct class_interface switchtec_interface = {
>
> static int __init switchtec_ntb_init(void)
> {
> - switchtec_interface.class = switchtec_class;
> + switchtec_interface.class = &switchtec_class;
> return class_interface_register(&switchtec_interface);
> }
> module_init(switchtec_ntb_init);
> diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
> index 5a4adf6c04cf..c7e1089ffdaf 100644
> --- a/drivers/pci/switch/switchtec.c
> +++ b/drivers/pci/switch/switchtec.c
> @@ -37,7 +37,9 @@ MODULE_PARM_DESC(nirqs, "number of interrupts to allocate (more may be useful fo
> static dev_t switchtec_devt;
> static DEFINE_IDA(switchtec_minor_ida);
>
> -struct class *switchtec_class;
> +const struct class switchtec_class = {
> + .name = "switchtec",
> +};
> EXPORT_SYMBOL_GPL(switchtec_class);
>
> enum mrpc_state {
> @@ -1363,7 +1365,7 @@ static struct switchtec_dev *stdev_create(struct pci_dev *pdev)
>
> dev = &stdev->dev;
> device_initialize(dev);
> - dev->class = switchtec_class;
> + dev->class = &switchtec_class;
> dev->parent = &pdev->dev;
> dev->groups = switchtec_device_groups;
> dev->release = stdev_release;
> @@ -1851,11 +1853,9 @@ static int __init switchtec_init(void)
> if (rc)
> return rc;
>
> - switchtec_class = class_create("switchtec");
> - if (IS_ERR(switchtec_class)) {
> - rc = PTR_ERR(switchtec_class);
> + rc = class_register(&switchtec_class);
> + if (rc)
> goto err_create_class;
> - }
>
> rc = pci_register_driver(&switchtec_pci_driver);
> if (rc)
> @@ -1866,7 +1866,7 @@ static int __init switchtec_init(void)
> return 0;
>
> err_pci_register:
> - class_destroy(switchtec_class);
> + class_unregister(&switchtec_class);
>
> err_create_class:
> unregister_chrdev_region(switchtec_devt, max_devices);
> @@ -1878,7 +1878,7 @@ module_init(switchtec_init);
> static void __exit switchtec_exit(void)
> {
> pci_unregister_driver(&switchtec_pci_driver);
> - class_destroy(switchtec_class);
> + class_unregister(&switchtec_class);
> unregister_chrdev_region(switchtec_devt, max_devices);
> ida_destroy(&switchtec_minor_ida);
>
> diff --git a/include/linux/switchtec.h b/include/linux/switchtec.h
> index 8d8fac1626bd..cdb58d61c152 100644
> --- a/include/linux/switchtec.h
> +++ b/include/linux/switchtec.h
> @@ -521,6 +521,6 @@ static inline struct switchtec_dev *to_stdev(struct device *dev)
> return container_of(dev, struct switchtec_dev, dev);
> }
>
> -extern struct class *switchtec_class;
> +extern const struct class switchtec_class;
>
> #endif
> --
> 2.45.2
>
prev parent reply other threads:[~2024-06-10 20:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-10 8:20 [PATCH] PCI: switchtec: make switchtec_class constant Greg Kroah-Hartman
2024-06-10 15:30 ` Dave Jiang
2024-06-10 17:05 ` Logan Gunthorpe
2024-06-10 20:04 ` 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=20240610200434.GA958238@bhelgaas \
--to=helgaas@kernel.org \
--cc=allenbh@gmail.com \
--cc=bhelgaas@google.com \
--cc=dave.jiang@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jdmason@kudzu.us \
--cc=kurt.schwemmer@microsemi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=logang@deltatee.com \
--cc=ntb@lists.linux.dev \
/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