[Xenomai-git] Philippe Gerum : nucleus/intr: convert to vfile
Module: xenomai-rpm Branch: queue/rtipc Commit: ef7e7d1c8daac0efd9c66980777dd537f708c080 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=ef7e7d1c8daac0efd9c66980777dd537f708c080 Author: Philippe Gerum r...@xenomai.org Date: Thu Jun 10 12:23:12 2010 +0200 nucleus/intr: convert to vfile --- ksrc/nucleus/intr.c | 155 --- 1 files changed, 72 insertions(+), 83 deletions(-) diff --git a/ksrc/nucleus/intr.c b/ksrc/nucleus/intr.c index a6de4ea..d18a26a 100644 --- a/ksrc/nucleus/intr.c +++ b/ksrc/nucleus/intr.c @@ -983,28 +983,27 @@ int xnintr_query_next(int irq, xnintr_iterator_t *iterator, char *name_buf) #ifdef CONFIG_PROC_FS -#include linux/proc_fs.h -#include linux/ctype.h +#include nucleus/vfile.h -static int format_irq_proc(unsigned int irq, char *str) +static inline int format_irq_proc(unsigned int irq, + struct xnvfile_regular_iterator *it) { - xnintr_t *intr; - char *p = str; + struct xnintr *intr; spl_t s; if (rthal_virtual_irq_p(irq)) { - p += sprintf(p, [virtual]); - return p - str; + xnvfile_puts(it, [virtual]); + return 0; } else if (irq == XNARCH_TIMER_IRQ) { - p += sprintf(p, [timer]); - return p - str; + xnvfile_puts(it, [timer]); + return 0; #ifdef CONFIG_SMP } else if (irq == RTHAL_SERVICE_IPI0) { - p += sprintf(p, [IPI]); - return p - str; + xnvfile_puts(it, [IPI]); + return 0; } else if (irq == RTHAL_CRITICAL_IPI) { - p += sprintf(p, [critical sync]); - return p - str; + xnvfile_puts(it, [critical sync]); + return 0; #endif /* CONFIG_SMP */ } @@ -1012,134 +1011,124 @@ static int format_irq_proc(unsigned int irq, char *str) intr = xnintr_shirq_first(irq); if (intr) { - strcpy(p, ); p += 8; + xnvfile_puts(it, ); do { - *p = ' '; p += 1; - strcpy(p, intr-name); p += strlen(intr-name); - + xnvfile_putc(it, ' '); + xnvfile_puts(it, intr-name); intr = xnintr_shirq_next(intr); } while (intr); } xnlock_put_irqrestore(intrlock, s); - return p - str; + return 0; } -static int irq_read_proc(char *page, -char **start, -off_t off, int count, int *eof, void *data) +static int irq_vfile_show(struct xnvfile_regular_iterator *it, + void *data) { - int len = 0, cpu, irq; - char *p = page; + int cpu, irq; - p += sprintf(p, IRQ ); + /* FIXME: We assume the entire output fits in a single page. */ - for_each_online_cpu(cpu) { - p += sprintf(p, CPU%d, cpu); - } + xnvfile_puts(it, IRQ ); + + for_each_online_cpu(cpu) + xnvfile_printf(it, CPU%d, cpu); for (irq = 0; irq XNARCH_NR_IRQS; irq++) { if (rthal_irq_handler(rthal_domain, irq) == NULL) continue; - p += sprintf(p, \n%3d:, irq); + xnvfile_printf(it, \n%3d:, irq); for_each_online_cpu(cpu) { - p += sprintf(p, %12lu, -rthal_cpudata_irq_hits(rthal_domain, cpu, - irq)); + xnvfile_printf(it, %12lu, + rthal_cpudata_irq_hits(rthal_domain, cpu, + irq)); } - p += format_irq_proc(irq, p); + format_irq_proc(irq, it); } - p += sprintf(p, \n); + xnvfile_putc(it, '\n'); - len = p - page - off; - if (len = off + count) - *eof = 1; - *start = page + off; - if (len count) - len = count; - if (len 0) - len = 0; - - return len; + return 0; } +static struct xnvfile_regular_ops irq_vfile_ops = { + .show = irq_vfile_show, +}; + +static struct xnvfile_regular irq_vfile = { + .ops = irq_vfile_ops, +}; + #ifdef CONFIG_SMP -static int affinity_read_proc(char *page, - char **start, - off_t off, int count, int *eof, void *data) + +static int affinity_vfile_show(struct xnvfile_regular_iterator *it, + void *data) { unsigned long val = 0; - int len, cpu; + int cpu; - for (cpu = 0; cpu sizeof(val) * 8;
[Xenomai-git] Philippe Gerum : nucleus/intr: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: b712547dbdc19caba7589df432a59e9924f2f80c URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=b712547dbdc19caba7589df432a59e9924f2f80c Author: Philippe Gerum r...@xenomai.org Date: Thu Jun 10 12:23:12 2010 +0200 nucleus/intr: convert to vfile --- ksrc/nucleus/intr.c | 155 --- 1 files changed, 72 insertions(+), 83 deletions(-) diff --git a/ksrc/nucleus/intr.c b/ksrc/nucleus/intr.c index a6de4ea..300251e 100644 --- a/ksrc/nucleus/intr.c +++ b/ksrc/nucleus/intr.c @@ -983,28 +983,27 @@ int xnintr_query_next(int irq, xnintr_iterator_t *iterator, char *name_buf) #ifdef CONFIG_PROC_FS -#include linux/proc_fs.h -#include linux/ctype.h +#include nucleus/vfile.h -static int format_irq_proc(unsigned int irq, char *str) +static inline int format_irq_proc(unsigned int irq, + struct xnvfile_regular_iterator *it) { - xnintr_t *intr; - char *p = str; + struct xnintr *intr; spl_t s; if (rthal_virtual_irq_p(irq)) { - p += sprintf(p, [virtual]); - return p - str; + xnvfile_puts(it, [virtual]); + return 0; } else if (irq == XNARCH_TIMER_IRQ) { - p += sprintf(p, [timer]); - return p - str; + xnvfile_puts(it, [timer]); + return 0; #ifdef CONFIG_SMP } else if (irq == RTHAL_SERVICE_IPI0) { - p += sprintf(p, [IPI]); - return p - str; + xnvfile_puts(it, [IPI]); + return 0; } else if (irq == RTHAL_CRITICAL_IPI) { - p += sprintf(p, [critical sync]); - return p - str; + xnvfile_puts(it, [critical sync]); + return 0; #endif /* CONFIG_SMP */ } @@ -1012,134 +1011,124 @@ static int format_irq_proc(unsigned int irq, char *str) intr = xnintr_shirq_first(irq); if (intr) { - strcpy(p, ); p += 8; + xnvfile_puts(it, ); do { - *p = ' '; p += 1; - strcpy(p, intr-name); p += strlen(intr-name); - + xnvfile_putc(it, ' '); + xnvfile_puts(it, intr-name); intr = xnintr_shirq_next(intr); } while (intr); } xnlock_put_irqrestore(intrlock, s); - return p - str; + return 0; } -static int irq_read_proc(char *page, -char **start, -off_t off, int count, int *eof, void *data) +static int irq_vfile_show(struct xnvfile_regular_iterator *it, + void *data) { - int len = 0, cpu, irq; - char *p = page; + int cpu, irq; - p += sprintf(p, IRQ ); + /* FIXME: We assume the entire output fits in a single page. */ - for_each_online_cpu(cpu) { - p += sprintf(p, CPU%d, cpu); - } + xnvfile_puts(it, IRQ ); + + for_each_online_cpu(cpu) + xnvfile_printf(it, CPU%d, cpu); for (irq = 0; irq XNARCH_NR_IRQS; irq++) { if (rthal_irq_handler(rthal_domain, irq) == NULL) continue; - p += sprintf(p, \n%3d:, irq); + xnvfile_printf(it, \n%3d:, irq); for_each_online_cpu(cpu) { - p += sprintf(p, %12lu, -rthal_cpudata_irq_hits(rthal_domain, cpu, - irq)); + xnvfile_printf(it, %12lu, + rthal_cpudata_irq_hits(rthal_domain, cpu, + irq)); } - p += format_irq_proc(irq, p); + format_irq_proc(irq, it); } - p += sprintf(p, \n); + xnvfile_putc(it, '\n'); - len = p - page - off; - if (len = off + count) - *eof = 1; - *start = page + off; - if (len count) - len = count; - if (len 0) - len = 0; - - return len; + return 0; } +static struct xnvfile_regular_ops irq_vfile_ops = { + .show = irq_vfile_show, +}; + +static struct xnvfile_regular irq_vfile = { + .ops = irq_vfile_ops, +}; + #ifdef CONFIG_SMP -static int affinity_read_proc(char *page, - char **start, - off_t off, int count, int *eof, void *data) + +static int affinity_vfile_show(struct xnvfile_regular_iterator *it, + void *data) { unsigned long val = 0; - int len, cpu; + int cpu; - for (cpu = 0; cpu sizeof(val) * 8;
[Xenomai-git] Philippe Gerum : nucleus/intr: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: a21686c025f268e8d69b571e6cf1e35c148b89e0 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=a21686c025f268e8d69b571e6cf1e35c148b89e0 Author: Philippe Gerum r...@xenomai.org Date: Thu Jun 10 12:23:12 2010 +0200 nucleus/intr: convert to vfile --- ksrc/nucleus/intr.c | 153 +++--- 1 files changed, 70 insertions(+), 83 deletions(-) diff --git a/ksrc/nucleus/intr.c b/ksrc/nucleus/intr.c index a6de4ea..bdaa4ed 100644 --- a/ksrc/nucleus/intr.c +++ b/ksrc/nucleus/intr.c @@ -983,28 +983,27 @@ int xnintr_query_next(int irq, xnintr_iterator_t *iterator, char *name_buf) #ifdef CONFIG_PROC_FS -#include linux/proc_fs.h -#include linux/ctype.h +#include nucleus/vfile.h -static int format_irq_proc(unsigned int irq, char *str) +static inline int format_irq_proc(unsigned int irq, + struct xnvfile_regular_iterator *it) { - xnintr_t *intr; - char *p = str; + struct xnintr *intr; spl_t s; if (rthal_virtual_irq_p(irq)) { - p += sprintf(p, [virtual]); - return p - str; + xnvfile_puts(it, [virtual]); + return 0; } else if (irq == XNARCH_TIMER_IRQ) { - p += sprintf(p, [timer]); - return p - str; + xnvfile_puts(it, [timer]); + return 0; #ifdef CONFIG_SMP } else if (irq == RTHAL_SERVICE_IPI0) { - p += sprintf(p, [IPI]); - return p - str; + xnvfile_puts(it, [IPI]); + return 0; } else if (irq == RTHAL_CRITICAL_IPI) { - p += sprintf(p, [critical sync]); - return p - str; + xnvfile_puts(it, [critical sync]); + return 0; #endif /* CONFIG_SMP */ } @@ -1012,134 +1011,122 @@ static int format_irq_proc(unsigned int irq, char *str) intr = xnintr_shirq_first(irq); if (intr) { - strcpy(p, ); p += 8; + xnvfile_puts(it, ); do { - *p = ' '; p += 1; - strcpy(p, intr-name); p += strlen(intr-name); - + xnvfile_putc(it, ' '); + xnvfile_puts(it, intr-name); intr = xnintr_shirq_next(intr); } while (intr); } xnlock_put_irqrestore(intrlock, s); - return p - str; + return 0; } -static int irq_read_proc(char *page, -char **start, -off_t off, int count, int *eof, void *data) +static int irq_vfile_show(struct xnvfile_regular_iterator *it, + void *data) { - int len = 0, cpu, irq; - char *p = page; + int cpu, irq; - p += sprintf(p, IRQ ); + xnvfile_puts(it, IRQ ); - for_each_online_cpu(cpu) { - p += sprintf(p, CPU%d, cpu); - } + for_each_online_cpu(cpu) + xnvfile_printf(it, CPU%d, cpu); for (irq = 0; irq XNARCH_NR_IRQS; irq++) { if (rthal_irq_handler(rthal_domain, irq) == NULL) continue; - p += sprintf(p, \n%3d:, irq); + xnvfile_printf(it, \n%3d:, irq); for_each_online_cpu(cpu) { - p += sprintf(p, %12lu, -rthal_cpudata_irq_hits(rthal_domain, cpu, - irq)); + xnvfile_printf(it, %12lu, + rthal_cpudata_irq_hits(rthal_domain, cpu, + irq)); } - p += format_irq_proc(irq, p); + format_irq_proc(irq, it); } - p += sprintf(p, \n); + xnvfile_putc(it, '\n'); - len = p - page - off; - if (len = off + count) - *eof = 1; - *start = page + off; - if (len count) - len = count; - if (len 0) - len = 0; - - return len; + return 0; } +static struct xnvfile_regular_ops irq_vfile_ops = { + .show = irq_vfile_show, +}; + +static struct xnvfile_regular irq_vfile = { + .ops = irq_vfile_ops, +}; + #ifdef CONFIG_SMP -static int affinity_read_proc(char *page, - char **start, - off_t off, int count, int *eof, void *data) + +static int affinity_vfile_show(struct xnvfile_regular_iterator *it, + void *data) { unsigned long val = 0; - int len, cpu; + int cpu; - for (cpu = 0; cpu sizeof(val) * 8; cpu++) + for (cpu = 0; cpu BITS_PER_LONG; cpu++) if