diff options
author | Jesper Juhl <jesper.juhl@gmail.com> | 2006-05-01 15:15:57 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-05-01 21:17:44 -0400 |
commit | 191ef966ac164a1ce3e06290ca52296744a4aee2 (patch) | |
tree | 0b141e946ed9ff65d94d393ba15384b958793586 /arch/um/kernel/irq.c | |
parent | 893bb96a29bee4a5cf2486720ac79412aaee5066 (diff) |
[PATCH] uml: remove NULL checks and add some CodingStyle
Remove redundant NULL checks before [kv]free + small CodingStyle cleanup for
arch/
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/kernel/irq.c')
-rw-r--r-- | arch/um/kernel/irq.c | 93 |
1 files changed, 47 insertions, 46 deletions
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c index c39ea3abeda4..2ffda012385e 100644 --- a/arch/um/kernel/irq.c +++ b/arch/um/kernel/irq.c | |||
@@ -89,16 +89,18 @@ void sigio_handler(int sig, union uml_pt_regs *regs) | |||
89 | struct irq_fd *irq_fd; | 89 | struct irq_fd *irq_fd; |
90 | int n; | 90 | int n; |
91 | 91 | ||
92 | if(smp_sigio_handler()) return; | 92 | if (smp_sigio_handler()) |
93 | while(1){ | 93 | return; |
94 | |||
95 | while (1) { | ||
94 | n = os_waiting_for_events(active_fds); | 96 | n = os_waiting_for_events(active_fds); |
95 | if (n <= 0) { | 97 | if (n <= 0) { |
96 | if(n == -EINTR) continue; | 98 | if(n == -EINTR) continue; |
97 | else break; | 99 | else break; |
98 | } | 100 | } |
99 | 101 | ||
100 | for(irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next){ | 102 | for (irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next) { |
101 | if(irq_fd->current_events != 0){ | 103 | if (irq_fd->current_events != 0) { |
102 | irq_fd->current_events = 0; | 104 | irq_fd->current_events = 0; |
103 | do_IRQ(irq_fd->irq, regs); | 105 | do_IRQ(irq_fd->irq, regs); |
104 | } | 106 | } |
@@ -110,19 +112,17 @@ void sigio_handler(int sig, union uml_pt_regs *regs) | |||
110 | 112 | ||
111 | static void maybe_sigio_broken(int fd, int type) | 113 | static void maybe_sigio_broken(int fd, int type) |
112 | { | 114 | { |
113 | if(os_isatty(fd)){ | 115 | if (os_isatty(fd)) { |
114 | if((type == IRQ_WRITE) && !pty_output_sigio){ | 116 | if ((type == IRQ_WRITE) && !pty_output_sigio) { |
115 | write_sigio_workaround(); | 117 | write_sigio_workaround(); |
116 | add_sigio_fd(fd, 0); | 118 | add_sigio_fd(fd, 0); |
117 | } | 119 | } else if ((type == IRQ_READ) && !pty_close_sigio) { |
118 | else if((type == IRQ_READ) && !pty_close_sigio){ | ||
119 | write_sigio_workaround(); | 120 | write_sigio_workaround(); |
120 | add_sigio_fd(fd, 1); | 121 | add_sigio_fd(fd, 1); |
121 | } | 122 | } |
122 | } | 123 | } |
123 | } | 124 | } |
124 | 125 | ||
125 | |||
126 | int activate_fd(int irq, int fd, int type, void *dev_id) | 126 | int activate_fd(int irq, int fd, int type, void *dev_id) |
127 | { | 127 | { |
128 | struct pollfd *tmp_pfd; | 128 | struct pollfd *tmp_pfd; |
@@ -132,16 +132,18 @@ int activate_fd(int irq, int fd, int type, void *dev_id) | |||
132 | 132 | ||
133 | pid = os_getpid(); | 133 | pid = os_getpid(); |
134 | err = os_set_fd_async(fd, pid); | 134 | err = os_set_fd_async(fd, pid); |
135 | if(err < 0) | 135 | if (err < 0) |
136 | goto out; | 136 | goto out; |
137 | 137 | ||
138 | new_fd = um_kmalloc(sizeof(*new_fd)); | 138 | new_fd = um_kmalloc(sizeof(*new_fd)); |
139 | err = -ENOMEM; | 139 | err = -ENOMEM; |
140 | if(new_fd == NULL) | 140 | if (new_fd == NULL) |
141 | goto out; | 141 | goto out; |
142 | 142 | ||
143 | if(type == IRQ_READ) events = UM_POLLIN | UM_POLLPRI; | 143 | if (type == IRQ_READ) |
144 | else events = UM_POLLOUT; | 144 | events = UM_POLLIN | UM_POLLPRI; |
145 | else | ||
146 | events = UM_POLLOUT; | ||
145 | *new_fd = ((struct irq_fd) { .next = NULL, | 147 | *new_fd = ((struct irq_fd) { .next = NULL, |
146 | .id = dev_id, | 148 | .id = dev_id, |
147 | .fd = fd, | 149 | .fd = fd, |
@@ -165,8 +167,8 @@ int activate_fd(int irq, int fd, int type, void *dev_id) | |||
165 | * a semaphore. | 167 | * a semaphore. |
166 | */ | 168 | */ |
167 | flags = irq_lock(); | 169 | flags = irq_lock(); |
168 | for(irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next){ | 170 | for (irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next) { |
169 | if((irq_fd->fd == fd) && (irq_fd->type == type)){ | 171 | if ((irq_fd->fd == fd) && (irq_fd->type == type)) { |
170 | printk("Registering fd %d twice\n", fd); | 172 | printk("Registering fd %d twice\n", fd); |
171 | printk("Irqs : %d, %d\n", irq_fd->irq, irq); | 173 | printk("Irqs : %d, %d\n", irq_fd->irq, irq); |
172 | printk("Ids : 0x%p, 0x%p\n", irq_fd->id, dev_id); | 174 | printk("Ids : 0x%p, 0x%p\n", irq_fd->id, dev_id); |
@@ -175,13 +177,13 @@ int activate_fd(int irq, int fd, int type, void *dev_id) | |||
175 | } | 177 | } |
176 | 178 | ||
177 | /*-------------*/ | 179 | /*-------------*/ |
178 | if(type == IRQ_WRITE) | 180 | if (type == IRQ_WRITE) |
179 | fd = -1; | 181 | fd = -1; |
180 | 182 | ||
181 | tmp_pfd = NULL; | 183 | tmp_pfd = NULL; |
182 | n = 0; | 184 | n = 0; |
183 | 185 | ||
184 | while(1){ | 186 | while (1) { |
185 | n = os_create_pollfd(fd, events, tmp_pfd, n); | 187 | n = os_create_pollfd(fd, events, tmp_pfd, n); |
186 | if (n == 0) | 188 | if (n == 0) |
187 | break; | 189 | break; |
@@ -198,10 +200,8 @@ int activate_fd(int irq, int fd, int type, void *dev_id) | |||
198 | * then we free the buffer tmp_fds and try again. | 200 | * then we free the buffer tmp_fds and try again. |
199 | */ | 201 | */ |
200 | irq_unlock(flags); | 202 | irq_unlock(flags); |
201 | if (tmp_pfd != NULL) { | 203 | kfree(tmp_pfd); |
202 | kfree(tmp_pfd); | 204 | tmp_pfd = NULL; |
203 | tmp_pfd = NULL; | ||
204 | } | ||
205 | 205 | ||
206 | tmp_pfd = um_kmalloc(n); | 206 | tmp_pfd = um_kmalloc(n); |
207 | if (tmp_pfd == NULL) | 207 | if (tmp_pfd == NULL) |
@@ -249,7 +249,7 @@ static int same_irq_and_dev(struct irq_fd *irq, void *d) | |||
249 | { | 249 | { |
250 | struct irq_and_dev *data = d; | 250 | struct irq_and_dev *data = d; |
251 | 251 | ||
252 | return((irq->irq == data->irq) && (irq->id == data->dev)); | 252 | return ((irq->irq == data->irq) && (irq->id == data->dev)); |
253 | } | 253 | } |
254 | 254 | ||
255 | void free_irq_by_irq_and_dev(unsigned int irq, void *dev) | 255 | void free_irq_by_irq_and_dev(unsigned int irq, void *dev) |
@@ -262,7 +262,7 @@ void free_irq_by_irq_and_dev(unsigned int irq, void *dev) | |||
262 | 262 | ||
263 | static int same_fd(struct irq_fd *irq, void *fd) | 263 | static int same_fd(struct irq_fd *irq, void *fd) |
264 | { | 264 | { |
265 | return(irq->fd == *((int *) fd)); | 265 | return (irq->fd == *((int *)fd)); |
266 | } | 266 | } |
267 | 267 | ||
268 | void free_irq_by_fd(int fd) | 268 | void free_irq_by_fd(int fd) |
@@ -276,16 +276,17 @@ static struct irq_fd *find_irq_by_fd(int fd, int irqnum, int *index_out) | |||
276 | int i = 0; | 276 | int i = 0; |
277 | int fdi; | 277 | int fdi; |
278 | 278 | ||
279 | for(irq=active_fds; irq != NULL; irq = irq->next){ | 279 | for (irq = active_fds; irq != NULL; irq = irq->next) { |
280 | if((irq->fd == fd) && (irq->irq == irqnum)) break; | 280 | if ((irq->fd == fd) && (irq->irq == irqnum)) |
281 | break; | ||
281 | i++; | 282 | i++; |
282 | } | 283 | } |
283 | if(irq == NULL){ | 284 | if (irq == NULL) { |
284 | printk("find_irq_by_fd doesn't have descriptor %d\n", fd); | 285 | printk("find_irq_by_fd doesn't have descriptor %d\n", fd); |
285 | goto out; | 286 | goto out; |
286 | } | 287 | } |
287 | fdi = os_get_pollfd(i); | 288 | fdi = os_get_pollfd(i); |
288 | if((fdi != -1) && (fdi != fd)){ | 289 | if ((fdi != -1) && (fdi != fd)) { |
289 | printk("find_irq_by_fd - mismatch between active_fds and " | 290 | printk("find_irq_by_fd - mismatch between active_fds and " |
290 | "pollfds, fd %d vs %d, need %d\n", irq->fd, | 291 | "pollfds, fd %d vs %d, need %d\n", irq->fd, |
291 | fdi, fd); | 292 | fdi, fd); |
@@ -294,7 +295,7 @@ static struct irq_fd *find_irq_by_fd(int fd, int irqnum, int *index_out) | |||
294 | } | 295 | } |
295 | *index_out = i; | 296 | *index_out = i; |
296 | out: | 297 | out: |
297 | return(irq); | 298 | return irq; |
298 | } | 299 | } |
299 | 300 | ||
300 | void reactivate_fd(int fd, int irqnum) | 301 | void reactivate_fd(int fd, int irqnum) |
@@ -305,7 +306,7 @@ void reactivate_fd(int fd, int irqnum) | |||
305 | 306 | ||
306 | flags = irq_lock(); | 307 | flags = irq_lock(); |
307 | irq = find_irq_by_fd(fd, irqnum, &i); | 308 | irq = find_irq_by_fd(fd, irqnum, &i); |
308 | if(irq == NULL){ | 309 | if (irq == NULL) { |
309 | irq_unlock(flags); | 310 | irq_unlock(flags); |
310 | return; | 311 | return; |
311 | } | 312 | } |
@@ -326,7 +327,7 @@ void deactivate_fd(int fd, int irqnum) | |||
326 | 327 | ||
327 | flags = irq_lock(); | 328 | flags = irq_lock(); |
328 | irq = find_irq_by_fd(fd, irqnum, &i); | 329 | irq = find_irq_by_fd(fd, irqnum, &i); |
329 | if(irq == NULL) | 330 | if (irq == NULL) |
330 | goto out; | 331 | goto out; |
331 | os_set_pollfd(i, -1); | 332 | os_set_pollfd(i, -1); |
332 | out: | 333 | out: |
@@ -338,15 +339,15 @@ int deactivate_all_fds(void) | |||
338 | struct irq_fd *irq; | 339 | struct irq_fd *irq; |
339 | int err; | 340 | int err; |
340 | 341 | ||
341 | for(irq=active_fds;irq != NULL;irq = irq->next){ | 342 | for (irq = active_fds; irq != NULL; irq = irq->next) { |
342 | err = os_clear_fd_async(irq->fd); | 343 | err = os_clear_fd_async(irq->fd); |
343 | if(err) | 344 | if (err) |
344 | return(err); | 345 | return err; |
345 | } | 346 | } |
346 | /* If there is a signal already queued, after unblocking ignore it */ | 347 | /* If there is a signal already queued, after unblocking ignore it */ |
347 | os_set_ioignore(); | 348 | os_set_ioignore(); |
348 | 349 | ||
349 | return(0); | 350 | return 0; |
350 | } | 351 | } |
351 | 352 | ||
352 | void forward_interrupts(int pid) | 353 | void forward_interrupts(int pid) |
@@ -356,9 +357,9 @@ void forward_interrupts(int pid) | |||
356 | int err; | 357 | int err; |
357 | 358 | ||
358 | flags = irq_lock(); | 359 | flags = irq_lock(); |
359 | for(irq=active_fds;irq != NULL;irq = irq->next){ | 360 | for (irq = active_fds; irq != NULL; irq = irq->next) { |
360 | err = os_set_owner(irq->fd, pid); | 361 | err = os_set_owner(irq->fd, pid); |
361 | if(err < 0){ | 362 | if (err < 0) { |
362 | /* XXX Just remove the irq rather than | 363 | /* XXX Just remove the irq rather than |
363 | * print out an infinite stream of these | 364 | * print out an infinite stream of these |
364 | */ | 365 | */ |
@@ -379,7 +380,7 @@ void forward_interrupts(int pid) | |||
379 | unsigned int do_IRQ(int irq, union uml_pt_regs *regs) | 380 | unsigned int do_IRQ(int irq, union uml_pt_regs *regs) |
380 | { | 381 | { |
381 | irq_enter(); | 382 | irq_enter(); |
382 | __do_IRQ(irq, (struct pt_regs *) regs); | 383 | __do_IRQ(irq, (struct pt_regs *)regs); |
383 | irq_exit(); | 384 | irq_exit(); |
384 | return 1; | 385 | return 1; |
385 | } | 386 | } |
@@ -392,12 +393,12 @@ int um_request_irq(unsigned int irq, int fd, int type, | |||
392 | int err; | 393 | int err; |
393 | 394 | ||
394 | err = request_irq(irq, handler, irqflags, devname, dev_id); | 395 | err = request_irq(irq, handler, irqflags, devname, dev_id); |
395 | if(err) | 396 | if (err) |
396 | return(err); | 397 | return err; |
397 | 398 | ||
398 | if(fd != -1) | 399 | if (fd != -1) |
399 | err = activate_fd(irq, fd, type, dev_id); | 400 | err = activate_fd(irq, fd, type, dev_id); |
400 | return(err); | 401 | return err; |
401 | } | 402 | } |
402 | EXPORT_SYMBOL(um_request_irq); | 403 | EXPORT_SYMBOL(um_request_irq); |
403 | EXPORT_SYMBOL(reactivate_fd); | 404 | EXPORT_SYMBOL(reactivate_fd); |
@@ -409,7 +410,7 @@ unsigned long irq_lock(void) | |||
409 | unsigned long flags; | 410 | unsigned long flags; |
410 | 411 | ||
411 | spin_lock_irqsave(&irq_spinlock, flags); | 412 | spin_lock_irqsave(&irq_spinlock, flags); |
412 | return(flags); | 413 | return flags; |
413 | } | 414 | } |
414 | 415 | ||
415 | void irq_unlock(unsigned long flags) | 416 | void irq_unlock(unsigned long flags) |
@@ -452,7 +453,7 @@ void __init init_IRQ(void) | |||
452 | irq_desc[TIMER_IRQ].depth = 1; | 453 | irq_desc[TIMER_IRQ].depth = 1; |
453 | irq_desc[TIMER_IRQ].handler = &SIGVTALRM_irq_type; | 454 | irq_desc[TIMER_IRQ].handler = &SIGVTALRM_irq_type; |
454 | enable_irq(TIMER_IRQ); | 455 | enable_irq(TIMER_IRQ); |
455 | for(i=1;i<NR_IRQS;i++){ | 456 | for (i = 1; i < NR_IRQS; i++) { |
456 | irq_desc[i].status = IRQ_DISABLED; | 457 | irq_desc[i].status = IRQ_DISABLED; |
457 | irq_desc[i].action = NULL; | 458 | irq_desc[i].action = NULL; |
458 | irq_desc[i].depth = 1; | 459 | irq_desc[i].depth = 1; |
@@ -467,7 +468,7 @@ int init_aio_irq(int irq, char *name, irqreturn_t (*handler)(int, void *, | |||
467 | int fds[2], err; | 468 | int fds[2], err; |
468 | 469 | ||
469 | err = os_pipe(fds, 1, 1); | 470 | err = os_pipe(fds, 1, 1); |
470 | if(err){ | 471 | if (err) { |
471 | printk("init_aio_irq - os_pipe failed, err = %d\n", -err); | 472 | printk("init_aio_irq - os_pipe failed, err = %d\n", -err); |
472 | goto out; | 473 | goto out; |
473 | } | 474 | } |
@@ -475,7 +476,7 @@ int init_aio_irq(int irq, char *name, irqreturn_t (*handler)(int, void *, | |||
475 | err = um_request_irq(irq, fds[0], IRQ_READ, handler, | 476 | err = um_request_irq(irq, fds[0], IRQ_READ, handler, |
476 | SA_INTERRUPT | SA_SAMPLE_RANDOM, name, | 477 | SA_INTERRUPT | SA_SAMPLE_RANDOM, name, |
477 | (void *) (long) fds[0]); | 478 | (void *) (long) fds[0]); |
478 | if(err){ | 479 | if (err) { |
479 | printk("init_aio_irq - : um_request_irq failed, err = %d\n", | 480 | printk("init_aio_irq - : um_request_irq failed, err = %d\n", |
480 | err); | 481 | err); |
481 | goto out_close; | 482 | goto out_close; |
@@ -488,5 +489,5 @@ int init_aio_irq(int irq, char *name, irqreturn_t (*handler)(int, void *, | |||
488 | os_close_file(fds[0]); | 489 | os_close_file(fds[0]); |
489 | os_close_file(fds[1]); | 490 | os_close_file(fds[1]); |
490 | out: | 491 | out: |
491 | return(err); | 492 | return err; |
492 | } | 493 | } |