* [PATCH 0/6] s390: constify struct class usage
@ 2024-03-05 11:25 Ricardo B. Marliere
2024-03-05 11:25 ` [PATCH 1/6] s390: zcrypt: make zcrypt_class constant Ricardo B. Marliere
` (6 more replies)
0 siblings, 7 replies; 12+ messages in thread
From: Ricardo B. Marliere @ 2024-03-05 11:25 UTC (permalink / raw)
To: Harald Freudenberger, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle
Cc: linux-s390, linux-kernel, Ricardo B. Marliere, Greg Kroah-Hartman
This is a simple and straight forward cleanup series that aims to make the
class structures in s390 constant. This has been possible since 2023 [1].
[1]: https://lore.kernel.org/all/2023040248-customary-release-4aec@gregkh/
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
Ricardo B. Marliere (6):
s390: zcrypt: make zcrypt_class constant
s390: vmur: make vmur_class constant
s390: vmlogrdr: make vmlogrdr_class constant
s390: tape: make tape_class constant
s390: raw3270: improve raw3270_init() readability
s390: raw3270: make class3270 constant
drivers/s390/char/fs3270.c | 8 ++++----
drivers/s390/char/raw3270.c | 32 ++++++++++++++++++++------------
drivers/s390/char/raw3270.h | 2 +-
drivers/s390/char/tape_class.c | 17 ++++++++---------
drivers/s390/char/vmlogrdr.c | 19 +++++++++----------
drivers/s390/char/vmur.c | 18 +++++++++---------
drivers/s390/crypto/zcrypt_api.c | 33 +++++++++++++++++----------------
7 files changed, 68 insertions(+), 61 deletions(-)
---
base-commit: 6a42aaf8e867f4876370c3d482ee0c21769dff58
change-id: 20240305-class_cleanup-s390-d57f7ccc15c9
Best regards,
--
Ricardo B. Marliere <ricardo@marliere.net>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/6] s390: zcrypt: make zcrypt_class constant
2024-03-05 11:25 [PATCH 0/6] s390: constify struct class usage Ricardo B. Marliere
@ 2024-03-05 11:25 ` Ricardo B. Marliere
2024-03-08 14:19 ` Harald Freudenberger
2024-03-05 11:25 ` [PATCH 2/6] s390: vmur: make vmur_class constant Ricardo B. Marliere
` (5 subsequent siblings)
6 siblings, 1 reply; 12+ messages in thread
From: Ricardo B. Marliere @ 2024-03-05 11:25 UTC (permalink / raw)
To: Harald Freudenberger, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle
Cc: linux-s390, linux-kernel, Ricardo B. Marliere, Greg Kroah-Hartman
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 zcrypt_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@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
drivers/s390/crypto/zcrypt_api.c | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
index e8742757085b..d0358bb6ccf2 100644
--- a/drivers/s390/crypto/zcrypt_api.c
+++ b/drivers/s390/crypto/zcrypt_api.c
@@ -116,7 +116,11 @@ EXPORT_SYMBOL(zcrypt_msgtype);
struct zcdn_device;
-static struct class *zcrypt_class;
+static void zcdn_device_release(struct device *dev);
+static const struct class zcrypt_class = {
+ .name = ZCRYPT_NAME,
+ .dev_release = zcdn_device_release,
+};
static dev_t zcrypt_devt;
static struct cdev zcrypt_cdev;
@@ -139,7 +143,7 @@ static int zcdn_destroy(const char *name);
*/
static inline struct zcdn_device *find_zcdndev_by_name(const char *name)
{
- struct device *dev = class_find_device_by_name(zcrypt_class, name);
+ struct device *dev = class_find_device_by_name(&zcrypt_class, name);
return dev ? to_zcdn_dev(dev) : NULL;
}
@@ -151,7 +155,7 @@ static inline struct zcdn_device *find_zcdndev_by_name(const char *name)
*/
static inline struct zcdn_device *find_zcdndev_by_devt(dev_t devt)
{
- struct device *dev = class_find_device_by_devt(zcrypt_class, devt);
+ struct device *dev = class_find_device_by_devt(&zcrypt_class, devt);
return dev ? to_zcdn_dev(dev) : NULL;
}
@@ -405,7 +409,7 @@ static int zcdn_create(const char *name)
goto unlockout;
}
zcdndev->device.release = zcdn_device_release;
- zcdndev->device.class = zcrypt_class;
+ zcdndev->device.class = &zcrypt_class;
zcdndev->device.devt = devt;
zcdndev->device.groups = zcdn_dev_attr_groups;
if (name[0])
@@ -2067,12 +2071,9 @@ static int __init zcdn_init(void)
int rc;
/* create a new class 'zcrypt' */
- zcrypt_class = class_create(ZCRYPT_NAME);
- if (IS_ERR(zcrypt_class)) {
- rc = PTR_ERR(zcrypt_class);
+ rc = class_register(&zcrypt_class);
+ if (rc)
goto out_class_create_failed;
- }
- zcrypt_class->dev_release = zcdn_device_release;
/* alloc device minor range */
rc = alloc_chrdev_region(&zcrypt_devt,
@@ -2088,35 +2089,35 @@ static int __init zcdn_init(void)
goto out_cdev_add_failed;
/* need some class specific sysfs attributes */
- rc = class_create_file(zcrypt_class, &class_attr_zcdn_create);
+ rc = class_create_file(&zcrypt_class, &class_attr_zcdn_create);
if (rc)
goto out_class_create_file_1_failed;
- rc = class_create_file(zcrypt_class, &class_attr_zcdn_destroy);
+ rc = class_create_file(&zcrypt_class, &class_attr_zcdn_destroy);
if (rc)
goto out_class_create_file_2_failed;
return 0;
out_class_create_file_2_failed:
- class_remove_file(zcrypt_class, &class_attr_zcdn_create);
+ class_remove_file(&zcrypt_class, &class_attr_zcdn_create);
out_class_create_file_1_failed:
cdev_del(&zcrypt_cdev);
out_cdev_add_failed:
unregister_chrdev_region(zcrypt_devt, ZCRYPT_MAX_MINOR_NODES);
out_alloc_chrdev_failed:
- class_destroy(zcrypt_class);
+ class_unregister(&zcrypt_class);
out_class_create_failed:
return rc;
}
static void zcdn_exit(void)
{
- class_remove_file(zcrypt_class, &class_attr_zcdn_create);
- class_remove_file(zcrypt_class, &class_attr_zcdn_destroy);
+ class_remove_file(&zcrypt_class, &class_attr_zcdn_create);
+ class_remove_file(&zcrypt_class, &class_attr_zcdn_destroy);
zcdn_destroy_all();
cdev_del(&zcrypt_cdev);
unregister_chrdev_region(zcrypt_devt, ZCRYPT_MAX_MINOR_NODES);
- class_destroy(zcrypt_class);
+ class_unregister(&zcrypt_class);
}
/*
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/6] s390: vmur: make vmur_class constant
2024-03-05 11:25 [PATCH 0/6] s390: constify struct class usage Ricardo B. Marliere
2024-03-05 11:25 ` [PATCH 1/6] s390: zcrypt: make zcrypt_class constant Ricardo B. Marliere
@ 2024-03-05 11:25 ` Ricardo B. Marliere
2024-03-05 11:25 ` [PATCH 3/6] s390: vmlogrdr: make vmlogrdr_class constant Ricardo B. Marliere
` (4 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Ricardo B. Marliere @ 2024-03-05 11:25 UTC (permalink / raw)
To: Harald Freudenberger, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle
Cc: linux-s390, linux-kernel, Ricardo B. Marliere, Greg Kroah-Hartman
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 vmur_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@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
drivers/s390/char/vmur.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c
index 1d17a83569ce..47bfb50f8eb1 100644
--- a/drivers/s390/char/vmur.c
+++ b/drivers/s390/char/vmur.c
@@ -48,7 +48,9 @@ MODULE_DESCRIPTION("s390 z/VM virtual unit record device driver");
MODULE_LICENSE("GPL");
static dev_t ur_first_dev_maj_min;
-static struct class *vmur_class;
+static const struct class vmur_class = {
+ .name = "vmur",
+};
static struct debug_info *vmur_dbf;
/* We put the device's record length (for writes) in the driver_info field */
@@ -912,7 +914,7 @@ static int ur_set_online(struct ccw_device *cdev)
goto fail_free_cdev;
}
- urd->device = device_create(vmur_class, &cdev->dev,
+ urd->device = device_create(&vmur_class, &cdev->dev,
urd->char_device->dev, NULL, "%s", node_id);
if (IS_ERR(urd->device)) {
rc = PTR_ERR(urd->device);
@@ -958,7 +960,7 @@ static int ur_set_offline_force(struct ccw_device *cdev, int force)
/* Work not run yet - need to release reference here */
urdev_put(urd);
}
- device_destroy(vmur_class, urd->char_device->dev);
+ device_destroy(&vmur_class, urd->char_device->dev);
cdev_del(urd->char_device);
urd->char_device = NULL;
rc = 0;
@@ -1022,11 +1024,9 @@ static int __init ur_init(void)
debug_set_level(vmur_dbf, 6);
- vmur_class = class_create("vmur");
- if (IS_ERR(vmur_class)) {
- rc = PTR_ERR(vmur_class);
+ rc = class_register(&vmur_class);
+ if (rc)
goto fail_free_dbf;
- }
rc = ccw_driver_register(&ur_driver);
if (rc)
@@ -1046,7 +1046,7 @@ static int __init ur_init(void)
fail_unregister_driver:
ccw_driver_unregister(&ur_driver);
fail_class_destroy:
- class_destroy(vmur_class);
+ class_unregister(&vmur_class);
fail_free_dbf:
debug_unregister(vmur_dbf);
return rc;
@@ -1056,7 +1056,7 @@ static void __exit ur_exit(void)
{
unregister_chrdev_region(ur_first_dev_maj_min, NUM_MINORS);
ccw_driver_unregister(&ur_driver);
- class_destroy(vmur_class);
+ class_unregister(&vmur_class);
debug_unregister(vmur_dbf);
pr_info("%s unloaded.\n", ur_banner);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/6] s390: vmlogrdr: make vmlogrdr_class constant
2024-03-05 11:25 [PATCH 0/6] s390: constify struct class usage Ricardo B. Marliere
2024-03-05 11:25 ` [PATCH 1/6] s390: zcrypt: make zcrypt_class constant Ricardo B. Marliere
2024-03-05 11:25 ` [PATCH 2/6] s390: vmur: make vmur_class constant Ricardo B. Marliere
@ 2024-03-05 11:25 ` Ricardo B. Marliere
2024-03-05 11:25 ` [PATCH 4/6] s390: tape: make tape_class constant Ricardo B. Marliere
` (3 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Ricardo B. Marliere @ 2024-03-05 11:25 UTC (permalink / raw)
To: Harald Freudenberger, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle
Cc: linux-s390, linux-kernel, Ricardo B. Marliere, Greg Kroah-Hartman
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 vmlogrdr_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@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
drivers/s390/char/vmlogrdr.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index 6946ba9a9de2..063d8f3565c9 100644
--- a/drivers/s390/char/vmlogrdr.c
+++ b/drivers/s390/char/vmlogrdr.c
@@ -679,7 +679,9 @@ static const struct attribute_group *vmlogrdr_attr_groups[] = {
NULL,
};
-static struct class *vmlogrdr_class;
+static const struct class vmlogrdr_class = {
+ .name = "vmlogrdr_class",
+};
static struct device_driver vmlogrdr_driver = {
.name = "vmlogrdr",
.bus = &iucv_bus,
@@ -699,12 +701,10 @@ static int vmlogrdr_register_driver(void)
if (ret)
goto out_iucv;
- vmlogrdr_class = class_create("vmlogrdr");
- if (IS_ERR(vmlogrdr_class)) {
- ret = PTR_ERR(vmlogrdr_class);
- vmlogrdr_class = NULL;
+ ret = class_register(&vmlogrdr_class);
+ if (ret)
goto out_driver;
- }
+
return 0;
out_driver:
@@ -718,8 +718,7 @@ static int vmlogrdr_register_driver(void)
static void vmlogrdr_unregister_driver(void)
{
- class_destroy(vmlogrdr_class);
- vmlogrdr_class = NULL;
+ class_unregister(&vmlogrdr_class);
driver_unregister(&vmlogrdr_driver);
iucv_unregister(&vmlogrdr_iucv_handler, 1);
}
@@ -754,7 +753,7 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
return ret;
}
- priv->class_device = device_create(vmlogrdr_class, dev,
+ priv->class_device = device_create(&vmlogrdr_class, dev,
MKDEV(vmlogrdr_major,
priv->minor_num),
priv, "%s", dev_name(dev));
@@ -771,7 +770,7 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
static int vmlogrdr_unregister_device(struct vmlogrdr_priv_t *priv)
{
- device_destroy(vmlogrdr_class, MKDEV(vmlogrdr_major, priv->minor_num));
+ device_destroy(&vmlogrdr_class, MKDEV(vmlogrdr_major, priv->minor_num));
if (priv->device != NULL) {
device_unregister(priv->device);
priv->device=NULL;
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/6] s390: tape: make tape_class constant
2024-03-05 11:25 [PATCH 0/6] s390: constify struct class usage Ricardo B. Marliere
` (2 preceding siblings ...)
2024-03-05 11:25 ` [PATCH 3/6] s390: vmlogrdr: make vmlogrdr_class constant Ricardo B. Marliere
@ 2024-03-05 11:25 ` Ricardo B. Marliere
2024-03-05 11:25 ` [PATCH 5/6] s390: raw3270: improve raw3270_init() readability Ricardo B. Marliere
` (2 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Ricardo B. Marliere @ 2024-03-05 11:25 UTC (permalink / raw)
To: Harald Freudenberger, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle
Cc: linux-s390, linux-kernel, Ricardo B. Marliere, Greg Kroah-Hartman
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 tape_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@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
drivers/s390/char/tape_class.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/s390/char/tape_class.c b/drivers/s390/char/tape_class.c
index 277a0f903d11..eae362bbfbb5 100644
--- a/drivers/s390/char/tape_class.c
+++ b/drivers/s390/char/tape_class.c
@@ -22,7 +22,9 @@ MODULE_DESCRIPTION(
);
MODULE_LICENSE("GPL");
-static struct class *tape_class;
+static const struct class tape_class = {
+ .name = "tape390",
+};
/*
* Register a tape device and return a pointer to the cdev structure.
@@ -74,7 +76,7 @@ struct tape_class_device *register_tape_dev(
if (rc)
goto fail_with_cdev;
- tcd->class_device = device_create(tape_class, device,
+ tcd->class_device = device_create(&tape_class, device,
tcd->char_device->dev, NULL,
"%s", tcd->device_name);
rc = PTR_ERR_OR_ZERO(tcd->class_device);
@@ -91,7 +93,7 @@ struct tape_class_device *register_tape_dev(
return tcd;
fail_with_class_device:
- device_destroy(tape_class, tcd->char_device->dev);
+ device_destroy(&tape_class, tcd->char_device->dev);
fail_with_cdev:
cdev_del(tcd->char_device);
@@ -107,7 +109,7 @@ void unregister_tape_dev(struct device *device, struct tape_class_device *tcd)
{
if (tcd != NULL && !IS_ERR(tcd)) {
sysfs_remove_link(&device->kobj, tcd->mode_name);
- device_destroy(tape_class, tcd->char_device->dev);
+ device_destroy(&tape_class, tcd->char_device->dev);
cdev_del(tcd->char_device);
kfree(tcd);
}
@@ -117,15 +119,12 @@ EXPORT_SYMBOL(unregister_tape_dev);
static int __init tape_init(void)
{
- tape_class = class_create("tape390");
-
- return 0;
+ return class_register(&tape_class);
}
static void __exit tape_exit(void)
{
- class_destroy(tape_class);
- tape_class = NULL;
+ class_unregister(&tape_class);
}
postcore_initcall(tape_init);
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 5/6] s390: raw3270: improve raw3270_init() readability
2024-03-05 11:25 [PATCH 0/6] s390: constify struct class usage Ricardo B. Marliere
` (3 preceding siblings ...)
2024-03-05 11:25 ` [PATCH 4/6] s390: tape: make tape_class constant Ricardo B. Marliere
@ 2024-03-05 11:25 ` Ricardo B. Marliere
2024-03-05 11:25 ` [PATCH 6/6] s390: raw3270: make class3270 constant Ricardo B. Marliere
2024-03-08 16:19 ` [PATCH 0/6] s390: constify struct class usage Heiko Carstens
6 siblings, 0 replies; 12+ messages in thread
From: Ricardo B. Marliere @ 2024-03-05 11:25 UTC (permalink / raw)
To: Harald Freudenberger, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle
Cc: linux-s390, linux-kernel, Ricardo B. Marliere, Greg Kroah-Hartman
Instead of checking if rc is 0, check whether it is non-zero and return
early if so. The call to class_create() can fail, so add a check to it and
move it out of the mutex region.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
drivers/s390/char/raw3270.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
index 7115c0f85650..acc4cb37a9d8 100644
--- a/drivers/s390/char/raw3270.c
+++ b/drivers/s390/char/raw3270.c
@@ -1316,17 +1316,22 @@ static int raw3270_init(void)
return 0;
raw3270_registered = 1;
rc = ccw_driver_register(&raw3270_ccw_driver);
- if (rc == 0) {
- /* Create attributes for early (= console) device. */
- mutex_lock(&raw3270_mutex);
- class3270 = class_create("3270");
- list_for_each_entry(rp, &raw3270_devices, list) {
- get_device(&rp->cdev->dev);
- raw3270_create_attributes(rp);
- }
- mutex_unlock(&raw3270_mutex);
+ if (rc)
+ return rc;
+
+ class3270 = class_create("3270");
+ if (IS_ERR(class3270))
+ return PTR_ERR(class3270);
+
+ /* Create attributes for early (= console) device. */
+ mutex_lock(&raw3270_mutex);
+ list_for_each_entry(rp, &raw3270_devices, list) {
+ get_device(&rp->cdev->dev);
+ raw3270_create_attributes(rp);
}
- return rc;
+ mutex_unlock(&raw3270_mutex);
+
+ return 0;
}
static void raw3270_exit(void)
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 6/6] s390: raw3270: make class3270 constant
2024-03-05 11:25 [PATCH 0/6] s390: constify struct class usage Ricardo B. Marliere
` (4 preceding siblings ...)
2024-03-05 11:25 ` [PATCH 5/6] s390: raw3270: improve raw3270_init() readability Ricardo B. Marliere
@ 2024-03-05 11:25 ` Ricardo B. Marliere
2024-03-08 16:19 ` [PATCH 0/6] s390: constify struct class usage Heiko Carstens
6 siblings, 0 replies; 12+ messages in thread
From: Ricardo B. Marliere @ 2024-03-05 11:25 UTC (permalink / raw)
To: Harald Freudenberger, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle
Cc: linux-s390, linux-kernel, Ricardo B. Marliere, Greg Kroah-Hartman
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 class3270 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@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
drivers/s390/char/fs3270.c | 8 ++++----
drivers/s390/char/raw3270.c | 13 ++++++++-----
drivers/s390/char/raw3270.h | 2 +-
3 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/drivers/s390/char/fs3270.c b/drivers/s390/char/fs3270.c
index 4f26b0a55620..f83ec248e68e 100644
--- a/drivers/s390/char/fs3270.c
+++ b/drivers/s390/char/fs3270.c
@@ -521,13 +521,13 @@ static const struct file_operations fs3270_fops = {
static void fs3270_create_cb(int minor)
{
__register_chrdev(IBM_FS3270_MAJOR, minor, 1, "tub", &fs3270_fops);
- device_create(class3270, NULL, MKDEV(IBM_FS3270_MAJOR, minor),
+ device_create(&class3270, NULL, MKDEV(IBM_FS3270_MAJOR, minor),
NULL, "3270/tub%d", minor);
}
static void fs3270_destroy_cb(int minor)
{
- device_destroy(class3270, MKDEV(IBM_FS3270_MAJOR, minor));
+ device_destroy(&class3270, MKDEV(IBM_FS3270_MAJOR, minor));
__unregister_chrdev(IBM_FS3270_MAJOR, minor, 1, "tub");
}
@@ -546,7 +546,7 @@ static int __init fs3270_init(void)
rc = __register_chrdev(IBM_FS3270_MAJOR, 0, 1, "fs3270", &fs3270_fops);
if (rc)
return rc;
- device_create(class3270, NULL, MKDEV(IBM_FS3270_MAJOR, 0),
+ device_create(&class3270, NULL, MKDEV(IBM_FS3270_MAJOR, 0),
NULL, "3270/tub");
raw3270_register_notifier(&fs3270_notifier);
return 0;
@@ -555,7 +555,7 @@ static int __init fs3270_init(void)
static void __exit fs3270_exit(void)
{
raw3270_unregister_notifier(&fs3270_notifier);
- device_destroy(class3270, MKDEV(IBM_FS3270_MAJOR, 0));
+ device_destroy(&class3270, MKDEV(IBM_FS3270_MAJOR, 0));
__unregister_chrdev(IBM_FS3270_MAJOR, 0, 1, "fs3270");
}
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
index acc4cb37a9d8..8e9868581e0a 100644
--- a/drivers/s390/char/raw3270.c
+++ b/drivers/s390/char/raw3270.c
@@ -29,7 +29,9 @@
#include <linux/device.h>
#include <linux/mutex.h>
-struct class *class3270;
+const struct class class3270 = {
+ .name = "3270",
+};
EXPORT_SYMBOL(class3270);
/* The main 3270 data structure. */
@@ -1315,13 +1317,14 @@ static int raw3270_init(void)
if (raw3270_registered)
return 0;
raw3270_registered = 1;
+
rc = ccw_driver_register(&raw3270_ccw_driver);
if (rc)
return rc;
- class3270 = class_create("3270");
- if (IS_ERR(class3270))
- return PTR_ERR(class3270);
+ rc = class_register(&class3270);
+ if (rc)
+ return rc;
/* Create attributes for early (= console) device. */
mutex_lock(&raw3270_mutex);
@@ -1337,7 +1340,7 @@ static int raw3270_init(void)
static void raw3270_exit(void)
{
ccw_driver_unregister(&raw3270_ccw_driver);
- class_destroy(class3270);
+ class_unregister(&class3270);
}
MODULE_LICENSE("GPL");
diff --git a/drivers/s390/char/raw3270.h b/drivers/s390/char/raw3270.h
index b1beecc7a0a9..5040c7e0e051 100644
--- a/drivers/s390/char/raw3270.h
+++ b/drivers/s390/char/raw3270.h
@@ -14,7 +14,7 @@
struct raw3270;
struct raw3270_view;
-extern struct class *class3270;
+extern const struct class class3270;
/* 3270 CCW request */
struct raw3270_request {
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/6] s390: zcrypt: make zcrypt_class constant
2024-03-05 11:25 ` [PATCH 1/6] s390: zcrypt: make zcrypt_class constant Ricardo B. Marliere
@ 2024-03-08 14:19 ` Harald Freudenberger
2024-03-08 14:38 ` Ricardo B. Marliere
0 siblings, 1 reply; 12+ messages in thread
From: Harald Freudenberger @ 2024-03-08 14:19 UTC (permalink / raw)
To: Ricardo B. Marliere, Heiko Carstens, Vasily Gorbik
Cc: Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
linux-s390, linux-kernel, Greg Kroah-Hartman
On 2024-03-05 12:25, 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 zcrypt_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@linuxfoundation.org>
> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
> ---
> drivers/s390/crypto/zcrypt_api.c | 33
> +++++++++++++++++----------------
> 1 file changed, 17 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/s390/crypto/zcrypt_api.c
> b/drivers/s390/crypto/zcrypt_api.c
> index e8742757085b..d0358bb6ccf2 100644
> --- a/drivers/s390/crypto/zcrypt_api.c
> +++ b/drivers/s390/crypto/zcrypt_api.c
> @@ -116,7 +116,11 @@ EXPORT_SYMBOL(zcrypt_msgtype);
>
> struct zcdn_device;
>
> -static struct class *zcrypt_class;
> +static void zcdn_device_release(struct device *dev);
> +static const struct class zcrypt_class = {
> + .name = ZCRYPT_NAME,
> + .dev_release = zcdn_device_release,
> +};
> static dev_t zcrypt_devt;
> static struct cdev zcrypt_cdev;
>
> @@ -139,7 +143,7 @@ static int zcdn_destroy(const char *name);
> */
> static inline struct zcdn_device *find_zcdndev_by_name(const char
> *name)
> {
> - struct device *dev = class_find_device_by_name(zcrypt_class, name);
> + struct device *dev = class_find_device_by_name(&zcrypt_class, name);
>
> return dev ? to_zcdn_dev(dev) : NULL;
> }
> @@ -151,7 +155,7 @@ static inline struct zcdn_device
> *find_zcdndev_by_name(const char *name)
> */
> static inline struct zcdn_device *find_zcdndev_by_devt(dev_t devt)
> {
> - struct device *dev = class_find_device_by_devt(zcrypt_class, devt);
> + struct device *dev = class_find_device_by_devt(&zcrypt_class, devt);
>
> return dev ? to_zcdn_dev(dev) : NULL;
> }
> @@ -405,7 +409,7 @@ static int zcdn_create(const char *name)
> goto unlockout;
> }
> zcdndev->device.release = zcdn_device_release;
> - zcdndev->device.class = zcrypt_class;
> + zcdndev->device.class = &zcrypt_class;
> zcdndev->device.devt = devt;
> zcdndev->device.groups = zcdn_dev_attr_groups;
> if (name[0])
> @@ -2067,12 +2071,9 @@ static int __init zcdn_init(void)
> int rc;
>
> /* create a new class 'zcrypt' */
> - zcrypt_class = class_create(ZCRYPT_NAME);
> - if (IS_ERR(zcrypt_class)) {
> - rc = PTR_ERR(zcrypt_class);
> + rc = class_register(&zcrypt_class);
> + if (rc)
> goto out_class_create_failed;
> - }
> - zcrypt_class->dev_release = zcdn_device_release;
>
> /* alloc device minor range */
> rc = alloc_chrdev_region(&zcrypt_devt,
> @@ -2088,35 +2089,35 @@ static int __init zcdn_init(void)
> goto out_cdev_add_failed;
>
> /* need some class specific sysfs attributes */
> - rc = class_create_file(zcrypt_class, &class_attr_zcdn_create);
> + rc = class_create_file(&zcrypt_class, &class_attr_zcdn_create);
> if (rc)
> goto out_class_create_file_1_failed;
> - rc = class_create_file(zcrypt_class, &class_attr_zcdn_destroy);
> + rc = class_create_file(&zcrypt_class, &class_attr_zcdn_destroy);
> if (rc)
> goto out_class_create_file_2_failed;
>
> return 0;
>
> out_class_create_file_2_failed:
> - class_remove_file(zcrypt_class, &class_attr_zcdn_create);
> + class_remove_file(&zcrypt_class, &class_attr_zcdn_create);
> out_class_create_file_1_failed:
> cdev_del(&zcrypt_cdev);
> out_cdev_add_failed:
> unregister_chrdev_region(zcrypt_devt, ZCRYPT_MAX_MINOR_NODES);
> out_alloc_chrdev_failed:
> - class_destroy(zcrypt_class);
> + class_unregister(&zcrypt_class);
> out_class_create_failed:
> return rc;
> }
>
> static void zcdn_exit(void)
> {
> - class_remove_file(zcrypt_class, &class_attr_zcdn_create);
> - class_remove_file(zcrypt_class, &class_attr_zcdn_destroy);
> + class_remove_file(&zcrypt_class, &class_attr_zcdn_create);
> + class_remove_file(&zcrypt_class, &class_attr_zcdn_destroy);
> zcdn_destroy_all();
> cdev_del(&zcrypt_cdev);
> unregister_chrdev_region(zcrypt_devt, ZCRYPT_MAX_MINOR_NODES);
> - class_destroy(zcrypt_class);
> + class_unregister(&zcrypt_class);
> }
>
> /*
Thanks Ricardo, nice work.
The only thing I would do is to rename the label
"out_class_create_failed"
with "out_class_register_failed".
Who will pick this patch? As this is part of a bundle of fixes, Richardo
do you have a way to push this into the kernel? Otherwise as the
AP/zcrypt
maintainer I would pick only this patch and forward it to the s390
subsystem.
Acked-by: Harald Freudenberger <freude@linux.ibm.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/6] s390: zcrypt: make zcrypt_class constant
2024-03-08 14:19 ` Harald Freudenberger
@ 2024-03-08 14:38 ` Ricardo B. Marliere
2024-03-08 14:44 ` Heiko Carstens
0 siblings, 1 reply; 12+ messages in thread
From: Ricardo B. Marliere @ 2024-03-08 14:38 UTC (permalink / raw)
To: Harald Freudenberger
Cc: Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, linux-s390, linux-kernel,
Greg Kroah-Hartman
On 8 Mar 15:19, Harald Freudenberger wrote:
> On 2024-03-05 12:25, 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 zcrypt_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@linuxfoundation.org>
> > Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
> > ---
> > drivers/s390/crypto/zcrypt_api.c | 33 +++++++++++++++++----------------
> > 1 file changed, 17 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/s390/crypto/zcrypt_api.c
> > b/drivers/s390/crypto/zcrypt_api.c
> > index e8742757085b..d0358bb6ccf2 100644
> > --- a/drivers/s390/crypto/zcrypt_api.c
> > +++ b/drivers/s390/crypto/zcrypt_api.c
> > @@ -116,7 +116,11 @@ EXPORT_SYMBOL(zcrypt_msgtype);
> >
> > struct zcdn_device;
> >
> > -static struct class *zcrypt_class;
> > +static void zcdn_device_release(struct device *dev);
> > +static const struct class zcrypt_class = {
> > + .name = ZCRYPT_NAME,
> > + .dev_release = zcdn_device_release,
> > +};
> > static dev_t zcrypt_devt;
> > static struct cdev zcrypt_cdev;
> >
> > @@ -139,7 +143,7 @@ static int zcdn_destroy(const char *name);
> > */
> > static inline struct zcdn_device *find_zcdndev_by_name(const char
> > *name)
> > {
> > - struct device *dev = class_find_device_by_name(zcrypt_class, name);
> > + struct device *dev = class_find_device_by_name(&zcrypt_class, name);
> >
> > return dev ? to_zcdn_dev(dev) : NULL;
> > }
> > @@ -151,7 +155,7 @@ static inline struct zcdn_device
> > *find_zcdndev_by_name(const char *name)
> > */
> > static inline struct zcdn_device *find_zcdndev_by_devt(dev_t devt)
> > {
> > - struct device *dev = class_find_device_by_devt(zcrypt_class, devt);
> > + struct device *dev = class_find_device_by_devt(&zcrypt_class, devt);
> >
> > return dev ? to_zcdn_dev(dev) : NULL;
> > }
> > @@ -405,7 +409,7 @@ static int zcdn_create(const char *name)
> > goto unlockout;
> > }
> > zcdndev->device.release = zcdn_device_release;
> > - zcdndev->device.class = zcrypt_class;
> > + zcdndev->device.class = &zcrypt_class;
> > zcdndev->device.devt = devt;
> > zcdndev->device.groups = zcdn_dev_attr_groups;
> > if (name[0])
> > @@ -2067,12 +2071,9 @@ static int __init zcdn_init(void)
> > int rc;
> >
> > /* create a new class 'zcrypt' */
> > - zcrypt_class = class_create(ZCRYPT_NAME);
> > - if (IS_ERR(zcrypt_class)) {
> > - rc = PTR_ERR(zcrypt_class);
> > + rc = class_register(&zcrypt_class);
> > + if (rc)
> > goto out_class_create_failed;
> > - }
> > - zcrypt_class->dev_release = zcdn_device_release;
> >
> > /* alloc device minor range */
> > rc = alloc_chrdev_region(&zcrypt_devt,
> > @@ -2088,35 +2089,35 @@ static int __init zcdn_init(void)
> > goto out_cdev_add_failed;
> >
> > /* need some class specific sysfs attributes */
> > - rc = class_create_file(zcrypt_class, &class_attr_zcdn_create);
> > + rc = class_create_file(&zcrypt_class, &class_attr_zcdn_create);
> > if (rc)
> > goto out_class_create_file_1_failed;
> > - rc = class_create_file(zcrypt_class, &class_attr_zcdn_destroy);
> > + rc = class_create_file(&zcrypt_class, &class_attr_zcdn_destroy);
> > if (rc)
> > goto out_class_create_file_2_failed;
> >
> > return 0;
> >
> > out_class_create_file_2_failed:
> > - class_remove_file(zcrypt_class, &class_attr_zcdn_create);
> > + class_remove_file(&zcrypt_class, &class_attr_zcdn_create);
> > out_class_create_file_1_failed:
> > cdev_del(&zcrypt_cdev);
> > out_cdev_add_failed:
> > unregister_chrdev_region(zcrypt_devt, ZCRYPT_MAX_MINOR_NODES);
> > out_alloc_chrdev_failed:
> > - class_destroy(zcrypt_class);
> > + class_unregister(&zcrypt_class);
> > out_class_create_failed:
> > return rc;
> > }
> >
> > static void zcdn_exit(void)
> > {
> > - class_remove_file(zcrypt_class, &class_attr_zcdn_create);
> > - class_remove_file(zcrypt_class, &class_attr_zcdn_destroy);
> > + class_remove_file(&zcrypt_class, &class_attr_zcdn_create);
> > + class_remove_file(&zcrypt_class, &class_attr_zcdn_destroy);
> > zcdn_destroy_all();
> > cdev_del(&zcrypt_cdev);
> > unregister_chrdev_region(zcrypt_devt, ZCRYPT_MAX_MINOR_NODES);
> > - class_destroy(zcrypt_class);
> > + class_unregister(&zcrypt_class);
> > }
> >
> > /*
>
> Thanks Ricardo, nice work.
> The only thing I would do is to rename the label "out_class_create_failed"
> with "out_class_register_failed".
Ah, indeed. Thanks for catching that. I will wait for more feedback on
the other patches and send a v2 if required.
>
> Who will pick this patch? As this is part of a bundle of fixes, Richardo
> do you have a way to push this into the kernel? Otherwise as the AP/zcrypt
> maintainer I would pick only this patch and forward it to the s390
> subsystem.
I have no ways of pushing this, sorry. The series is based on
s390/linux.git/for-next, so perhaps the s390 maintainers can pick this
one along with the others with your Acked-by: provided? :)
Thank you,
- Ricardo.
>
> Acked-by: Harald Freudenberger <freude@linux.ibm.com>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/6] s390: zcrypt: make zcrypt_class constant
2024-03-08 14:38 ` Ricardo B. Marliere
@ 2024-03-08 14:44 ` Heiko Carstens
2024-03-08 16:49 ` Ricardo B. Marliere
0 siblings, 1 reply; 12+ messages in thread
From: Heiko Carstens @ 2024-03-08 14:44 UTC (permalink / raw)
To: Ricardo B. Marliere
Cc: Harald Freudenberger, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, linux-s390, linux-kernel,
Greg Kroah-Hartman
On Fri, Mar 08, 2024 at 11:38:14AM -0300, Ricardo B. Marliere wrote:
> > Thanks Ricardo, nice work.
> > The only thing I would do is to rename the label "out_class_create_failed"
> > with "out_class_register_failed".
>
> Ah, indeed. Thanks for catching that. I will wait for more feedback on
> the other patches and send a v2 if required.
>
> >
> > Who will pick this patch? As this is part of a bundle of fixes, Richardo
> > do you have a way to push this into the kernel? Otherwise as the AP/zcrypt
> > maintainer I would pick only this patch and forward it to the s390
> > subsystem.
>
> I have no ways of pushing this, sorry. The series is based on
> s390/linux.git/for-next, so perhaps the s390 maintainers can pick this
> one along with the others with your Acked-by: provided? :)
I will pick up the whole series, but need some more time.
There is no need to send a v2 for this patch - I'll change the label as
requested by Harald.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/6] s390: constify struct class usage
2024-03-05 11:25 [PATCH 0/6] s390: constify struct class usage Ricardo B. Marliere
` (5 preceding siblings ...)
2024-03-05 11:25 ` [PATCH 6/6] s390: raw3270: make class3270 constant Ricardo B. Marliere
@ 2024-03-08 16:19 ` Heiko Carstens
6 siblings, 0 replies; 12+ messages in thread
From: Heiko Carstens @ 2024-03-08 16:19 UTC (permalink / raw)
To: Ricardo B. Marliere
Cc: Harald Freudenberger, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, linux-s390, linux-kernel,
Greg Kroah-Hartman
On Tue, Mar 05, 2024 at 08:25:18AM -0300, Ricardo B. Marliere wrote:
> This is a simple and straight forward cleanup series that aims to make the
> class structures in s390 constant. This has been possible since 2023 [1].
>
> [1]: https://lore.kernel.org/all/2023040248-customary-release-4aec@gregkh/
>
> Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
> ---
> Ricardo B. Marliere (6):
> s390: zcrypt: make zcrypt_class constant
> s390: vmur: make vmur_class constant
> s390: vmlogrdr: make vmlogrdr_class constant
> s390: tape: make tape_class constant
> s390: raw3270: improve raw3270_init() readability
> s390: raw3270: make class3270 constant
>
> drivers/s390/char/fs3270.c | 8 ++++----
> drivers/s390/char/raw3270.c | 32 ++++++++++++++++++++------------
> drivers/s390/char/raw3270.h | 2 +-
> drivers/s390/char/tape_class.c | 17 ++++++++---------
> drivers/s390/char/vmlogrdr.c | 19 +++++++++----------
> drivers/s390/char/vmur.c | 18 +++++++++---------
> drivers/s390/crypto/zcrypt_api.c | 33 +++++++++++++++++----------------
> 7 files changed, 68 insertions(+), 61 deletions(-)
Series applied, thanks!
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/6] s390: zcrypt: make zcrypt_class constant
2024-03-08 14:44 ` Heiko Carstens
@ 2024-03-08 16:49 ` Ricardo B. Marliere
0 siblings, 0 replies; 12+ messages in thread
From: Ricardo B. Marliere @ 2024-03-08 16:49 UTC (permalink / raw)
To: Heiko Carstens
Cc: Harald Freudenberger, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, linux-s390, linux-kernel,
Greg Kroah-Hartman
Hi Heiko!
On 8 Mar 15:44, Heiko Carstens wrote:
> On Fri, Mar 08, 2024 at 11:38:14AM -0300, Ricardo B. Marliere wrote:
> > > Thanks Ricardo, nice work.
> > > The only thing I would do is to rename the label "out_class_create_failed"
> > > with "out_class_register_failed".
> >
> > Ah, indeed. Thanks for catching that. I will wait for more feedback on
> > the other patches and send a v2 if required.
> >
> > >
> > > Who will pick this patch? As this is part of a bundle of fixes, Richardo
> > > do you have a way to push this into the kernel? Otherwise as the AP/zcrypt
> > > maintainer I would pick only this patch and forward it to the s390
> > > subsystem.
> >
> > I have no ways of pushing this, sorry. The series is based on
> > s390/linux.git/for-next, so perhaps the s390 maintainers can pick this
> > one along with the others with your Acked-by: provided? :)
>
> I will pick up the whole series, but need some more time.
>
> There is no need to send a v2 for this patch - I'll change the label as
> requested by Harald.
Thank you for this.
- Ricardo
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-03-08 16:49 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-05 11:25 [PATCH 0/6] s390: constify struct class usage Ricardo B. Marliere
2024-03-05 11:25 ` [PATCH 1/6] s390: zcrypt: make zcrypt_class constant Ricardo B. Marliere
2024-03-08 14:19 ` Harald Freudenberger
2024-03-08 14:38 ` Ricardo B. Marliere
2024-03-08 14:44 ` Heiko Carstens
2024-03-08 16:49 ` Ricardo B. Marliere
2024-03-05 11:25 ` [PATCH 2/6] s390: vmur: make vmur_class constant Ricardo B. Marliere
2024-03-05 11:25 ` [PATCH 3/6] s390: vmlogrdr: make vmlogrdr_class constant Ricardo B. Marliere
2024-03-05 11:25 ` [PATCH 4/6] s390: tape: make tape_class constant Ricardo B. Marliere
2024-03-05 11:25 ` [PATCH 5/6] s390: raw3270: improve raw3270_init() readability Ricardo B. Marliere
2024-03-05 11:25 ` [PATCH 6/6] s390: raw3270: make class3270 constant Ricardo B. Marliere
2024-03-08 16:19 ` [PATCH 0/6] s390: constify struct class usage Heiko Carstens
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).