mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 09:16:33 +00:00
sysfs: treewide: constify attribute callback of bin_is_visible()
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: Martin K. Petersen <martin.petersen@oracle.com> Acked-by: Jason Gunthorpe <jgg@nvidia.com> Acked-by: Ira Weiny <ira.weiny@intel.com> Acked-by: Krzysztof Wilczyński <kw@linux.com> Link: https://lore.kernel.org/r/20241103-sysfs-const-bin_attr-v2-5-71110628844c@weissschuh.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
00ab6e97de
commit
b626816fdd
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user