2024-02-20 12:51:48

by Ricardo B. Marliere

[permalink] [raw]
Subject: [PATCH] siox: constify the struct device_type usage

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver
core can properly handle constant struct device_type. Move the
siox_device_type and siox_master_type variables to be constant structures
as well, placing it into read-only memory which can not be modified at
runtime.

Cc: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Ricardo B. Marliere <[email protected]>
---
drivers/siox/siox-core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/siox/siox-core.c b/drivers/siox/siox-core.c
index 561408583b2b..8eca20c2ea9c 100644
--- a/drivers/siox/siox-core.c
+++ b/drivers/siox/siox-core.c
@@ -498,7 +498,7 @@ static void siox_device_release(struct device *dev)
kfree(sdevice);
}

-static struct device_type siox_device_type = {
+static const struct device_type siox_device_type = {
.groups = siox_device_groups,
.release = siox_device_release,
};
@@ -676,7 +676,7 @@ static void siox_master_release(struct device *dev)
kfree(smaster);
}

-static struct device_type siox_master_type = {
+static const struct device_type siox_master_type = {
.groups = siox_master_groups,
.release = siox_master_release,
};

---
base-commit: b401b621758e46812da61fa58a67c3fd8d91de0d
change-id: 20240219-device_cleanup-siox-82890e4378d0

Best regards,
--
Ricardo B. Marliere <[email protected]>



2024-02-27 05:23:30

by Thorsten Scherer

[permalink] [raw]
Subject: Re: [PATCH] siox: constify the struct device_type usage

Hello,

On Mon, Feb 19, 2024 at 04:49:30PM -0300, Ricardo B. Marliere wrote:
> Since commit aed65af1cc2f ("drivers: make device_type const"), the driver
> core can properly handle constant struct device_type. Move the
> siox_device_type and siox_master_type variables to be constant structures
> as well, placing it into read-only memory which can not be modified at
> runtime.
>
> Cc: Greg Kroah-Hartman <[email protected]>
> Signed-off-by: Ricardo B. Marliere <[email protected]>

Acked-by: Thorsten Scherer <[email protected]>

@gregkh: Could you please pick up this patch? There already is another
patch [1] from Ricardo. I wonder if this one flew under you radar or
if I did something wrong...

Thanks to you both.

Best regards
Thorsten

[1] [email protected]