From: Bjorn Helgaas <helgaas@kernel.org>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Srinivas Kandagatla" <srinivas.kandagatla@linaro.org>,
"Davidlohr Bueso" <dave@stgolabs.net>,
"Jonathan Cameron" <jonathan.cameron@huawei.com>,
"Dave Jiang" <dave.jiang@intel.com>,
"Alison Schofield" <alison.schofield@intel.com>,
"Vishal Verma" <vishal.l.verma@intel.com>,
"Ira Weiny" <ira.weiny@intel.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"Xinhui Pan" <Xinhui.Pan@amd.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Dennis Dalessandro" <dennis.dalessandro@cornelisnetworks.com>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
"Leon Romanovsky" <leon@kernel.org>,
"Tudor Ambarus" <tudor.ambarus@linaro.org>,
"Pratyush Yadav" <pratyush@kernel.org>,
"Michael Walle" <mwalle@kernel.org>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Richard Weinberger" <richard@nod.at>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Naveen Krishna Chatradhi" <naveenkrishna.chatradhi@amd.com>,
"Carlos Bilbao" <carlos.bilbao.osdev@gmail.com>,
"Hans de Goede" <hdegoede@redhat.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"David E. Box" <david.e.box@linux.intel.com>,
"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Matt Turner" <mattst88@gmail.com>,
"Frederic Barrat" <fbarrat@linux.ibm.com>,
"Andrew Donnellan" <ajd@linux.ibm.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Logan Gunthorpe" <logang@deltatee.com>,
"K. Y. Srinivasan" <kys@microsoft.com>,
"Haiyang Zhang" <haiyangz@microsoft.com>,
"Wei Liu" <wei.liu@kernel.org>,
"Dexuan Cui" <decui@microsoft.com>,
"Dan Williams" <dan.j.williams@intel.com>,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
linux-cxl@vger.kernel.org, amd-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org,
linux-mtd@lists.infradead.org,
platform-driver-x86@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-usb@vger.kernel.org, linux-alpha@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, linux-hyperv@vger.kernel.org
Subject: Re: [PATCH v2 05/10] sysfs: treewide: constify attribute callback of bin_is_visible()
Date: Tue, 5 Nov 2024 09:26:50 -0600 [thread overview]
Message-ID: <20241105152650.GA1472729@bhelgaas> (raw)
In-Reply-To: <20241103-sysfs-const-bin_attr-v2-5-71110628844c@weissschuh.net>
On Sun, Nov 03, 2024 at 05:03:34PM +0000, Thomas Weißschuh wrote:
> The is_bin_visible() callbacks should not modify the struct
> bin_attribute passed as argument.
> Enforce this by marking the argument as const.
>
> As there are not many callback implementers perform this change
> throughout the tree at once.
>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Bjorn Helgaas <bhelgaas@google.com> # drivers/pci
> ---
> drivers/cxl/port.c | 2 +-
> drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 +-
> drivers/infiniband/hw/qib/qib_sysfs.c | 2 +-
> drivers/mtd/spi-nor/sysfs.c | 2 +-
> drivers/nvmem/core.c | 3 ++-
> drivers/pci/pci-sysfs.c | 2 +-
> drivers/pci/vpd.c | 2 +-
> drivers/platform/x86/amd/hsmp.c | 2 +-
> drivers/platform/x86/intel/sdsi.c | 2 +-
> drivers/scsi/scsi_sysfs.c | 2 +-
> drivers/usb/core/sysfs.c | 2 +-
> include/linux/sysfs.h | 30 +++++++++++++++---------------
> 12 files changed, 27 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c
> index 9dc394295e1fcd1610813837b2f515b66995eb25..24041cf85cfbe6c54c467ac325e48c775562b938 100644
> --- a/drivers/cxl/port.c
> +++ b/drivers/cxl/port.c
> @@ -173,7 +173,7 @@ static ssize_t CDAT_read(struct file *filp, struct kobject *kobj,
> static BIN_ATTR_ADMIN_RO(CDAT, 0);
>
> static umode_t cxl_port_bin_attr_is_visible(struct kobject *kobj,
> - struct bin_attribute *attr, int i)
> + const struct bin_attribute *attr, int i)
> {
> struct device *dev = kobj_to_dev(kobj);
> struct cxl_port *port = to_cxl_port(dev);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index 0b28b2cf1517d130da01989df70b9dff6433edc4..c1c329eb920b52af100a93bdf00df450e25608c4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -3999,7 +3999,7 @@ static umode_t amdgpu_flash_attr_is_visible(struct kobject *kobj, struct attribu
> }
>
> static umode_t amdgpu_bin_flash_attr_is_visible(struct kobject *kobj,
> - struct bin_attribute *attr,
> + const struct bin_attribute *attr,
> int idx)
> {
> struct device *dev = kobj_to_dev(kobj);
> diff --git a/drivers/infiniband/hw/qib/qib_sysfs.c b/drivers/infiniband/hw/qib/qib_sysfs.c
> index 53ec7510e4ebfb144e79884ca7dd7d0c873bd8a7..ba2cd68b53e6c240f1afc65c64012c75ccf488e0 100644
> --- a/drivers/infiniband/hw/qib/qib_sysfs.c
> +++ b/drivers/infiniband/hw/qib/qib_sysfs.c
> @@ -283,7 +283,7 @@ static struct bin_attribute *port_ccmgta_attributes[] = {
> };
>
> static umode_t qib_ccmgta_is_bin_visible(struct kobject *kobj,
> - struct bin_attribute *attr, int n)
> + const struct bin_attribute *attr, int n)
> {
> struct qib_pportdata *ppd = qib_get_pportdata_kobj(kobj);
>
> diff --git a/drivers/mtd/spi-nor/sysfs.c b/drivers/mtd/spi-nor/sysfs.c
> index 96064e4babf01f6950c81586764386e7671cbf97..5e9eb268073d18e0a46089000f18a3200b4bf13d 100644
> --- a/drivers/mtd/spi-nor/sysfs.c
> +++ b/drivers/mtd/spi-nor/sysfs.c
> @@ -87,7 +87,7 @@ static umode_t spi_nor_sysfs_is_visible(struct kobject *kobj,
> }
>
> static umode_t spi_nor_sysfs_is_bin_visible(struct kobject *kobj,
> - struct bin_attribute *attr, int n)
> + const struct bin_attribute *attr, int n)
> {
> struct spi_device *spi = to_spi_device(kobj_to_dev(kobj));
> struct spi_mem *spimem = spi_get_drvdata(spi);
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 63370c76394ee9b8d514da074779617cef67c311..73e44d724f90f4cd8fe8cafb9fa0c0fb23078e61 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -298,7 +298,8 @@ static umode_t nvmem_bin_attr_get_umode(struct nvmem_device *nvmem)
> }
>
> static umode_t nvmem_bin_attr_is_visible(struct kobject *kobj,
> - struct bin_attribute *attr, int i)
> + const struct bin_attribute *attr,
> + int i)
> {
> struct device *dev = kobj_to_dev(kobj);
> struct nvmem_device *nvmem = to_nvmem_device(dev);
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index 040f01b2b999175e8d98b05851edc078bbabbe0d..13912940ed2bb66c0086e5bea9a3cb6417ac14dd 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -1326,7 +1326,7 @@ static struct bin_attribute *pci_dev_rom_attrs[] = {
> };
>
> static umode_t pci_dev_rom_attr_is_visible(struct kobject *kobj,
> - struct bin_attribute *a, int n)
> + const struct bin_attribute *a, int n)
> {
> struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
>
> diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c
> index e4300f5f304f3ca55a657fd25a1fa5ed919737a7..a469bcbc0da7f7677485c7f999f8dfb58b8ae8a3 100644
> --- a/drivers/pci/vpd.c
> +++ b/drivers/pci/vpd.c
> @@ -325,7 +325,7 @@ static struct bin_attribute *vpd_attrs[] = {
> };
>
> static umode_t vpd_attr_is_visible(struct kobject *kobj,
> - struct bin_attribute *a, int n)
> + const struct bin_attribute *a, int n)
> {
> struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
>
> diff --git a/drivers/platform/x86/amd/hsmp.c b/drivers/platform/x86/amd/hsmp.c
> index 8fcf38eed7f00ee01aade6e3e55e20402458d5aa..8f00850c139fa8d419bc1c140c1832bf84b2c3bd 100644
> --- a/drivers/platform/x86/amd/hsmp.c
> +++ b/drivers/platform/x86/amd/hsmp.c
> @@ -620,7 +620,7 @@ static int hsmp_get_tbl_dram_base(u16 sock_ind)
> }
>
> static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj,
> - struct bin_attribute *battr, int id)
> + const struct bin_attribute *battr, int id)
> {
> if (plat_dev.proto_ver == HSMP_PROTO_VER6)
> return battr->attr.mode;
> diff --git a/drivers/platform/x86/intel/sdsi.c b/drivers/platform/x86/intel/sdsi.c
> index 9d137621f0e6e7a23be0e0bbc6175c51c403169f..33f33b1070fdc949c1373251c3bca4234d9da119 100644
> --- a/drivers/platform/x86/intel/sdsi.c
> +++ b/drivers/platform/x86/intel/sdsi.c
> @@ -541,7 +541,7 @@ static struct bin_attribute *sdsi_bin_attrs[] = {
> };
>
> static umode_t
> -sdsi_battr_is_visible(struct kobject *kobj, struct bin_attribute *attr, int n)
> +sdsi_battr_is_visible(struct kobject *kobj, const struct bin_attribute *attr, int n)
> {
> struct device *dev = kobj_to_dev(kobj);
> struct sdsi_priv *priv = dev_get_drvdata(dev);
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index 32f94db6d6bf5d2bd289c1a121da7ffc6a7cb2ff..f3a1ecb42128a2b221ca5c362e041eb59dba0f20 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -1274,7 +1274,7 @@ static umode_t scsi_sdev_attr_is_visible(struct kobject *kobj,
> }
>
> static umode_t scsi_sdev_bin_attr_is_visible(struct kobject *kobj,
> - struct bin_attribute *attr, int i)
> + const struct bin_attribute *attr, int i)
> {
> struct device *dev = kobj_to_dev(kobj);
> struct scsi_device *sdev = to_scsi_device(dev);
> diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
> index 61b6d978892c799e213018bed22d9fb12a19d429..b4cba23831acd2d7d395b9f7683cd3ee3a8623c8 100644
> --- a/drivers/usb/core/sysfs.c
> +++ b/drivers/usb/core/sysfs.c
> @@ -925,7 +925,7 @@ static struct bin_attribute *dev_bin_attrs[] = {
> };
>
> static umode_t dev_bin_attrs_are_visible(struct kobject *kobj,
> - struct bin_attribute *a, int n)
> + const struct bin_attribute *a, int n)
> {
> struct device *dev = kobj_to_dev(kobj);
> struct usb_device *udev = to_usb_device(dev);
> diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
> index 4746cccb95898b24df6f53de9421ea7649b5568f..d1b22d56198b55ee39fe4c4fc994f5b753641992 100644
> --- a/include/linux/sysfs.h
> +++ b/include/linux/sysfs.h
> @@ -101,7 +101,7 @@ struct attribute_group {
> umode_t (*is_visible)(struct kobject *,
> struct attribute *, int);
> umode_t (*is_bin_visible)(struct kobject *,
> - struct bin_attribute *, int);
> + const struct bin_attribute *, int);
> size_t (*bin_size)(struct kobject *,
> const struct bin_attribute *,
> int);
> @@ -199,22 +199,22 @@ struct attribute_group {
> * attributes, the group visibility is determined by the function
> * specified to is_visible() not is_bin_visible()
> */
> -#define DEFINE_SYSFS_BIN_GROUP_VISIBLE(name) \
> - static inline umode_t sysfs_group_visible_##name( \
> - struct kobject *kobj, struct bin_attribute *attr, int n) \
> - { \
> - if (n == 0 && !name##_group_visible(kobj)) \
> - return SYSFS_GROUP_INVISIBLE; \
> - return name##_attr_visible(kobj, attr, n); \
> +#define DEFINE_SYSFS_BIN_GROUP_VISIBLE(name) \
> + static inline umode_t sysfs_group_visible_##name( \
> + struct kobject *kobj, const struct bin_attribute *attr, int n) \
> + { \
> + if (n == 0 && !name##_group_visible(kobj)) \
> + return SYSFS_GROUP_INVISIBLE; \
> + return name##_attr_visible(kobj, attr, n); \
> }
>
> -#define DEFINE_SIMPLE_SYSFS_BIN_GROUP_VISIBLE(name) \
> - static inline umode_t sysfs_group_visible_##name( \
> - struct kobject *kobj, struct bin_attribute *a, int n) \
> - { \
> - if (n == 0 && !name##_group_visible(kobj)) \
> - return SYSFS_GROUP_INVISIBLE; \
> - return a->mode; \
> +#define DEFINE_SIMPLE_SYSFS_BIN_GROUP_VISIBLE(name) \
> + static inline umode_t sysfs_group_visible_##name( \
> + struct kobject *kobj, const struct bin_attribute *a, int n) \
> + { \
> + if (n == 0 && !name##_group_visible(kobj)) \
> + return SYSFS_GROUP_INVISIBLE; \
> + return a->mode; \
> }
>
> #define SYSFS_GROUP_VISIBLE(fn) sysfs_group_visible_##fn
>
> --
> 2.47.0
>
next prev parent reply other threads:[~2024-11-05 15:26 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-03 17:03 [PATCH v2 00/10] sysfs: constify struct bin_attribute (Part 1) Thomas Weißschuh
2024-11-03 17:03 ` [PATCH v2 01/10] sysfs: explicitly pass size to sysfs_add_bin_file_mode_ns() Thomas Weißschuh
2024-11-03 17:03 ` [PATCH v2 02/10] sysfs: introduce callback attribute_group::bin_size Thomas Weißschuh
2024-11-05 16:12 ` Bjorn Helgaas
2024-11-06 19:27 ` Armin Wolf
2024-11-06 20:05 ` Krzysztof Wilczyński
2024-11-07 5:21 ` Greg Kroah-Hartman
2024-11-07 15:50 ` Krzysztof Wilczyński
2024-11-03 17:03 ` [PATCH v2 03/10] PCI/sysfs: Calculate bin_attribute size through bin_size() Thomas Weißschuh
2024-11-07 16:27 ` Bjorn Helgaas
2024-11-03 17:03 ` [PATCH v2 04/10] nvmem: core: calculate " Thomas Weißschuh
2024-11-08 9:58 ` Srinivas Kandagatla
2024-11-03 17:03 ` [PATCH v2 05/10] sysfs: treewide: constify attribute callback of bin_is_visible() Thomas Weißschuh
2024-11-04 13:25 ` Ilpo Järvinen
2024-11-04 13:52 ` Jason Gunthorpe
2024-11-04 14:56 ` Ira Weiny
2024-11-05 1:25 ` Martin K. Petersen
2024-11-05 15:26 ` Bjorn Helgaas [this message]
2024-11-07 17:20 ` Pratyush Yadav
2024-11-08 9:57 ` Srinivas Kandagatla
2024-11-03 17:03 ` [PATCH v2 06/10] sysfs: treewide: constify attribute callback of bin_attribute::mmap() Thomas Weißschuh
2024-11-04 1:24 ` Andrew Donnellan
2024-11-03 17:03 ` [PATCH v2 07/10] sysfs: treewide: constify attribute callback of bin_attribute::llseek() Thomas Weißschuh
2024-11-03 17:03 ` [PATCH v2 08/10] sysfs: implement all BIN_ATTR_* macros in terms of __BIN_ATTR() Thomas Weißschuh
2024-11-03 17:03 ` [PATCH v2 09/10] sysfs: bin_attribute: add const read/write callback variants Thomas Weißschuh
2024-12-03 16:06 ` James Bottomley
2024-12-03 16:11 ` Thomas Weißschuh
2024-11-03 17:03 ` [PATCH v2 10/10] driver core: Constify attribute arguments of binary attributes Thomas Weißschuh
2024-11-03 20:02 ` [PATCH v2 00/10] sysfs: constify struct bin_attribute (Part 1) Krzysztof Wilczyński
2024-11-05 16:15 ` Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241105152650.GA1472729@bhelgaas \
--to=helgaas@kernel.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@gmail.com \
--cc=ajd@linux.ibm.com \
--cc=alexander.deucher@amd.com \
--cc=alison.schofield@intel.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=arnd@arndb.de \
--cc=bhelgaas@google.com \
--cc=carlos.bilbao.osdev@gmail.com \
--cc=christian.koenig@amd.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=david.e.box@linux.intel.com \
--cc=decui@microsoft.com \
--cc=dennis.dalessandro@cornelisnetworks.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=fbarrat@linux.ibm.com \
--cc=gregkh@linuxfoundation.org \
--cc=haiyangz@microsoft.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=ira.weiny@intel.com \
--cc=jgg@ziepe.ca \
--cc=jonathan.cameron@huawei.com \
--cc=kys@microsoft.com \
--cc=leon@kernel.org \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=logang@deltatee.com \
--cc=martin.petersen@oracle.com \
--cc=mattst88@gmail.com \
--cc=miquel.raynal@bootlin.com \
--cc=mwalle@kernel.org \
--cc=naveenkrishna.chatradhi@amd.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=pratyush@kernel.org \
--cc=rafael@kernel.org \
--cc=richard.henderson@linaro.org \
--cc=richard@nod.at \
--cc=simona@ffwll.ch \
--cc=srinivas.kandagatla@linaro.org \
--cc=tudor.ambarus@linaro.org \
--cc=vigneshr@ti.com \
--cc=vishal.l.verma@intel.com \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).