summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/kexec/kexec-tools/0001-kexec-exntend-the-semantics-of-kexec_iomem_for_each_.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-kernel/kexec/kexec-tools/0001-kexec-exntend-the-semantics-of-kexec_iomem_for_each_.patch')
-rw-r--r--meta/recipes-kernel/kexec/kexec-tools/0001-kexec-exntend-the-semantics-of-kexec_iomem_for_each_.patch78
1 files changed, 78 insertions, 0 deletions
diff --git a/meta/recipes-kernel/kexec/kexec-tools/0001-kexec-exntend-the-semantics-of-kexec_iomem_for_each_.patch b/meta/recipes-kernel/kexec/kexec-tools/0001-kexec-exntend-the-semantics-of-kexec_iomem_for_each_.patch
new file mode 100644
index 0000000000..822f28c44b
--- /dev/null
+++ b/meta/recipes-kernel/kexec/kexec-tools/0001-kexec-exntend-the-semantics-of-kexec_iomem_for_each_.patch
@@ -0,0 +1,78 @@
1From 02eed0f8f2748fd7579f69e5373445b52b2b8754 Mon Sep 17 00:00:00 2001
2From: AKASHI Takahiro <takahiro.akashi@linaro.org>
3Date: Mon, 17 Oct 2016 13:56:58 +0900
4Subject: [PATCH 1/9] kexec: exntend the semantics of kexec_iomem_for_each_line
5
6The current kexec_iomem_for_each_line() counts up all the lines for which
7a callback function returns zero(0) or positive, and otherwise it stops
8further scanning.
9This behavior is incovenient in some cases. For instance, on arm64, we want
10to count up "System RAM" entries, but need to skip "reserved" entries.
11
12So this patch extends the semantics so that we will continue to scan
13succeeding entries but not count lines for which a callback function
14returns positive.
15
16The current users of kexec_iomem_for_each_line(), arm, sh and x86, will not
17be affected by this change because
18* arm
19 The callback function only returns -1 or 0, and the return value of
20 kexec_iomem_for_each_line() will never be used.
21* sh, x86
22 The callback function may return (-1 for sh,) 0 or 1, but always returns
23 1 once we have reached the maximum number of entries allowed.
24 Even so the current kexec_iomem_for_each_line() counts them up.
25 This change actually fixes this bug.
26
27Upstream-Status: Backport [https://git.linaro.org/people/takahiro.akashi/kexec-tools.git]
28
29Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
30Signed-off-by: He Zhe <zhe.he@windriver.com>
31---
32 kexec/kexec-iomem.c | 15 ++++++++++-----
33 1 file changed, 10 insertions(+), 5 deletions(-)
34
35diff --git a/kexec/kexec-iomem.c b/kexec/kexec-iomem.c
36index 485a2e8..0a0277a 100644
37--- a/kexec/kexec-iomem.c
38+++ b/kexec/kexec-iomem.c
39@@ -18,6 +18,9 @@
40 * Iterate over each line in the file returned by proc_iomem(). If match is
41 * NULL or if the line matches with our match-pattern then call the
42 * callback if non-NULL.
43+ * If match is NULL, callback should return a negative if error.
44+ * Otherwise the interation goes on, incrementing nr but only if callback
45+ * returns 0 (matched).
46 *
47 * Return the number of lines matched.
48 */
49@@ -37,7 +40,7 @@ int kexec_iomem_for_each_line(char *match,
50 char *str;
51 int consumed;
52 int count;
53- int nr = 0;
54+ int nr = 0, ret;
55
56 fp = fopen(iomem, "r");
57 if (!fp)
58@@ -50,11 +53,13 @@ int kexec_iomem_for_each_line(char *match,
59 str = line + consumed;
60 size = end - start + 1;
61 if (!match || memcmp(str, match, strlen(match)) == 0) {
62- if (callback
63- && callback(data, nr, str, start, size) < 0) {
64- break;
65+ if (callback) {
66+ ret = callback(data, nr, str, start, size);
67+ if (ret < 0)
68+ break;
69+ else if (ret == 0)
70+ nr++;
71 }
72- nr++;
73 }
74 }
75
76--
771.9.1
78