Skip to content

Commit 5136b2d

Browse files
gregkhbjorn-helgaas
authored andcommitted
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: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
1 parent 2229c1f commit 5136b2d

File tree

3 files changed

+48
-29
lines changed

3 files changed

+48
-29
lines changed

drivers/pci/pci-driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ struct bus_type pci_bus_type = {
13191319
.probe = pci_device_probe,
13201320
.remove = pci_device_remove,
13211321
.shutdown = pci_device_shutdown,
1322-
.dev_attrs = pci_dev_attrs,
1322+
.dev_groups = pci_dev_groups,
13231323
.bus_groups = pci_bus_groups,
13241324
.drv_groups = pci_drv_groups,
13251325
.pm = PCI_PM_OPS_PTR,

drivers/pci/pci-sysfs.c

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ field##_show(struct device *dev, struct device_attribute *attr, char *buf) \
4242
\
4343
pdev = to_pci_dev (dev); \
4444
return sprintf (buf, format_string, pdev->field); \
45-
}
45+
} \
46+
static DEVICE_ATTR_RO(field)
4647

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

7475
return count;
7576
}
77+
static DEVICE_ATTR_RW(broken_parity_status);
7678

7779
static ssize_t local_cpus_show(struct device *dev,
7880
struct device_attribute *attr, char *buf)
@@ -91,7 +93,7 @@ static ssize_t local_cpus_show(struct device *dev,
9193
buf[len] = '\0';
9294
return len;
9395
}
94-
96+
static DEVICE_ATTR_RO(local_cpus);
9597

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

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

174178
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
175179
{
@@ -181,10 +185,11 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
181185
(u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8),
182186
(u8)(pci_dev->class));
183187
}
188+
static DEVICE_ATTR_RO(modalias);
184189

185-
static ssize_t is_enabled_store(struct device *dev,
186-
struct device_attribute *attr, const char *buf,
187-
size_t count)
190+
static ssize_t enabled_store(struct device *dev,
191+
struct device_attribute *attr, const char *buf,
192+
size_t count)
188193
{
189194
struct pci_dev *pdev = to_pci_dev(dev);
190195
unsigned long val;
@@ -208,21 +213,23 @@ static ssize_t is_enabled_store(struct device *dev,
208213
return result < 0 ? result : count;
209214
}
210215

211-
static ssize_t is_enabled_show(struct device *dev,
212-
struct device_attribute *attr, char *buf)
216+
static ssize_t enabled_show(struct device *dev,
217+
struct device_attribute *attr, char *buf)
213218
{
214219
struct pci_dev *pdev;
215220

216221
pdev = to_pci_dev (dev);
217222
return sprintf (buf, "%u\n", atomic_read(&pdev->enable_cnt));
218223
}
224+
static DEVICE_ATTR_RW(enabled);
219225

220226
#ifdef CONFIG_NUMA
221227
static ssize_t
222228
numa_node_show(struct device *dev, struct device_attribute *attr, char *buf)
223229
{
224230
return sprintf (buf, "%d\n", dev->numa_node);
225231
}
232+
static DEVICE_ATTR_RO(numa_node);
226233
#endif
227234

228235
static ssize_t
@@ -232,13 +239,15 @@ dma_mask_bits_show(struct device *dev, struct device_attribute *attr, char *buf)
232239

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

236244
static ssize_t
237245
consistent_dma_mask_bits_show(struct device *dev, struct device_attribute *attr,
238246
char *buf)
239247
{
240248
return sprintf (buf, "%d\n", fls64(dev->coherent_dma_mask));
241249
}
250+
static DEVICE_ATTR_RO(consistent_dma_mask_bits);
242251

243252
static ssize_t
244253
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,
283292

284293
return count;
285294
}
295+
static DEVICE_ATTR_RW(msi_bus);
286296

287297
static DEFINE_MUTEX(pci_remove_rescan_mutex);
288298
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,
414424
struct pci_dev *pdev = to_pci_dev(dev);
415425
return sprintf (buf, "%u\n", pdev->d3cold_allowed);
416426
}
427+
static DEVICE_ATTR_RW(d3cold_allowed);
417428
#endif
418429

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

502-
struct device_attribute pci_dev_attrs[] = {
503-
__ATTR_RO(resource),
504-
__ATTR_RO(vendor),
505-
__ATTR_RO(device),
506-
__ATTR_RO(subsystem_vendor),
507-
__ATTR_RO(subsystem_device),
508-
__ATTR_RO(class),
509-
__ATTR_RO(irq),
510-
__ATTR_RO(local_cpus),
511-
__ATTR_RO(local_cpulist),
512-
__ATTR_RO(modalias),
513+
struct attribute *pci_dev_attrs[] = {
514+
&dev_attr_resource.attr,
515+
&dev_attr_vendor.attr,
516+
&dev_attr_device.attr,
517+
&dev_attr_subsystem_vendor.attr,
518+
&dev_attr_subsystem_device.attr,
519+
&dev_attr_class.attr,
520+
&dev_attr_irq.attr,
521+
&dev_attr_local_cpus.attr,
522+
&dev_attr_local_cpulist.attr,
523+
&dev_attr_modalias.attr,
513524
#ifdef CONFIG_NUMA
514-
__ATTR_RO(numa_node),
525+
&dev_attr_numa_node.attr,
515526
#endif
516-
__ATTR_RO(dma_mask_bits),
517-
__ATTR_RO(consistent_dma_mask_bits),
518-
__ATTR(enable, 0600, is_enabled_show, is_enabled_store),
519-
__ATTR(broken_parity_status,(S_IRUGO|S_IWUSR),
520-
broken_parity_status_show,broken_parity_status_store),
521-
__ATTR(msi_bus, 0644, msi_bus_show, msi_bus_store),
527+
&dev_attr_dma_mask_bits.attr,
528+
&dev_attr_consistent_dma_mask_bits.attr,
529+
&dev_attr_enabled.attr,
530+
&dev_attr_broken_parity_status.attr,
531+
&dev_attr_msi_bus.attr,
522532
#if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI)
523-
__ATTR(d3cold_allowed, 0644, d3cold_allowed_show, d3cold_allowed_store),
533+
&dev_attr_d3cold_allowed.attr,
524534
#endif
525-
__ATTR_NULL,
535+
NULL,
536+
};
537+
538+
static const struct attribute_group pci_dev_group = {
539+
.attrs = pci_dev_attrs,
540+
};
541+
542+
const struct attribute_group *pci_dev_groups[] = {
543+
&pci_dev_group,
544+
NULL,
526545
};
527546

528547
static struct attribute *pcibus_attrs[] = {

drivers/pci/pci.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static inline int pci_no_d1d2(struct pci_dev *dev)
153153
return (dev->no_d1d2 || parent_dstates);
154154

155155
}
156-
extern struct device_attribute pci_dev_attrs[];
156+
extern const struct attribute_group *pci_dev_groups[];
157157
extern const struct attribute_group *pcibus_groups[];
158158
extern struct device_type pci_dev_type;
159159
extern const struct attribute_group *pci_bus_groups[];

0 commit comments

Comments
 (0)