@@ -89,16 +89,18 @@ void sigio_handler(int sig, union uml_pt_regs *regs)
89
89
struct irq_fd * irq_fd ;
90
90
int n ;
91
91
92
- if (smp_sigio_handler ()) return ;
93
- while (1 ){
92
+ if (smp_sigio_handler ())
93
+ return ;
94
+
95
+ while (1 ) {
94
96
n = os_waiting_for_events (active_fds );
95
97
if (n <= 0 ) {
96
98
if (n == - EINTR ) continue ;
97
99
else break ;
98
100
}
99
101
100
- for (irq_fd = active_fds ; irq_fd != NULL ; irq_fd = irq_fd -> next ){
101
- if (irq_fd -> current_events != 0 ){
102
+ for (irq_fd = active_fds ; irq_fd != NULL ; irq_fd = irq_fd -> next ) {
103
+ if (irq_fd -> current_events != 0 ) {
102
104
irq_fd -> current_events = 0 ;
103
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
113
static void maybe_sigio_broken (int fd , int type )
112
114
{
113
- if (os_isatty (fd )){
114
- if ((type == IRQ_WRITE ) && !pty_output_sigio ){
115
+ if (os_isatty (fd )) {
116
+ if ((type == IRQ_WRITE ) && !pty_output_sigio ) {
115
117
write_sigio_workaround ();
116
118
add_sigio_fd (fd , 0 );
117
- }
118
- else if ((type == IRQ_READ ) && !pty_close_sigio ){
119
+ } else if ((type == IRQ_READ ) && !pty_close_sigio ) {
119
120
write_sigio_workaround ();
120
121
add_sigio_fd (fd , 1 );
121
122
}
122
123
}
123
124
}
124
125
125
-
126
126
int activate_fd (int irq , int fd , int type , void * dev_id )
127
127
{
128
128
struct pollfd * tmp_pfd ;
@@ -132,16 +132,18 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
132
132
133
133
pid = os_getpid ();
134
134
err = os_set_fd_async (fd , pid );
135
- if (err < 0 )
135
+ if (err < 0 )
136
136
goto out ;
137
137
138
138
new_fd = um_kmalloc (sizeof (* new_fd ));
139
139
err = - ENOMEM ;
140
- if (new_fd == NULL )
140
+ if (new_fd == NULL )
141
141
goto out ;
142
142
143
- if (type == IRQ_READ ) events = UM_POLLIN | UM_POLLPRI ;
144
- else events = UM_POLLOUT ;
143
+ if (type == IRQ_READ )
144
+ events = UM_POLLIN | UM_POLLPRI ;
145
+ else
146
+ events = UM_POLLOUT ;
145
147
* new_fd = ((struct irq_fd ) { .next = NULL ,
146
148
.id = dev_id ,
147
149
.fd = fd ,
@@ -165,8 +167,8 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
165
167
* a semaphore.
166
168
*/
167
169
flags = irq_lock ();
168
- for (irq_fd = active_fds ; irq_fd != NULL ; irq_fd = irq_fd -> next ){
169
- if ((irq_fd -> fd == fd ) && (irq_fd -> type == type )){
170
+ for (irq_fd = active_fds ; irq_fd != NULL ; irq_fd = irq_fd -> next ) {
171
+ if ((irq_fd -> fd == fd ) && (irq_fd -> type == type )) {
170
172
printk ("Registering fd %d twice\n" , fd );
171
173
printk ("Irqs : %d, %d\n" , irq_fd -> irq , irq );
172
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
181
fd = -1 ;
180
182
181
183
tmp_pfd = NULL ;
182
184
n = 0 ;
183
185
184
- while (1 ){
186
+ while (1 ) {
185
187
n = os_create_pollfd (fd , events , tmp_pfd , n );
186
188
if (n == 0 )
187
189
break ;
@@ -198,10 +200,8 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
198
200
* then we free the buffer tmp_fds and try again.
199
201
*/
200
202
irq_unlock (flags );
201
- if (tmp_pfd != NULL ) {
202
- kfree (tmp_pfd );
203
- tmp_pfd = NULL ;
204
- }
203
+ kfree (tmp_pfd );
204
+ tmp_pfd = NULL ;
205
205
206
206
tmp_pfd = um_kmalloc (n );
207
207
if (tmp_pfd == NULL )
@@ -249,7 +249,7 @@ static int same_irq_and_dev(struct irq_fd *irq, void *d)
249
249
{
250
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
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
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
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
276
int i = 0 ;
277
277
int fdi ;
278
278
279
- for (irq = active_fds ; irq != NULL ; irq = irq -> next ){
280
- if ((irq -> fd == fd ) && (irq -> irq == irqnum )) break ;
279
+ for (irq = active_fds ; irq != NULL ; irq = irq -> next ) {
280
+ if ((irq -> fd == fd ) && (irq -> irq == irqnum ))
281
+ break ;
281
282
i ++ ;
282
283
}
283
- if (irq == NULL ){
284
+ if (irq == NULL ) {
284
285
printk ("find_irq_by_fd doesn't have descriptor %d\n" , fd );
285
286
goto out ;
286
287
}
287
288
fdi = os_get_pollfd (i );
288
- if ((fdi != -1 ) && (fdi != fd )){
289
+ if ((fdi != -1 ) && (fdi != fd )) {
289
290
printk ("find_irq_by_fd - mismatch between active_fds and "
290
291
"pollfds, fd %d vs %d, need %d\n" , irq -> fd ,
291
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
296
* index_out = i ;
296
297
out :
297
- return ( irq ) ;
298
+ return irq ;
298
299
}
299
300
300
301
void reactivate_fd (int fd , int irqnum )
@@ -305,7 +306,7 @@ void reactivate_fd(int fd, int irqnum)
305
306
306
307
flags = irq_lock ();
307
308
irq = find_irq_by_fd (fd , irqnum , & i );
308
- if (irq == NULL ){
309
+ if (irq == NULL ) {
309
310
irq_unlock (flags );
310
311
return ;
311
312
}
@@ -326,7 +327,7 @@ void deactivate_fd(int fd, int irqnum)
326
327
327
328
flags = irq_lock ();
328
329
irq = find_irq_by_fd (fd , irqnum , & i );
329
- if (irq == NULL )
330
+ if (irq == NULL )
330
331
goto out ;
331
332
os_set_pollfd (i , -1 );
332
333
out :
@@ -338,15 +339,15 @@ int deactivate_all_fds(void)
338
339
struct irq_fd * irq ;
339
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
343
err = os_clear_fd_async (irq -> fd );
343
- if (err )
344
- return ( err ) ;
344
+ if (err )
345
+ return err ;
345
346
}
346
347
/* If there is a signal already queued, after unblocking ignore it */
347
348
os_set_ioignore ();
348
349
349
- return ( 0 ) ;
350
+ return 0 ;
350
351
}
351
352
352
353
void forward_interrupts (int pid )
@@ -356,9 +357,9 @@ void forward_interrupts(int pid)
356
357
int err ;
357
358
358
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
361
err = os_set_owner (irq -> fd , pid );
361
- if (err < 0 ){
362
+ if (err < 0 ) {
362
363
/* XXX Just remove the irq rather than
363
364
* print out an infinite stream of these
364
365
*/
@@ -379,7 +380,7 @@ void forward_interrupts(int pid)
379
380
unsigned int do_IRQ (int irq , union uml_pt_regs * regs )
380
381
{
381
382
irq_enter ();
382
- __do_IRQ (irq , (struct pt_regs * ) regs );
383
+ __do_IRQ (irq , (struct pt_regs * )regs );
383
384
irq_exit ();
384
385
return 1 ;
385
386
}
@@ -392,12 +393,12 @@ int um_request_irq(unsigned int irq, int fd, int type,
392
393
int err ;
393
394
394
395
err = request_irq (irq , handler , irqflags , devname , dev_id );
395
- if (err )
396
- return ( err ) ;
396
+ if (err )
397
+ return err ;
397
398
398
- if (fd != -1 )
399
+ if (fd != -1 )
399
400
err = activate_fd (irq , fd , type , dev_id );
400
- return ( err ) ;
401
+ return err ;
401
402
}
402
403
EXPORT_SYMBOL (um_request_irq );
403
404
EXPORT_SYMBOL (reactivate_fd );
@@ -409,7 +410,7 @@ unsigned long irq_lock(void)
409
410
unsigned long flags ;
410
411
411
412
spin_lock_irqsave (& irq_spinlock , flags );
412
- return ( flags ) ;
413
+ return flags ;
413
414
}
414
415
415
416
void irq_unlock (unsigned long flags )
@@ -452,7 +453,7 @@ void __init init_IRQ(void)
452
453
irq_desc [TIMER_IRQ ].depth = 1 ;
453
454
irq_desc [TIMER_IRQ ].handler = & SIGVTALRM_irq_type ;
454
455
enable_irq (TIMER_IRQ );
455
- for ( i = 1 ; i < NR_IRQS ;i ++ ){
456
+ for ( i = 1 ; i < NR_IRQS ; i ++ ) {
456
457
irq_desc [i ].status = IRQ_DISABLED ;
457
458
irq_desc [i ].action = NULL ;
458
459
irq_desc [i ].depth = 1 ;
@@ -467,15 +468,15 @@ int init_aio_irq(int irq, char *name, irqreturn_t (*handler)(int, void *,
467
468
int fds [2 ], err ;
468
469
469
470
err = os_pipe (fds , 1 , 1 );
470
- if (err ){
471
+ if (err ) {
471
472
printk ("init_aio_irq - os_pipe failed, err = %d\n" , - err );
472
473
goto out ;
473
474
}
474
475
475
476
err = um_request_irq (irq , fds [0 ], IRQ_READ , handler ,
476
477
SA_INTERRUPT | SA_SAMPLE_RANDOM , name ,
477
478
(void * ) (long ) fds [0 ]);
478
- if (err ){
479
+ if (err ) {
479
480
printk ("init_aio_irq - : um_request_irq failed, err = %d\n" ,
480
481
err );
481
482
goto out_close ;
@@ -488,5 +489,5 @@ int init_aio_irq(int irq, char *name, irqreturn_t (*handler)(int, void *,
488
489
os_close_file (fds [0 ]);
489
490
os_close_file (fds [1 ]);
490
491
out :
491
- return ( err ) ;
492
+ return err ;
492
493
}
0 commit comments