From: Stephen H. <she...@os...> - 2003-11-05 01:12:48
|
Since Sparc can't handle irqflags in start/stop iterator, just use single_open method. --- linux-2.5/net/irda/ircomm/ircomm_core.c 2003-09-30 13:54:15.000000000 -0700 +++ irda-2.5/net/irda/ircomm/ircomm_core.c 2003-11-04 16:49:48.520981152 -0800 @@ -62,7 +62,7 @@ .open = ircomm_seq_open, .read = seq_read, .llseek = seq_lseek, - .release = seq_release_private, + .release = seq_release, }; #endif /* CONFIG_PROC_FS */ @@ -508,98 +508,48 @@ EXPORT_SYMBOL(ircomm_flow_request); #ifdef CONFIG_PROC_FS -struct ircomm_iter_state { - unsigned long flags; -}; - -static void *ircomm_seq_start(struct seq_file *seq, loff_t *pos) +static int ircomm_seq_show(struct seq_file *seq, void *v) { - struct ircomm_iter_state *iter = seq->private; struct ircomm_cb *self; - loff_t off = 0; + unsigned long flags; - spin_lock_irqsave(&ircomm->hb_spinlock, iter->flags); + ASSERT(ircomm != NULL, return -EINVAL; ); + spin_lock_irqsave(&ircomm->hb_spinlock, flags); for (self = (struct ircomm_cb *) hashbin_get_first(ircomm); self != NULL; self = (struct ircomm_cb *) hashbin_get_next(ircomm)) { - if (off++ == *pos) - break; - - } - return self; -} -static void *ircomm_seq_next(struct seq_file *seq, void *v, loff_t *pos) -{ - ++*pos; - - return (void *) hashbin_get_next(ircomm); -} + ASSERT(self->magic == IRCOMM_MAGIC, break; ); -static void ircomm_seq_stop(struct seq_file *seq, void *v) -{ - struct ircomm_iter_state *iter = seq->private; - spin_unlock_irqrestore(&ircomm->hb_spinlock, iter->flags); -} - -static int ircomm_seq_show(struct seq_file *seq, void *v) -{ - const struct ircomm_cb *self = v; - - ASSERT(self->magic == IRCOMM_MAGIC, return -EINVAL; ); - - if(self->line < 0x10) - seq_printf(seq, "ircomm%d", self->line); - else - seq_printf(seq, "irlpt%d", self->line - 0x10); - - seq_printf(seq, - " state: %s, slsap_sel: %#02x, dlsap_sel: %#02x, mode:", - ircomm_state[ self->state], - self->slsap_sel, self->dlsap_sel); - - if(self->service_type & IRCOMM_3_WIRE_RAW) - seq_printf(seq, " 3-wire-raw"); - if(self->service_type & IRCOMM_3_WIRE) - seq_printf(seq, " 3-wire"); - if(self->service_type & IRCOMM_9_WIRE) - seq_printf(seq, " 9-wire"); - if(self->service_type & IRCOMM_CENTRONICS) - seq_printf(seq, " Centronics"); - seq_putc(seq, '\n'); + if(self->line < 0x10) + seq_printf(seq, "ircomm%d", self->line); + else + seq_printf(seq, "irlpt%d", self->line - 0x10); + + seq_printf(seq, + " state: %s, slsap_sel: %#02x, dlsap_sel: %#02x, mode:", + ircomm_state[ self->state], + self->slsap_sel, self->dlsap_sel); + + if(self->service_type & IRCOMM_3_WIRE_RAW) + seq_printf(seq, " 3-wire-raw"); + if(self->service_type & IRCOMM_3_WIRE) + seq_printf(seq, " 3-wire"); + if(self->service_type & IRCOMM_9_WIRE) + seq_printf(seq, " 9-wire"); + if(self->service_type & IRCOMM_CENTRONICS) + seq_printf(seq, " Centronics"); + seq_putc(seq, '\n'); + } + spin_unlock_irqrestore(&ircomm->hb_spinlock, flags); return 0; } -static struct seq_operations ircomm_seq_ops = { - .start = ircomm_seq_start, - .next = ircomm_seq_next, - .stop = ircomm_seq_stop, - .show = ircomm_seq_show, -}; - static int ircomm_seq_open(struct inode *inode, struct file *file) { - struct seq_file *seq; - int rc = -ENOMEM; - struct ircomm_iter_state *s = kmalloc(sizeof(*s), GFP_KERNEL); - - if (!s) - goto out; - - rc = seq_open(file, &ircomm_seq_ops); - if (rc) - goto out_kfree; - - seq = file->private_data; - seq->private = s; - memset(s, 0, sizeof(*s)); -out: - return rc; -out_kfree: - kfree(s); - goto out; + return single_open(file, ircomm_seq_show, NULL); } #endif /* CONFIG_PROC_FS */ |