Skip to contentSkip to conversation

PCI: Improve printout in pdev_sort_resources()

PATCH In review Ilpo Järvinen 3 participants 5 messages Oct 17, 2024 PCI

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 PCI: Improve printout in pdev_sort_resources()

Use pci_resource_name() helper in pdev_sort_resources() to print resources in user-friendly format. Also replace the vague "bogus alignment" with a more precise explanation of the problem.

---

v2:
- Place colon after %s %pR to be consistent with other printouts
- Replace vague "bogus alignment" with the exact cause

 drivers/pci/setup-bus.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/setup-bus.c +3 -2
index 23082bc0ca37..0fd286f79674 100644
@@ -134,6 +134,7 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head)
 	int i;
 
 	pci_dev_for_each_resource(dev, r, i) {
+		const char *r_name = pci_resource_name(dev, i);
 		struct pci_dev_resource *dev_res, *tmp;
 		resource_size_t r_align;
 		struct list_head *n;
@@ -146,8 +147,8 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head)
 
 		r_align = pci_resource_alignment(dev, r);
 		if (!r_align) {
-			pci_warn(dev, "BAR %d: %pR has bogus alignment\n",
-				 i, r);
+			pci_warn(dev, "%s %pR: alignment must not be zero\n",
+				 r_name, r);
 			continue;
 		}
 
Signature · 1 line
2.39.5
#1 lore raw
Quoted 27 lines · On Thu, 17 Oct 2024 12:55:45 +0300 Ilpo Järvinen…

Use pci_resource_name() helper in pdev_sort_resources() to print resources in user-friendly format. Also replace the vague "bogus alignment" with a more precise explanation of the problem.

---

v2:
- Place colon after %s %pR to be consistent with other printouts
- Replace vague "bogus alignment" with the exact cause

 drivers/pci/setup-bus.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/setup-bus.c +1 -0
index 23082bc0ca37..0fd286f79674 100644
@@ -134,6 +134,7 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head)
 	int i;
 
 	pci_dev_for_each_resource(dev, r, i) {
+		const char *r_name = pci_resource_name(dev, i);
 		struct pci_dev_resource *dev_res, *tmp;
 		resource_size_t r_align;
 		struct list_head *n;

drivers/pci/setup-bus.c static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head) · line 151

Quoted 7 lines
drivers/pci/setup-bus.c +2 -2
@@ -146,8 +147,8 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head)
 
 		r_align = pci_resource_alignment(dev, r);
 		if (!r_align) {
-			pci_warn(dev, "BAR %d: %pR has bogus alignment\n",
-				 i, r);
+			pci_warn(dev, "%s %pR: alignment must not be zero\n",
+				 r_name, r);

Why bother with local variable if only used here?
Absolutely fine if you have more code coming that uses it again though!

Otherwise seems sensible change.

Quoted 3 lines
drivers/pci/setup-bus.c +0 -0
 			continue;
 		}
 
#2 lore raw
Quoted 31 lines · Jonathan Cameron
Quoted 28 lines · On Thu, 17 Oct 2024 12:55:45 +0300 Ilpo Järvinen…

Use pci_resource_name() helper in pdev_sort_resources() to print resources in user-friendly format. Also replace the vague "bogus alignment" with a more precise explanation of the problem.

---

v2:
- Place colon after %s %pR to be consistent with other printouts
- Replace vague "bogus alignment" with the exact cause

 drivers/pci/setup-bus.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/setup-bus.c +1 -0
index 23082bc0ca37..0fd286f79674 100644
@@ -134,6 +134,7 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head)
 	int i;
 
 	pci_dev_for_each_resource(dev, r, i) {
+		const char *r_name = pci_resource_name(dev, i);
 		struct pci_dev_resource *dev_res, *tmp;
 		resource_size_t r_align;
 		struct list_head *n;
@@ -146,8 +147,8 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head)
 
Quoted 8 lines

drivers/pci/setup-bus.c static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head) · line 151

Quoted 6 lines
drivers/pci/setup-bus.c +2 -2
 		r_align = pci_resource_alignment(dev, r);
 		if (!r_align) {
-			pci_warn(dev, "BAR %d: %pR has bogus alignment\n",
-				 i, r);
+			pci_warn(dev, "%s %pR: alignment must not be zero\n",
+				 r_name, r);

Why bother with local variable if only used here?

No other reason than it seems to always be a local variable in the other places too regardless the number of uses.

Quoted 3 lines

Absolutely fine if you have more code coming that uses it again though!

Otherwise seems sensible change.

Signature · 1 line
 i.
#3 lore raw
Quoted 42 lines · On Thu, 17 Oct 2024 14:35:55 +0300 (EEST) Ilpo Järvinen…
Quoted 31 lines · Jonathan Cameron
Quoted 28 lines · On Thu, 17 Oct 2024 12:55:45 +0300 Ilpo Järvinen…

Use pci_resource_name() helper in pdev_sort_resources() to print resources in user-friendly format. Also replace the vague "bogus alignment" with a more precise explanation of the problem.

---

v2:
- Place colon after %s %pR to be consistent with other printouts
- Replace vague "bogus alignment" with the exact cause

 drivers/pci/setup-bus.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/setup-bus.c +1 -0
index 23082bc0ca37..0fd286f79674 100644
@@ -134,6 +134,7 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head)
 	int i;
 
 	pci_dev_for_each_resource(dev, r, i) {
+		const char *r_name = pci_resource_name(dev, i);
 		struct pci_dev_resource *dev_res, *tmp;
 		resource_size_t r_align;
 		struct list_head *n;
@@ -146,8 +147,8 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head)
 
Quoted 8 lines

drivers/pci/setup-bus.c static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head) · line 151

Quoted 6 lines
drivers/pci/setup-bus.c +2 -2
 		r_align = pci_resource_alignment(dev, r);
 		if (!r_align) {
-			pci_warn(dev, "BAR %d: %pR has bogus alignment\n",
-				 i, r);
+			pci_warn(dev, "%s %pR: alignment must not be zero\n",
+				 r_name, r);  

Why bother with local variable if only used here?

Quoted 2 lines

No other reason than it seems to always be a local variable in the other places too regardless the number of uses.

Fair enough. local style is perfectly valid reasoning.

Jonathan

Quoted 5 lines
Quoted 4 lines

Absolutely fine if you have more code coming that uses it again though!

Otherwise seems sensible change.

Reviewed-by on v2 1/1
#4 lore raw
In reply to Ilpo Järvinen
Quoted 5 lines · Ilpo Järvinen

Use pci_resource_name() helper in pdev_sort_resources() to print resources in user-friendly format. Also replace the vague "bogus alignment" with a more precise explanation of the problem.

Quoted 36 lines

---

v2:
- Place colon after %s %pR to be consistent with other printouts
- Replace vague "bogus alignment" with the exact cause

 drivers/pci/setup-bus.c | 5 +++--

 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/setup-bus.c +0 -0
index 23082bc0ca37..0fd286f79674 100644
@@ -134,6 +134,7 @@ static void pdev_sort_resources(struct pci_dev
 *dev, struct list_head *head)
  	int i;


  pci_dev_for_each_resource(dev, r, i) {

drivers/pci/setup-bus.c +1 -0
+		const char *r_name = pci_resource_name(dev, i);

  struct pci_dev_resource *dev_res, *tmp; resource_size_t r_align; struct list_head *n;

drivers/pci/setup-bus.c +0 -0
@@ -146,8 +147,8 @@ static void pdev_sort_resources(struct pci_dev
 *dev, struct list_head *head)


  r_align = pci_resource_alignment(dev, r); if (!r_align) {

drivers/pci/setup-bus.c +0 -1
-			pci_warn(dev, "BAR %d: %pR has bogus

alignment\n",

drivers/pci/setup-bus.c +1 -1
-				 i, r);
+			pci_warn(dev, "%s %pR: alignment must not be

zero\n",

drivers/pci/setup-bus.c +1 -0
+				 r_name, r);

  continue;
  }