Thread (21 messages) flat view 21 messages, 4 authors, 2019-02-13

Re: [PATCH 3/7] powerpc/eeh_cache: Add a way to dump the EEH address cache

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2019-02-11 02:18:23

Oliver [off-list ref] writes:
On Fri, Feb 8, 2019 at 8:47 PM Michael Ellerman [off-list ref] wrote:
quoted
Oliver O'Halloran [off-list ref] writes:
quoted
diff --git a/arch/powerpc/kernel/eeh_cache.c b/arch/powerpc/kernel/eeh_cache.c
index b2c320e0fcef..dba421a577e7 100644
--- a/arch/powerpc/kernel/eeh_cache.c
+++ b/arch/powerpc/kernel/eeh_cache.c
@@ -298,9 +299,34 @@ void eeh_addr_cache_build(void)
              eeh_addr_cache_insert_dev(dev);
              eeh_sysfs_add_device(dev);
      }
+}

-#ifdef DEBUG
-     /* Verify tree built up above, echo back the list of addrs. */
-     eeh_addr_cache_print(&pci_io_addr_cache_root);
-#endif
+static int eeh_addr_cache_show(struct seq_file *s, void *v)
+{
+     struct rb_node *n = rb_first(&pci_io_addr_cache_root.rb_root);
+     struct pci_io_addr_range *piar;
+     int cnt = 0;
+
+     spin_lock(&pci_io_addr_cache_root.piar_lock);
+     while (n) {
+             piar = rb_entry(n, struct pci_io_addr_range, rb_node);
+
+             seq_printf(s, "%s addr range %3d [%pap-%pap]: %s\n",
+                    (piar->flags & IORESOURCE_IO) ? "i/o" : "mem", cnt,
+                    &piar->addr_lo, &piar->addr_hi, pci_name(piar->pcidev));
+
+             n = rb_next(n);
+             cnt++;
+     }
You can write that as a for loop can't you?

        struct rb_node *n;
        int i = 0;

        for (n = rb_first(&pci_io_addr_cache_root.rb_root); n; n = rb_next(n), i++) {
IIRC I did try that, but it's too long. 85 cols wide according to my editor.
Don't care.

Long lines aren't inherently evil, they have some downsides but so do
the other options. In a case like this 85 columns would be preferable to
splitting the line or writing it a while loop.

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help