diff options
author | Glauber de Oliveira Costa <gcosta@redhat.com> | 2008-01-17 16:19:42 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2008-01-30 06:50:18 -0500 |
commit | 382ac6b3fbc0ea6a5697fc6caaf7e7de12fa8b96 (patch) | |
tree | bdda012251f29775b2e1201f3b2b3e38c4680f42 /drivers/lguest/core.c | |
parent | 934faab464c6a26ed1a226b6cf7111b35405dde1 (diff) |
lguest: get rid of lg variable assignments
We can save some lines of code by getting rid of
*lg = cpu... lines of code spread everywhere by now.
Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/lguest/core.c')
-rw-r--r-- | drivers/lguest/core.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c index 6023872e32d0..7743d73768df 100644 --- a/drivers/lguest/core.c +++ b/drivers/lguest/core.c | |||
@@ -151,23 +151,23 @@ int lguest_address_ok(const struct lguest *lg, | |||
151 | /* This routine copies memory from the Guest. Here we can see how useful the | 151 | /* This routine copies memory from the Guest. Here we can see how useful the |
152 | * kill_lguest() routine we met in the Launcher can be: we return a random | 152 | * kill_lguest() routine we met in the Launcher can be: we return a random |
153 | * value (all zeroes) instead of needing to return an error. */ | 153 | * value (all zeroes) instead of needing to return an error. */ |
154 | void __lgread(struct lguest *lg, void *b, unsigned long addr, unsigned bytes) | 154 | void __lgread(struct lg_cpu *cpu, void *b, unsigned long addr, unsigned bytes) |
155 | { | 155 | { |
156 | if (!lguest_address_ok(lg, addr, bytes) | 156 | if (!lguest_address_ok(cpu->lg, addr, bytes) |
157 | || copy_from_user(b, lg->mem_base + addr, bytes) != 0) { | 157 | || copy_from_user(b, cpu->lg->mem_base + addr, bytes) != 0) { |
158 | /* copy_from_user should do this, but as we rely on it... */ | 158 | /* copy_from_user should do this, but as we rely on it... */ |
159 | memset(b, 0, bytes); | 159 | memset(b, 0, bytes); |
160 | kill_guest(lg, "bad read address %#lx len %u", addr, bytes); | 160 | kill_guest(cpu, "bad read address %#lx len %u", addr, bytes); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | /* This is the write (copy into guest) version. */ | 164 | /* This is the write (copy into guest) version. */ |
165 | void __lgwrite(struct lguest *lg, unsigned long addr, const void *b, | 165 | void __lgwrite(struct lg_cpu *cpu, unsigned long addr, const void *b, |
166 | unsigned bytes) | 166 | unsigned bytes) |
167 | { | 167 | { |
168 | if (!lguest_address_ok(lg, addr, bytes) | 168 | if (!lguest_address_ok(cpu->lg, addr, bytes) |
169 | || copy_to_user(lg->mem_base + addr, b, bytes) != 0) | 169 | || copy_to_user(cpu->lg->mem_base + addr, b, bytes) != 0) |
170 | kill_guest(lg, "bad write address %#lx len %u", addr, bytes); | 170 | kill_guest(cpu, "bad write address %#lx len %u", addr, bytes); |
171 | } | 171 | } |
172 | /*:*/ | 172 | /*:*/ |
173 | 173 | ||
@@ -176,10 +176,8 @@ void __lgwrite(struct lguest *lg, unsigned long addr, const void *b, | |||
176 | * going around and around until something interesting happens. */ | 176 | * going around and around until something interesting happens. */ |
177 | int run_guest(struct lg_cpu *cpu, unsigned long __user *user) | 177 | int run_guest(struct lg_cpu *cpu, unsigned long __user *user) |
178 | { | 178 | { |
179 | struct lguest *lg = cpu->lg; | ||
180 | |||
181 | /* We stop running once the Guest is dead. */ | 179 | /* We stop running once the Guest is dead. */ |
182 | while (!lg->dead) { | 180 | while (!cpu->lg->dead) { |
183 | /* First we run any hypercalls the Guest wants done. */ | 181 | /* First we run any hypercalls the Guest wants done. */ |
184 | if (cpu->hcall) | 182 | if (cpu->hcall) |
185 | do_hypercalls(cpu); | 183 | do_hypercalls(cpu); |
@@ -212,7 +210,7 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user) | |||
212 | 210 | ||
213 | /* Just make absolutely sure the Guest is still alive. One of | 211 | /* Just make absolutely sure the Guest is still alive. One of |
214 | * those hypercalls could have been fatal, for example. */ | 212 | * those hypercalls could have been fatal, for example. */ |
215 | if (lg->dead) | 213 | if (cpu->lg->dead) |
216 | break; | 214 | break; |
217 | 215 | ||
218 | /* If the Guest asked to be stopped, we sleep. The Guest's | 216 | /* If the Guest asked to be stopped, we sleep. The Guest's |
@@ -237,7 +235,7 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user) | |||
237 | lguest_arch_handle_trap(cpu); | 235 | lguest_arch_handle_trap(cpu); |
238 | } | 236 | } |
239 | 237 | ||
240 | if (lg->dead == ERR_PTR(-ERESTART)) | 238 | if (cpu->lg->dead == ERR_PTR(-ERESTART)) |
241 | return -ERESTART; | 239 | return -ERESTART; |
242 | /* The Guest is dead => "No such file or directory" */ | 240 | /* The Guest is dead => "No such file or directory" */ |
243 | return -ENOENT; | 241 | return -ENOENT; |