diff options
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_.patch | 78 |
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 @@ | |||
1 | From 02eed0f8f2748fd7579f69e5373445b52b2b8754 Mon Sep 17 00:00:00 2001 | ||
2 | From: AKASHI Takahiro <takahiro.akashi@linaro.org> | ||
3 | Date: Mon, 17 Oct 2016 13:56:58 +0900 | ||
4 | Subject: [PATCH 1/9] kexec: exntend the semantics of kexec_iomem_for_each_line | ||
5 | |||
6 | The current kexec_iomem_for_each_line() counts up all the lines for which | ||
7 | a callback function returns zero(0) or positive, and otherwise it stops | ||
8 | further scanning. | ||
9 | This behavior is incovenient in some cases. For instance, on arm64, we want | ||
10 | to count up "System RAM" entries, but need to skip "reserved" entries. | ||
11 | |||
12 | So this patch extends the semantics so that we will continue to scan | ||
13 | succeeding entries but not count lines for which a callback function | ||
14 | returns positive. | ||
15 | |||
16 | The current users of kexec_iomem_for_each_line(), arm, sh and x86, will not | ||
17 | be 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 | |||
27 | Upstream-Status: Backport [https://git.linaro.org/people/takahiro.akashi/kexec-tools.git] | ||
28 | |||
29 | Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> | ||
30 | Signed-off-by: He Zhe <zhe.he@windriver.com> | ||
31 | --- | ||
32 | kexec/kexec-iomem.c | 15 ++++++++++----- | ||
33 | 1 file changed, 10 insertions(+), 5 deletions(-) | ||
34 | |||
35 | diff --git a/kexec/kexec-iomem.c b/kexec/kexec-iomem.c | ||
36 | index 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 | -- | ||
77 | 1.9.1 | ||
78 | |||