From a94ae70c2e7e985ee8f3a11eceac62e1250a38bf Mon Sep 17 00:00:00 2001
From: c_ankurb <ankurb@codeaurora.org>
Date: Mon, 17 Oct 2016 17:39:00 +0530
Subject: [PATCH] lrdv_v2: fix for broken lpm.py

Changing variable name num_childs_in_sync -> num_children_in_sync
due to structure change in 3.18 kernel

Change-Id: I454f547959c861d0aced65b0006f40b583cf7b7a
---
 linux-ramdump-parser-v2/parsers/lpm.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/linux-ramdump-parser-v2/parsers/lpm.py b/linux-ramdump-parser-v2/parsers/lpm.py
index 5eb94cf..e02b138 100644
--- a/linux-ramdump-parser-v2/parsers/lpm.py
+++ b/linux-ramdump-parser-v2/parsers/lpm.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2015, The Linux Foundation. All rights reserved.
+# Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License version 2 and
@@ -117,10 +117,17 @@ class lpm(RamParser):
         offset = self.ramdump.field_offset('struct lpm_cluster', 'child_cpus')
         node = self.ramdump.read_int(lpm_cluster + offset)
         self.output.append("{:20}:{}({})\n".format("child_cpus", hex(node).rstrip("L"), bin(node).lstrip("0b")))
-
-        offset = self.ramdump.field_offset('struct lpm_cluster', 'num_childs_in_sync')
+        if (self.ramdump.kernel_version >= (3, 18, 0) or
+            self.ramdump.kernel_version < (3, 14, 0) ):
+                offset = self.ramdump.field_offset(
+                        'struct lpm_cluster', 'num_children_in_sync')
+        else:
+                offset = self.ramdump.field_offset(
+                        'struct lpm_cluster', 'num_childs_in_sync')
         node = self.ramdump.read_int(lpm_cluster + offset)
-        self.output.append("{:20}:{}({})\n".format("num_childs_in_sync", hex(node).rstrip("L"), bin(node).lstrip("0b")))
+        self.output.append("{:20}:{}({})\n".format(
+                "num_children_in_sync", hex(node).rstrip("L"),
+                    bin(node).lstrip("0b")))
         self.output.append("\n")
 
     def lpm_walker(self, lpm_cluster):
-- 
GitLab