mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-01 10:45:49 +00:00
PCI/sysfs: Calculate bin_attribute size through bin_size()
Stop abusing the is_bin_visible() callback to calculate the attribute size. Instead use the new, dedicated bin_size() one. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Krzysztof Wilczyński <kw@linux.com> Link: https://lore.kernel.org/r/20241103-sysfs-const-bin_attr-v2-3-71110628844c@weissschuh.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
bebf29b18f
commit
a1ab720ee5
@ -818,21 +818,20 @@ static struct bin_attribute *pci_dev_config_attrs[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static umode_t pci_dev_config_attr_is_visible(struct kobject *kobj,
|
||||
struct bin_attribute *a, int n)
|
||||
static size_t pci_dev_config_attr_bin_size(struct kobject *kobj,
|
||||
const struct bin_attribute *a,
|
||||
int n)
|
||||
{
|
||||
struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
|
||||
|
||||
a->size = PCI_CFG_SPACE_SIZE;
|
||||
if (pdev->cfg_size > PCI_CFG_SPACE_SIZE)
|
||||
a->size = PCI_CFG_SPACE_EXP_SIZE;
|
||||
|
||||
return a->attr.mode;
|
||||
return PCI_CFG_SPACE_EXP_SIZE;
|
||||
return PCI_CFG_SPACE_SIZE;
|
||||
}
|
||||
|
||||
static const struct attribute_group pci_dev_config_attr_group = {
|
||||
.bin_attrs = pci_dev_config_attrs,
|
||||
.is_bin_visible = pci_dev_config_attr_is_visible,
|
||||
.bin_size = pci_dev_config_attr_bin_size,
|
||||
};
|
||||
|
||||
/*
|
||||
@ -1330,21 +1329,26 @@ static umode_t pci_dev_rom_attr_is_visible(struct kobject *kobj,
|
||||
struct bin_attribute *a, int n)
|
||||
{
|
||||
struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
|
||||
size_t rom_size;
|
||||
|
||||
/* If the device has a ROM, try to expose it in sysfs. */
|
||||
rom_size = pci_resource_len(pdev, PCI_ROM_RESOURCE);
|
||||
if (!rom_size)
|
||||
if (!pci_resource_end(pdev, PCI_ROM_RESOURCE))
|
||||
return 0;
|
||||
|
||||
a->size = rom_size;
|
||||
|
||||
return a->attr.mode;
|
||||
}
|
||||
|
||||
static size_t pci_dev_rom_attr_bin_size(struct kobject *kobj,
|
||||
const struct bin_attribute *a, int n)
|
||||
{
|
||||
struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
|
||||
|
||||
return pci_resource_len(pdev, PCI_ROM_RESOURCE);
|
||||
}
|
||||
|
||||
static const struct attribute_group pci_dev_rom_attr_group = {
|
||||
.bin_attrs = pci_dev_rom_attrs,
|
||||
.is_bin_visible = pci_dev_rom_attr_is_visible,
|
||||
.bin_size = pci_dev_rom_attr_bin_size,
|
||||
};
|
||||
|
||||
static ssize_t reset_store(struct device *dev, struct device_attribute *attr,
|
||||
|
Loading…
Reference in New Issue
Block a user