From: Frederic Barrat <fbarrat@linux.ibm.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
Andrew Donnellan <ajd@linux.ibm.com>
Subject: Re: [PATCH] cxl: make cxl_class constant
Date: Wed, 25 Oct 2023 10:16:55 +0200 [thread overview]
Message-ID: <9573ec63-a8d6-4c69-a70b-9095838d521d@linux.ibm.com> (raw)
In-Reply-To: <2023102434-haiku-uphill-0c11@gregkh>
On 24/10/2023 13:48, 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: Frederic Barrat <fbarrat@linux.ibm.com>
> Cc: Andrew Donnellan <ajd@linux.ibm.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: linuxppc-dev@lists.ozlabs.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
Thanks!
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
Fred
> drivers/misc/cxl/file.c | 21 ++++++++++-----------
> 1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c
> index 144d1f2d78ce..012e11b959bc 100644
> --- a/drivers/misc/cxl/file.c
> +++ b/drivers/misc/cxl/file.c
> @@ -38,8 +38,6 @@
>
> static dev_t cxl_dev;
>
> -static struct class *cxl_class;
> -
> static int __afu_open(struct inode *inode, struct file *file, bool master)
> {
> struct cxl *adapter;
> @@ -559,7 +557,10 @@ static char *cxl_devnode(const struct device *dev, umode_t *mode)
> return kasprintf(GFP_KERNEL, "cxl/%s", dev_name(dev));
> }
>
> -extern struct class *cxl_class;
> +static const struct class cxl_class = {
> + .name = "cxl",
> + .devnode = cxl_devnode,
> +};
>
> static int cxl_add_chardev(struct cxl_afu *afu, dev_t devt, struct cdev *cdev,
> struct device **chardev, char *postfix, char *desc,
> @@ -575,7 +576,7 @@ static int cxl_add_chardev(struct cxl_afu *afu, dev_t devt, struct cdev *cdev,
> return rc;
> }
>
> - dev = device_create(cxl_class, &afu->dev, devt, afu,
> + dev = device_create(&cxl_class, &afu->dev, devt, afu,
> "afu%i.%i%s", afu->adapter->adapter_num, afu->slice, postfix);
> if (IS_ERR(dev)) {
> rc = PTR_ERR(dev);
> @@ -633,14 +634,14 @@ void cxl_chardev_afu_remove(struct cxl_afu *afu)
>
> int cxl_register_afu(struct cxl_afu *afu)
> {
> - afu->dev.class = cxl_class;
> + afu->dev.class = &cxl_class;
>
> return device_register(&afu->dev);
> }
>
> int cxl_register_adapter(struct cxl *adapter)
> {
> - adapter->dev.class = cxl_class;
> + adapter->dev.class = &cxl_class;
>
> /*
> * Future: When we support dynamically reprogramming the PSL & AFU we
> @@ -678,13 +679,11 @@ int __init cxl_file_init(void)
>
> pr_devel("CXL device allocated, MAJOR %i\n", MAJOR(cxl_dev));
>
> - cxl_class = class_create("cxl");
> - if (IS_ERR(cxl_class)) {
> + rc = class_register(&cxl_class);
> + if (rc) {
> pr_err("Unable to create CXL class\n");
> - rc = PTR_ERR(cxl_class);
> goto err;
> }
> - cxl_class->devnode = cxl_devnode;
>
> return 0;
>
> @@ -696,5 +695,5 @@ int __init cxl_file_init(void)
> void cxl_file_exit(void)
> {
> unregister_chrdev_region(cxl_dev, CXL_NUM_MINORS);
> - class_destroy(cxl_class);
> + class_unregister(&cxl_class);
> }
WARNING: multiple messages have this Message-ID (diff)
From: Frederic Barrat <fbarrat@linux.ibm.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org,
Andrew Donnellan <ajd@linux.ibm.com>,
Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH] cxl: make cxl_class constant
Date: Wed, 25 Oct 2023 10:16:55 +0200 [thread overview]
Message-ID: <9573ec63-a8d6-4c69-a70b-9095838d521d@linux.ibm.com> (raw)
In-Reply-To: <2023102434-haiku-uphill-0c11@gregkh>
On 24/10/2023 13:48, 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: Frederic Barrat <fbarrat@linux.ibm.com>
> Cc: Andrew Donnellan <ajd@linux.ibm.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: linuxppc-dev@lists.ozlabs.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
Thanks!
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
Fred
> drivers/misc/cxl/file.c | 21 ++++++++++-----------
> 1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c
> index 144d1f2d78ce..012e11b959bc 100644
> --- a/drivers/misc/cxl/file.c
> +++ b/drivers/misc/cxl/file.c
> @@ -38,8 +38,6 @@
>
> static dev_t cxl_dev;
>
> -static struct class *cxl_class;
> -
> static int __afu_open(struct inode *inode, struct file *file, bool master)
> {
> struct cxl *adapter;
> @@ -559,7 +557,10 @@ static char *cxl_devnode(const struct device *dev, umode_t *mode)
> return kasprintf(GFP_KERNEL, "cxl/%s", dev_name(dev));
> }
>
> -extern struct class *cxl_class;
> +static const struct class cxl_class = {
> + .name = "cxl",
> + .devnode = cxl_devnode,
> +};
>
> static int cxl_add_chardev(struct cxl_afu *afu, dev_t devt, struct cdev *cdev,
> struct device **chardev, char *postfix, char *desc,
> @@ -575,7 +576,7 @@ static int cxl_add_chardev(struct cxl_afu *afu, dev_t devt, struct cdev *cdev,
> return rc;
> }
>
> - dev = device_create(cxl_class, &afu->dev, devt, afu,
> + dev = device_create(&cxl_class, &afu->dev, devt, afu,
> "afu%i.%i%s", afu->adapter->adapter_num, afu->slice, postfix);
> if (IS_ERR(dev)) {
> rc = PTR_ERR(dev);
> @@ -633,14 +634,14 @@ void cxl_chardev_afu_remove(struct cxl_afu *afu)
>
> int cxl_register_afu(struct cxl_afu *afu)
> {
> - afu->dev.class = cxl_class;
> + afu->dev.class = &cxl_class;
>
> return device_register(&afu->dev);
> }
>
> int cxl_register_adapter(struct cxl *adapter)
> {
> - adapter->dev.class = cxl_class;
> + adapter->dev.class = &cxl_class;
>
> /*
> * Future: When we support dynamically reprogramming the PSL & AFU we
> @@ -678,13 +679,11 @@ int __init cxl_file_init(void)
>
> pr_devel("CXL device allocated, MAJOR %i\n", MAJOR(cxl_dev));
>
> - cxl_class = class_create("cxl");
> - if (IS_ERR(cxl_class)) {
> + rc = class_register(&cxl_class);
> + if (rc) {
> pr_err("Unable to create CXL class\n");
> - rc = PTR_ERR(cxl_class);
> goto err;
> }
> - cxl_class->devnode = cxl_devnode;
>
> return 0;
>
> @@ -696,5 +695,5 @@ int __init cxl_file_init(void)
> void cxl_file_exit(void)
> {
> unregister_chrdev_region(cxl_dev, CXL_NUM_MINORS);
> - class_destroy(cxl_class);
> + class_unregister(&cxl_class);
> }
next prev parent reply other threads:[~2023-10-25 8:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-24 11:48 [PATCH] cxl: make cxl_class constant Greg Kroah-Hartman
2023-10-24 11:48 ` Greg Kroah-Hartman
2023-10-25 8:16 ` Frederic Barrat [this message]
2023-10-25 8:16 ` Frederic Barrat
2023-10-25 9:08 ` Greg Kroah-Hartman
2023-10-25 9:08 ` Greg Kroah-Hartman
2023-10-27 10:47 ` Michael Ellerman
2023-10-27 10:47 ` Michael Ellerman
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=9573ec63-a8d6-4c69-a70b-9095838d521d@linux.ibm.com \
--to=fbarrat@linux.ibm.com \
--cc=ajd@linux.ibm.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.