* [PATCH 0/3] PCI/sysfs: Follow-up to the static attribute conversion
@ 2026-07-21 2:04 Krzysztof Wilczyński
2026-07-21 2:04 ` [PATCH 1/3] PCI/sysfs: Add pci_ prefix to static PCI resource attribute names Krzysztof Wilczyński
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Krzysztof Wilczyński @ 2026-07-21 2:04 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Bjorn Helgaas, Manivannan Sadhasivam, Lorenzo Pieralisi,
linux-pci
Hello,
This series is a follow-up to the PCI sysfs static attribute
conversion [1], carrying the clean-up changes from its v8 revision.
The v7 revision of the series was applied and went out with the PCI
pull request for 7.2 [2], so the changes from v8 did not land in time
to make the 7.2 release.
The series consists of three clean-ups:
- Add the pci_ prefix to the generated PCI resource attribute names
dev_resourceN_{io,uc,wc}_attr, for consistency with the macros
that generate them and the arrays that collect them.
- Make the attribute name suffix the first parameter of Alpha's
__pci_dev_resource_attr() macro, resolving a checkpatch.pl
complaint about two consecutive commas.
- Add the pci_legacy_resource_{io,mem}_attr() macros, and use them
for the legacy I/O and memory attribute definitions instead of
open-coding each struct bin_attribute.
These correspond to the items listed under "Changes in v8" in the v8
cover letter [1].
No functional changes intended.
1. https://lore.kernel.org/linux-pci/20260619085200.3729431-1-kwilczynski@kernel.org/
2. https://lore.kernel.org/linux-pci/20260624110021.GA996382@bhelgaas/
Krzysztof Wilczyński (3):
PCI/sysfs: Add pci_ prefix to static PCI resource attribute names
alpha/PCI: Make the suffix the first __pci_dev_resource_attr()
parameter
PCI/sysfs: Add legacy I/O and memory attribute macros
arch/alpha/kernel/pci-sysfs.c | 26 ++++----
drivers/pci/pci-sysfs.c | 119 ++++++++++++++++------------------
2 files changed, 68 insertions(+), 77 deletions(-)
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] PCI/sysfs: Add pci_ prefix to static PCI resource attribute names
2026-07-21 2:04 [PATCH 0/3] PCI/sysfs: Follow-up to the static attribute conversion Krzysztof Wilczyński
@ 2026-07-21 2:04 ` Krzysztof Wilczyński
2026-07-21 2:07 ` sashiko-bot
2026-07-21 2:04 ` [PATCH 2/3] alpha/PCI: Make the suffix the first __pci_dev_resource_attr() parameter Krzysztof Wilczyński
2026-07-21 2:04 ` [PATCH 3/3] PCI/sysfs: Add legacy I/O and memory attribute macros Krzysztof Wilczyński
2 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Wilczyński @ 2026-07-21 2:04 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Bjorn Helgaas, Manivannan Sadhasivam, Lorenzo Pieralisi,
linux-pci
Currently, the static binary attributes for the PCI resource files are
generated with the names dev_resource<N>_io_attr, dev_resource<N>_uc_attr
and dev_resource<N>_wc_attr.
The macros that generate these attributes and the arrays that collect
them already carry the pci_ prefix, as do the sibling legacy I/O and
memory attributes, such as pci_legacy_io_attr. Only the generated
variable names lack it.
Thus, rename the generated variables to pci_dev_resource<N>_io_attr,
pci_dev_resource<N>_uc_attr and pci_dev_resource<N>_wc_attr, and update
the attribute pointer arrays to match.
While at it, re-align the continuation backslashes in the resource
attribute macros to match.
No functional changes intended.
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
drivers/pci/pci-sysfs.c | 60 ++++++++++++++++++++---------------------
1 file changed, 30 insertions(+), 30 deletions(-)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 5ec0b245a69b..cb7a121e5988 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1239,16 +1239,16 @@ static loff_t pci_llseek_resource(struct file *filep,
* attribute, it's not going to work, so override it as well.
*/
#if arch_can_pci_mmap_io()
-# define __PCI_RESOURCE_IO_MMAP_ATTRS \
- .f_mapping = iomem_get_mapping, \
- .llseek = pci_llseek_resource, \
+# define __PCI_RESOURCE_IO_MMAP_ATTRS \
+ .f_mapping = iomem_get_mapping, \
+ .llseek = pci_llseek_resource, \
.mmap = pci_mmap_resource_uc,
#else
# define __PCI_RESOURCE_IO_MMAP_ATTRS
#endif
#define pci_dev_resource_io_attr(_bar) \
-static const struct bin_attribute dev_resource##_bar##_io_attr = { \
+static const struct bin_attribute pci_dev_resource##_bar##_io_attr = { \
.attr = { .name = "resource" __stringify(_bar), .mode = 0600 }, \
.private = (void *)(unsigned long)(_bar), \
.read = pci_read_resource, \
@@ -1257,7 +1257,7 @@ static const struct bin_attribute dev_resource##_bar##_io_attr = { \
}
#define pci_dev_resource_uc_attr(_bar) \
-static const struct bin_attribute dev_resource##_bar##_uc_attr = { \
+static const struct bin_attribute pci_dev_resource##_bar##_uc_attr = { \
.attr = { .name = "resource" __stringify(_bar), .mode = 0600 }, \
.private = (void *)(unsigned long)(_bar), \
.f_mapping = iomem_get_mapping, \
@@ -1265,13 +1265,13 @@ static const struct bin_attribute dev_resource##_bar##_uc_attr = { \
.mmap = pci_mmap_resource_uc, \
}
-#define pci_dev_resource_wc_attr(_bar) \
-static const struct bin_attribute dev_resource##_bar##_wc_attr = { \
- .attr = { .name = "resource" __stringify(_bar) "_wc", .mode = 0600 }, \
- .private = (void *)(unsigned long)(_bar), \
- .f_mapping = iomem_get_mapping, \
- .llseek = pci_llseek_resource, \
- .mmap = pci_mmap_resource_wc, \
+#define pci_dev_resource_wc_attr(_bar) \
+static const struct bin_attribute pci_dev_resource##_bar##_wc_attr = { \
+ .attr = { .name = "resource" __stringify(_bar) "_wc", .mode = 0600 }, \
+ .private = (void *)(unsigned long)(_bar), \
+ .f_mapping = iomem_get_mapping, \
+ .llseek = pci_llseek_resource, \
+ .mmap = pci_mmap_resource_wc, \
}
static inline umode_t
@@ -1352,32 +1352,32 @@ pci_dev_resource_wc_attr(4);
pci_dev_resource_wc_attr(5);
static const struct bin_attribute *const pci_dev_resource_io_attrs[] = {
- &dev_resource0_io_attr,
- &dev_resource1_io_attr,
- &dev_resource2_io_attr,
- &dev_resource3_io_attr,
- &dev_resource4_io_attr,
- &dev_resource5_io_attr,
+ &pci_dev_resource0_io_attr,
+ &pci_dev_resource1_io_attr,
+ &pci_dev_resource2_io_attr,
+ &pci_dev_resource3_io_attr,
+ &pci_dev_resource4_io_attr,
+ &pci_dev_resource5_io_attr,
NULL,
};
static const struct bin_attribute *const pci_dev_resource_uc_attrs[] = {
- &dev_resource0_uc_attr,
- &dev_resource1_uc_attr,
- &dev_resource2_uc_attr,
- &dev_resource3_uc_attr,
- &dev_resource4_uc_attr,
- &dev_resource5_uc_attr,
+ &pci_dev_resource0_uc_attr,
+ &pci_dev_resource1_uc_attr,
+ &pci_dev_resource2_uc_attr,
+ &pci_dev_resource3_uc_attr,
+ &pci_dev_resource4_uc_attr,
+ &pci_dev_resource5_uc_attr,
NULL,
};
static const struct bin_attribute *const pci_dev_resource_wc_attrs[] = {
- &dev_resource0_wc_attr,
- &dev_resource1_wc_attr,
- &dev_resource2_wc_attr,
- &dev_resource3_wc_attr,
- &dev_resource4_wc_attr,
- &dev_resource5_wc_attr,
+ &pci_dev_resource0_wc_attr,
+ &pci_dev_resource1_wc_attr,
+ &pci_dev_resource2_wc_attr,
+ &pci_dev_resource3_wc_attr,
+ &pci_dev_resource4_wc_attr,
+ &pci_dev_resource5_wc_attr,
NULL,
};
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] alpha/PCI: Make the suffix the first __pci_dev_resource_attr() parameter
2026-07-21 2:04 [PATCH 0/3] PCI/sysfs: Follow-up to the static attribute conversion Krzysztof Wilczyński
2026-07-21 2:04 ` [PATCH 1/3] PCI/sysfs: Add pci_ prefix to static PCI resource attribute names Krzysztof Wilczyński
@ 2026-07-21 2:04 ` Krzysztof Wilczyński
2026-07-21 2:07 ` sashiko-bot
2026-07-21 2:04 ` [PATCH 3/3] PCI/sysfs: Add legacy I/O and memory attribute macros Krzysztof Wilczyński
2 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Wilczyński @ 2026-07-21 2:04 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Bjorn Helgaas, Manivannan Sadhasivam, Lorenzo Pieralisi,
linux-pci
Currently, the __pci_dev_resource_attr() helper macro takes the
attribute name suffix as its third parameter, even though the suffix is
what distinguishes the three attribute variants built on top of it.
Additionally, the pci_dev_resource_attr() wrapper passes an empty
suffix, and with the suffix placed in the middle of the parameter list
its invocation contains two consecutive commas, which checkpatch.pl
highlights, as follows:
ERROR: space required after that ',' (ctx:VxO)
Thus, move the suffix to the front so that the variant selector comes
first and the empty argument follows the opening parenthesis, which
checkpatch.pl does not complain about. This also matches the parameter
order used by the PCI legacy I/O and memory attribute macros introduced
in a subsequent change.
No functional changes intended.
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
arch/alpha/kernel/pci-sysfs.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/arch/alpha/kernel/pci-sysfs.c b/arch/alpha/kernel/pci-sysfs.c
index 94dbc470cd6c..37cba711ade5 100644
--- a/arch/alpha/kernel/pci-sysfs.c
+++ b/arch/alpha/kernel/pci-sysfs.c
@@ -102,25 +102,25 @@ static int pci_mmap_resource_dense(struct file *filp, struct kobject *kobj,
return pci_mmap_resource(kobj, attr, vma, 0);
}
-#define __pci_dev_resource_attr(_bar, _name, _suffix, _mmap) \
-static const struct bin_attribute \
-pci_dev_resource##_bar##_suffix##_attr = { \
- .attr = { .name = __stringify(_name), .mode = 0600 }, \
- .private = (void *)(unsigned long)(_bar), \
- .mmap = (_mmap), \
+#define __pci_dev_resource_attr(_suffix, _bar, _name, _mmap) \
+static const struct bin_attribute \
+pci_dev_resource##_bar##_suffix##_attr = { \
+ .attr = { .name = __stringify(_name), .mode = 0600 }, \
+ .private = (void *)(unsigned long)(_bar), \
+ .mmap = (_mmap), \
}
-#define pci_dev_resource_attr(_bar) \
- __pci_dev_resource_attr(_bar, resource##_bar,, \
- pci_mmap_resource_dense)
+#define pci_dev_resource_attr(_bar) \
+ __pci_dev_resource_attr(, _bar, resource##_bar, \
+ pci_mmap_resource_dense)
#define pci_dev_resource_sparse_attr(_bar) \
- __pci_dev_resource_attr(_bar, resource##_bar##_sparse, _sparse, \
- pci_mmap_resource_sparse)
+ __pci_dev_resource_attr(_sparse, _bar, resource##_bar##_sparse, \
+ pci_mmap_resource_sparse)
#define pci_dev_resource_dense_attr(_bar) \
- __pci_dev_resource_attr(_bar, resource##_bar##_dense, _dense, \
- pci_mmap_resource_dense)
+ __pci_dev_resource_attr(_dense, _bar, resource##_bar##_dense, \
+ pci_mmap_resource_dense)
static int sparse_mem_mmap_fits(struct pci_dev *pdev, int num)
{
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] PCI/sysfs: Add legacy I/O and memory attribute macros
2026-07-21 2:04 [PATCH 0/3] PCI/sysfs: Follow-up to the static attribute conversion Krzysztof Wilczyński
2026-07-21 2:04 ` [PATCH 1/3] PCI/sysfs: Add pci_ prefix to static PCI resource attribute names Krzysztof Wilczyński
2026-07-21 2:04 ` [PATCH 2/3] alpha/PCI: Make the suffix the first __pci_dev_resource_attr() parameter Krzysztof Wilczyński
@ 2026-07-21 2:04 ` Krzysztof Wilczyński
2026-07-21 2:11 ` sashiko-bot
2 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Wilczyński @ 2026-07-21 2:04 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Bjorn Helgaas, Manivannan Sadhasivam, Lorenzo Pieralisi,
linux-pci
Currently, the static binary attributes for the PCI legacy I/O port
and ISA memory space files (legacy_io, legacy_io_sparse, legacy_mem and
legacy_mem_sparse) are open-coded, with each definition repeating the
same set of properties and callbacks.
Thus, add two macros for declaring such attributes:
- pci_legacy_resource_io_attr(), for legacy I/O port space (read/write)
- pci_legacy_resource_mem_attr(), for legacy memory space (mmap)
Each macro takes the fixed attribute size as a parameter.
Then, replace the open-coded definitions with the newly added macros.
No functional changes intended.
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
drivers/pci/pci-sysfs.c | 59 +++++++++++++++++------------------------
1 file changed, 25 insertions(+), 34 deletions(-)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index cb7a121e5988..26a10984a843 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -871,6 +871,27 @@ static const struct attribute_group pci_dev_config_attr_group = {
};
#ifdef HAVE_PCI_LEGACY
+
+#define pci_legacy_resource_io_attr(_suffix, _size) \
+static const struct bin_attribute pci_legacy_io##_suffix##_attr = { \
+ .attr = { .name = "legacy_io" __stringify(_suffix), .mode = 0600 }, \
+ .size = (_size), \
+ .read = pci_read_legacy_io, \
+ .write = pci_write_legacy_io, \
+ .f_mapping = iomem_get_mapping, \
+ .llseek = pci_llseek_resource_legacy, \
+ .mmap = pci_mmap_legacy_io, \
+}
+
+#define pci_legacy_resource_mem_attr(_suffix, _size) \
+static const struct bin_attribute pci_legacy_mem##_suffix##_attr = { \
+ .attr = { .name = "legacy_mem" __stringify(_suffix), .mode = 0600 }, \
+ .size = (_size), \
+ .f_mapping = iomem_get_mapping, \
+ .llseek = pci_llseek_resource_legacy, \
+ .mmap = pci_mmap_legacy_mem, \
+}
+
/**
* pci_read_legacy_io - read byte(s) from legacy I/O port space
* @filp: open sysfs file
@@ -1014,41 +1035,11 @@ static loff_t pci_llseek_resource_legacy(struct file *filep,
return fixed_size_llseek(filep, offset, whence, attr->size);
}
-static const struct bin_attribute pci_legacy_io_attr = {
- .attr = { .name = "legacy_io", .mode = 0600 },
- .size = PCI_LEGACY_IO_SIZE,
- .read = pci_read_legacy_io,
- .write = pci_write_legacy_io,
- .mmap = pci_mmap_legacy_io,
- .llseek = pci_llseek_resource_legacy,
- .f_mapping = iomem_get_mapping,
-};
+pci_legacy_resource_io_attr(, PCI_LEGACY_IO_SIZE);
+pci_legacy_resource_io_attr(_sparse, PCI_LEGACY_IO_SIZE << 5);
-static const struct bin_attribute pci_legacy_io_sparse_attr = {
- .attr = { .name = "legacy_io_sparse", .mode = 0600 },
- .size = PCI_LEGACY_IO_SIZE << 5,
- .read = pci_read_legacy_io,
- .write = pci_write_legacy_io,
- .mmap = pci_mmap_legacy_io,
- .llseek = pci_llseek_resource_legacy,
- .f_mapping = iomem_get_mapping,
-};
-
-static const struct bin_attribute pci_legacy_mem_attr = {
- .attr = { .name = "legacy_mem", .mode = 0600 },
- .size = PCI_LEGACY_MEM_SIZE,
- .mmap = pci_mmap_legacy_mem,
- .llseek = pci_llseek_resource_legacy,
- .f_mapping = iomem_get_mapping,
-};
-
-static const struct bin_attribute pci_legacy_mem_sparse_attr = {
- .attr = { .name = "legacy_mem_sparse", .mode = 0600 },
- .size = PCI_LEGACY_MEM_SIZE << 5,
- .mmap = pci_mmap_legacy_mem,
- .llseek = pci_llseek_resource_legacy,
- .f_mapping = iomem_get_mapping,
-};
+pci_legacy_resource_mem_attr(, PCI_LEGACY_MEM_SIZE);
+pci_legacy_resource_mem_attr(_sparse, PCI_LEGACY_MEM_SIZE << 5);
static const struct bin_attribute *const pci_legacy_io_attrs[] = {
&pci_legacy_io_attr,
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] alpha/PCI: Make the suffix the first __pci_dev_resource_attr() parameter
2026-07-21 2:04 ` [PATCH 2/3] alpha/PCI: Make the suffix the first __pci_dev_resource_attr() parameter Krzysztof Wilczyński
@ 2026-07-21 2:07 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-07-21 2:07 UTC (permalink / raw)
To: Krzysztof Wilczyński; +Cc: linux-pci
> Currently, the __pci_dev_resource_attr() helper macro takes the
> attribute name suffix as its third parameter, even though the suffix is
> what distinguishes the three attribute variants built on top of it.
>
> Additionally, the pci_dev_resource_attr() wrapper passes an empty
> suffix, and with the suffix placed in the middle of the parameter list
> its invocation contains two consecutive commas, which checkpatch.pl
> highlights, as follows:
>
> ERROR: space required after that ',' (ctx:VxO)
>
> Thus, move the suffix to the front so that the variant selector comes
> first and the empty argument follows the opening parenthesis, which
> checkpatch.pl does not complain about. This also matches the parameter
> order used by the PCI legacy I/O and memory attribute macros introduced
> in a subsequent change.
>
> No functional changes intended.
>
> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260721020427.1541197-1-kwilczynski@kernel.org?part=2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] PCI/sysfs: Add pci_ prefix to static PCI resource attribute names
2026-07-21 2:04 ` [PATCH 1/3] PCI/sysfs: Add pci_ prefix to static PCI resource attribute names Krzysztof Wilczyński
@ 2026-07-21 2:07 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-07-21 2:07 UTC (permalink / raw)
To: Krzysztof Wilczyński; +Cc: linux-pci
> Currently, the static binary attributes for the PCI resource files are
> generated with the names dev_resource<N>_io_attr, dev_resource<N>_uc_attr
> and dev_resource<N>_wc_attr.
>
> The macros that generate these attributes and the arrays that collect
> them already carry the pci_ prefix, as do the sibling legacy I/O and
> memory attributes, such as pci_legacy_io_attr. Only the generated
> variable names lack it.
>
> Thus, rename the generated variables to pci_dev_resource<N>_io_attr,
> pci_dev_resource<N>_uc_attr and pci_dev_resource<N>_wc_attr, and update
> the attribute pointer arrays to match.
>
> While at it, re-align the continuation backslashes in the resource
> attribute macros to match.
>
> No functional changes intended.
>
> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260721020427.1541197-1-kwilczynski@kernel.org?part=1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] PCI/sysfs: Add legacy I/O and memory attribute macros
2026-07-21 2:04 ` [PATCH 3/3] PCI/sysfs: Add legacy I/O and memory attribute macros Krzysztof Wilczyński
@ 2026-07-21 2:11 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-07-21 2:11 UTC (permalink / raw)
To: Krzysztof Wilczyński; +Cc: linux-pci
> Currently, the static binary attributes for the PCI legacy I/O port
> and ISA memory space files (legacy_io, legacy_io_sparse, legacy_mem and
> legacy_mem_sparse) are open-coded, with each definition repeating the
> same set of properties and callbacks.
>
> Thus, add two macros for declaring such attributes:
>
> - pci_legacy_resource_io_attr(), for legacy I/O port space (read/write)
> - pci_legacy_resource_mem_attr(), for legacy memory space (mmap)
>
> Each macro takes the fixed attribute size as a parameter.
>
> Then, replace the open-coded definitions with the newly added macros.
>
> No functional changes intended.
>
> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260721020427.1541197-1-kwilczynski@kernel.org?part=3
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-07-21 2:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-21 2:04 [PATCH 0/3] PCI/sysfs: Follow-up to the static attribute conversion Krzysztof Wilczyński
2026-07-21 2:04 ` [PATCH 1/3] PCI/sysfs: Add pci_ prefix to static PCI resource attribute names Krzysztof Wilczyński
2026-07-21 2:07 ` sashiko-bot
2026-07-21 2:04 ` [PATCH 2/3] alpha/PCI: Make the suffix the first __pci_dev_resource_attr() parameter Krzysztof Wilczyński
2026-07-21 2:07 ` sashiko-bot
2026-07-21 2:04 ` [PATCH 3/3] PCI/sysfs: Add legacy I/O and memory attribute macros Krzysztof Wilczyński
2026-07-21 2:11 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox