[1/2] clocksource: make clocksource_subsys const

Message ID 20240204-bus_cleanup-time-v1-1-207ec18e24b8@marliere.net
State New
Headers
Series [1/2] clocksource: make clocksource_subsys const |

Commit Message

Ricardo B. Marliere Feb. 4, 2024, 1:40 p.m. UTC
  Now that the driver core can properly handle constant struct bus_type,
move the clocksource_subsys variable to be a constant structure as well,
placing it into read-only memory which can not be modified at runtime.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
 kernel/time/clocksource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

John Stultz Feb. 5, 2024, 5:59 p.m. UTC | #1
On Sun, Feb 4, 2024 at 5:39 AM Ricardo B. Marliere <ricardo@marliere.net> wrote:
>
> Now that the driver core can properly handle constant struct bus_type,
> move the clocksource_subsys variable to be a constant structure as well,
> placing it into read-only memory which can not be modified at runtime.
>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>


Acked-by: John Stultz <jstultz@google.com>
  

Patch

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index c108ed8a9804..4f0932f0a0f6 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -1445,7 +1445,7 @@  static struct attribute *clocksource_attrs[] = {
 };
 ATTRIBUTE_GROUPS(clocksource);
 
-static struct bus_type clocksource_subsys = {
+static const struct bus_type clocksource_subsys = {
 	.name = "clocksource",
 	.dev_name = "clocksource",
 };