Commit 7029705a9d0544186c29ae09708b3e5adb512835

Authored by Chen Gang
Committed by Benjamin Herrenschmidt
1 parent cce606feb4

powerpc/nvram64: Need return the related error code on failure occurs

When error occurs, need return the related error code to let upper
caller know about it.

ppc_md.nvram_size() can return the error code (e.g. core99_nvram_size()
in 'arch/powerpc/platforms/powermac/nvram.c').

Also set ret value when only need it, so can save structions for normal
cases.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Showing 1 changed file with 14 additions and 6 deletions Side-by-side Diff

arch/powerpc/kernel/nvram_64.c
... ... @@ -84,22 +84,30 @@
84 84 char *tmp = NULL;
85 85 ssize_t size;
86 86  
87   - ret = -ENODEV;
88   - if (!ppc_md.nvram_size)
  87 + if (!ppc_md.nvram_size) {
  88 + ret = -ENODEV;
89 89 goto out;
  90 + }
90 91  
91   - ret = 0;
92 92 size = ppc_md.nvram_size();
93   - if (*ppos >= size || size < 0)
  93 + if (size < 0) {
  94 + ret = size;
94 95 goto out;
  96 + }
95 97  
  98 + if (*ppos >= size) {
  99 + ret = 0;
  100 + goto out;
  101 + }
  102 +
96 103 count = min_t(size_t, count, size - *ppos);
97 104 count = min(count, PAGE_SIZE);
98 105  
99   - ret = -ENOMEM;
100 106 tmp = kmalloc(count, GFP_KERNEL);
101   - if (!tmp)
  107 + if (!tmp) {
  108 + ret = -ENOMEM;
102 109 goto out;
  110 + }
103 111  
104 112 ret = ppc_md.nvram_read(tmp, count, ppos);
105 113 if (ret <= 0)