Re: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant

From: Winiarska, Iwona
Date: Wed Mar 15 2023 - 11:05:53 EST


On Mon, 2023-03-13 at 19:29 +0100, Greg Kroah-Hartman wrote:
> 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@xxxxxxxxxxxxx>
> Cc: "James E.J. Bottomley" <jejb@xxxxxxxxxxxxx>
> Cc: "K. Y. Srinivasan" <kys@xxxxxxxxxxxxx>
> Cc: "Martin K. Petersen" <martin.petersen@xxxxxxxxxx>
> Cc: Alex Shi <alexs@xxxxxxxxxx>
> Cc: Alexander Gordeev <agordeev@xxxxxxxxxxxxx>
> Cc: Alexandre Bounine <alex.bou9@xxxxxxxxx>
> Cc: Alison Schofield <alison.schofield@xxxxxxxxx>
> Cc: Ben Widawsky <bwidawsk@xxxxxxxxxx>
> Cc: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
> Cc: Dan Williams <dan.j.williams@xxxxxxxxx>
> Cc: Dexuan Cui <decui@xxxxxxxxxxxxx>
> Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
> Cc: Haiyang Zhang <haiyangz@xxxxxxxxxxxxx>
> Cc: Hannes Reinecke <hare@xxxxxxx>
> Cc: Harald Freudenberger <freude@xxxxxxxxxxxxx>
> Cc: Heiko Carstens <hca@xxxxxxxxxxxxx>
> Cc: Hu Haowen <src.res@xxxxxxxx>
> Cc: Ilya Dryomov <idryomov@xxxxxxxxx>
> Cc: Ira Weiny <ira.weiny@xxxxxxxxx>
> Cc: Iwona Winiarska <iwona.winiarska@xxxxxxxxx>
> Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
> Cc: Jens Axboe <axboe@xxxxxxxxx>
> Cc: Jonathan Corbet <corbet@xxxxxxx>
> Cc: Laurentiu Tudor <laurentiu.tudor@xxxxxxx>
> Cc: Matt Porter <mporter@xxxxxxxxxxxxxxxxxxx>
> Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
> Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
> Cc: Stuart Yoder <stuyoder@xxxxxxxxx>
> Cc: Vasily Gorbik <gor@xxxxxxxxxxxxx>
> Cc: Vishal Verma <vishal.l.verma@xxxxxxxxx>
> Cc: Wei Liu <wei.liu@xxxxxxxxxx>
> Cc: Yanteng Si <siyanteng@xxxxxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes.  It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
>
>  Documentation/driver-api/driver-model/bus.rst |  4 +-
>  Documentation/filesystems/sysfs.rst           |  4 +-
>  .../translations/zh_CN/filesystems/sysfs.txt  |  4 +-
>  .../translations/zh_TW/filesystems/sysfs.txt  |  4 +-
>  arch/powerpc/platforms/pseries/ibmebus.c      |  4 +-
>  arch/powerpc/platforms/pseries/vio.c          |  8 ++--
>  drivers/ata/pata_parport/pata_parport.c       |  6 +--
>  drivers/base/bus.c                            |  8 ++--
>  drivers/block/rbd.c                           | 34 +++++++--------
>  drivers/bus/fsl-mc/fsl-mc-bus.c               |  6 +--
>  drivers/cxl/core/port.c                       |  2 +-
>  drivers/hv/vmbus_drv.c                        |  2 +-
>  drivers/net/netdevsim/bus.c                   |  4 +-
>  drivers/pci/pci-sysfs.c                       |  2 +-
>  drivers/pci/pci.c                             |  4 +-
>  drivers/peci/sysfs.c                          |  2 +-
>  drivers/rapidio/rio-sysfs.c                   |  2 +-
>  drivers/s390/crypto/ap_bus.c                  | 42 +++++++++----------
>  drivers/scsi/fcoe/fcoe_sysfs.c                |  8 ++--
>  drivers/scsi/fcoe/fcoe_transport.c            |  6 +--
>  include/linux/device/bus.h                    |  4 +-
>  include/scsi/libfcoe.h                        |  6 +--
>  22 files changed, 78 insertions(+), 88 deletions(-)
>

[..]

> diff --git a/drivers/peci/sysfs.c b/drivers/peci/sysfs.c
> index db9ef05776e3..c04244075794 100644
> --- a/drivers/peci/sysfs.c
> +++ b/drivers/peci/sysfs.c
> @@ -15,7 +15,7 @@ static int rescan_controller(struct device *dev, void *data)
>         return peci_controller_scan_devices(to_peci_controller(dev));
>  }
>  
> -static ssize_t rescan_store(struct bus_type *bus, const char *buf, size_t
> count)
> +static ssize_t rescan_store(const struct bus_type *bus, const char *buf,
> size_t count)
>  {
>         bool res;
>         int ret;

Acked-by: Iwona Winiarska <iwona.winiarska@xxxxxxxxx>

Thanks
-Iwona