From: Steven Rostedt <[email protected]>

Simplify the logic by removing the goto in the first condition and
inverting the logic of the early return.

This changes the reading logic slightly. Before, the goto would exit the
function right away with the output of missed events. The next read would
then update print the saved hiter->dev and update it.

Now, in one iteration, if count_overruns() retruns !0, the lost events is
printed as well as the next hiter->dev without needing a second loop.

Reviewed-by: Masami Hiramatsu (Google) <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
Changes since v1: 
https://patch.msgid.link/[email protected]

- Broke it up into two patches

 kernel/trace/trace_mmiotrace.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
index 0034d6af3d9d..c49738cdb439 100644
--- a/kernel/trace/trace_mmiotrace.c
+++ b/kernel/trace/trace_mmiotrace.c
@@ -143,16 +143,13 @@ static ssize_t mmio_read(struct trace_iterator *iter, 
struct file *filp,
                if (!overrun_detected)
                        pr_warn("mmiotrace has lost events\n");
                overrun_detected = true;
-               goto print_out;
        }
 
-       if (!hiter || !hiter->dev)
-               return 0;
-
-       mmio_print_pcidev(s, hiter->dev);
-       hiter->dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, hiter->dev);
+       if (hiter && hiter->dev) {
+               mmio_print_pcidev(s, hiter->dev);
+               hiter->dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, hiter->dev);
+       }
 
-print_out:
        ret = trace_seq_to_user(s, ubuf, cnt);
        return (ret == -EBUSY) ? 0 : ret;
 }
-- 
2.53.0



Reply via email to