diff mbox series

peci: constify the struct device_type usage

Message ID 20240219-device_cleanup-peci-v1-1-0727662616f7@marliere.net
State New
Headers show
Series peci: constify the struct device_type usage | expand

Commit Message

Ricardo B. Marliere Feb. 19, 2024, 12:36 p.m. UTC
Since commit aed65af1cc2f ("drivers: make device_type const"), the driver
core can properly handle constant struct device_type. Move the
peci_controller_type and peci_device_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 <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
 drivers/peci/core.c     | 2 +-
 drivers/peci/device.c   | 2 +-
 drivers/peci/internal.h | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)


---
base-commit: b401b621758e46812da61fa58a67c3fd8d91de0d
change-id: 20240219-device_cleanup-peci-a4f87c77703a

Best regards,

Comments

Winiarska, Iwona Feb. 26, 2024, 1:49 p.m. UTC | #1
On Mon, 2024-02-19 at 09:36 -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
> peci_controller_type and peci_device_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 <gregkh@linuxfoundation.org>
> Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>

Reviewed-by: Iwona Winiarska <iwona.winiarska@intel.com>

Thanks
-Iwona

> ---
>  drivers/peci/core.c     | 2 +-
>  drivers/peci/device.c   | 2 +-
>  drivers/peci/internal.h | 4 ++--
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/peci/core.c b/drivers/peci/core.c
> index 0f83a9c6093b..ab22d7d1948f 100644
> --- a/drivers/peci/core.c
> +++ b/drivers/peci/core.c
> @@ -25,7 +25,7 @@ static void peci_controller_dev_release(struct device *dev)
>  	kfree(controller);
>  }
>  
> -struct device_type peci_controller_type = {
> +const struct device_type peci_controller_type = {
>  	.release	= peci_controller_dev_release,
>  };
>  
> diff --git a/drivers/peci/device.c b/drivers/peci/device.c
> index e6b0bffb14f4..ee01f03c29b7 100644
> --- a/drivers/peci/device.c
> +++ b/drivers/peci/device.c
> @@ -246,7 +246,7 @@ static void peci_device_release(struct device *dev)
>  	kfree(device);
>  }
>  
> -struct device_type peci_device_type = {
> +const struct device_type peci_device_type = {
>  	.groups		= peci_device_groups,
>  	.release	= peci_device_release,
>  };
> diff --git a/drivers/peci/internal.h b/drivers/peci/internal.h
> index 9d75ea54504c..fddae86bf13c 100644
> --- a/drivers/peci/internal.h
> +++ b/drivers/peci/internal.h
> @@ -75,7 +75,7 @@ struct peci_device_id {
>  	u8 model;
>  };
>  
> -extern struct device_type peci_device_type;
> +extern const struct device_type peci_device_type;
>  extern const struct attribute_group *peci_device_groups[];
>  
>  int peci_device_create(struct peci_controller *controller, u8 addr);
> @@ -129,7 +129,7 @@ void peci_driver_unregister(struct peci_driver *driver);
>  #define module_peci_driver(__peci_driver) \
>  	module_driver(__peci_driver, peci_driver_register,
> peci_driver_unregister)
>  
> -extern struct device_type peci_controller_type;
> +extern const struct device_type peci_controller_type;
>  
>  int peci_controller_scan_devices(struct peci_controller *controller);
>  
> 
> ---
> base-commit: b401b621758e46812da61fa58a67c3fd8d91de0d
> change-id: 20240219-device_cleanup-peci-a4f87c77703a
> 
> Best regards,
diff mbox series

Patch

diff --git a/drivers/peci/core.c b/drivers/peci/core.c
index 0f83a9c6093b..ab22d7d1948f 100644
--- a/drivers/peci/core.c
+++ b/drivers/peci/core.c
@@ -25,7 +25,7 @@  static void peci_controller_dev_release(struct device *dev)
 	kfree(controller);
 }
 
-struct device_type peci_controller_type = {
+const struct device_type peci_controller_type = {
 	.release	= peci_controller_dev_release,
 };
 
diff --git a/drivers/peci/device.c b/drivers/peci/device.c
index e6b0bffb14f4..ee01f03c29b7 100644
--- a/drivers/peci/device.c
+++ b/drivers/peci/device.c
@@ -246,7 +246,7 @@  static void peci_device_release(struct device *dev)
 	kfree(device);
 }
 
-struct device_type peci_device_type = {
+const struct device_type peci_device_type = {
 	.groups		= peci_device_groups,
 	.release	= peci_device_release,
 };
diff --git a/drivers/peci/internal.h b/drivers/peci/internal.h
index 9d75ea54504c..fddae86bf13c 100644
--- a/drivers/peci/internal.h
+++ b/drivers/peci/internal.h
@@ -75,7 +75,7 @@  struct peci_device_id {
 	u8 model;
 };
 
-extern struct device_type peci_device_type;
+extern const struct device_type peci_device_type;
 extern const struct attribute_group *peci_device_groups[];
 
 int peci_device_create(struct peci_controller *controller, u8 addr);
@@ -129,7 +129,7 @@  void peci_driver_unregister(struct peci_driver *driver);
 #define module_peci_driver(__peci_driver) \
 	module_driver(__peci_driver, peci_driver_register, peci_driver_unregister)
 
-extern struct device_type peci_controller_type;
+extern const struct device_type peci_controller_type;
 
 int peci_controller_scan_devices(struct peci_controller *controller);