Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5136b2da authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Bjorn Helgaas
Browse files

PCI: convert bus code to use dev_groups



The dev_attrs field of struct bus_type is going away soon, dev_groups
should be used instead.  This converts the PCI bus code to use the
correct field.

Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent 2229c1fb
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1319,7 +1319,7 @@ struct bus_type pci_bus_type = {
	.probe		= pci_device_probe,
	.probe		= pci_device_probe,
	.remove		= pci_device_remove,
	.remove		= pci_device_remove,
	.shutdown	= pci_device_shutdown,
	.shutdown	= pci_device_shutdown,
	.dev_attrs	= pci_dev_attrs,
	.dev_groups	= pci_dev_groups,
	.bus_groups	= pci_bus_groups,
	.bus_groups	= pci_bus_groups,
	.drv_groups	= pci_drv_groups,
	.drv_groups	= pci_drv_groups,
	.pm		= PCI_PM_OPS_PTR,
	.pm		= PCI_PM_OPS_PTR,
+46 −27
Original line number Original line Diff line number Diff line
@@ -42,7 +42,8 @@ field##_show(struct device *dev, struct device_attribute *attr, char *buf) \
									\
									\
	pdev = to_pci_dev (dev);					\
	pdev = to_pci_dev (dev);					\
	return sprintf (buf, format_string, pdev->field);		\
	return sprintf (buf, format_string, pdev->field);		\
}
}									\
static DEVICE_ATTR_RO(field)


pci_config_attr(vendor, "0x%04x\n");
pci_config_attr(vendor, "0x%04x\n");
pci_config_attr(device, "0x%04x\n");
pci_config_attr(device, "0x%04x\n");
@@ -73,6 +74,7 @@ static ssize_t broken_parity_status_store(struct device *dev,


	return count;
	return count;
}
}
static DEVICE_ATTR_RW(broken_parity_status);


static ssize_t local_cpus_show(struct device *dev,
static ssize_t local_cpus_show(struct device *dev,
			struct device_attribute *attr, char *buf)
			struct device_attribute *attr, char *buf)
@@ -91,7 +93,7 @@ static ssize_t local_cpus_show(struct device *dev,
	buf[len] = '\0';
	buf[len] = '\0';
	return len;
	return len;
}
}

static DEVICE_ATTR_RO(local_cpus);


static ssize_t local_cpulist_show(struct device *dev,
static ssize_t local_cpulist_show(struct device *dev,
			struct device_attribute *attr, char *buf)
			struct device_attribute *attr, char *buf)
@@ -110,6 +112,7 @@ static ssize_t local_cpulist_show(struct device *dev,
	buf[len] = '\0';
	buf[len] = '\0';
	return len;
	return len;
}
}
static DEVICE_ATTR_RO(local_cpulist);


/*
/*
 * PCI Bus Class Devices
 * PCI Bus Class Devices
@@ -170,6 +173,7 @@ resource_show(struct device * dev, struct device_attribute *attr, char * buf)
	}
	}
	return (str - buf);
	return (str - buf);
}
}
static DEVICE_ATTR_RO(resource);


static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
{
{
@@ -181,8 +185,9 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
		       (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8),
		       (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8),
		       (u8)(pci_dev->class));
		       (u8)(pci_dev->class));
}
}
static DEVICE_ATTR_RO(modalias);


static ssize_t is_enabled_store(struct device *dev,
static ssize_t enabled_store(struct device *dev,
			     struct device_attribute *attr, const char *buf,
			     struct device_attribute *attr, const char *buf,
			     size_t count)
			     size_t count)
{
{
@@ -208,7 +213,7 @@ static ssize_t is_enabled_store(struct device *dev,
	return result < 0 ? result : count;
	return result < 0 ? result : count;
}
}


static ssize_t is_enabled_show(struct device *dev,
static ssize_t enabled_show(struct device *dev,
			    struct device_attribute *attr, char *buf)
			    struct device_attribute *attr, char *buf)
{
{
	struct pci_dev *pdev;
	struct pci_dev *pdev;
@@ -216,6 +221,7 @@ static ssize_t is_enabled_show(struct device *dev,
	pdev = to_pci_dev (dev);
	pdev = to_pci_dev (dev);
	return sprintf (buf, "%u\n", atomic_read(&pdev->enable_cnt));
	return sprintf (buf, "%u\n", atomic_read(&pdev->enable_cnt));
}
}
static DEVICE_ATTR_RW(enabled);


#ifdef CONFIG_NUMA
#ifdef CONFIG_NUMA
static ssize_t
static ssize_t
@@ -223,6 +229,7 @@ numa_node_show(struct device *dev, struct device_attribute *attr, char *buf)
{
{
	return sprintf (buf, "%d\n", dev->numa_node);
	return sprintf (buf, "%d\n", dev->numa_node);
}
}
static DEVICE_ATTR_RO(numa_node);
#endif
#endif


static ssize_t
static ssize_t
@@ -232,6 +239,7 @@ dma_mask_bits_show(struct device *dev, struct device_attribute *attr, char *buf)


	return sprintf (buf, "%d\n", fls64(pdev->dma_mask));
	return sprintf (buf, "%d\n", fls64(pdev->dma_mask));
}
}
static DEVICE_ATTR_RO(dma_mask_bits);


static ssize_t
static ssize_t
consistent_dma_mask_bits_show(struct device *dev, struct device_attribute *attr,
consistent_dma_mask_bits_show(struct device *dev, struct device_attribute *attr,
@@ -239,6 +247,7 @@ consistent_dma_mask_bits_show(struct device *dev, struct device_attribute *attr,
{
{
	return sprintf (buf, "%d\n", fls64(dev->coherent_dma_mask));
	return sprintf (buf, "%d\n", fls64(dev->coherent_dma_mask));
}
}
static DEVICE_ATTR_RO(consistent_dma_mask_bits);


static ssize_t
static ssize_t
msi_bus_show(struct device *dev, struct device_attribute *attr, char *buf)
msi_bus_show(struct device *dev, struct device_attribute *attr, char *buf)
@@ -283,6 +292,7 @@ msi_bus_store(struct device *dev, struct device_attribute *attr,


	return count;
	return count;
}
}
static DEVICE_ATTR_RW(msi_bus);


static DEFINE_MUTEX(pci_remove_rescan_mutex);
static DEFINE_MUTEX(pci_remove_rescan_mutex);
static ssize_t bus_rescan_store(struct bus_type *bus, const char *buf,
static ssize_t bus_rescan_store(struct bus_type *bus, const char *buf,
@@ -414,6 +424,7 @@ static ssize_t d3cold_allowed_show(struct device *dev,
	struct pci_dev *pdev = to_pci_dev(dev);
	struct pci_dev *pdev = to_pci_dev(dev);
	return sprintf (buf, "%u\n", pdev->d3cold_allowed);
	return sprintf (buf, "%u\n", pdev->d3cold_allowed);
}
}
static DEVICE_ATTR_RW(d3cold_allowed);
#endif
#endif


#ifdef CONFIG_PCI_IOV
#ifdef CONFIG_PCI_IOV
@@ -499,30 +510,38 @@ static struct device_attribute sriov_numvfs_attr =
		       sriov_numvfs_show, sriov_numvfs_store);
		       sriov_numvfs_show, sriov_numvfs_store);
#endif /* CONFIG_PCI_IOV */
#endif /* CONFIG_PCI_IOV */


struct device_attribute pci_dev_attrs[] = {
struct attribute *pci_dev_attrs[] = {
	__ATTR_RO(resource),
	&dev_attr_resource.attr,
	__ATTR_RO(vendor),
	&dev_attr_vendor.attr,
	__ATTR_RO(device),
	&dev_attr_device.attr,
	__ATTR_RO(subsystem_vendor),
	&dev_attr_subsystem_vendor.attr,
	__ATTR_RO(subsystem_device),
	&dev_attr_subsystem_device.attr,
	__ATTR_RO(class),
	&dev_attr_class.attr,
	__ATTR_RO(irq),
	&dev_attr_irq.attr,
	__ATTR_RO(local_cpus),
	&dev_attr_local_cpus.attr,
	__ATTR_RO(local_cpulist),
	&dev_attr_local_cpulist.attr,
	__ATTR_RO(modalias),
	&dev_attr_modalias.attr,
#ifdef CONFIG_NUMA
#ifdef CONFIG_NUMA
	__ATTR_RO(numa_node),
	&dev_attr_numa_node.attr,
#endif
#endif
	__ATTR_RO(dma_mask_bits),
	&dev_attr_dma_mask_bits.attr,
	__ATTR_RO(consistent_dma_mask_bits),
	&dev_attr_consistent_dma_mask_bits.attr,
	__ATTR(enable, 0600, is_enabled_show, is_enabled_store),
	&dev_attr_enabled.attr,
	__ATTR(broken_parity_status,(S_IRUGO|S_IWUSR),
	&dev_attr_broken_parity_status.attr,
		broken_parity_status_show,broken_parity_status_store),
	&dev_attr_msi_bus.attr,
	__ATTR(msi_bus, 0644, msi_bus_show, msi_bus_store),
#if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI)
#if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI)
	__ATTR(d3cold_allowed, 0644, d3cold_allowed_show, d3cold_allowed_store),
	&dev_attr_d3cold_allowed.attr,
#endif
#endif
	__ATTR_NULL,
	NULL,
};

static const struct attribute_group pci_dev_group = {
	.attrs = pci_dev_attrs,
};

const struct attribute_group *pci_dev_groups[] = {
	&pci_dev_group,
	NULL,
};
};


static struct attribute *pcibus_attrs[] = {
static struct attribute *pcibus_attrs[] = {
+1 −1
Original line number Original line Diff line number Diff line
@@ -153,7 +153,7 @@ static inline int pci_no_d1d2(struct pci_dev *dev)
	return (dev->no_d1d2 || parent_dstates);
	return (dev->no_d1d2 || parent_dstates);


}
}
extern struct device_attribute pci_dev_attrs[];
extern const struct attribute_group *pci_dev_groups[];
extern const struct attribute_group *pcibus_groups[];
extern const struct attribute_group *pcibus_groups[];
extern struct device_type pci_dev_type;
extern struct device_type pci_dev_type;
extern const struct attribute_group *pci_bus_groups[];
extern const struct attribute_group *pci_bus_groups[];