From: Ivan Orlov <ivan.orlov0322@gmail.com>
To: mdf@kernel.org, hao.wu@intel.com, yilun.xu@intel.com, trix@redhat.com
Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org,
gregkh@linuxfoundation.org
Subject: Re: [PATCH v2 2/3] fpga: fpga-mgr: make fpga_mgr_class a static const structure
Date: Fri, 11 Aug 2023 11:33:55 +0400 [thread overview]
Message-ID: <7a945f1e-51d1-ec90-d98f-adcd58ad1991@gmail.com> (raw)
In-Reply-To: <20230811073043.52808-2-ivan.orlov0322@gmail.com>
On 8/11/23 11:30, Ivan Orlov wrote:
> Now that the driver core allows for struct class to be in read-only
> memory, move the fpga_mgr_class structure to be declared at build time
> placing it into read-only memory, instead of having to be dynamically
> allocated at boot time.
>
> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
> ---
> drivers/fpga/fpga-mgr.c | 25 ++++++++++++-------------
> 1 file changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
> index eb583f86a0b9..06651389c592 100644
> --- a/drivers/fpga/fpga-mgr.c
> +++ b/drivers/fpga/fpga-mgr.c
> @@ -19,7 +19,7 @@
> #include <linux/highmem.h>
>
> static DEFINE_IDA(fpga_mgr_ida);
> -static struct class *fpga_mgr_class;
> +static const struct class fpga_mgr_class;
>
> struct fpga_mgr_devres {
> struct fpga_manager *mgr;
> @@ -693,7 +693,7 @@ static int fpga_mgr_dev_match(struct device *dev, const void *data)
> */
> struct fpga_manager *fpga_mgr_get(struct device *dev)
> {
> - struct device *mgr_dev = class_find_device(fpga_mgr_class, NULL, dev,
> + struct device *mgr_dev = class_find_device(&fpga_mgr_class, NULL, dev,
> fpga_mgr_dev_match);
> if (!mgr_dev)
> return ERR_PTR(-ENODEV);
> @@ -713,7 +713,7 @@ struct fpga_manager *of_fpga_mgr_get(struct device_node *node)
> {
> struct device *dev;
>
> - dev = class_find_device_by_of_node(fpga_mgr_class, node);
> + dev = class_find_device_by_of_node(&fpga_mgr_class, node);
> if (!dev)
> return ERR_PTR(-ENODEV);
>
> @@ -809,7 +809,7 @@ fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *in
> mgr->priv = info->priv;
> mgr->compat_id = info->compat_id;
>
> - mgr->dev.class = fpga_mgr_class;
> + mgr->dev.class = &fpga_mgr_class;
> mgr->dev.groups = mops->groups;
> mgr->dev.parent = parent;
> mgr->dev.of_node = parent->of_node;
> @@ -967,23 +967,22 @@ static void fpga_mgr_dev_release(struct device *dev)
> kfree(mgr);
> }
>
> +static const struct class fpga_mgr_class = {
> + .name = "fpga_manager",
> + .dev_groups = fpga_mgr_groups,
> + .dev_release = fpga_mgr_dev_release,
> +};
> +
> static int __init fpga_mgr_class_init(void)
> {
> pr_info("FPGA manager framework\n");
>
> - fpga_mgr_class = class_create("fpga_manager");
> - if (IS_ERR(fpga_mgr_class))
> - return PTR_ERR(fpga_mgr_class);
> -
> - fpga_mgr_class->dev_groups = fpga_mgr_groups;
> - fpga_mgr_class->dev_release = fpga_mgr_dev_release;
> -
> - return 0;
> + return class_register(&fpga_mgr_class);
> }
>
> static void __exit fpga_mgr_class_exit(void)
> {
> - class_destroy(fpga_mgr_class);
> + class_unregister(&fpga_mgr_class);
> ida_destroy(&fpga_mgr_ida);
> }
>
And I forgot the changelog here.
V1 -> V2:
- Add forward declaration of fpga_mgr_class
- Move definition of fpga_mgr_class to more logical place
next prev parent reply other threads:[~2023-08-11 7:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-11 7:30 [PATCH v2 1/3] fpga: bridge: make fpga_bridge_class a static const structure Ivan Orlov
2023-08-11 7:30 ` [PATCH v2 2/3] fpga: fpga-mgr: make fpga_mgr_class " Ivan Orlov
2023-08-11 7:33 ` Ivan Orlov [this message]
2023-08-11 7:30 ` [PATCH v2 3/3] fpga: region: make fpga_region_class " Ivan Orlov
2023-08-11 7:34 ` Ivan Orlov
2023-08-11 7:33 ` [PATCH v2 1/3] fpga: bridge: make fpga_bridge_class " Ivan Orlov
2023-08-11 15:09 ` Xu Yilun
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=7a945f1e-51d1-ec90-d98f-adcd58ad1991@gmail.com \
--to=ivan.orlov0322@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hao.wu@intel.com \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mdf@kernel.org \
--cc=trix@redhat.com \
--cc=yilun.xu@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).