Greg Kroah-Hartman
75a2d4226b
driver core: class: mark the struct class for sysfs callbacks as constant
...
struct class should never be modified in a sysfs callback as there is
nothing in the structure to modify, and frankly, the structure is almost
never used in a sysfs callback, so mark it as constant to allow struct
class to be moved to read-only memory.
While we are touching all class sysfs callbacks also mark the attribute
as constant as it can not be modified. The bonding code still uses this
structure so it can not be removed from the function callbacks.
Cc: "David S. Miller" <davem@davemloft.net >
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Cc: Bartosz Golaszewski <brgl@bgdev.pl >
Cc: Eric Dumazet <edumazet@google.com >
Cc: Jakub Kicinski <kuba@kernel.org >
Cc: Jens Axboe <axboe@kernel.dk >
Cc: Johannes Berg <johannes@sipsolutions.net >
Cc: Linus Walleij <linus.walleij@linaro.org >
Cc: Minchan Kim <minchan@kernel.org >
Cc: Miquel Raynal <miquel.raynal@bootlin.com >
Cc: Namjae Jeon <linkinjeon@kernel.org >
Cc: Paolo Abeni <pabeni@redhat.com >
Cc: Russ Weight <russell.h.weight@intel.com >
Cc: Sergey Senozhatsky <senozhatsky@chromium.org >
Cc: Steve French <sfrench@samba.org >
Cc: Vignesh Raghavendra <vigneshr@ti.com >
Cc: linux-cifs@vger.kernel.org
Cc: linux-gpio@vger.kernel.org
Cc: linux-mtd@lists.infradead.org
Cc: linux-rdma@vger.kernel.org
Cc: linux-s390@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: netdev@vger.kernel.org
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org >
Link: https://lore.kernel.org/r/20230325084537.3622280-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-29 07:54:58 +02:00
Greg Kroah-Hartman
517d4927aa
driver core: bus: constify class_unregister/destroy()
...
The class_unregister() and class_destroy() function should be taking a
const * to struct class, not just a *, so fix that up.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230325084526.3622123-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-28 08:27:48 +02:00
Greg Kroah-Hartman
5c9a27df4e
driver core: move sysfs_dev_char_kobj out of class.h
...
The structure sysfs_dev_char_kobj is local only to the driver core code,
so move it out of the global class.h file and into the internal base.h
file as no one else should be touching this symbol.
Acked-by: Rafael J. Wysocki <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230327160319.513974-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-27 18:24:29 +02:00
Greg Kroah-Hartman
009455205e
driver core: bus: move documentation for lock_key to proper location.
...
In commit 37e98d9bed ("driver core: bus: move lock_class_key into
dynamic structure"), the lock_key variable moved out of struct bus_type
and into struct subsys_private, yet the documentation for it did not
move. Fix that up and place the documentation comment in the correct
location.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Fixes: 37e98d9bed ("driver core: bus: move lock_class_key into dynamic structure")
Link: https://lore.kernel.org/r/20230324090814.386654-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-25 09:38:08 +01:00
Greg Kroah-Hartman
8a2b9c84c7
driver core: driver.h: remove extern from function prototypes
...
The kernel coding style does not require 'extern' in function prototypes
in .h files, so remove them from include/linux/device/driver.h as they
are not needed.
Acked-by: Rafael J. Wysocki <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230324122711.2664537-3-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-24 15:35:42 +01:00
Greg Kroah-Hartman
0d62b79fd8
driver core: bus.h: remove extern from function prototypes
...
The kernel coding style does not require 'extern' in function prototypes
in .h files, so remove them from include/linux/device/bus.h as they are
not needed.
Acked-by: Rafael J. Wysocki <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230324122711.2664537-2-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-24 15:35:38 +01:00
Greg Kroah-Hartman
43718dca48
driver core: class.h: remove extern from function prototypes
...
The kernel coding style does not require 'extern' in function prototypes
in .h files, so remove them from include/linux/device/class.h as they
are not needed.
Acked-by: Rafael J. Wysocki <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230324100132.1633647-2-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-24 15:34:24 +01:00
Greg Kroah-Hartman
dcfbb67e48
driver core: class: use lock_class_key already present in struct subsys_private
...
In commit 37e98d9bed ("driver core: bus: move lock_class_key into
dynamic structure"), we moved the lock_class_key into the internal
structure shared by busses and classes, but only used it for buses.
Move the class code to use this structure as it is already present and
being allocated, instead of the statically allocated on-the-stack
variable that class_create() was using as part of a macro wrapper around
the core function call.
Reviewed-by: Rafael J. Wysocki <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230324100132.1633647-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-24 15:34:18 +01:00
Greg Kroah-Hartman
c28dd08ef7
driver core: make the bus_type in struct device_driver constant
...
The pointer to struct bus_type in struct device_driver should only be
pointing to something that can never change now that the driver core has
fixed up the previously writable fields. So mark it as a constant
pointer to enforce this and move forward with the goal of moving
bus_type into read-only memory.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230313182918.1312597-28-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-23 13:21:26 +01:00
Greg Kroah-Hartman
7c06be0425
driver core: bus: constify driver_find()
...
The driver_find() function can now take a const * to bus_type, not just
a * so fix that up.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230313182918.1312597-26-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-23 13:21:22 +01:00
Greg Kroah-Hartman
9622b9f282
driver core: bus: constify bus_rescan_devices()
...
The bus_rescan_devices() function was missed in the previous change of
the bus_for_each* constant pointer changes, so fix it up now to take a
const * to struct bus_type.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230313182918.1312597-25-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-23 13:21:20 +01:00
Greg Kroah-Hartman
00c4a3c47d
driver core: bus: constantify bus_register()
...
bus_register() is now safe to take a constant * to bus_type, so make
that change and mark the subsys_private bus_type * constant as well.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230313182918.1312597-24-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-23 13:21:17 +01:00
Greg Kroah-Hartman
75cff725d9
driver core: bus: mark the struct bus_type for sysfs callbacks as constant
...
struct bus_type should never be modified in a sysfs callback as there is
nothing in the structure to modify, and frankly, the structure is almost
never used in a sysfs callback, so mark it as constant to allow struct
bus_type to be moved to read-only memory.
Cc: "David S. Miller" <davem@davemloft.net >
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Alexander Gordeev <agordeev@linux.ibm.com >
Cc: Alexandre Bounine <alex.bou9@gmail.com >
Cc: Alison Schofield <alison.schofield@intel.com >
Cc: Ben Widawsky <bwidawsk@kernel.org >
Cc: Dexuan Cui <decui@microsoft.com >
Cc: Eric Dumazet <edumazet@google.com >
Cc: Haiyang Zhang <haiyangz@microsoft.com >
Cc: Hannes Reinecke <hare@suse.de >
Cc: Harald Freudenberger <freude@linux.ibm.com >
Cc: Heiko Carstens <hca@linux.ibm.com >
Cc: Hu Haowen <src.res@email.cn >
Cc: Jakub Kicinski <kuba@kernel.org >
Cc: Jens Axboe <axboe@kernel.dk >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com >
Cc: Matt Porter <mporter@kernel.crashing.org >
Cc: Michael Ellerman <mpe@ellerman.id.au >
Cc: Paolo Abeni <pabeni@redhat.com >
Cc: Stuart Yoder <stuyoder@gmail.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Vishal Verma <vishal.l.verma@intel.com >
Cc: Yanteng Si <siyanteng@loongson.cn >
Acked-by: Ilya Dryomov <idryomov@gmail.com > # rbd
Acked-by: Ira Weiny <ira.weiny@intel.com > # cxl
Reviewed-by: Alex Shi <alexs@kernel.org >
Acked-by: Iwona Winiarska <iwona.winiarska@intel.com >
Acked-by: Dan Williams <dan.j.williams@intel.com >
Acked-by: Bjorn Helgaas <bhelgaas@google.com > # pci
Acked-by: Wei Liu <wei.liu@kernel.org >
Acked-by: Martin K. Petersen <martin.petersen@oracle.com > # scsi
Link: https://lore.kernel.org/r/20230313182918.1312597-23-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-23 13:20:40 +01:00
Greg Kroah-Hartman
9cc61e5fbd
driver core: bus: move dev_root out of struct bus_type
...
Now that all accesses of dev_root is through the bus_get_dev_root()
call, move the pointer out of struct bus_type and into the private
dynamic structure, subsys_private.
With this change, there is no modifiable portions of struct bus_type so
it can be marked as a constant structure and moved to read-only memory.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230313182918.1312597-22-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-23 13:20:36 +01:00
Greg Kroah-Hartman
80842a9290
driver core: class: make class_create/remove_file*() options const
...
The class_create_file*() and class_remove_file*() functions do not
modify the struct class at all, so mark them as const * to enforce that.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230313181843.1207845-8-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-17 15:16:41 +01:00
Greg Kroah-Hartman
cf41015ea8
driver core: class: make class_find_device*() options const
...
The class_find_device*() functions do not modify the struct class or the
struct device passed into it, so mark them as const * to enforce that.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230313181843.1207845-7-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-17 15:16:39 +01:00
Greg Kroah-Hartman
69df024ebb
driver core: class: make class_for_each_device() options const
...
class_for_each_device() does not modify the struct class or the struct
device passed into it, so mark them as const * to enforce that.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230313181843.1207845-6-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-17 15:16:37 +01:00
Greg Kroah-Hartman
a2fd6e42e4
driver core: class: make class_dev_iter_init() options const
...
class_dev_iter_init() does not modify the struct class or the struct
device passed into it, so mark them as const * to enforce that.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230313181843.1207845-5-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-17 15:16:35 +01:00
Greg Kroah-Hartman
1aaba11da9
driver core: class: remove module * from class_create()
...
The module pointer in class_create() never actually did anything, and it
shouldn't have been requred to be set as a parameter even if it did
something. So just remove it and fix up all callers of the function in
the kernel tree at the same time.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com >
Link: https://lore.kernel.org/r/20230313181843.1207845-4-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-17 15:16:33 +01:00
Greg Kroah-Hartman
6e30a66433
driver core: class: remove struct module owner out of struct class
...
The module owner field for a struct class was never actually used, so
remove it as it is not doing anything at all.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230313181843.1207845-3-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-17 15:16:30 +01:00
Greg Kroah-Hartman
4a46ac9d64
driver core: class: specify the module owner in __class_register()
...
There's no need to manually have to set the module owner of a class, the
compiler should do it automatically for you, so add a module * to the
__class_register() function and allow it to set the module owner
automatically.
This will let us move the module pointer out of struct class eventually,
as it should not be embedded in there if we wish for it to be a
read-only structure eventually.
And, funny story, this module pointer isn't even being used for
anything, so while we will keep it around for now, it's not like it even
matters.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230313181843.1207845-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-17 15:16:24 +01:00
Greg Kroah-Hartman
8c99377e61
driver core: bus: add bus_get_dev_root() function
...
Instead of poking around in the struct bus_type directly for the
dev_root pointer, provide a function to return it properly reference
counted, if it is present in the bus. This will be needed to move the
pointer out of struct bus_type in the future.
Use the function in the driver core code at the same time it is
introduced to verify that it works properly.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230209093556.19132-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-02-10 10:16:42 +01:00
Greg Kroah-Hartman
ad8685d0f6
driver core: bus: constify bus_unregister()
...
The bus_unregister() function can now take a const * to bus_type, not
just a * so fix that up.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230208111330.439504-22-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-02-09 10:43:45 +01:00
Greg Kroah-Hartman
f91482be9b
driver core: bus: constify bus_get_kset()
...
The bus_get_kset() function should be taking a const * to bus_type, not
just a * so fix that up.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230208111330.439504-20-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-02-09 10:43:41 +01:00
Greg Kroah-Hartman
bc8b793101
driver core: bus: constify bus_register/unregister_notifier()
...
The bus_register_notifier() and bus_unregister_notifier() functions
should be taking a const * to bus_type, not just a * so fix that up.
Cc: "Rafael J. Wysocki" <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230208111330.439504-19-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-02-09 10:43:39 +01:00