Re: [PATCH v2 05/10] sysfs: treewide: constify attribute callback of bin_is_visible()

2024-11-08 Thread Srinivas Kandagatla




On 03/11/2024 17:03, 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 
---
  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 +-


thanks for the patch.

Acked-by: Srinivas Kandagatla  #nvmem


--srini

  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 bi

Re: [PATCH v2 05/10] sysfs: treewide: constify attribute callback of bin_is_visible()

2024-11-07 Thread Pratyush Yadav
On Sun, Nov 03 2024, 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 
> ---
> 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)

Acked-by: Pratyush Yadav  # for spi-nor

>  {
>   struct spi_device *spi = to_spi_device(kobj_to_dev(kobj));
>   struct spi_mem *spimem = spi_get_drvdata(spi);

-- 
Regards,
Pratyush Yadav


Re: [PATCH v2 05/10] sysfs: treewide: constify attribute callback of bin_is_visible()

2024-11-05 Thread Bjorn Helgaas
On Sun, Nov 03, 2024 at 05:03:34PM +, 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 

Acked-by: Bjorn Helgaas# 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 *k

Re: [PATCH v2 05/10] sysfs: treewide: constify attribute callback of bin_is_visible()

2024-11-04 Thread Martin K. Petersen


Thomas,

> 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.

For scsi:

Acked-by: Martin K. Petersen 

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH v2 05/10] sysfs: treewide: constify attribute callback of bin_is_visible()

2024-11-04 Thread Ira Weiny
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 
> ---
>  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);

For CXL

Acked-by: Ira Weiny 


Re: [PATCH v2 05/10] sysfs: treewide: constify attribute callback of bin_is_visible()

2024-11-04 Thread Jason Gunthorpe
On Sun, Nov 03, 2024 at 05:03:34PM +, 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 
> ---
>  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(-)

For infiniband:

Acked-by: Jason Gunthorpe 


Re: [PATCH v2 05/10] sysfs: treewide: constify attribute callback of bin_is_visible()

2024-11-04 Thread Ilpo Järvinen
On Sun, 3 Nov 2024, 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 
> ---
>  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/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)

Hi Thomas,

This driver is reworked in pdx86/for-next.

-- 
 i.


>  {
>   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);