aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-label.c
diff options
context:
space:
mode:
authorKrzysztof Wilczyński <kw@linux.com>2021-04-27 13:48:51 -0500
committerBjorn Helgaas <bhelgaas@google.com>2021-04-29 10:07:31 -0500
commit2ed6494155444dd4d2005869edce1ae73b4f23ca (patch)
tree896b3779d4f6b259b24997a33a7dd054ac79fc79 /drivers/pci/pci-label.c
parentPCI/sysfs: Rename device_has_dsm() to device_has_acpi_name() (diff)
downloadlinux-dev-2ed6494155444dd4d2005869edce1ae73b4f23ca.tar.xz
linux-dev-2ed6494155444dd4d2005869edce1ae73b4f23ca.zip
PCI/sysfs: Define ACPI label attributes with DEVICE_ATTR*()
Use DEVICE_ATTR*() to simplify definitions of the ACPI label attributes. No functional change intended. [bhelgaas: split to separate patch] Link: https://lore.kernel.org/r/20210416205856.3234481-6-kw@linux.com Signed-off-by: Krzysztof Wilczyński <kw@linux.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/pci-label.c')
-rw-r--r--drivers/pci/pci-label.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c
index 5fd5824db82f..4fef6fc0740f 100644
--- a/drivers/pci/pci-label.c
+++ b/drivers/pci/pci-label.c
@@ -225,50 +225,42 @@ static int dsm_get_label(struct device *dev, char *buf,
return len;
}
-static umode_t acpi_index_string_exist(struct kobject *kobj,
- struct attribute *attr, int n)
+static umode_t acpi_attr_is_visible(struct kobject *kobj, struct attribute *a,
+ int n)
{
struct device *dev;
dev = kobj_to_dev(kobj);
- if (device_has_acpi_name(dev))
- return S_IRUGO;
+ if (!device_has_acpi_name(dev))
+ return 0;
- return 0;
+ return a->mode;
}
-static ssize_t acpilabel_show(struct device *dev,
- struct device_attribute *attr, char *buf)
+static ssize_t label_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
{
return dsm_get_label(dev, buf, ACPI_ATTR_LABEL_SHOW);
}
+static DEVICE_ATTR_RO(label);
-static ssize_t acpiindex_show(struct device *dev,
+static ssize_t acpi_index_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return dsm_get_label(dev, buf, ACPI_ATTR_INDEX_SHOW);
}
+static DEVICE_ATTR_RO(acpi_index);
-static struct device_attribute acpi_attr_label = {
- .attr = {.name = "label", .mode = 0444},
- .show = acpilabel_show,
-};
-
-static struct device_attribute acpi_attr_index = {
- .attr = {.name = "acpi_index", .mode = 0444},
- .show = acpiindex_show,
-};
-
-static struct attribute *acpi_attributes[] = {
- &acpi_attr_label.attr,
- &acpi_attr_index.attr,
+static struct attribute *acpi_attrs[] = {
+ &dev_attr_label.attr,
+ &dev_attr_acpi_index.attr,
NULL,
};
static const struct attribute_group acpi_attr_group = {
- .attrs = acpi_attributes,
- .is_visible = acpi_index_string_exist,
+ .attrs = acpi_attrs,
+ .is_visible = acpi_attr_is_visible,
};
static int pci_create_acpi_index_label_files(struct pci_dev *pdev)