[Xenomai-git] Philippe Gerum : powerpc: introduce HW_MATH_EMU symbol
Module: xenomai-rpm Branch: for-upstream Commit: 7f59bc2bfc9d5533fae1b7130e085d485c8350a1 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=7f59bc2bfc9d5533fae1b7130e085d485c8350a1 Author: Philippe Gerum r...@xenomai.org Date: Wed Jun 23 16:00:06 2010 +0200 powerpc: introduce HW_MATH_EMU symbol We need a way to identify platforms for which kernel-based FPU support is not available, because some form of math emulation is required to handle FP code. Introduce and check CONFIG_XENO_HW_MATH_EMU for this purpose; that conditional symbol is set by the arch-dep Kconfig frag, depending on the presence of other platform-specific symbols it may test. --- include/asm-powerpc/fptest.h |4 ++-- ksrc/arch/powerpc/Kconfig|4 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/asm-powerpc/fptest.h b/include/asm-powerpc/fptest.h index de3e9af..02c5cb3 100644 --- a/include/asm-powerpc/fptest.h +++ b/include/asm-powerpc/fptest.h @@ -7,11 +7,11 @@ static inline int fp_kernel_supported(void) { -#ifdef CONFIG_MATH_EMULATION +#ifdef CONFIG_XENO_HW_MATH_EMU static int once = 0; if (!once) { once = 1; - printk(Warning: CONFIG_MATH_EMULATION defined in kernel\n + printk(Warning: math emulation code defined in kernel\n no kernel-based FPU support for this platform\n); } return 0; diff --git a/ksrc/arch/powerpc/Kconfig b/ksrc/arch/powerpc/Kconfig index d630eb9..1f2eeb2 100644 --- a/ksrc/arch/powerpc/Kconfig +++ b/ksrc/arch/powerpc/Kconfig @@ -6,6 +6,10 @@ config XENO_FASTSYNCH bool default y +config XENO_HW_MATH_EMU +bool + default y if MATH_EMU || 8XX_MINIMAL_FPEMU + source kernel/xenomai/nucleus/Kconfig menu Machine ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : switchtest: bail out upon sem_wait() error
Module: xenomai-rpm Branch: for-upstream Commit: e8e4e5d958bc07014b240c5967ab6546db529dbe URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=e8e4e5d958bc07014b240c5967ab6546db529dbe Author: Philippe Gerum r...@xenomai.org Date: Thu Jun 24 12:09:55 2010 +0200 switchtest: bail out upon sem_wait() error When CONFIG_FUTEX is disabled for the target kernel, we rightfully get ENOSYS from the sem_wait() call on futex-enabled glibc. Check the sem_wait() return as we should to spot the issue, so that we don't run into subtle races due to incorrect synchronization. --- src/testsuite/switchtest/switchtest.c |8 +++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/src/testsuite/switchtest/switchtest.c b/src/testsuite/switchtest/switchtest.c index 7114a9f..31b840d 100644 --- a/src/testsuite/switchtest/switchtest.c +++ b/src/testsuite/switchtest/switchtest.c @@ -273,6 +273,7 @@ static void *sleeper_switcher(void *cookie) cpu_set_t cpu_set; unsigned i = 1; /* Start at 1 to avoid returning to a non-existing task. */ + int ret; CPU_ZERO(cpu_set); CPU_SET(param-cpu-index, cpu_set); @@ -287,7 +288,12 @@ static void *sleeper_switcher(void *cookie) ts.tv_sec = 0; ts.tv_nsec = 100; - __real_sem_wait(sleeper_start); + ret = __real_sem_wait(sleeper_start); + if (ret) { + fprintf(stderr, sem_wait FAILED (%d)\n, errno); + fflush(stderr); + exit(77); + } clock_gettime(CLOCK_REALTIME, last); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : nucleus: export xnshadow_call_mayday() as a service
Module: xenomai-rpm Branch: for-upstream Commit: 2205a8f2a7aa8fdc7b7d7f5a96f8064a771382ec URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=2205a8f2a7aa8fdc7b7d7f5a96f8064a771382ec Author: Philippe Gerum r...@xenomai.org Date: Thu Jun 24 12:16:27 2010 +0200 nucleus: export xnshadow_call_mayday() as a service --- include/asm-arm/bits/shadow.h |4 ++-- include/asm-blackfin/bits/shadow.h |4 ++-- include/asm-nios2/bits/shadow.h|4 ++-- include/asm-powerpc/bits/shadow.h |4 ++-- include/asm-powerpc/calibration.h |4 include/asm-x86/bits/shadow_32.h |4 ++-- include/asm-x86/bits/shadow_64.h |4 ++-- include/nucleus/shadow.h |5 +++-- ksrc/nucleus/sched.c |5 ++--- ksrc/nucleus/shadow.c |9 ++--- 10 files changed, 27 insertions(+), 20 deletions(-) diff --git a/include/asm-arm/bits/shadow.h b/include/asm-arm/bits/shadow.h index 6021dad..9fe491a 100644 --- a/include/asm-arm/bits/shadow.h +++ b/include/asm-arm/bits/shadow.h @@ -262,9 +262,9 @@ static inline void xnarch_setup_mayday_page(void *page) flush_dcache_page(vmalloc_to_page(page)); } -static inline void xnarch_call_mayday(void) +static inline void xnarch_call_mayday(struct task_struct *p) { - rthal_return_intercept(current); + rthal_return_intercept(p); } static inline void xnarch_handle_mayday(struct xnarchtcb *tcb, diff --git a/include/asm-blackfin/bits/shadow.h b/include/asm-blackfin/bits/shadow.h index 1a77fe4..778cf30 100644 --- a/include/asm-blackfin/bits/shadow.h +++ b/include/asm-blackfin/bits/shadow.h @@ -119,9 +119,9 @@ static inline void xnarch_setup_mayday_page(void *page) (unsigned long)page + sizeof(code)); } -static inline void xnarch_call_mayday(void) +static inline void xnarch_call_mayday(struct task_struct *p) { - rthal_return_intercept(current); + rthal_return_intercept(p); } static inline void xnarch_handle_mayday(struct xnarchtcb *tcb, diff --git a/include/asm-nios2/bits/shadow.h b/include/asm-nios2/bits/shadow.h index 8917045..8133128 100644 --- a/include/asm-nios2/bits/shadow.h +++ b/include/asm-nios2/bits/shadow.h @@ -101,9 +101,9 @@ static inline void xnarch_setup_mayday_page(void *page) (unsigned long)page + sizeof(code)); } -static inline void xnarch_call_mayday(void) +static inline void xnarch_call_mayday(struct task_struct *p) { - rthal_return_intercept(current); + rthal_return_intercept(p); } static inline void xnarch_handle_mayday(struct xnarchtcb *tcb, diff --git a/include/asm-powerpc/bits/shadow.h b/include/asm-powerpc/bits/shadow.h index 7f3554e..0763c57 100644 --- a/include/asm-powerpc/bits/shadow.h +++ b/include/asm-powerpc/bits/shadow.h @@ -95,9 +95,9 @@ static inline void xnarch_setup_mayday_page(void *page) (unsigned long)page + sizeof(insn)); } -static inline void xnarch_call_mayday(void) +static inline void xnarch_call_mayday(struct task_struct *p) { - rthal_return_intercept(current); + rthal_return_intercept(p); } static inline void xnarch_handle_mayday(struct xnarchtcb *tcb, diff --git a/include/asm-powerpc/calibration.h b/include/asm-powerpc/calibration.h index 25dd66d..7edf96b 100644 --- a/include/asm-powerpc/calibration.h +++ b/include/asm-powerpc/calibration.h @@ -76,6 +76,8 @@ static inline unsigned long xnarch_get_sched_latency(void) #define __sched_latency 1000 #elif defined(CONFIG_TQM8555) #define __sched_latency 2000 +#elif defined(CONFIG_KUP4K) +#define __sched_latency 1 /* * Check for the most generic configs at the bottom of this list, so * that the most specific choices available are picked first. @@ -86,6 +88,8 @@ static inline unsigned long xnarch_get_sched_latency(void) #define __sched_latency 9000 #elif defined(CONFIG_PPC_MPC52xx) #define __sched_latency 4500 +#elif defined(CONFIG_PPC_8xx) +#define __sched_latency 15000 #endif #ifndef __sched_latency diff --git a/include/asm-x86/bits/shadow_32.h b/include/asm-x86/bits/shadow_32.h index 40ccc62..c5ce164 100644 --- a/include/asm-x86/bits/shadow_32.h +++ b/include/asm-x86/bits/shadow_32.h @@ -135,9 +135,9 @@ static inline void xnarch_setup_mayday_page(void *page) /* no cache flush required. */ } -static inline void xnarch_call_mayday(void) +static inline void xnarch_call_mayday(struct task_struct *p) { - rthal_return_intercept(current); + rthal_return_intercept(p); } static inline void xnarch_handle_mayday(struct xnarchtcb *tcb, diff --git a/include/asm-x86/bits/shadow_64.h b/include/asm-x86/bits/shadow_64.h index 41a266f..d347ef6 100644 --- a/include/asm-x86/bits/shadow_64.h +++ b/include/asm-x86/bits/shadow_64.h @@ -98,9 +98,9 @@ static inline void xnarch_setup_mayday_page(void *page) /* no cache flush required. */ } -static inline void xnarch_call_mayday(void) +static inline void
[Xenomai-git] Philippe Gerum : powerpc: upgrade I-pipe support to 2.6.34-powerpc-2.10-03
Module: xenomai-rpm Branch: for-upstream Commit: 32fb6aadadf3c136888bb647177d25789b2717f8 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=32fb6aadadf3c136888bb647177d25789b2717f8 Author: Philippe Gerum r...@xenomai.org Date: Thu Jun 24 15:12:45 2010 +0200 powerpc: upgrade I-pipe support to 2.6.34-powerpc-2.10-03 This patch introduces support for the KUP4K board (Kieback Peter, mpc855). --- include/asm-powerpc/calibration.h |4 +- ...ch = adeos-ipipe-2.6.34-powerpc-2.10-03.patch} | 196 +++- 2 files changed, 191 insertions(+), 9 deletions(-) diff --git a/include/asm-powerpc/calibration.h b/include/asm-powerpc/calibration.h index 7edf96b..52b3475 100644 --- a/include/asm-powerpc/calibration.h +++ b/include/asm-powerpc/calibration.h @@ -77,7 +77,7 @@ static inline unsigned long xnarch_get_sched_latency(void) #elif defined(CONFIG_TQM8555) #define __sched_latency 2000 #elif defined(CONFIG_KUP4K) -#define __sched_latency 1 +#define __sched_latency 22000 /* * Check for the most generic configs at the bottom of this list, so * that the most specific choices available are picked first. @@ -89,7 +89,7 @@ static inline unsigned long xnarch_get_sched_latency(void) #elif defined(CONFIG_PPC_MPC52xx) #define __sched_latency 4500 #elif defined(CONFIG_PPC_8xx) -#define __sched_latency 15000 +#define __sched_latency 25000 #endif #ifndef __sched_latency diff --git a/ksrc/arch/powerpc/patches/adeos-ipipe-2.6.34-powerpc-2.10-02.patch b/ksrc/arch/powerpc/patches/adeos-ipipe-2.6.34-powerpc-2.10-03.patch similarity index 98% rename from ksrc/arch/powerpc/patches/adeos-ipipe-2.6.34-powerpc-2.10-02.patch rename to ksrc/arch/powerpc/patches/adeos-ipipe-2.6.34-powerpc-2.10-03.patch index 8f27969..233e0b4 100644 --- a/ksrc/arch/powerpc/patches/adeos-ipipe-2.6.34-powerpc-2.10-02.patch +++ b/ksrc/arch/powerpc/patches/adeos-ipipe-2.6.34-powerpc-2.10-03.patch @@ -262,7 +262,7 @@ index bd100fc..8fa1901 100644 * or should we not care like we do now ? --BenH. diff --git a/arch/powerpc/include/asm/ipipe.h b/arch/powerpc/include/asm/ipipe.h new file mode 100644 -index 000..8aa91f0 +index 000..31d54bb --- /dev/null +++ b/arch/powerpc/include/asm/ipipe.h @@ -0,0 +1,277 @@ @@ -313,10 +313,10 @@ index 000..8aa91f0 +#include asm/paca.h +#endif + -+#define IPIPE_ARCH_STRING 2.10-02 ++#define IPIPE_ARCH_STRING 2.10-03 +#define IPIPE_MAJOR_NUMBER2 +#define IPIPE_MINOR_NUMBER10 -+#define IPIPE_PATCH_NUMBER2 ++#define IPIPE_PATCH_NUMBER3 + +#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH + @@ -2079,7 +2079,7 @@ index bed9a29..172418a 100644 bl .start_kernel diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S -index 3ef743f..53a6c9e 100644 +index 3ef743f..f4a3d7b 100644 --- a/arch/powerpc/kernel/head_8xx.S +++ b/arch/powerpc/kernel/head_8xx.S @@ -185,6 +185,12 @@ i##n: \ @@ -2119,6 +2119,31 @@ index 3ef743f..53a6c9e 100644 EXCEPTION(0xa00, Trap_0a, unknown_exception, EXC_XFER_EE) EXCEPTION(0xb00, Trap_0b, unknown_exception, EXC_XFER_EE) +@@ -918,15 +932,24 @@ _GLOBAL(set_context) + * It is important we get called with interrupts disabled. I used to + * do that, but it appears that all code that calls this already had + * interrupt disabled. ++ * I-pipe: we enforce this back, we need to bypass virtualization ++ * here. + */ + .globl set_dec_cpu6 + set_dec_cpu6: ++#ifdef CONFIG_IPIPE ++ mfmsr r6 ++ rlwinm r5,r6,0,17,15 /* clear MSR_EE */ ++#endif + lis r7, cpu6_errata_w...@h + ori r7, r7, cpu6_errata_w...@l + li r4, 0x2c00 + stw r4, 8(r7) + lwz r4, 8(r7) + mtspr 22, r3/* Update Decrementer */ ++#ifdef CONFIG_IPIPE ++ MTMSRD(r6) ++#endif + SYNC + blr + #endif diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h index 50504ae..01b3d31 100644 --- a/arch/powerpc/kernel/head_booke.h @@ -4311,6 +4336,64 @@ index 5b0ab99..6e057d7 100644 } #endif /* CONFIG_CPM2 */ +diff --git a/arch/powerpc/platforms/8xx/m8xx_setup.c b/arch/powerpc/platforms/8xx/m8xx_setup.c +index 60168c1..a39bcff 100644 +--- a/arch/powerpc/platforms/8xx/m8xx_setup.c b/arch/powerpc/platforms/8xx/m8xx_setup.c +@@ -170,6 +170,7 @@ int mpc8xx_set_rtc_time(struct rtc_time *tm) + { + sitk8xx_t __iomem *sys_tmr1; + sit8xx_t __iomem *sys_tmr2; ++ unsigned long flags; + int time; + + sys_tmr1 = immr_map(im_sitk); +@@ -177,9 +178,11 @@ int mpc8xx_set_rtc_time(struct rtc_time *tm) + time = mktime(tm-tm_year+1900, tm-tm_mon+1, tm-tm_mday, + tm-tm_hour, tm-tm_min, tm-tm_sec); + ++ local_irq_save_hw_cond(flags); + out_be32(sys_tmr1-sitk_rtck, KAPWR_KEY); + out_be32(sys_tmr2-sit_rtc, time); +
[Xenomai-git] Philippe Gerum : powerpc: add calibration values for mpc8xx
Module: xenomai-rpm Branch: for-upstream Commit: 19acad8d1d33f0d51edd5bccf3877f94955142af URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=19acad8d1d33f0d51edd5bccf3877f94955142af Author: Philippe Gerum r...@xenomai.org Date: Thu Jun 24 15:27:14 2010 +0200 powerpc: add calibration values for mpc8xx --- include/asm-powerpc/calibration.h |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/asm-powerpc/calibration.h b/include/asm-powerpc/calibration.h index 7edf96b..52b3475 100644 --- a/include/asm-powerpc/calibration.h +++ b/include/asm-powerpc/calibration.h @@ -77,7 +77,7 @@ static inline unsigned long xnarch_get_sched_latency(void) #elif defined(CONFIG_TQM8555) #define __sched_latency 2000 #elif defined(CONFIG_KUP4K) -#define __sched_latency 1 +#define __sched_latency 22000 /* * Check for the most generic configs at the bottom of this list, so * that the most specific choices available are picked first. @@ -89,7 +89,7 @@ static inline unsigned long xnarch_get_sched_latency(void) #elif defined(CONFIG_PPC_MPC52xx) #define __sched_latency 4500 #elif defined(CONFIG_PPC_8xx) -#define __sched_latency 15000 +#define __sched_latency 25000 #endif #ifndef __sched_latency ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : powerpc: upgrade I-pipe support to 2.6.34-powerpc-2.10-03
Module: xenomai-rpm Branch: for-upstream Commit: 999041a2c5a1e2d24db1bebbffde202377f3ce6b URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=999041a2c5a1e2d24db1bebbffde202377f3ce6b Author: Philippe Gerum r...@xenomai.org Date: Thu Jun 24 15:12:45 2010 +0200 powerpc: upgrade I-pipe support to 2.6.34-powerpc-2.10-03 This patch introduces support for the KUP4K board (Kieback Peter, mpc855). --- ...ch = adeos-ipipe-2.6.34-powerpc-2.10-03.patch} | 196 +++- 1 files changed, 189 insertions(+), 7 deletions(-) diff --git a/ksrc/arch/powerpc/patches/adeos-ipipe-2.6.34-powerpc-2.10-02.patch b/ksrc/arch/powerpc/patches/adeos-ipipe-2.6.34-powerpc-2.10-03.patch similarity index 98% rename from ksrc/arch/powerpc/patches/adeos-ipipe-2.6.34-powerpc-2.10-02.patch rename to ksrc/arch/powerpc/patches/adeos-ipipe-2.6.34-powerpc-2.10-03.patch index 8f27969..233e0b4 100644 --- a/ksrc/arch/powerpc/patches/adeos-ipipe-2.6.34-powerpc-2.10-02.patch +++ b/ksrc/arch/powerpc/patches/adeos-ipipe-2.6.34-powerpc-2.10-03.patch @@ -262,7 +262,7 @@ index bd100fc..8fa1901 100644 * or should we not care like we do now ? --BenH. diff --git a/arch/powerpc/include/asm/ipipe.h b/arch/powerpc/include/asm/ipipe.h new file mode 100644 -index 000..8aa91f0 +index 000..31d54bb --- /dev/null +++ b/arch/powerpc/include/asm/ipipe.h @@ -0,0 +1,277 @@ @@ -313,10 +313,10 @@ index 000..8aa91f0 +#include asm/paca.h +#endif + -+#define IPIPE_ARCH_STRING 2.10-02 ++#define IPIPE_ARCH_STRING 2.10-03 +#define IPIPE_MAJOR_NUMBER2 +#define IPIPE_MINOR_NUMBER10 -+#define IPIPE_PATCH_NUMBER2 ++#define IPIPE_PATCH_NUMBER3 + +#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH + @@ -2079,7 +2079,7 @@ index bed9a29..172418a 100644 bl .start_kernel diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S -index 3ef743f..53a6c9e 100644 +index 3ef743f..f4a3d7b 100644 --- a/arch/powerpc/kernel/head_8xx.S +++ b/arch/powerpc/kernel/head_8xx.S @@ -185,6 +185,12 @@ i##n: \ @@ -2119,6 +2119,31 @@ index 3ef743f..53a6c9e 100644 EXCEPTION(0xa00, Trap_0a, unknown_exception, EXC_XFER_EE) EXCEPTION(0xb00, Trap_0b, unknown_exception, EXC_XFER_EE) +@@ -918,15 +932,24 @@ _GLOBAL(set_context) + * It is important we get called with interrupts disabled. I used to + * do that, but it appears that all code that calls this already had + * interrupt disabled. ++ * I-pipe: we enforce this back, we need to bypass virtualization ++ * here. + */ + .globl set_dec_cpu6 + set_dec_cpu6: ++#ifdef CONFIG_IPIPE ++ mfmsr r6 ++ rlwinm r5,r6,0,17,15 /* clear MSR_EE */ ++#endif + lis r7, cpu6_errata_w...@h + ori r7, r7, cpu6_errata_w...@l + li r4, 0x2c00 + stw r4, 8(r7) + lwz r4, 8(r7) + mtspr 22, r3/* Update Decrementer */ ++#ifdef CONFIG_IPIPE ++ MTMSRD(r6) ++#endif + SYNC + blr + #endif diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h index 50504ae..01b3d31 100644 --- a/arch/powerpc/kernel/head_booke.h @@ -4311,6 +4336,64 @@ index 5b0ab99..6e057d7 100644 } #endif /* CONFIG_CPM2 */ +diff --git a/arch/powerpc/platforms/8xx/m8xx_setup.c b/arch/powerpc/platforms/8xx/m8xx_setup.c +index 60168c1..a39bcff 100644 +--- a/arch/powerpc/platforms/8xx/m8xx_setup.c b/arch/powerpc/platforms/8xx/m8xx_setup.c +@@ -170,6 +170,7 @@ int mpc8xx_set_rtc_time(struct rtc_time *tm) + { + sitk8xx_t __iomem *sys_tmr1; + sit8xx_t __iomem *sys_tmr2; ++ unsigned long flags; + int time; + + sys_tmr1 = immr_map(im_sitk); +@@ -177,9 +178,11 @@ int mpc8xx_set_rtc_time(struct rtc_time *tm) + time = mktime(tm-tm_year+1900, tm-tm_mon+1, tm-tm_mday, + tm-tm_hour, tm-tm_min, tm-tm_sec); + ++ local_irq_save_hw_cond(flags); + out_be32(sys_tmr1-sitk_rtck, KAPWR_KEY); + out_be32(sys_tmr2-sit_rtc, time); + out_be32(sys_tmr1-sitk_rtck, ~KAPWR_KEY); ++ local_irq_restore_hw_cond(flags); + + immr_unmap(sys_tmr2); + immr_unmap(sys_tmr1); +@@ -205,7 +208,7 @@ void mpc8xx_restart(char *cmd) + car8xx_t __iomem *clk_r = immr_map(im_clkrst); + + +- local_irq_disable(); ++ local_irq_disable_hw(); + + setbits32(clk_r-car_plprcr, 0x0080); + /* Clear the ME bit in MSR to cause checkstop on machine check +@@ -220,6 +223,16 @@ static void cpm_cascade(unsigned int irq, struct irq_desc *desc) + { + int cascade_irq; + ++#ifdef CONFIG_IPIPE ++ desc-chip-eoi(irq); ++ if ((cascade_irq = cpm_get_irq()) = 0) { ++ struct irq_desc *cdesc = irq_to_desc(cascade_irq); ++ ++ cdesc-chip-eoi(cascade_irq); ++ ipipe_handle_chained_irq(cascade_irq); ++ } ++ desc-chip-unmask(irq); ++#else + if ((cascade_irq =
[Xenomai-git] Alexis Berlemont : analogy: the subdevice structure got a new status field (broken)
Module: xenomai-abe Branch: experimental Commit: b598c947343c235b391620fb0998c7513557f6e5 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=b598c947343c235b391620fb0998c7513557f6e5 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun May 16 23:20:51 2010 +0200 analogy: the subdevice structure got a new status field (broken) --- include/analogy/subdevice.h | 26 +- 1 files changed, 25 insertions(+), 1 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 1c3bcd4..11a345e 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -141,12 +141,28 @@ /*! @} ANALOGY_SUBD_FT_xxx */ +/*! + * @anchor ANALOGY_SUBD_ST_xxx @name Subdevice status + * @brief Flags to define the subdevice's status + * @{ + */ + +/* Subdevice status flag(s) */ +/** + * The subdevice is busy, a synchronous or an asynchronous acquisition + * is occuring + */ +#define A4L_SUBD_BUSY_NR 0 +#define A4L_SUBD_BUSY (1 A4L_SUBD_BUSY_NR) + + /*! @} ANALOGY_SUBD_ST_xxx */ + #ifdef __KERNEL__ /* --- Subdevice descriptor structure --- */ struct a4l_device; -struct a4l_driver; +struct a4l_buffer; /*! * @brief Structure describing the subdevice @@ -160,9 +176,17 @@ struct a4l_subdevice { struct a4l_device *dev; /** Containing device */ + unsigned int idx; /** Subdevice index */ + struct a4l_buffer *buf; + /** Linked buffer */ + + /* Subdevice's status (busy, linked?) */ + unsigned long status; +/** Subdevice's status */ + /* Descriptors stuff */ unsigned long flags; /** Type flags */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: change the context's role (broken)
Module: xenomai-abe Branch: experimental Commit: 4480b6ebfe57954f59177e272891890e675c7a1f URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=4480b6ebfe57954f59177e272891890e675c7a1f Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun May 16 23:11:47 2010 +0200 analogy: change the context's role (broken) --- include/analogy/context.h | 27 +-- 1 files changed, 9 insertions(+), 18 deletions(-) diff --git a/include/analogy/context.h b/include/analogy/context.h index 7bd225a..d30bbba 100644 --- a/include/analogy/context.h +++ b/include/analogy/context.h @@ -25,29 +25,20 @@ #if defined(__KERNEL__) !defined(DOXYGEN_CPP) -#include analogy/os_facilities.h - struct a4l_device; +struct a4l_buffer; -struct a4l_context { - - /* This field is redundant with the following parameters; - setting it at the head of the structure may save - useless operations */ - struct a4l_device *dev; +struct a4l_device_context { + /* No need to hold user_info, thanks to container_of, we could + get it back */ rtdm_user_info_t *user_info; - struct rtdm_dev_context *rtdm_cxt; -}; -typedef struct a4l_context a4l_cxt_t; -#define a4l_get_minor(x) ((x)-rtdm_cxt-device-device_id) + struct a4l_device *dev; /* Which is retrieved thanks to minor + at open time */ -#define a4l_init_cxt(c, u, x) \ -{ \ - (x)-rtdm_cxt = c; \ - (x)-user_info = u; \ - (x)-dev = NULL;\ -} + struct buffer buffer; /* The buffer field is extracted from +the transfer structure */ +}; #endif /* __KERNEL__ !DOXYGEN_CPP */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: the buffer structure is now the central field of a4l_context (broken)
Module: xenomai-abe Branch: experimental Commit: a32d500ee4ed944836b98e5c3b34a66dd7a7e141 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=a32d500ee4ed944836b98e5c3b34a66dd7a7e141 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun May 16 23:19:52 2010 +0200 analogy: the buffer structure is now the central field of a4l_context (broken) --- include/analogy/buffer.h | 14 -- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 007f01e..49d2a9f 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -43,11 +43,21 @@ #define A4L_BUF_ERROR (1 A4L_BUF_ERROR_NR) #define A4L_BUF_EOA (1 A4L_BUF_EOA_NR) +/* Status bits */ +#define A4L_BUF_BULK_NR 8 +#define A4L_BUF_MAP_NR 8 +/* Status flags */ +#define A4L_BUF_BULK (1 A4L_BUF_BULK_NR) +#define A4L_BUF_MAP (1 A4L_BUF_MAP_NR) + struct a4l_subdevice; /* Buffer descriptor structure */ struct a4l_buffer { + /* Added by the structure update */ + a4l_subd_t *subd; + /* Buffer's first virtual page pointer */ void *buf; @@ -65,8 +75,8 @@ struct a4l_buffer { unsigned long cns_count; unsigned long tmp_count; - /* Events occuring during transfer */ - unsigned long evt_flags; + /* Status + events occuring during transfer */ + unsigned long flags; /* Command on progress */ a4l_cmd_t *cur_cmd; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: the transfer structure is left with a minimal role (broken)
Module: xenomai-abe Branch: experimental Commit: 8bb9a218fcf6a6d8e3fe997c37700850a501c6cb URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=8bb9a218fcf6a6d8e3fe997c37700850a501c6cb Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun May 16 23:22:36 2010 +0200 analogy: the transfer structure is left with a minimal role (broken) This structure should be renamed. --- include/analogy/transfer.h | 17 - 1 files changed, 4 insertions(+), 13 deletions(-) diff --git a/include/analogy/transfer.h b/include/analogy/transfer.h index e6bdc3c..929022b 100644 --- a/include/analogy/transfer.h +++ b/include/analogy/transfer.h @@ -30,15 +30,14 @@ #include analogy/buffer.h /* Status flags / bits */ -#define A4L_TSF_BUSY 0 -#define A4L_TSF_BULK 1 -#define A4L_TSF_MMAP 2 -#define A4L_TSF_CLEAN 3 +#define A4L_TSF_CLEAN 0 /* Fields init values */ #define A4L_IRQ_UNUSED (unsigned int)((unsigned short)(~0)) #define A4L_IDX_UNUSED (unsigned int)(~0) +/* TODO: IRQ handling must leave transfer for os_facilities */ + /* IRQ types */ #define A4L_IRQ_SHARED RTDM_IRQTYPE_SHARED #define A4L_IRQ_EDGE RTDM_IRQTYPE_EDGE @@ -51,24 +50,16 @@ #ifdef __KERNEL__ struct a4l_device; - /* Analogy transfer descriptor */ struct a4l_transfer { /* Subdevices desc */ unsigned int nb_subd; a4l_subd_t **subds; - int idx_read_subd; - int idx_write_subd; - - /* Buffer desc */ - a4l_buf_t **bufs; /* IRQ in use */ + /* TODO: irq_desc should vanish */ a4l_irq_desc_t irq_desc; - - /* Events/status desc */ - unsigned long *status; }; typedef struct a4l_transfer a4l_trf_t; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: adapt open, r/w, select and ioctl functions ( broken)
Module: xenomai-abe Branch: experimental Commit: a9e1e43dd08c5119f5a1af4208c61d65fb458d3d URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=a9e1e43dd08c5119f5a1af4208c61d65fb458d3d Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun May 16 23:25:49 2010 +0200 analogy: adapt open, r/w, select and ioctl functions (broken) --- ksrc/drivers/analogy/rtdm_interface.c | 130 +++- 1 files changed, 61 insertions(+), 69 deletions(-) diff --git a/ksrc/drivers/analogy/rtdm_interface.c b/ksrc/drivers/analogy/rtdm_interface.c index cbc3ca6..d37ce4c 100644 --- a/ksrc/drivers/analogy/rtdm_interface.c +++ b/ksrc/drivers/analogy/rtdm_interface.c @@ -121,125 +121,117 @@ void a4l_cleanup_proc(void) #endif /* CONFIG_PROC_FS */ -int a4l_rt_open(struct rtdm_dev_context *context, - rtdm_user_info_t * user_info, int flags) +int a4l_open(struct rtdm_dev_context *context, +rtdm_user_info_t * user_info, int flags) { - a4l_cxt_t cxt; + a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; - a4l_init_cxt(context, user_info, cxt); - a4l_set_dev(cxt); - __a4l_dbg(1, core_dbg, - a4l_rt_open: minor=%d\n, a4l_get_minor(cxt)); + /* Get a pointer on the selected device + (thanks to minor index) */ + a4l_set_dev(context); + + /* Initialize the buffer structure */ + a4l_init_buffer(cxt-buffer); + + /* Allocate the asynchronous buffer + NOTE: it should be interesting to allocate the buffer only + on demand especially if the system is short of memory + NOTE2: the default buffer size could be configured via + kernel config*/ + a4l_alloc_buffer(cxt-buffer, A4L_DEFAULT_BFSIZE); return 0; } -int a4l_rt_close(struct rtdm_dev_context *context, -rtdm_user_info_t * user_info) +int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) { - a4l_cxt_t cxt; + int err; + a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + + /* Cancel the maybe occuring asynchronous transfer */ + err = a4l_cancel_buffer(cxt-buffer); + if (err 0) { + __a4l_err(close: unable to stop the asynchronous transfer\n); + return err; + } - a4l_init_cxt(context, user_info, cxt); - a4l_set_dev(cxt); - __a4l_dbg(1, core_dbg, - a4l_rt_close: minor=%d\n, a4l_get_minor(cxt)); + /* Free the buffer which was linked with this context */ + err = a4l_free_buffer(cxt-buffer); - return a4l_cancel_transfers(cxt);; + return err; } -ssize_t a4l_rt_read(struct rtdm_dev_context * context, - rtdm_user_info_t * user_info, void *buf, size_t nbytes) +ssize_t a4l_read(struct rtdm_dev_context * context, +rtdm_user_info_t * user_info, void *buf, size_t nbytes) { - a4l_cxt_t cxt; + a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + /* Jump into the RT domain if possible */ if (!rtdm_in_rt_context() rtdm_rt_capable(user_info)) return -ENOSYS; - a4l_init_cxt(context, user_info, cxt); - a4l_set_dev(cxt); - - __a4l_dbg(1, core_dbg, - a4l_rt_read: minor=%d\n, a4l_get_minor(cxt)); - if (nbytes == 0) return 0; - return a4l_read(cxt, buf, nbytes); + cxt-user_info = user_info; + + return a4l_read(cxt, buf, nbytes); } -ssize_t a4l_rt_write(struct rtdm_dev_context * context, -rtdm_user_info_t * user_info, const void *buf, -size_t nbytes) +ssize_t a4l_write(struct rtdm_dev_context * context, + rtdm_user_info_t *user_info, const void *buf, size_t nbytes) { - a4l_cxt_t cxt; + a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + /* Jump into the RT domain if possible */ if (!rtdm_in_rt_context() rtdm_rt_capable(user_info)) return -ENOSYS; - a4l_init_cxt(context, user_info, cxt); - a4l_set_dev(cxt); - - __a4l_dbg(1, core_dbg, a4l_rt_write: minor=%d\n, a4l_get_minor(cxt)); - if (nbytes == 0) return 0; - return a4l_write(cxt, buf, nbytes); + cxt-user_info = user_info; + + return a4l_write(cxt, buf, nbytes); } -int a4l_rt_ioctl(struct rtdm_dev_context *context, -rtdm_user_info_t * user_info, -unsigned int request, void *arg) +int a4l_ioctl(struct rtdm_dev_context *context, + rtdm_user_info_t *user_info, unsigned int request, void *arg) { - a4l_cxt_t cxt; + a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; - a4l_init_cxt(context, user_info, cxt); - a4l_set_dev(cxt); - __a4l_dbg(1, core_dbg, - a4l_rt_ioctl: minor=%d\n, a4l_get_minor(cxt)); + cxt-user_info = user_info; - return
[Xenomai-git] Alexis Berlemont : analogy: adapt a4l_set_dev() after a4l_context' s overhaul (broken)
Module: xenomai-abe Branch: experimental Commit: e31a28c27483615fb3b90846aabea6d358228bb9 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=e31a28c27483615fb3b90846aabea6d358228bb9 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun May 16 23:55:48 2010 +0200 analogy: adapt a4l_set_dev() after a4l_context's overhaul (broken) --- ksrc/drivers/analogy/device.c | 10 -- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ksrc/drivers/analogy/device.c b/ksrc/drivers/analogy/device.c index b3ef9bf..4a3c879 100644 --- a/ksrc/drivers/analogy/device.c +++ b/ksrc/drivers/analogy/device.c @@ -59,9 +59,15 @@ int a4l_check_cleanup_devs(void) return ret; } -void a4l_set_dev(a4l_cxt_t * cxt) +void a4l_set_dev(struct rtdm_dev_context *context) { - cxt-dev = (a4l_devs[a4l_get_minor(cxt)]); + /* Get the context's private structure */ + a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + /* Retrive the minor index */ + static int minor = context-device-device_id; + + /* Fill the dev fields accordingly */ + cxt-dev = (a4l_devs[minor]); } /* --- Device tab proc section --- */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: update a4l_set_dev() declaration (broken)
Module: xenomai-abe Branch: experimental Commit: cb94eb2062b771518b02b797e63b9d8f4abf109a URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=cb94eb2062b771518b02b797e63b9d8f4abf109a Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun May 16 23:56:48 2010 +0200 analogy: update a4l_set_dev() declaration (broken) --- include/analogy/device.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/analogy/device.h b/include/analogy/device.h index 27a3bd0..51b99b5 100644 --- a/include/analogy/device.h +++ b/include/analogy/device.h @@ -91,7 +91,7 @@ int a4l_rdproc_devs(char *page, off_t off, int count, int *eof, void *data); /* --- Context related function / macro --- */ -void a4l_set_dev(a4l_cxt_t * cxt); +void a4l_set_dev(struct rtdm_dev_context *context); #define a4l_get_dev(x) ((x)-dev) /* --- Upper layer functions --- */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: update comments on a4l_context (broken)
Module: xenomai-abe Branch: experimental Commit: a25a03ac28a3e6e484590debe1ce2c57f4b49218 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=a25a03ac28a3e6e484590debe1ce2c57f4b49218 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun May 16 23:57:19 2010 +0200 analogy: update comments on a4l_context (broken) --- include/analogy/context.h | 15 +-- 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/analogy/context.h b/include/analogy/context.h index d30bbba..e0cf01c 100644 --- a/include/analogy/context.h +++ b/include/analogy/context.h @@ -29,15 +29,18 @@ struct a4l_device; struct a4l_buffer; struct a4l_device_context { - /* No need to hold user_info, thanks to container_of, we could - get it back */ + + /* Needed to call rtdm_*_copy_from/to_user functions */ rtdm_user_info_t *user_info; - struct a4l_device *dev; /* Which is retrieved thanks to minor - at open time */ + /* The adequate device pointer + (retrieved thanks to minor at open time) */ + struct a4l_device *dev; - struct buffer buffer; /* The buffer field is extracted from -the transfer structure */ + /* The buffer structure contains everything to transfer data + from asynchronous acquisition operations on a specific + subdevice */ + struct buffer buffer; }; #endif /* __KERNEL__ !DOXYGEN_CPP */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: changes related with subdevice's status field ( broken)
Module: xenomai-abe Branch: experimental Commit: 353287226edb99dfef56abd0f986740a87b3cd94 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=353287226edb99dfef56abd0f986740a87b3cd94 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon May 17 00:08:40 2010 +0200 analogy: changes related with subdevice's status field (broken) --- include/analogy/subdevice.h |8 ksrc/drivers/analogy/subdevice.c |2 +- ksrc/drivers/analogy/transfer.c | 73 -- 3 files changed, 16 insertions(+), 67 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 11a345e..0f9e1c5 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -155,6 +155,14 @@ #define A4L_SUBD_BUSY_NR 0 #define A4L_SUBD_BUSY (1 A4L_SUBD_BUSY_NR) +/** + * The subdevice is about to be cleaned in the middle of the detach + * procedure + */ +#define A4L_SUBD_CLEAN_NR 1 +#define A4L_SUBD_CLEAN (1 A4L_SUBD_CLEAN_NR) + + /*! @} ANALOGY_SUBD_ST_xxx */ #ifdef __KERNEL__ diff --git a/ksrc/drivers/analogy/subdevice.c b/ksrc/drivers/analogy/subdevice.c index 28aa4a0..1278081 100644 --- a/ksrc/drivers/analogy/subdevice.c +++ b/ksrc/drivers/analogy/subdevice.c @@ -201,7 +201,7 @@ int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg) for (i = 0; i dev-transfer.nb_subd; i++) { subd_info[i].flags = dev-transfer.subds[i]-flags; - subd_info[i].status = dev-transfer.status[i]; + subd_info[i].status = dev-transfer.subds[i]-status; subd_info[i].nb_chan = (dev-transfer.subds[i]-chan_desc != NULL) ? dev-transfer.subds[i]-chan_desc-length : 0; diff --git a/ksrc/drivers/analogy/transfer.c b/ksrc/drivers/analogy/transfer.c index c8a7d43..b1e511d 100644 --- a/ksrc/drivers/analogy/transfer.c +++ b/ksrc/drivers/analogy/transfer.c @@ -53,31 +53,26 @@ int a4l_precleanup_transfer(a4l_cxt_t * cxt) } for (i = 0; i tsf-nb_subd; i++) { + unsigned long *status = tsf-subds[i]-status; - if (test_bit(A4L_TSF_MMAP, (tsf-status[i]))) { - __a4l_err(a4l_precleanup_transfer: - device busy, buffer must be unmapped\n); - err = -EPERM; - goto out_error; - } - - if (test_and_set_bit(A4L_TSF_BUSY, (tsf-status[i]))) { + if (test_and_set_bit(A4L_SUBD_BUSY, status)) { __a4l_err(a4l_precleanup_transfer: device busy, acquisition occuring\n); err = -EBUSY; goto out_error; } else - set_bit(A4L_TSF_CLEAN, (tsf-status[i])); + set_bit(A4L_SUBD_CLEAN, status); } return 0; out_error: for (i = 0; i tsf-nb_subd; i++) { + unsigned long *status = tsf-subds[i]-status; - if (test_bit(A4L_TSF_CLEAN, (tsf-status[i]))){ - clear_bit(A4L_TSF_BUSY, (tsf-status[i])); - clear_bit(A4L_TSF_CLEAN, (tsf-status[i])); + if (test_bit(A4L_TSF_CLEAN, status)){ + clear_bit(A4L_SUBD_BUSY, status); + clear_bit(A4L_SUBD_CLEAN, status); } } @@ -97,21 +92,6 @@ int a4l_cleanup_transfer(a4l_cxt_t * cxt) dev = a4l_get_dev(cxt); tsf = dev-transfer; - /* Releases the various buffers */ - if (tsf-status != NULL) - rtdm_free(tsf-status); - - if (tsf-bufs != NULL) { - for (i = 0; i tsf-nb_subd; i++) { - if (tsf-bufs[i] != NULL) { - a4l_free_buffer(tsf-bufs[i]); - a4l_cleanup_sync(tsf-bufs[i]-sync); - rtdm_free(tsf-bufs[i]); - } - } - rtdm_free(tsf-bufs); - } - /* Releases the pointers tab, if need be */ if (tsf-subds != NULL) { rtdm_free(tsf-subds); @@ -135,10 +115,6 @@ void a4l_presetup_transfer(a4l_cxt_t *cxt) /* Clear the structure */ memset(tsf, 0, sizeof(a4l_trf_t)); - /* We consider 0 can be valid index */ - tsf-idx_read_subd = A4L_IDX_UNUSED; - tsf-idx_write_subd = A4L_IDX_UNUSED; - /* 0 is also considered as a valid IRQ, then the IRQ number must be initialized with another value */ tsf-irq_desc.irq = A4L_IRQ_UNUSED; @@ -186,41 +162,6 @@ int a4l_setup_transfer(a4l_cxt_t * cxt) tsf-subds[i++] = subd; } - /* Allocates various buffers */ - tsf-bufs = rtdm_malloc(tsf-nb_subd * sizeof(a4l_buf_t *)); - if (tsf-bufs == NULL) { - __a4l_err(a4l_setup_transfer: call2(alloc)
[Xenomai-git] Alexis Berlemont : analogy: replace transfer setup functions with buffer setup ones (broken)
Module: xenomai-abe Branch: experimental Commit: 99a8b1a36361ca433d33d6d465cfb12ada674d32 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=99a8b1a36361ca433d33d6d465cfb12ada674d32 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon May 17 23:31:20 2010 +0200 analogy: replace transfer setup functions with buffer setup ones (broken) --- ksrc/drivers/analogy/buffer.c |3 + ksrc/drivers/analogy/command.c | 19 +++ ksrc/drivers/analogy/instruction.c |2 +- ksrc/drivers/analogy/transfer.c| 98 +++ 4 files changed, 22 insertions(+), 100 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index a27a1d6..92f1f4e 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -145,6 +145,9 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) } buf_desc-end_count *= cmd-stop_arg; } + + __a4l_dbg(1, core_dbg, + a4l_setup_buffer: end_count=%lu\n, buf_desc-end_count); return 0; } diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c index a6c1dec..b300d9a 100644 --- a/ksrc/drivers/analogy/command.c +++ b/ksrc/drivers/analogy/command.c @@ -299,7 +299,8 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) { int ret = 0, simul_flag = 0; a4l_cmd_t *cmd_desc = NULL; - a4l_dev_t *dev = a4l_get_dev(cxt); + a4l_subd_t *subd; + a4l_dev_t *dev = a4l_get_dev(cxt); __a4l_dbg(1, core_dbg, a4l_ioctl_cmd: minor=%d\n, a4l_get_minor(cxt)); @@ -344,11 +345,11 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) __a4l_dbg(1, core_dbg, a4l_ioctl_cmd: 1st cmd checks passed\n); + subd = dev-transfer.subds[cmd_desc-idx_subd]; + /* Tests the command with the cmdtest function */ - if (dev-transfer.subds[cmd_desc-idx_subd]-do_cmdtest != NULL) - ret = dev-transfer.subds[cmd_desc-idx_subd]- - do_cmdtest(dev-transfer.subds[cmd_desc-idx_subd], - cmd_desc); + if (subd-do_cmdtest != NULL) + ret = subd-do_cmdtest(subd, cmd_desc); if (ret != 0) { __a4l_err(a4l_ioctl_cmd: driver's cmd_test failed\n); goto out_ioctl_cmd; @@ -363,17 +364,15 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) } /* Sets the concerned subdevice as busy */ - ret = a4l_reserve_transfer(cxt, cmd_desc-idx_subd); + ret = a4l_reserve_subd(subd); if (ret 0) goto out_ioctl_cmd; /* Gets the transfer system ready */ - a4l_init_transfer(cxt, cmd_desc); + a4l_setup_buffer(cxt, cmd_desc); /* Eventually launches the command */ - ret = dev-transfer.subds[cmd_desc-idx_subd]- - do_cmd(dev-transfer.subds[cmd_desc-idx_subd], - cmd_desc); + ret = subd-do_cmd(subd, cmd_desc); if (ret != 0) { a4l_cancel_transfer(cxt, cmd_desc-idx_subd); diff --git a/ksrc/drivers/analogy/instruction.c b/ksrc/drivers/analogy/instruction.c index 64c7a04..941fa69 100644 --- a/ksrc/drivers/analogy/instruction.c +++ b/ksrc/drivers/analogy/instruction.c @@ -266,7 +266,7 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc) /* Prevents the subdevice from being used during the following operations */ - ret = a4l_reserve_transfer(cxt, dsc-idx_subd); + ret = a4l_reserve_subd(subd); if (ret 0) goto out_do_insn; diff --git a/ksrc/drivers/analogy/transfer.c b/ksrc/drivers/analogy/transfer.c index b1e511d..9fc279a 100644 --- a/ksrc/drivers/analogy/transfer.c +++ b/ksrc/drivers/analogy/transfer.c @@ -39,10 +39,6 @@ int a4l_precleanup_transfer(a4l_cxt_t * cxt) a4l_trf_t *tsf; int i, err = 0; - __a4l_dbg(1, core_dbg, - a4l_precleanup_transfer: minor=%d\n, - a4l_get_minor(cxt)); - dev = a4l_get_dev(cxt); tsf = dev-transfer; @@ -55,6 +51,10 @@ int a4l_precleanup_transfer(a4l_cxt_t * cxt) for (i = 0; i tsf-nb_subd; i++) { unsigned long *status = tsf-subds[i]-status; + __a4l_dbg(1, core_dbg, + a4l_precleanup_transfer: + subd[%d]-status=0x%08x\n, *status); + if (test_and_set_bit(A4L_SUBD_BUSY, status)) { __a4l_err(a4l_precleanup_transfer: device busy, acquisition occuring\n); @@ -70,7 +70,7 @@ out_error: for (i = 0; i tsf-nb_subd; i++) { unsigned long *status = tsf-subds[i]-status; - if (test_bit(A4L_TSF_CLEAN, status)){ + if (test_bit(A4L_SUBD_CLEAN, status)){ clear_bit(A4L_SUBD_BUSY, status);
[Xenomai-git] Alexis Berlemont : analogy: rewrite the cancel ioctl handler (broken)
Module: xenomai-abe Branch: experimental Commit: 40d2d7c368f3b3636f30cdb3c08a825c4cd4a39c URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=40d2d7c368f3b3636f30cdb3c08a825c4cd4a39c Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Tue May 18 23:53:11 2010 +0200 analogy: rewrite the cancel ioctl handler (broken) --- ksrc/drivers/analogy/buffer.c | 38 - ksrc/drivers/analogy/transfer.c | 45 --- 2 files changed, 37 insertions(+), 46 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index cb4beb7..bc162d3 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -155,7 +155,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) int err = 0; - if (!subd !! !a4l_check_subd(subd)) + if (!subd || !a4l_check_subd(subd)) return 0; /* If a cancel function is registered, call it @@ -547,6 +547,42 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) /* --- IOCTL / FOPS functions --- */ +int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) +{ + unsigned int idx_subd = (unsigned long)arg; + a4l_dev_t *dev = a4l_get_dev(cxt); + a4l_subd_t *subd; + + /* Basically check the device */ + if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + __a4l_err(a4l_ioctl_cancel: operation not supported on + an unattached device\n); + return -EINVAL; + } + + if (cxt-buffer-subd == NULL) { + __a4l_err(a4l_ioctl_cancel: + no acquisition to cancel on this context\n); + return -EINVAL; + } + + if (idx_subd = dev-transfer.nb_subd) { + __a4l_err(a4l_ioctl_cancel: bad subdevice index\n); + return -EINVAL; + } + + subd = dev-transfer.subds[idx_subd]; + + if (subd != cxt-buffer.subd) { + __a4l_err(a4l_ioctl_cancel: + current context works on another subdevice + (%d!=%d)\n, cxt-buffer.subd-idx, subd-idx); + return -EINVAL; + } + + return a4l_cancel_buffer(cxt); +} + int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) { a4l_dev_t *dev = a4l_get_dev(cxt); diff --git a/ksrc/drivers/analogy/transfer.c b/ksrc/drivers/analogy/transfer.c index aa0ae82..945402f 100644 --- a/ksrc/drivers/analogy/transfer.c +++ b/ksrc/drivers/analogy/transfer.c @@ -290,49 +290,4 @@ int a4l_rdproc_transfer(char *page, #endif /* CONFIG_PROC_FS */ -/* --- IOCTL / FOPS functions --- */ - -int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) -{ - unsigned int idx_subd = (unsigned long)arg; - a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_subd_t *subd; - - __a4l_dbg(1, core_dbg, - a4l_ioctl_cancel: minor=%d\n, a4l_get_minor(cxt)); - - /* Basically check the device */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { - __a4l_err(a4l_ioctl_cancel: operation not supported on - an unattached device\n); - return -EINVAL; - } - - if (idx_subd = dev-transfer.nb_subd) { - __a4l_err(a4l_ioctl_cancel: bad subdevice index\n); - return -EINVAL; - } - - if ((dev-transfer.subds[idx_subd]-flags A4L_SUBD_TYPES) == - A4L_SUBD_UNUSED) { - __a4l_err(a4l_ioctl_cancel: non functional subdevice\n); - return -EIO; - } - - if (!(dev-transfer.subds[idx_subd]-flags A4L_SUBD_CMD)) { - __a4l_err(a4l_ioctl_cancel: operation not supported, - synchronous only subdevice\n); - return -EIO; - } - - subd = dev-transfer.subds[idx_subd]; - - if (!test_bit(A4L_TSF_BUSY, (dev-transfer.status[idx_subd]))) { - __a4l_err(a4l_ioctl_cancel: subdevice currently idle\n); - return -EINVAL; - } - - return a4l_cancel_transfer(cxt, idx_subd); -} - #endif /* !DOXYGEN_CPP */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: update cancel functions (broken)
Module: xenomai-abe Branch: experimental Commit: 3bd3fad57fe10639597c5dc88cc96848715b6773 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=3bd3fad57fe10639597c5dc88cc96848715b6773 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon May 17 23:58:52 2010 +0200 analogy: update cancel functions (broken) --- ksrc/drivers/analogy/buffer.c | 58 - ksrc/drivers/analogy/transfer.c | 61 --- 2 files changed, 44 insertions(+), 75 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 92f1f4e..cb4beb7 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -91,10 +91,8 @@ out_virt_contig_alloc: return ret; } -int a4l_init_buffer(a4l_buf_t * buf_desc) +void a4l_init_buffer(a4l_buf_t * buf_desc) { - int err; - /* No command to process yet */ buf_desc-cur_cmd = NULL; @@ -111,13 +109,11 @@ int a4l_init_buffer(a4l_buf_t * buf_desc) /* Flush pending events */ buf_desc-flags = 0; a4l_flush_sync(buf_desc-sync); - - return err; } int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) { - a4l_buf_t * buf_desc = cxt-buffer; + a4l_buf_t *buf_desc = cxt-buffer; int i; /* Retrieve the related subdevice */ @@ -152,6 +148,40 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) return 0; } +int a4l_cancel_buffer(a4l_cxt_t *cxt) +{ + a4l_buf_t *buf_desc = cxt-buffer; + a4l_subd_t *subd = buf_desc-subd; + + int err = 0; + + if (!subd !! !a4l_check_subd(subd)) + return 0; + + /* If a cancel function is registered, call it + (Note: this function is called before having checked + if a command is under progress; we consider that + the cancel function can be used as as to (re)initialize + some component) */ + if (subd-cancel != NULL (err = subd-cancel(subd)) 0) { + __a4l_err(a4l_cancel: + subdevice %d cancel handler failed (err=%d)\n, + idx_subd, err); + } + + a4l_release_subd(subd); + + if (buf_desc-cur_cmd != NULL) { + a4l_free_cmddesc(buf_desc-cur_cmd); + rtdm_free(buf_desc-cur_cmd); + buf_desc-cur_cmd = NULL; + } + + a4l_init_buffer(buf_desc); + + return err; +} + /* --- current Command management function --- */ a4l_cmd_t *a4l_get_cmd(a4l_subd_t *subd) @@ -646,13 +676,13 @@ int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg) if ((ret 0 ret != -ENOENT) || (ret == -ENOENT tmp_cnt == 0)) { - a4l_cancel_transfer(cxt, info.idx_subd); + a4l_cancel_buffer(cxt); return ret; } } else if (info.idx_subd == dev-transfer.idx_write_subd) { if (ret 0) { - a4l_cancel_transfer(cxt, info.idx_subd); + a4l_cancel_buffer(cxt); if (info.rw_count != 0) return ret; } @@ -744,14 +774,14 @@ ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) /* We check whether there is an error */ if (ret 0 ret != -ENOENT) { - a4l_cancel_transfer(cxt, idx_subd); + a4l_cancel_buffer(cxt); count = ret; goto out_a4l_read; } /* We check whether the acquisition is over */ if (ret == -ENOENT tmp_cnt == 0) { - a4l_cancel_transfer(cxt, idx_subd); + a4l_cancel_buffer(cxt); count = 0; goto out_a4l_read; } @@ -846,7 +876,7 @@ ssize_t a4l_write(a4l_cxt_t *cxt, tmp_cnt = nbytes - count; if (ret 0) { - a4l_cancel_transfer(cxt, idx_subd); + a4l_cancel_buffer(cxt); count = (ret == -ENOENT) ? -EINVAL : ret; goto out_a4l_write; } @@ -993,20 +1023,20 @@ int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg) /* Check if some error occured */ if (ret 0 ret != -ENOENT) { - a4l_cancel_transfer(cxt, poll.idx_subd); + a4l_cancel_buffer(cxt); return ret; } /* Check whether the acquisition is over */ if (ret == -ENOENT tmp_cnt == 0) { - a4l_cancel_transfer(cxt, poll.idx_subd); + a4l_cancel_buffer(cxt); return 0;
[Xenomai-git] Alexis Berlemont : analogy: fix bulk flag declaration in buffer.h (broken)
Module: xenomai-abe Branch: experimental Commit: f324cf68e70d5953dd9816883f7a46cfe1d37550 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=f324cf68e70d5953dd9816883f7a46cfe1d37550 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Wed May 19 00:13:36 2010 +0200 analogy: fix bulk flag declaration in buffer.h (broken) --- include/analogy/buffer.h | 10 +- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 49d2a9f..786c8e1 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -45,7 +45,7 @@ /* Status bits */ #define A4L_BUF_BULK_NR 8 -#define A4L_BUF_MAP_NR 8 +#define A4L_BUF_MAP_NR 9 /* Status flags */ #define A4L_BUF_BULK (1 A4L_BUF_BULK_NR) #define A4L_BUF_MAP (1 A4L_BUF_MAP_NR) @@ -89,8 +89,8 @@ typedef struct a4l_buffer a4l_buf_t; /* Static inline Buffer related functions */ /* Produce memcpy function */ -static inline int __produce(a4l_cxt_t * cxt, - a4l_buf_t * buf, void *pin, unsigned long count) +static inline int __produce(a4l_cxt_t *cxt, + a4l_buf_t *buf, void *pin, unsigned long count) { unsigned long start_ptr = (buf-prd_count % buf-size); unsigned long tmp_cnt = count; @@ -119,8 +119,8 @@ static inline int __produce(a4l_cxt_t * cxt, } /* Consume memcpy function */ -static inline int __consume(a4l_cxt_t * cxt, - a4l_buf_t * buf, void *pout, unsigned long count) +static inline int __consume(a4l_cxt_t *cxt, + a4l_buf_t *buf, void *pout, unsigned long count) { unsigned long start_ptr = (buf-cns_count % buf-size); unsigned long tmp_cnt = count; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: last updates in the buffer part (broken)
Module: xenomai-abe Branch: experimental Commit: 156a26764c8ff05db4dd031165730987d08c80ee URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=156a26764c8ff05db4dd031165730987d08c80ee Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Wed May 19 23:35:12 2010 +0200 analogy: last updates in the buffer part (broken) --- ksrc/drivers/analogy/buffer.c | 13 ++--- 1 files changed, 2 insertions(+), 11 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index c9b1682..011753a 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -387,8 +387,8 @@ void a4l_unmap(struct vm_area_struct *area) } static struct vm_operations_struct a4l_vm_ops = { -open:a4l_map, -close:a4l_unmap, + .open = a4l_map, + .close = a4l_unmap, }; int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) @@ -397,9 +397,6 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) a4l_dev_t *dev; int ret; - __a4l_dbg(1, core_dbg, - a4l_ioctl_mmap: minor=%d\n, a4l_get_minor(cxt)); - /* The mmap operation cannot be performed in a real-time context */ if (rtdm_in_rt_context()) { @@ -511,9 +508,6 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) a4l_dev_t *dev = a4l_get_dev(cxt); a4l_bufcfg_t buf_cfg; - __a4l_dbg(1, core_dbg, - a4l_ioctl_bufcfg: minor=%d\n, a4l_get_minor(cxt)); - /* As Linux API is used to allocate a virtual buffer, the calling process must not be in primary mode */ if (rtdm_in_rt_context()) { @@ -580,9 +574,6 @@ int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg) unsigned long tmp_cnt; int ret; - __a4l_dbg(1, core_dbg, - a4l_ioctl_bufinfo: minor=%d\n, a4l_get_minor(cxt)); - if (!rtdm_in_rt_context() rtdm_rt_capable(cxt-user_info)) return -ENOSYS; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: cosmetic changes (broken)
Module: xenomai-abe Branch: experimental Commit: 856fe0b531d885f3044e876879c9231aaffeaf6a URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=856fe0b531d885f3044e876879c9231aaffeaf6a Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon May 24 16:44:03 2010 +0200 analogy: cosmetic changes (broken) --- ksrc/drivers/analogy/buffer.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 011753a..0ca1b4c 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -35,7 +35,7 @@ /* --- Initialization functions (init, alloc, free) --- */ -void a4l_free_buffer(a4l_buf_t * buf_desc) +void a4l_free_buffer(a4l_buf_t *buf_desc) { if (buf_desc-pg_list != NULL) { rtdm_free(buf_desc-pg_list); @@ -52,7 +52,7 @@ void a4l_free_buffer(a4l_buf_t * buf_desc) } } -int a4l_alloc_buffer(a4l_buf_t * buf_desc, int buf_size) +int a4l_alloc_buffer(a4l_buf_t *buf_desc, int buf_size) { int ret = 0; char *vaddr, *vabase; @@ -91,7 +91,7 @@ out_virt_contig_alloc: return ret; } -void a4l_init_buffer(a4l_buf_t * buf_desc) +void a4l_init_buffer(a4l_buf_t *buf_desc) { /* No command to process yet */ buf_desc-cur_cmd = NULL; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: update a4l_read and a4l_write (broken)
Module: xenomai-abe Branch: experimental Commit: 9813a5e98fafa16fb7549d63ad20f49121c8f63c URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=9813a5e98fafa16fb7549d63ad20f49121c8f63c Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Wed May 19 00:15:00 2010 +0200 analogy: update a4l_read and a4l_write (broken) --- ksrc/drivers/analogy/buffer.c | 50 +--- 1 files changed, 16 insertions(+), 34 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index bc162d3..9bd9829 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -773,28 +773,21 @@ a4l_ioctl_bufinfo_out: ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) { a4l_dev_t *dev = a4l_get_dev(cxt); - int idx_subd = dev-transfer.idx_read_subd; - a4l_buf_t *buf = dev-transfer.bufs[idx_subd]; + a4l_buf_t *buf = cxt-buffer; ssize_t count = 0; /* Basic checkings */ + if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { __a4l_err(a4l_read: unattached device\n); return -EINVAL; } - if (!test_bit(A4L_TSF_BUSY, (dev-transfer.status[idx_subd]))) { - __a4l_err(a4l_read: idle subdevice\n); + if (!buf-subd || !test_bit(A4L_SUBD_BUSY, buf-subd-status)) { + __a4l_err(a4l_read: idle subdevice on this context\n); return -ENOENT; } - /* TODO: to be removed - Check the subdevice capabilities */ - if ((dev-transfer.subds[idx_subd]-flags A4L_SUBD_CMD) == 0) { - __a4l_err(a4l_read: incoherent state\n); - return -EINVAL; - } - while (count nbytes) { /* Check the events */ @@ -825,10 +818,9 @@ ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) if (tmp_cnt 0) { /* Performs the munge if need be */ - if (dev-transfer.subds[idx_subd]-munge != NULL) { - __munge(dev-transfer.subds[idx_subd], - dev-transfer.subds[idx_subd]-munge, - buf, tmp_cnt); + if (buf-subd-munge != NULL) { + __munge(buf-subd, + buf-subd-munge, buf, tmp_cnt); /* Updates munge count */ buf-mng_count += tmp_cnt; @@ -850,8 +842,7 @@ ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) /* If the driver does not work in bulk mode, we must leave this function */ - if (!test_bit(A4L_TSF_BULK, - (dev-transfer.status[idx_subd]))) + if (!test_bit(A4L_BUF_BULK, buf-flags)) goto out_a4l_read; } /* If the acquisition is not over, we must not @@ -876,28 +867,21 @@ ssize_t a4l_write(a4l_cxt_t *cxt, const void *bufdata, size_t nbytes) { a4l_dev_t *dev = a4l_get_dev(cxt); - int idx_subd = dev-transfer.idx_write_subd; - a4l_buf_t *buf = dev-transfer.bufs[idx_subd]; + a4l_buf_t *buf = cxt-buffer; ssize_t count = 0; /* Basic checkings */ + if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { __a4l_err(a4l_write: unattached device\n); return -EINVAL; } - if (!test_bit(A4L_TSF_BUSY, (dev-transfer.status[idx_subd]))) { - __a4l_err(a4l_write: idle subdevice\n); + if (!buf-subd || !test_bit(A4L_SUBD_BUSY, buf-subd-status)) { + __a4l_err(a4l_read: idle subdevice on this context\n); return -ENOENT; } - /* TODO: to be removed - Check the subdevice capabilities */ - if ((dev-transfer.subds[idx_subd]-flags A4L_SUBD_CMD) == 0) { - __a4l_err(a4l_write: incoherent state\n); - return -EINVAL; - } - while (count nbytes) { /* Check the events */ @@ -928,10 +912,9 @@ ssize_t a4l_write(a4l_cxt_t *cxt, } /* Performs the munge if need be */ - if (dev-transfer.subds[idx_subd]-munge != NULL) { - __munge(dev-transfer.subds[idx_subd], - dev-transfer.subds[idx_subd]-munge, - buf, tmp_cnt); + if (buf-subd-munge != NULL) { + __munge(buf-subd, + buf-subd-munge, buf, tmp_cnt); /* Updates munge count */ buf-mng_count += tmp_cnt; @@ -945,8 +928,7 @@
[Xenomai-git] Alexis Berlemont : analogy: update all a4l_buf_* functions (broken)
Module: xenomai-abe Branch: experimental Commit: 80ecc82b494736a660e04154f1b50be80844f2e3 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=80ecc82b494736a660e04154f1b50be80844f2e3 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Wed May 19 23:29:59 2010 +0200 analogy: update all a4l_buf_* functions (broken) --- include/analogy/buffer.h | 11 ++- ksrc/drivers/analogy/buffer.c| 157 -- ksrc/drivers/analogy/driver_facilities.c |4 +- 3 files changed, 51 insertions(+), 121 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 786c8e1..cf82811 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -329,9 +329,11 @@ static inline unsigned long __count_to_get(a4l_buf_t * buf) /* --- Buffer internal functions --- */ -int a4l_alloc_buffer(a4l_buf_t * buf_desc); +void a4l_init_buffer(a4l_buf_t * buf_desc); -void a4l_free_buffer(a4l_buf_t * buf_desc); +int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd); + +int a4l_cancel_buffer(a4l_cxt_t *cxt); int a4l_buf_prepare_absput(struct a4l_subdevice *subd, unsigned long count); @@ -369,7 +371,10 @@ unsigned long a4l_buf_count(struct a4l_subdevice *subd); /* --- Current Command management function --- */ -a4l_cmd_t *a4l_get_cmd(struct a4l_subdevice *subd); +static inline a4l_cmd_t *a4l_get_cmd(a4l_subd_t *subd) +{ + return (subd-buf) ? subd-buf-cur_cmd : NULL; +} /* --- Munge related function --- */ diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 9bd9829..c9b1682 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -182,38 +182,17 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) return err; } -/* --- current Command management function --- */ - -a4l_cmd_t *a4l_get_cmd(a4l_subd_t *subd) -{ - a4l_dev_t *dev = subd-dev; - - /* Check that subdevice supports commands */ - if (dev-transfer.bufs == NULL) - return NULL; - - return dev-transfer.bufs[subd-idx]-cur_cmd; -} - /* --- Munge related function --- */ int a4l_get_chan(a4l_subd_t *subd) { - a4l_dev_t *dev = subd-dev; int i, j, tmp_count, tmp_size = 0; a4l_cmd_t *cmd; - /* Check that subdevice supports commands */ - if (dev-transfer.bufs == NULL) - return -EINVAL; - - /* Check a command is executed */ - if (dev-transfer.bufs[subd-idx]-cur_cmd == NULL) + cmd = a4l_get_cmd(subd); + if (!cmd) return -EINVAL; - /* Retrieve the proper command descriptor */ - cmd = dev-transfer.bufs[subd-idx]-cur_cmd; - /* There is no need to check the channel idx, it has already been controlled in command_test */ @@ -252,185 +231,128 @@ int a4l_get_chan(a4l_subd_t *subd) int a4l_buf_prepare_absput(a4l_subd_t *subd, unsigned long count) { - a4l_dev_t *dev; - a4l_buf_t *buf; - - if ((subd-flags A4L_SUBD_MASK_READ) == 0) + if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) return -EINVAL; - dev = subd-dev; - buf = dev-transfer.bufs[subd-idx]; - - return __pre_abs_put(buf, count); + return __pre_abs_put(subd-buf, count); } int a4l_buf_commit_absput(a4l_subd_t *subd, unsigned long count) { - a4l_dev_t *dev; - a4l_buf_t *buf; - - if ((subd-flags A4L_SUBD_MASK_READ) == 0) + if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) return -EINVAL; - dev = subd-dev; - buf = dev-transfer.bufs[subd-idx]; - - return __abs_put(buf, count); + return __abs_put(subd-buf, count); } int a4l_buf_prepare_put(a4l_subd_t *subd, unsigned long count) { - a4l_dev_t *dev; - a4l_buf_t *buf; - - if ((subd-flags A4L_SUBD_MASK_READ) == 0) + if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) return -EINVAL; - dev = subd-dev; - buf = dev-transfer.bufs[subd-idx]; - - return __pre_put(buf, count); + return __pre_put(subd-buf, count); } int a4l_buf_commit_put(a4l_subd_t *subd, unsigned long count) { - a4l_dev_t *dev; - a4l_buf_t *buf; - - if ((subd-flags A4L_SUBD_MASK_READ) == 0) + if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) return -EINVAL; - dev = subd-dev; - buf = dev-transfer.bufs[subd-idx]; - - return __put(buf, count); + return __put(subd-buf, count); } int a4l_buf_put(a4l_subd_t *subd, void *bufdata, unsigned long count) { int err; - a4l_dev_t *dev; - a4l_buf_t *buf; - - if ((subd-flags A4L_SUBD_MASK_READ) == 0) - return -EINVAL; - dev = subd-dev; - buf = dev-transfer.bufs[subd-idx]; - - if (__count_to_put(buf) count) + if
[Xenomai-git] Alexis Berlemont : analogy: update a4l_get_minor function (broken)
Module: xenomai-abe Branch: experimental Commit: 08825a06726cdf8c036e162c357bb539e5988c9d URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=08825a06726cdf8c036e162c357bb539e5988c9d Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon May 24 23:33:13 2010 +0200 analogy: update a4l_get_minor function (broken) --- include/analogy/context.h | 10 ++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/include/analogy/context.h b/include/analogy/context.h index e0cf01c..2442b6c 100644 --- a/include/analogy/context.h +++ b/include/analogy/context.h @@ -25,6 +25,8 @@ #if defined(__KERNEL__) !defined(DOXYGEN_CPP) +#include rtdm/rtdm_driver.h + struct a4l_device; struct a4l_buffer; @@ -43,6 +45,14 @@ struct a4l_device_context { struct buffer buffer; }; +static inline int a4l_get_minor(a4l_cxt_t *cxt) +{ + /* Get a pointer on the container structure */ + struct rtdm_dev_context * rtdm_cxt = rtdm_private_to_context(cxt); + /* Get the minor index */ + return rtdm_cxt-device-device_id; +} + #endif /* __KERNEL__ !DOXYGEN_CPP */ #endif /* __ANALOGY_CONTEXT__ */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: use rtdm_context_to_private (broken)
Module: xenomai-abe Branch: experimental Commit: a473d17258d0d1c7b1a2da8552248c8e2114f21d URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=a473d17258d0d1c7b1a2da8552248c8e2114f21d Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon May 24 23:35:47 2010 +0200 analogy: use rtdm_context_to_private (broken) --- ksrc/drivers/analogy/rtdm_interface.c | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ksrc/drivers/analogy/rtdm_interface.c b/ksrc/drivers/analogy/rtdm_interface.c index d37ce4c..6525425 100644 --- a/ksrc/drivers/analogy/rtdm_interface.c +++ b/ksrc/drivers/analogy/rtdm_interface.c @@ -124,11 +124,11 @@ void a4l_cleanup_proc(void) int a4l_open(struct rtdm_dev_context *context, rtdm_user_info_t * user_info, int flags) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Get a pointer on the selected device (thanks to minor index) */ - a4l_set_dev(context); + a4l_set_dev(cxt); /* Initialize the buffer structure */ a4l_init_buffer(cxt-buffer); @@ -146,7 +146,7 @@ int a4l_open(struct rtdm_dev_context *context, int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) { int err; - a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Cancel the maybe occuring asynchronous transfer */ err = a4l_cancel_buffer(cxt-buffer); @@ -164,7 +164,7 @@ int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) ssize_t a4l_read(struct rtdm_dev_context * context, rtdm_user_info_t * user_info, void *buf, size_t nbytes) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Jump into the RT domain if possible */ if (!rtdm_in_rt_context() rtdm_rt_capable(user_info)) @@ -181,7 +181,7 @@ ssize_t a4l_read(struct rtdm_dev_context * context, ssize_t a4l_write(struct rtdm_dev_context * context, rtdm_user_info_t *user_info, const void *buf, size_t nbytes) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Jump into the RT domain if possible */ if (!rtdm_in_rt_context() rtdm_rt_capable(user_info)) @@ -198,7 +198,7 @@ ssize_t a4l_write(struct rtdm_dev_context * context, int a4l_ioctl(struct rtdm_dev_context *context, rtdm_user_info_t *user_info, unsigned int request, void *arg) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); cxt-user_info = user_info; @@ -209,7 +209,7 @@ int a4l_rt_select(struct rtdm_dev_context *context, rtdm_selector_t *selector, enum rtdm_selecttype type, unsigned fd_index) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); return a4l_select(cxt, selector, type, fd_index); } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: update a4l_set_dev and remove useless info traces (broken)
Module: xenomai-abe Branch: experimental Commit: 4a9afd7d10ebb95d5fe324f4ee390b28fc2c075e URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=4a9afd7d10ebb95d5fe324f4ee390b28fc2c075e Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon May 24 23:34:19 2010 +0200 analogy: update a4l_set_dev and remove useless info traces (broken) --- include/analogy/device.h |2 +- ksrc/drivers/analogy/device.c | 39 +-- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/include/analogy/device.h b/include/analogy/device.h index 51b99b5..6930a38 100644 --- a/include/analogy/device.h +++ b/include/analogy/device.h @@ -91,7 +91,7 @@ int a4l_rdproc_devs(char *page, off_t off, int count, int *eof, void *data); /* --- Context related function / macro --- */ -void a4l_set_dev(struct rtdm_dev_context *context); +void a4l_set_dev(a4l_cxt_t *cxt); #define a4l_get_dev(x) ((x)-dev) /* --- Upper layer functions --- */ diff --git a/ksrc/drivers/analogy/device.c b/ksrc/drivers/analogy/device.c index 4a3c879..a2d23c8 100644 --- a/ksrc/drivers/analogy/device.c +++ b/ksrc/drivers/analogy/device.c @@ -43,8 +43,6 @@ void a4l_init_devs(void) for (i = 0; i A4L_NB_DEVICES; i++) { a4l_lock_init(a4l_devs[i].lock); a4l_devs[i].transfer.irq_desc.irq = A4L_IRQ_UNUSED; - a4l_devs[i].transfer.idx_read_subd = A4L_IDX_UNUSED; - a4l_devs[i].transfer.idx_write_subd = A4L_IDX_UNUSED; } } @@ -59,13 +57,10 @@ int a4l_check_cleanup_devs(void) return ret; } -void a4l_set_dev(struct rtdm_dev_context *context) +void a4l_set_dev(a4l_cxt_t *cxt) { - /* Get the context's private structure */ - a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; - /* Retrive the minor index */ - static int minor = context-device-device_id; - + /* Retrieve the minor index */ + static int minor = a4l_get_minor(cxt); /* Fill the dev fields accordingly */ cxt-dev = (a4l_devs[minor]); } @@ -208,9 +203,6 @@ int a4l_fill_lnkdesc(a4l_cxt_t * cxt, char *tmpname = NULL; void *tmpopts = NULL; - __a4l_dbg(1, core_dbg, - a4l_fill_lnkdesc: minor=%d\n, a4l_get_minor(cxt)); - ret = rtdm_safe_copy_from_user(cxt-user_info, link_arg, arg, sizeof(a4l_lnkdesc_t)); if (ret != 0) { @@ -285,9 +277,6 @@ int a4l_fill_lnkdesc(a4l_cxt_t * cxt, void a4l_free_lnkdesc(a4l_cxt_t * cxt, a4l_lnkdesc_t * link_arg) { - __a4l_dbg(1, core_dbg, - a4l_free_lnkdesc: minor=%d\n, a4l_get_minor(cxt)); - if (link_arg-bname != NULL) rtdm_free(link_arg-bname); @@ -301,9 +290,6 @@ int a4l_assign_driver(a4l_cxt_t * cxt, int ret = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - __a4l_dbg(1, core_dbg, - a4l_assign_driver: minor=%d\n, a4l_get_minor(cxt)); - dev-driver = drv; if (drv-privdata_size == 0) @@ -355,9 +341,6 @@ int a4l_release_driver(a4l_cxt_t * cxt) int ret = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - __a4l_dbg(1, core_dbg, - a4l_release_driver: minor=%d\n, a4l_get_minor(cxt)); - if ((ret = dev-driver-detach(dev)) != 0) goto out_release_driver; @@ -388,9 +371,6 @@ int a4l_device_attach(a4l_cxt_t * cxt, void *arg) a4l_lnkdesc_t link_arg; a4l_drv_t *drv = NULL; - __a4l_dbg(1, core_dbg, - a4l_device_attach: minor=%d\n, a4l_get_minor(cxt)); - if ((ret = a4l_fill_lnkdesc(cxt, link_arg, arg)) != 0) goto out_attach; @@ -412,9 +392,6 @@ int a4l_device_detach(a4l_cxt_t * cxt) { a4l_dev_t *dev = a4l_get_dev(cxt); - __a4l_dbg(1, core_dbg, - a4l_device_detach: minor=%d\n, a4l_get_minor(cxt)); - if (dev-driver == NULL) { __a4l_err(a4l_device_detach: incoherent state, driver not reachable\n); @@ -430,9 +407,6 @@ int a4l_ioctl_devcfg(a4l_cxt_t * cxt, void *arg) { int ret = 0; - __a4l_dbg(1, core_dbg, - a4l_ioctl_devcfg: minor=%d\n, a4l_get_minor(cxt)); - if (rtdm_in_rt_context()) return -ENOSYS; @@ -487,9 +461,6 @@ int a4l_ioctl_devinfo(a4l_cxt_t * cxt, void *arg) a4l_dvinfo_t info; a4l_dev_t *dev = a4l_get_dev(cxt); - __a4l_dbg(1, core_dbg, - a4l_ioctl_devinfo: minor=%d\n, a4l_get_minor(cxt)); - memset(info, 0, sizeof(a4l_dvinfo_t)); if (test_bit(A4L_DEV_ATTACHED, dev-flags)) { @@ -498,8 +469,8 @@ int a4l_ioctl_devinfo(a4l_cxt_t * cxt, void *arg) memcpy(info.board_name, dev-driver-board_name, len); info.nb_subd = dev-transfer.nb_subd; - info.idx_read_subd = dev-transfer.idx_read_subd; -
[Xenomai-git] Alexis Berlemont : analogy: declare the reserve / release functions at the subd level (broken)
Module: xenomai-abe Branch: experimental Commit: d20cb6dc3652d7dc866b5c8a7c8281bfc7f23b32 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=d20cb6dc3652d7dc866b5c8a7c8281bfc7f23b32 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon May 24 16:46:31 2010 +0200 analogy: declare the reserve / release functions at the subd level (broken) --- include/analogy/subdevice.h|2 ++ ksrc/drivers/analogy/command.c | 33 - ksrc/drivers/analogy/instruction.c |2 +- ksrc/drivers/analogy/subdevice.c | 15 +++ 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 0f9e1c5..ded82f3 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -290,6 +290,8 @@ a4l_subd_t * a4l_get_subd(struct a4l_device *dev, int idx); a4l_subd_t * a4l_alloc_subd(int sizeof_priv, void (*setup)(a4l_subd_t *)); int a4l_add_subd(struct a4l_device *dev, a4l_subd_t * subd); +int a4l_reserve_subd(a4l_subd_t *subd); +void a4l_release_subd(a4l_subd_t *subd); int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_chaninfo(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_rnginfo(a4l_cxt_t * cxt, void *arg); diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c index b300d9a..94d6137 100644 --- a/ksrc/drivers/analogy/command.c +++ b/ksrc/drivers/analogy/command.c @@ -90,11 +90,8 @@ void a4l_free_cmddesc(a4l_cmd_t * desc) int a4l_check_cmddesc(a4l_cxt_t * cxt, a4l_cmd_t * desc) { - int ret = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - - __a4l_dbg(1, core_dbg, -a4l_check_cmddesc: minor=%d\n, a4l_get_minor(cxt)); + a4l_subd_t *subd; if (desc-idx_subd = dev-transfer.nb_subd) { __a4l_err(a4l_check_cmddesc: @@ -103,25 +100,23 @@ int a4l_check_cmddesc(a4l_cxt_t * cxt, a4l_cmd_t * desc) return -EINVAL; } - if ((dev-transfer.subds[desc-idx_subd]-flags A4L_SUBD_TYPES) == - A4L_SUBD_UNUSED) { + subd = dev-transfer.subds[desc-idx_subd]; + + if ((subd-flags A4L_SUBD_TYPES) == A4L_SUBD_UNUSED) { __a4l_err(a4l_check_cmddesc: subdevice type incoherent\n); return -EIO; } - if (!(dev-transfer.subds[desc-idx_subd]-flags A4L_SUBD_CMD)) { + if (!(subd-flags A4L_SUBD_CMD)) { __a4l_err(a4l_check_cmddesc: operation not supported, synchronous only subdevice\n); return -EIO; } - if (test_bit(A4L_TSF_BUSY, (dev-transfer.status[desc-idx_subd]))) - return -EBUSY; - - if (ret != 0) { + if (test_bit(A4L_SUBD_BUSY, subd-status)) { __a4l_err(a4l_check_cmddesc: subdevice busy\n); - return ret; + return -EBUSY; } return a4l_check_chanlist(dev-transfer.subds[desc-idx_subd], @@ -299,17 +294,13 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) { int ret = 0, simul_flag = 0; a4l_cmd_t *cmd_desc = NULL; - a4l_subd_t *subd; a4l_dev_t *dev = a4l_get_dev(cxt); - - __a4l_dbg(1, core_dbg, - a4l_ioctl_cmd: minor=%d\n, a4l_get_minor(cxt)); + a4l_subd_t *subd; /* The command launching cannot be done in real-time because of some possible buffer allocations in the drivers */ - if (rtdm_in_rt_context()) { + if (rtdm_in_rt_context()) return -ENOSYS; - } /* Basically check the device */ if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { @@ -373,13 +364,13 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) /* Eventually launches the command */ ret = subd-do_cmd(subd, cmd_desc); - + if (ret != 0) { - a4l_cancel_transfer(cxt, cmd_desc-idx_subd); + a4l_cancel_buffer(cxt); goto out_ioctl_cmd; } - out_ioctl_cmd: +out_ioctl_cmd: if (ret != 0 || simul_flag == 1) { a4l_free_cmddesc(cmd_desc); rtdm_free(cmd_desc); diff --git a/ksrc/drivers/analogy/instruction.c b/ksrc/drivers/analogy/instruction.c index 941fa69..413c0d2 100644 --- a/ksrc/drivers/analogy/instruction.c +++ b/ksrc/drivers/analogy/instruction.c @@ -281,7 +281,7 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc) out_do_insn: /* Releases the subdevice from its reserved state */ - a4l_cancel_transfer(cxt, dsc-idx_subd); + a4l_release_subd(subd); return ret; } diff --git a/ksrc/drivers/analogy/subdevice.c b/ksrc/drivers/analogy/subdevice.c index 1278081..506b742 100644 --- a/ksrc/drivers/analogy/subdevice.c +++ b/ksrc/drivers/analogy/subdevice.c @@ -180,6 +180,21 @@ a4l_subd_t *a4l_get_subd(a4l_dev_t *dev, int idx) return subd; }
[Xenomai-git] Alexis Berlemont : analogy: minor fix in the subdevice structure declaration
Module: xenomai-abe Branch: experimental Commit: 01ba3e34020e052f37f92bab912385aba635a386 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=01ba3e34020e052f37f92bab912385aba635a386 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Fri Jun 4 00:04:41 2010 +0200 analogy: minor fix in the subdevice structure declaration --- include/analogy/buffer.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index cf82811..4846a4e 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -56,7 +56,7 @@ struct a4l_subdevice; struct a4l_buffer { /* Added by the structure update */ - a4l_subd_t *subd; + struct a4l_subdevice *subd; /* Buffer's first virtual page pointer */ void *buf; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: add some helper macros to test the subdevice' s characteristics
Module: xenomai-abe Branch: experimental Commit: 85d00748054600feedc87bc8521d58a28ff4bdef URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=85d00748054600feedc87bc8521d58a28ff4bdef Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Fri Jun 4 00:06:05 2010 +0200 analogy: add some helper macros to test the subdevice's characteristics --- include/analogy/subdevice.h | 16 ++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index ded82f3..0337092 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -286,12 +286,24 @@ int a4l_check_chanlist(a4l_subd_t * subd, /* --- Upper layer functions --- */ +static inline int a4l_reserve_subd(a4l_subd_t *subd) +{ +return test_and_set_bit(A4L_SUBD_BUSY, subd-status) ? -EBUSY : 0; +} +#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY, (x)-status)) +#define a4l_subd_is_busy(x) test_bit(A4L_SUBD_BUSY, (x)-status)) + +#define a4l_subd_is_input(x) ((A4L_SUBD_MASK_READ (x)-flags) != 0) +/* The following macro considers that a DIO subdevice is firstly an + output subdevice */ +#define a4l_subd_is_output(x) \ + ((A4L_SUBD_MASK_WRITE (x)-flags) != 0 || \ +(A4L_SUBD_DIO (x)-flags) != 0) + a4l_subd_t * a4l_get_subd(struct a4l_device *dev, int idx); a4l_subd_t * a4l_alloc_subd(int sizeof_priv, void (*setup)(a4l_subd_t *)); int a4l_add_subd(struct a4l_device *dev, a4l_subd_t * subd); -int a4l_reserve_subd(a4l_subd_t *subd); -void a4l_release_subd(a4l_subd_t *subd); int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_chaninfo(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_rnginfo(a4l_cxt_t * cxt, void *arg); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: remove useless functions in the subdevice part
Module: xenomai-abe Branch: experimental Commit: fd88364906c844562f60f7859eb6910b6199c322 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=fd88364906c844562f60f7859eb6910b6199c322 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Fri Jun 4 00:06:49 2010 +0200 analogy: remove useless functions in the subdevice part --- ksrc/drivers/analogy/subdevice.c | 15 --- 1 files changed, 0 insertions(+), 15 deletions(-) diff --git a/ksrc/drivers/analogy/subdevice.c b/ksrc/drivers/analogy/subdevice.c index 506b742..1278081 100644 --- a/ksrc/drivers/analogy/subdevice.c +++ b/ksrc/drivers/analogy/subdevice.c @@ -180,21 +180,6 @@ a4l_subd_t *a4l_get_subd(a4l_dev_t *dev, int idx) return subd; } -int a4l_reserve_subd(a4l_subd_t *subd) -{ -if (test_and_set_bit(A4L_SUBD_BUSY, subd-status)) { -__a4l_err(a4l_reserve_subd: subdevice currently busy\n); -return -EBUSY; -} - -return 0; -} - -void a4l_release_subd(a4l_subd_t *subd) -{ - clear_bit(A4L_SUBD_BUSY, subd-status)); -} - /* --- IOCTL / FOPS functions --- */ int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg) ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix the buffer syscalls (ioctl + r/w) after buffer review (broken)
Module: xenomai-abe Branch: experimental Commit: c53d56c76687969753859881209ee98270cb5366 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=c53d56c76687969753859881209ee98270cb5366 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Fri Jun 4 00:09:04 2010 +0200 analogy: fix the buffer syscalls (ioctl + r/w) after buffer review (broken) --- ksrc/drivers/analogy/buffer.c | 173 + 1 files changed, 73 insertions(+), 100 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 0ca1b4c..d3db892 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -506,6 +506,8 @@ int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) { a4l_dev_t *dev = a4l_get_dev(cxt); + a4l_buf_t *buf = cxt-buf; + a4l_subd_t *subd = buf-subd; a4l_bufcfg_t buf_cfg; /* As Linux API is used to allocate a virtual buffer, @@ -525,17 +527,9 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) arg, sizeof(a4l_bufcfg_t)) != 0) return -EFAULT; - /* Check the subdevice */ - if (buf_cfg.idx_subd = dev-transfer.nb_subd) { - __a4l_err(a4l_ioctl_bufcfg: subdevice index - out of range (idx=%d)\n, buf_cfg.idx_subd); - return -EINVAL; - } - - if ((dev-transfer.subds[buf_cfg.idx_subd]-flags A4L_SUBD_CMD) == 0) { - __a4l_err(a4l_ioctl_bufcfg: operation not supported, - synchronous only subdevice\n); - return -EINVAL; + if (subd a4l_subd_is_busy(subd)) { + __a4l_err(a4l_ioctl_bufcfg: acquisition in progress\n); + return -EBUSY; } if (buf_cfg.buf_size A4L_BUF_MAXSIZE) { @@ -543,34 +537,26 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) return -EINVAL; } - /* If a transfer is occuring or if the buffer is mmapped, - no buffer size change is allowed */ - if (test_bit(A4L_TSF_BUSY, -(dev-transfer.status[buf_cfg.idx_subd]))) { - __a4l_err(a4l_ioctl_bufcfg: acquisition in progress\n); - return -EBUSY; - } - - if (test_bit(A4L_TSF_MMAP, -(dev-transfer.status[buf_cfg.idx_subd]))) { + if (test_bit(A4L_BUF_MAP, buf-flags)) { __a4l_err(a4l_ioctl_bufcfg: please unmap before configuring buffer\n); return -EPERM; } - /* Performs the re-allocation */ - a4l_free_buffer(dev-transfer.bufs[buf_cfg.idx_subd]); + /* Free the buffer... */ + a4l_free_buffer(buf); - dev-transfer.bufs[buf_cfg.idx_subd]-size = buf_cfg.buf_size; - - return a4l_alloc_buffer(dev-transfer.bufs[buf_cfg.idx_subd]); + /* ...to reallocate it */ + return a4l_alloc_buffer(buf, buf_cfg.buf_size); } int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg) { a4l_dev_t *dev = a4l_get_dev(cxt); + a4l_buf_t *buf = cxt-buffer; + a4l_buf_t *subd = buf-subd; a4l_bufinfo_t info; - a4l_buf_t *buf; + unsigned long tmp_cnt; int ret; @@ -587,32 +573,17 @@ int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg) info, arg, sizeof(a4l_bufinfo_t)) != 0) return -EFAULT; - /* Check the subdevice */ - if (info.idx_subd = dev-transfer.nb_subd) { - __a4l_err(a4l_ioctl_bufinfo: subdevice index - out of range (idx=%d)\n, info.idx_subd); - return -EINVAL; - } - - if ((dev-transfer.subds[info.idx_subd]-flags A4L_SUBD_CMD) == 0) { - __a4l_err(a4l_ioctl_bufinfo: operation not supported, - synchronous only subdevice\n); - return -EINVAL; - } - - buf = dev-transfer.bufs[info.idx_subd]; /* If a transfer is not occuring, simply return buffer informations, otherwise make the transfer progress */ - if (!test_bit(A4L_TSF_BUSY, - (dev-transfer.status[info.idx_subd]))) { + if (!subd || !a4l_subd_is_busy(subd)) { info.rw_count = 0; goto a4l_ioctl_bufinfo_out; } ret = __handle_event(buf); - if (info.idx_subd == dev-transfer.idx_read_subd) { + if (a4l_subd_is_input(sudb)) { /* Updates consume count if rw_count is not null */ if (info.rw_count != 0) @@ -629,7 +600,7 @@ int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg) a4l_cancel_buffer(cxt); return ret; } - } else if (info.idx_subd == dev-transfer.idx_write_subd) { + } else if (a4l_subd_is_output(sudb)) { if (ret 0) {
[Xenomai-git] Alexis Berlemont : analogy: fix compilation issues and review the mmap ioctl handler (broken)
Module: xenomai-abe Branch: experimental Commit: ffd039850b41cb751eb5c7212c81add2bfdd44da URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=ffd039850b41cb751eb5c7212c81add2bfdd44da Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Thu Jun 10 22:35:06 2010 +0200 analogy: fix compilation issues and review the mmap ioctl handler (broken) --- ksrc/drivers/analogy/buffer.c | 200 - 1 files changed, 119 insertions(+), 81 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 1b413cc..0826a93 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -121,7 +121,7 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) if (buf_desc-subd == NULL) { __a4l_err(a4l_setup_buffer: subdevice index out of range (%d)\n, cmd-idx_subd); - goto -EINVAL; + return -EINVAL; } /* Checks if the transfer system has to work in bulk mode */ @@ -155,7 +155,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) int err = 0; - if (!subd || !a4l_check_subd(subd)) + if (!subd || !a4l_subd_is_busy(subd)) return 0; /* If a cancel function is registered, call it @@ -164,12 +164,11 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) the cancel function can be used as as to (re)initialize some component) */ if (subd-cancel != NULL (err = subd-cancel(subd)) 0) { - __a4l_err(a4l_cancel: - subdevice %d cancel handler failed (err=%d)\n, - idx_subd, err); + __a4l_err(a4l_cancel: cancel handler failed (err=%d)\n, err); } a4l_release_subd(subd); + subd-buf = NULL; if (buf_desc-cur_cmd != NULL) { a4l_free_cmddesc(buf_desc-cur_cmd); @@ -208,7 +207,7 @@ int a4l_get_chan(a4l_subd_t *subd) /* Translation bits - bytes */ tmp_size /= 8; - tmp_count = dev-transfer.bufs[subd-idx]-mng_count % tmp_size; + tmp_count = subd-buf-mng_count % tmp_size; /* Translation bytes - bits */ tmp_count *= 8; @@ -231,116 +230,174 @@ int a4l_get_chan(a4l_subd_t *subd) int a4l_buf_prepare_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_abs_put(subd-buf, count); + return __pre_abs_put(buf, count); } int a4l_buf_commit_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __abs_put(subd-buf, count); + return __abs_put(buf, count); } int a4l_buf_prepare_put(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_put(subd-buf, count); + return __pre_put(buf, count); } int a4l_buf_commit_put(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __put(subd-buf, count); + return __put(buf, count); } int a4l_buf_put(a4l_subd_t *subd, void *bufdata, unsigned long count) { + a4l_buf_t *buf = subd-buf; int err; - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - if (__count_to_put(subd-buf) count) + if (__count_to_put(buf) count) return -EAGAIN; - err = __produce(NULL, subd-buf, bufdata, count); + err = __produce(NULL, buf, bufdata, count); if (err 0) return err; - err = __put(subd-buf, count); + err = __put(buf, count); return err; } int a4l_buf_prepare_absget(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_WRITE) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_output(subd)) return -EINVAL; -
[Xenomai-git] Alexis Berlemont : analogy: fix buffer's compilation issues (broken)
Module: xenomai-abe Branch: experimental Commit: 6e08a1a8189bf08558d2f4d3ef064fb56484e69c URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=6e08a1a8189bf08558d2f4d3ef064fb56484e69c Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Thu Jun 10 22:42:40 2010 +0200 analogy: fix buffer's compilation issues (broken) --- include/analogy/buffer.h | 21 + 1 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 4846a4e..4bd5db0 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -32,6 +32,7 @@ #include rtdm/rtdm_driver.h +#include analogy/os_facilities.h #include analogy/context.h /* Events bits */ @@ -179,11 +180,11 @@ static inline int __handle_event(a4l_buf_t * buf) /* The event End of acquisition must not be cleaned before the complete flush of the buffer */ - if (test_bit(A4L_BUF_EOA_NR, buf-evt_flags)) { + if (test_bit(A4L_BUF_EOA_NR, buf-flags)) { ret = -ENOENT; } - if (test_bit(A4L_BUF_ERROR_NR, buf-evt_flags)) { + if (test_bit(A4L_BUF_ERROR_NR, buf-flags)) { ret = -EPIPE; } @@ -195,7 +196,7 @@ static inline int __handle_event(a4l_buf_t * buf) static inline int __pre_abs_put(a4l_buf_t * buf, unsigned long count) { if (count - buf-tmp_count buf-size) { - set_bit(A4L_BUF_ERROR_NR, buf-evt_flags); + set_bit(A4L_BUF_ERROR_NR, buf-flags); return -EPIPE; } @@ -235,7 +236,7 @@ static inline int __pre_abs_get(a4l_buf_t * buf, unsigned long count) was not greater a few cycles before; in such case, the DMA channel would have retrieved the wrong data */ if ((long)(count - buf-tmp_count) 0) { - set_bit(A4L_BUF_ERROR_NR, buf-evt_flags); + set_bit(A4L_BUF_ERROR_NR, buf-flags); return -EPIPE; } @@ -260,10 +261,10 @@ static inline int __abs_put(a4l_buf_t * buf, unsigned long count) buf-prd_count = count; if ((old / buf-size) != (count / buf-size)) - set_bit(A4L_BUF_EOBUF_NR, buf-evt_flags); + set_bit(A4L_BUF_EOBUF_NR, buf-flags); if (buf-end_count != 0 (long)(count - buf-end_count) = 0) - set_bit(A4L_BUF_EOA_NR, buf-evt_flags); + set_bit(A4L_BUF_EOA_NR, buf-flags); return 0; } @@ -283,10 +284,10 @@ static inline int __abs_get(a4l_buf_t * buf, unsigned long count) buf-cns_count = count; if ((old / buf-size) != count / buf-size) - set_bit(A4L_BUF_EOBUF_NR, buf-evt_flags); + set_bit(A4L_BUF_EOBUF_NR, buf-flags); if (buf-end_count != 0 (long)(count - buf-end_count) = 0) - set_bit(A4L_BUF_EOA_NR, buf-evt_flags); + set_bit(A4L_BUF_EOA_NR, buf-flags); return 0; } @@ -329,6 +330,10 @@ static inline unsigned long __count_to_get(a4l_buf_t * buf) /* --- Buffer internal functions --- */ +int a4l_alloc_buffer(a4l_buf_t *buf_desc, int buf_size); + +void a4l_free_buffer(a4l_buf_t *buf_desc); + void a4l_init_buffer(a4l_buf_t * buf_desc); int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix the declaration of the structure a4l_context (broken)
Module: xenomai-abe Branch: experimental Commit: d8ff2633bcf38114d610cb89371a0357f1cb4534 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=d8ff2633bcf38114d610cb89371a0357f1cb4534 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun Jun 6 16:21:44 2010 +0200 analogy: fix the declaration of the structure a4l_context (broken) In the structure a4l_context, replace the field buffer by a pointer to the structure a4l_buffer (a4l_buf_t - a4l_buf_t *). That fixes a bug in the headers dependencies. --- include/analogy/context.h |3 ++- ksrc/drivers/analogy/buffer.c | 12 ++-- ksrc/drivers/analogy/rtdm_interface.c | 14 ++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/analogy/context.h b/include/analogy/context.h index 2442b6c..3e61697 100644 --- a/include/analogy/context.h +++ b/include/analogy/context.h @@ -42,8 +42,9 @@ struct a4l_device_context { /* The buffer structure contains everything to transfer data from asynchronous acquisition operations on a specific subdevice */ - struct buffer buffer; + struct a4l_buffer *buffer; }; +typedef struct a4l_device_context a4l_cxt_t; static inline int a4l_get_minor(a4l_cxt_t *cxt) { diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index d3db892..1b413cc 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -493,10 +493,10 @@ int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) subd = dev-transfer.subds[idx_subd]; - if (subd != cxt-buffer.subd) { + if (subd != cxt-buffer-subd) { __a4l_err(a4l_ioctl_cancel: current context works on another subdevice - (%d!=%d)\n, cxt-buffer.subd-idx, subd-idx); + (%d!=%d)\n, cxt-buffer-subd-idx, subd-idx); return -EINVAL; } @@ -658,7 +658,7 @@ a4l_ioctl_bufinfo_out: ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) { a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = cxt-buffer; + a4l_buf_t *buf = cxt-buffer; a4l_buf_t *subd = buf-subd; ssize_t count = 0; @@ -758,7 +758,7 @@ ssize_t a4l_write(a4l_cxt_t *cxt, const void *bufdata, size_t nbytes) { a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = cxt-buffer; + a4l_buf_t *buf = cxt-buffer; a4l_subd_t *subd = buf-subd; ssize_t count = 0; @@ -849,7 +849,7 @@ int a4l_select(a4l_cxt_t *cxt, enum rtdm_selecttype type, unsigned fd_index) { a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = cxt-buffer; + a4l_buf_t *buf = cxt-buffer; a4l_subd_t *subd = buf-subd; /* Basic checkings */ @@ -894,7 +894,7 @@ int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg) int ret = 0; unsigned long tmp_cnt = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = cxt-buffer; + a4l_buf_t *buf = cxt-buffer; a4l_buf_t *subd = buf-subd; a4l_poll_t poll; diff --git a/ksrc/drivers/analogy/rtdm_interface.c b/ksrc/drivers/analogy/rtdm_interface.c index 6525425..8cfdf04 100644 --- a/ksrc/drivers/analogy/rtdm_interface.c +++ b/ksrc/drivers/analogy/rtdm_interface.c @@ -131,14 +131,15 @@ int a4l_open(struct rtdm_dev_context *context, a4l_set_dev(cxt); /* Initialize the buffer structure */ - a4l_init_buffer(cxt-buffer); + cxt-buffer = rtdm_malloc(sizeof(a4l_buf_t)); + a4l_init_buffer(cxt-buffer); /* Allocate the asynchronous buffer NOTE: it should be interesting to allocate the buffer only on demand especially if the system is short of memory NOTE2: the default buffer size could be configured via kernel config*/ - a4l_alloc_buffer(cxt-buffer, A4L_DEFAULT_BFSIZE); + a4l_alloc_buffer(cxt-buffer, A4L_DEFAULT_BFSIZE); return 0; } @@ -149,15 +150,20 @@ int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Cancel the maybe occuring asynchronous transfer */ - err = a4l_cancel_buffer(cxt-buffer); + err = a4l_cancel_buffer(cxt-buffer); if (err 0) { __a4l_err(close: unable to stop the asynchronous transfer\n); return err; } /* Free the buffer which was linked with this context */ - err = a4l_free_buffer(cxt-buffer); + err = a4l_free_buffer(cxt-buffer); + if (err 0) + goto out; + rtdm_free(cxt-buffer); + +out: return err; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: cosmetic change (broken)
Module: xenomai-abe Branch: experimental Commit: 666d35de6b61c1ca969ec7118a48eeefc6378b58 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=666d35de6b61c1ca969ec7118a48eeefc6378b58 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Thu Jun 10 22:41:53 2010 +0200 analogy: cosmetic change (broken) --- include/analogy/device.h |4 ++-- ksrc/drivers/analogy/buffer.c | 14 +++--- ksrc/drivers/analogy/command.c |2 +- ksrc/drivers/analogy/device.c | 16 ksrc/drivers/analogy/instruction.c |4 ++-- .../analogy/national_instruments/mio_common.c |2 +- ksrc/drivers/analogy/subdevice.c | 10 +- ksrc/drivers/analogy/testing/loop.c|2 +- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/include/analogy/device.h b/include/analogy/device.h index 6930a38..fca40cc 100644 --- a/include/analogy/device.h +++ b/include/analogy/device.h @@ -33,7 +33,7 @@ #define A4L_NB_DEVICES 10 -#define A4L_DEV_ATTACHED 0 +#define A4L_DEV_ATTACHED_NR 0 struct a4l_device { @@ -81,7 +81,7 @@ typedef struct a4l_dev_info a4l_dvinfo_t; #ifdef __KERNEL__ /* --- Device related macro --- */ -#define a4l_check_dev(x) test_bit(A4L_DEV_ATTACHED, (x-flags)) +#define a4l_dev_is_attached(x) test_bit(A4L_DEV_ATTACHED_NR, (x-flags)) /* --- Devices tab related functions --- */ void a4l_init_devs(void); diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 0826a93..ac1abce 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -513,7 +513,7 @@ int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) a4l_subd_t *subd; /* Basically check the device */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, dev-flags)) { __a4l_err(a4l_ioctl_cancel: operation not supported on an unattached device\n); return -EINVAL; @@ -556,7 +556,7 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) } /* Basic checking */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, dev-flags)) { __a4l_err(a4l_ioctl_bufcfg: unattached device\n); return -EINVAL; } @@ -603,7 +603,7 @@ int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg) return -ENOSYS; /* Basic checking */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, dev-flags)) { __a4l_err(a4l_ioctl_bufinfo: unattached device\n); return -EINVAL; } @@ -703,7 +703,7 @@ ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) /* Basic checkings */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, dev-flags)) { __a4l_err(a4l_read: unattached device\n); return -EINVAL; } @@ -803,7 +803,7 @@ ssize_t a4l_write(a4l_cxt_t *cxt, /* Basic checkings */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, dev-flags)) { __a4l_err(a4l_write: unattached device\n); return -EINVAL; } @@ -893,7 +893,7 @@ int a4l_select(a4l_cxt_t *cxt, /* Basic checkings */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, dev-flags)) { __a4l_err(a4l_select: unattached device\n); return -EINVAL; } @@ -942,7 +942,7 @@ int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg) /* Basic checking */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, dev-flags)) { __a4l_err(a4l_poll: unattached device\n); return -EINVAL; } diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c index 94d6137..51aad35 100644 --- a/ksrc/drivers/analogy/command.c +++ b/ksrc/drivers/analogy/command.c @@ -303,7 +303,7 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) return -ENOSYS; /* Basically check the device */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, dev-flags)) { __a4l_err(a4l_ioctl_cmd: cannot command an unattached device\n); return -EINVAL; diff --git a/ksrc/drivers/analogy/device.c b/ksrc/drivers/analogy/device.c index a2d23c8..99b9098 100644 --- a/ksrc/drivers/analogy/device.c +++ b/ksrc/drivers/analogy/device.c @@ -51,7 +51,7 @@ int a4l_check_cleanup_devs(void) int i, ret = 0; for (i = 0; i A4L_NB_DEVICES ret == 0; i++) - if (test_bit(A4L_DEV_ATTACHED, a4l_devs[i].flags)) +
[Xenomai-git] Alexis Berlemont : analogy: prettify some subdevice tests (broken)
Module: xenomai-abe Branch: experimental Commit: f26620cb08a9bf979bd3977988de5d2a7f7ff5ab URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=f26620cb08a9bf979bd3977988de5d2a7f7ff5ab Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Thu Jun 10 22:44:21 2010 +0200 analogy: prettify some subdevice tests (broken) --- include/analogy/subdevice.h | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 0337092..8649c8a 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -277,21 +277,19 @@ typedef struct a4l_rng_info_arg a4l_rnginfo_arg_t; #ifdef __KERNEL__ -/* --- Subdevice related functions --- */ +/* --- Subdevice related functions and macros --- */ + a4l_chan_t *a4l_get_chfeat(a4l_subd_t * sb, int idx); -a4l_rng_t *a4l_get_rngfeat(a4l_subd_t * sb, - int chidx, int rngidx); +a4l_rng_t *a4l_get_rngfeat(a4l_subd_t * sb, int chidx, int rngidx); int a4l_check_chanlist(a4l_subd_t * subd, unsigned char nb_chan, unsigned int *chans); -/* --- Upper layer functions --- */ - static inline int a4l_reserve_subd(a4l_subd_t *subd) { return test_and_set_bit(A4L_SUBD_BUSY, subd-status) ? -EBUSY : 0; } -#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY, (x)-status)) -#define a4l_subd_is_busy(x) test_bit(A4L_SUBD_BUSY, (x)-status)) +#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY, ((x)-status)) +#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY, ((x)-status))) #define a4l_subd_is_input(x) ((A4L_SUBD_MASK_READ (x)-flags) != 0) /* The following macro considers that a DIO subdevice is firstly an @@ -300,6 +298,8 @@ static inline int a4l_reserve_subd(a4l_subd_t *subd) ((A4L_SUBD_MASK_WRITE (x)-flags) != 0 || \ (A4L_SUBD_DIO (x)-flags) != 0) +/* --- Upper layer functions --- */ + a4l_subd_t * a4l_get_subd(struct a4l_device *dev, int idx); a4l_subd_t * a4l_alloc_subd(int sizeof_priv, void (*setup)(a4l_subd_t *)); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [pcimio] fix a huge hack in the mite initialization (broken)
Module: xenomai-abe Branch: experimental Commit: 252edcd951393e29901f0759a560f1f8d60d43cc URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=252edcd951393e29901f0759a560f1f8d60d43cc Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Thu Jun 10 23:59:00 2010 +0200 analogy: [pcimio] fix a huge hack in the mite initialization (broken) --- .../analogy/national_instruments/mio_common.c | 28 +-- ksrc/drivers/analogy/national_instruments/mite.c | 10 +++--- ksrc/drivers/analogy/national_instruments/mite.h |2 +- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/mio_common.c b/ksrc/drivers/analogy/national_instruments/mio_common.c index 46efd03..ead64b8 100644 --- a/ksrc/drivers/analogy/national_instruments/mio_common.c +++ b/ksrc/drivers/analogy/national_instruments/mio_common.c @@ -511,7 +511,7 @@ static int ni_ao_wait_for_dma_load(a4l_subd_t *subd) static const int timeout = 1; a4l_dev_t *dev = subd-dev; - a4l_buf_t *buf = dev-transfer.bufs[subd-idx]; + a4l_buf_t *buf = subd-buf; int i; @@ -522,7 +522,7 @@ static int ni_ao_wait_for_dma_load(a4l_subd_t *subd) b_status = devpriv-stc_readw(dev, AO_Status_1_Register); - buffer_filled = test_bit(A4L_BUF_EOA_NR, buf-evt_flags); + buffer_filled = test_bit(A4L_BUF_EOA_NR, buf-flags); buffer_filled |= (b_status AO_FIFO_Half_Full_St); if (buffer_filled) @@ -727,10 +727,9 @@ static void ni_handle_eos(a4l_subd_t *subd) static void ni_event(a4l_subd_t * subd) { /* Temporary hack */ - a4l_dev_t *dev = subd-dev; - a4l_buf_t *buf = dev-transfer.bufs[subd-idx]; + a4l_buf_t *buf = subd-buf; - if(test_bit(A4L_BUF_ERROR_NR, buf-evt_flags)) { + if(test_bit(A4L_BUF_ERROR_NR, buf-flags)) { if (subd-cancel != NULL) subd-cancel(subd); } @@ -1426,17 +1425,16 @@ static void ni_ai_munge32(a4l_subd_t *subd, void *buf, unsigned long size) #if (defined(CONFIG_XENO_DRIVERS_ANALOGY_NI_MITE) || \ defined(CONFIG_XENO_DRIVERS_ANALOGY_NI_MITE_MODULE)) -static int ni_ai_setup_MITE_dma(a4l_dev_t *dev) +static int ni_ai_setup_MITE_dma(a4l_subd_t *subd) { + a4l_dev_t *dev = subd-dev; int retval; retval = ni_request_ai_mite_channel(dev); if (retval) return retval; - /* Huge hack */ - mite_buf_change(devpriv-ai_mite_chan-ring, - dev-transfer.bufs[NI_AI_SUBDEV]); + mite_buf_change(devpriv-ai_mite_chan-ring, subd); switch (boardtype.reg_type) { case ni_reg_611x: @@ -1457,8 +1455,10 @@ static int ni_ai_setup_MITE_dma(a4l_dev_t *dev) return 0; } -static int ni_ao_setup_MITE_dma(a4l_dev_t *dev) +static int ni_ao_setup_MITE_dma(a4l_subd_t *subd) { + a4l_dev_t *dev = subd-dev; + int retval; unsigned long flags; @@ -1466,9 +1466,7 @@ static int ni_ao_setup_MITE_dma(a4l_dev_t *dev) if (retval) return retval; - /* Huge hack */ - mite_buf_change(devpriv-ao_mite_chan-ring, - dev-transfer.bufs[NI_AO_SUBDEV]); + mite_buf_change(devpriv-ao_mite_chan-ring, subd); a4l_lock_irqsave(devpriv-mite_channel_lock, flags); if (devpriv-ao_mite_chan) { @@ -2436,7 +2434,7 @@ static int ni_ai_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) #if (defined(CONFIG_XENO_DRIVERS_ANALOGY_NI_MITE) || \ defined(CONFIG_XENO_DRIVERS_ANALOGY_NI_MITE_MODULE)) { - int retval = ni_ai_setup_MITE_dma(dev); + int retval = ni_ai_setup_MITE_dma(subd); if (retval) return retval; } @@ -2846,7 +2844,7 @@ int ni_ao_inttrig(a4l_subd_t *subd, lsampl_t trignum) devpriv-stc_writew(dev, 1, DAC_FIFO_Clear); if (boardtype.reg_type ni_reg_6xxx_mask) ni_ao_win_outl(dev, 0x6, AO_FIFO_Offset_Load_611x); - ret = ni_ao_setup_MITE_dma(dev); + ret = ni_ao_setup_MITE_dma(subd); if (ret) return ret; ret = ni_ao_wait_for_dma_load(subd); diff --git a/ksrc/drivers/analogy/national_instruments/mite.c b/ksrc/drivers/analogy/national_instruments/mite.c index d1a7813..da1f6a5 100644 --- a/ksrc/drivers/analogy/national_instruments/mite.c +++ b/ksrc/drivers/analogy/national_instruments/mite.c @@ -379,8 +379,9 @@ void mite_dma_disarm(struct mite_channel *mite_chan) writel(chor, mite-mite_io_addr + MITE_CHOR(mite_chan-channel)); } -int mite_buf_change(struct mite_dma_descriptor_ring *ring, a4l_buf_t *buf) +int mite_buf_change(struct mite_dma_descriptor_ring *ring, a4l_subd_t *subd) { + a4l_buf_t *buf = subd-buf; unsigned int n_links; int i; @@ -587,10 +588,9 @@ int mite_sync_input_dma(struct mite_channel
[Xenomai-git] Alexis Berlemont : analogy: fix buffer initialization/cleanup calls at open /close times
Module: xenomai-abe Branch: experimental Commit: 6926fd70c9a46dfd110e4367d41be0e5ecb33c3a URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=6926fd70c9a46dfd110e4367d41be0e5ecb33c3a Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun Jun 13 00:42:00 2010 +0200 analogy: fix buffer initialization/cleanup calls at open/close times --- include/analogy/buffer.h |2 ++ ksrc/drivers/analogy/buffer.c | 16 ++-- ksrc/drivers/analogy/rtdm_interface.c |6 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 148c07f..9e5ae8a 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -339,6 +339,8 @@ void a4l_free_buffer(a4l_buf_t *buf_desc); void a4l_init_buffer(a4l_buf_t * buf_desc); +void a4l_cleanup_buffer(a4l_buf_t * buf_desc); + int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd); int a4l_cancel_buffer(a4l_cxt_t *cxt); diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 1134b8e..04922be 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -91,7 +91,7 @@ out_virt_contig_alloc: return ret; } -void a4l_init_buffer(a4l_buf_t *buf_desc) +static void a4l_reinit_buffer(a4l_buf_t *buf_desc) { /* No command to process yet */ buf_desc-cur_cmd = NULL; @@ -111,6 +111,18 @@ void a4l_init_buffer(a4l_buf_t *buf_desc) a4l_flush_sync(buf_desc-sync); } +void a4l_init_buffer(a4l_buf_t *buf_desc) +{ + + a4l_init_sync(buf_desc-sync); + a4l_reinit_buffer(buf_desc); +} + +void a4l_cleanup_buffer(a4l_buf_t *buf_desc) +{ + a4l_cleanup_sync(buf_desc-sync); +} + int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) { a4l_buf_t *buf_desc = cxt-buffer; @@ -182,7 +194,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) buf_desc-cur_cmd = NULL; } - a4l_init_buffer(buf_desc); + a4l_reinit_buffer(buf_desc); a4l_release_subd(subd); subd-buf = NULL; diff --git a/ksrc/drivers/analogy/rtdm_interface.c b/ksrc/drivers/analogy/rtdm_interface.c index 4eaada0..65acc86 100644 --- a/ksrc/drivers/analogy/rtdm_interface.c +++ b/ksrc/drivers/analogy/rtdm_interface.c @@ -156,9 +156,13 @@ int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) return err; } - /* Free the buffer which was linked with this context */ + /* Free the buffer which was linked with this context and... */ a4l_free_buffer(cxt-buffer); + /* ...free the other buffer resources (sync) and... */ + a4l_cleanup_buffer(cxt-buffer); + + /* ...free the structure */ rtdm_free(cxt-buffer); return 0; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix test of subdevice status in a4l_write
Module: xenomai-abe Branch: experimental Commit: 608393ae379b0243ddc85410eccd9d395ef58d5a URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=608393ae379b0243ddc85410eccd9d395ef58d5a Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Wed Jun 16 00:35:03 2010 +0200 analogy: fix test of subdevice status in a4l_write --- ksrc/drivers/analogy/buffer.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 04922be..12b8b9b 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -828,7 +828,7 @@ ssize_t a4l_write_buffer(a4l_cxt_t *cxt, const void *bufdata, size_t nbytes) return -EINVAL; } - if (!subd || !test_bit(A4L_SUBD_BUSY, subd-status)) { + if (!subd || !a4l_subd_is_busy(subd)) { __a4l_err(a4l_write: idle subdevice on this context\n); return -ENOENT; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: add a detail in a4l_close doxygen doc
Module: xenomai-abe Branch: experimental Commit: c860c7d8c2c731c41819b27d5362510d46f5c44f URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=c860c7d8c2c731c41819b27d5362510d46f5c44f Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sat Jun 19 00:39:42 2010 +0200 analogy: add a detail in a4l_close doxygen doc --- src/drvlib/analogy/descriptor.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/src/drvlib/analogy/descriptor.c b/src/drvlib/analogy/descriptor.c index c5bb0bc..a7addc0 100644 --- a/src/drvlib/analogy/descriptor.c +++ b/src/drvlib/analogy/descriptor.c @@ -315,6 +315,11 @@ int a4l_open(a4l_desc_t * dsc, const char *fname) /** * @brief Close the Analogy device related with the descriptor * + * The file descriptor is associated with a context. The context is + * one of the enabler of asynchronous transfers. So, by closing the + * file descriptor, the programer must keep in mind that the currently + * occuring asynchronous transfer will cancelled. + * * @param[in] dsc Device descriptor * * @return 0 on success. Otherwise: ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: add an arbitrary sleep in cmd_write before closing the device
Module: xenomai-abe Branch: experimental Commit: a4c6c149fed2ab95981feed79909569a97f8 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=a4c6c149fed2ab95981feed79909569a97f8 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sat Jun 19 00:45:16 2010 +0200 analogy: add an arbitrary sleep in cmd_write before closing the device --- src/utils/analogy/cmd_write.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/src/utils/analogy/cmd_write.c b/src/utils/analogy/cmd_write.c index 5ce9218..b65b8f6 100644 --- a/src/utils/analogy/cmd_write.c +++ b/src/utils/analogy/cmd_write.c @@ -22,6 +22,7 @@ #include stdio.h #include stdlib.h +#include unistd.h #include sys/mman.h #include errno.h #include getopt.h @@ -397,6 +398,8 @@ out_main: if (dsc.sbdata != NULL) free(dsc.sbdata); + sleep(1); + /* Release the file descriptor */ a4l_close(dsc); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [ni_pcimio] fix timeout value in digital trigger
Module: xenomai-abe Branch: experimental Commit: 2ad8726b19c5afeb5efcc86fdc2bfb13a7226df9 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=2ad8726b19c5afeb5efcc86fdc2bfb13a7226df9 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Tue Jun 22 00:25:51 2010 +0200 analogy: [ni_pcimio] fix timeout value in digital trigger --- .../analogy/national_instruments/mio_common.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/mio_common.c b/ksrc/drivers/analogy/national_instruments/mio_common.c index de1c570..55e0bc2 100644 --- a/ksrc/drivers/analogy/national_instruments/mio_common.c +++ b/ksrc/drivers/analogy/national_instruments/mio_common.c @@ -3451,7 +3451,7 @@ int ni_cdo_inttrig(a4l_subd_t *subd, lsampl_t trignum) unsigned long flags; int retval = 0; unsigned i; - const unsigned timeout = 100; + const unsigned timeout = 1000; /* TODO: disable trigger until a command is recorded. Null trig at beginning prevent ao start trigger from executing @@ -3476,6 +3476,7 @@ int ni_cdo_inttrig(a4l_subd_t *subd, lsampl_t trignum) break; a4l_udelay(10); } + if (i == timeout) { a4l_err(dev, ni_cdo_inttrig: dma failed to fill cdo fifo!); ni_cdio_cancel(subd); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: remove a4l_subd_is_busy calls in analogy core
Module: xenomai-abe Branch: experimental Commit: 321bbbc1dfd365383b6eade66243538c108381da URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=321bbbc1dfd365383b6eade66243538c108381da Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Wed Jun 23 21:01:46 2010 +0200 analogy: remove a4l_subd_is_busy calls in analogy core --- ksrc/drivers/analogy/buffer.c | 42 1 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 12b8b9b..b8b01d3 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -175,8 +175,8 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) a4l_subd_t *subd = buf_desc-subd; int err = 0; - - if (!subd || !a4l_subd_is_busy(subd)) + + if (!subd || !test_bit(A4L_SUBD_BUSY_NR, subd-status)) return 0; /* If a cancel function is registered, call it @@ -253,7 +253,7 @@ int a4l_buf_prepare_absput(a4l_subd_t *subd, unsigned long count) { a4l_buf_t *buf = subd-buf; - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, subd-status)) return -ENOENT; if (!a4l_subd_is_input(subd)) @@ -267,7 +267,7 @@ int a4l_buf_commit_absput(a4l_subd_t *subd, unsigned long count) { a4l_buf_t *buf = subd-buf; - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, subd-status)) return -ENOENT; if (!a4l_subd_is_input(subd)) @@ -280,7 +280,7 @@ int a4l_buf_prepare_put(a4l_subd_t *subd, unsigned long count) { a4l_buf_t *buf = subd-buf; - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, subd-status)) return -ENOENT; if (!a4l_subd_is_input(subd)) @@ -293,7 +293,7 @@ int a4l_buf_commit_put(a4l_subd_t *subd, unsigned long count) { a4l_buf_t *buf = subd-buf; - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, subd-status)) return -ENOENT; if (!a4l_subd_is_input(subd)) @@ -307,7 +307,7 @@ int a4l_buf_put(a4l_subd_t *subd, void *bufdata, unsigned long count) a4l_buf_t *buf = subd-buf; int err; - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, subd-status)) return -ENOENT; if (!a4l_subd_is_input(subd)) @@ -329,7 +329,7 @@ int a4l_buf_prepare_absget(a4l_subd_t *subd, unsigned long count) { a4l_buf_t *buf = subd-buf; - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, subd-status)) return -ENOENT; if (!a4l_subd_is_output(subd)) @@ -342,7 +342,7 @@ int a4l_buf_commit_absget(a4l_subd_t *subd, unsigned long count) { a4l_buf_t *buf = subd-buf; - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, subd-status)) return -ENOENT; if (!a4l_subd_is_output(subd)) @@ -355,7 +355,7 @@ int a4l_buf_prepare_get(a4l_subd_t *subd, unsigned long count) { a4l_buf_t *buf = subd-buf; - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, subd-status)) return -ENOENT; if (!a4l_subd_is_output(subd)) @@ -370,7 +370,7 @@ int a4l_buf_commit_get(a4l_subd_t *subd, unsigned long count) /* Basic checkings */ - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, subd-status)) return -ENOENT; if (!a4l_subd_is_output(subd)) @@ -386,12 +386,12 @@ int a4l_buf_get(a4l_subd_t *subd, void *bufdata, unsigned long count) /* Basic checkings */ + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, subd-status)) + return -ENOENT; + if (!a4l_subd_is_output(subd)) return -EINVAL; - if (!buf || !a4l_subd_is_busy(subd)) - return -ENOENT; - if (__count_to_get(buf) count) return -EAGAIN; @@ -418,7 +418,7 @@ int a4l_buf_evt(a4l_subd_t *subd, unsigned long evts) race conditions, not the framework */ /* Basic checking */ - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, subd-status)) return -ENOENT; /* Even if it is a little more complex, @@ -441,7 +441,7 @@ unsigned long a4l_buf_count(a4l_subd_t *subd) unsigned long ret = 0; /* Basic checking */ - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, subd-status)) return -ENOENT; if (a4l_subd_is_input(subd)) @@ -587,7 +587,7 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) arg, sizeof(a4l_bufcfg_t)) != 0)
[Xenomai-git] Alexis Berlemont : analogy: remove calls of a4l_release/ reserve_subd in the core
Module: xenomai-abe Branch: experimental Commit: 739a91a75b6e5f52e26bb0d4db5ead0265f41647 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=739a91a75b6e5f52e26bb0d4db5ead0265f41647 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Wed Jun 23 21:11:31 2010 +0200 analogy: remove calls of a4l_release/reserve_subd in the core --- include/analogy/subdevice.h|7 --- ksrc/drivers/analogy/buffer.c |4 ++-- ksrc/drivers/analogy/instruction.c |7 --- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 5be036b..a81fcb9 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -284,13 +284,6 @@ a4l_rng_t *a4l_get_rngfeat(a4l_subd_t * sb, int chidx, int rngidx); int a4l_check_chanlist(a4l_subd_t * subd, unsigned char nb_chan, unsigned int *chans); -static inline int a4l_reserve_subd(a4l_subd_t *subd) -{ -return test_and_set_bit(A4L_SUBD_BUSY_NR, subd-status) ? -EBUSY : 0; -} -#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY_NR, ((x)-status)) -#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY_NR, ((x)-status))) - #define a4l_subd_is_input(x) ((A4L_SUBD_MASK_READ (x)-flags) != 0) /* The following macro considers that a DIO subdevice is firstly an output subdevice */ diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index b8b01d3..f9bcad7 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -136,7 +136,7 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) return -EINVAL; } - if (a4l_reserve_subd(buf_desc-subd) 0) { + if (test_and_set_bit(A4L_SUBD_BUSY_NR, buf_desc-subd-status)) { __a4l_err(a4l_setup_buffer: subdevice %d already busy\n, cmd-idx_subd); return -EBUSY; @@ -196,7 +196,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) a4l_reinit_buffer(buf_desc); - a4l_release_subd(subd); + clear_bit(A4L_SUBD_BUSY_NR, subd-status); subd-buf = NULL; return err; diff --git a/ksrc/drivers/analogy/instruction.c b/ksrc/drivers/analogy/instruction.c index 644c40c..1050753 100644 --- a/ksrc/drivers/analogy/instruction.c +++ b/ksrc/drivers/analogy/instruction.c @@ -266,9 +266,10 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc) /* Prevents the subdevice from being used during the following operations */ - ret = a4l_reserve_subd(subd); - if (ret 0) + if (test_and_set_bit(A4L_SUBD_BUSY_NR, subd-status)) { + ret = -EBUSY; goto out_do_insn; + } /* Let's the driver-specific code perform the instruction */ ret = hdlr(subd, dsc); @@ -281,7 +282,7 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc) out_do_insn: /* Releases the subdevice from its reserved state */ - a4l_release_subd(subd); + clear_bit(A4L_SUBD_BUSY_NR, subd-status); return ret; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: remove some tests which become with the buffer overhaul
Module: xenomai-abe Branch: experimental Commit: 98d96cef7457a29333ea8f022e34587fc002 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=98d96cef7457a29333ea8f022e34587fc002 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Fri Jun 25 00:14:37 2010 +0200 analogy: remove some tests which become with the buffer overhaul --- include/analogy/device.h |3 --- .../analogy/national_instruments/mio_common.c |3 --- ksrc/drivers/analogy/testing/loop.c|3 --- 3 files changed, 0 insertions(+), 9 deletions(-) diff --git a/include/analogy/device.h b/include/analogy/device.h index fca40cc..76aca28 100644 --- a/include/analogy/device.h +++ b/include/analogy/device.h @@ -80,9 +80,6 @@ typedef struct a4l_dev_info a4l_dvinfo_t; #ifdef __KERNEL__ -/* --- Device related macro --- */ -#define a4l_dev_is_attached(x) test_bit(A4L_DEV_ATTACHED_NR, (x-flags)) - /* --- Devices tab related functions --- */ void a4l_init_devs(void); int a4l_check_cleanup_devs(void); diff --git a/ksrc/drivers/analogy/national_instruments/mio_common.c b/ksrc/drivers/analogy/national_instruments/mio_common.c index 55e0bc2..67c278e 100644 --- a/ksrc/drivers/analogy/national_instruments/mio_common.c +++ b/ksrc/drivers/analogy/national_instruments/mio_common.c @@ -1027,9 +1027,6 @@ int ni_E_interrupt(unsigned int irq, void *d) unsigned long flags; struct mite_struct *mite = devpriv-mite; - if(!a4l_dev_is_attached(dev)) - return IRQ_NONE; - /* Make sure dev-attached is checked before handler does anything else. */ smp_mb(); diff --git a/ksrc/drivers/analogy/testing/loop.c b/ksrc/drivers/analogy/testing/loop.c index f9c4bf8..e304ebc 100644 --- a/ksrc/drivers/analogy/testing/loop.c +++ b/ksrc/drivers/analogy/testing/loop.c @@ -65,9 +65,6 @@ static void loop_task_proc(void *arg) a4l_dev_t *dev = (a4l_dev_t*)arg; a4l_subd_t *input_subd, *output_subd; lpprv_t *priv = (lpprv_t *)dev-priv; - - while (!a4l_dev_is_attached(dev)) - a4l_task_sleep(LOOP_TASK_PERIOD); input_subd = a4l_get_subd(dev, LOOP_INPUT_SUBD); output_subd = a4l_get_subd(dev, LOOP_OUTPUT_SUBD); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: the buffer structure is now the central field of a4l_context (broken)
Module: xenomai-abe Branch: analogy Commit: a32d500ee4ed944836b98e5c3b34a66dd7a7e141 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=a32d500ee4ed944836b98e5c3b34a66dd7a7e141 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun May 16 23:19:52 2010 +0200 analogy: the buffer structure is now the central field of a4l_context (broken) --- include/analogy/buffer.h | 14 -- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 007f01e..49d2a9f 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -43,11 +43,21 @@ #define A4L_BUF_ERROR (1 A4L_BUF_ERROR_NR) #define A4L_BUF_EOA (1 A4L_BUF_EOA_NR) +/* Status bits */ +#define A4L_BUF_BULK_NR 8 +#define A4L_BUF_MAP_NR 8 +/* Status flags */ +#define A4L_BUF_BULK (1 A4L_BUF_BULK_NR) +#define A4L_BUF_MAP (1 A4L_BUF_MAP_NR) + struct a4l_subdevice; /* Buffer descriptor structure */ struct a4l_buffer { + /* Added by the structure update */ + a4l_subd_t *subd; + /* Buffer's first virtual page pointer */ void *buf; @@ -65,8 +75,8 @@ struct a4l_buffer { unsigned long cns_count; unsigned long tmp_count; - /* Events occuring during transfer */ - unsigned long evt_flags; + /* Status + events occuring during transfer */ + unsigned long flags; /* Command on progress */ a4l_cmd_t *cur_cmd; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: first draft of buffer initialization functions (broken)
Module: xenomai-abe Branch: analogy Commit: c5a16b3af7bdd6a646923db90ca8afaefe3e4726 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=c5a16b3af7bdd6a646923db90ca8afaefe3e4726 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun May 16 23:23:16 2010 +0200 analogy: first draft of buffer initialization functions (broken) --- ksrc/drivers/analogy/buffer.c | 69 1 files changed, 62 insertions(+), 7 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index ecbc379..a27a1d6 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -33,7 +33,7 @@ #include analogy/buffer.h #include analogy/transfer.h -/* --- Buffer allocation / free functions --- */ +/* --- Initialization functions (init, alloc, free) --- */ void a4l_free_buffer(a4l_buf_t * buf_desc) { @@ -52,18 +52,15 @@ void a4l_free_buffer(a4l_buf_t * buf_desc) } } -int a4l_alloc_buffer(a4l_buf_t * buf_desc) +int a4l_alloc_buffer(a4l_buf_t * buf_desc, int buf_size) { int ret = 0; char *vaddr, *vabase; - if (buf_desc-size == 0) - buf_desc-size = A4L_BUF_DEFSIZE; - + buf_desc-size = buf_size; buf_desc-size = PAGE_ALIGN(buf_desc-size); buf_desc-buf = vmalloc(buf_desc-size); - if (buf_desc-buf == NULL) { ret = -ENOMEM; goto out_virt_contig_alloc; @@ -94,7 +91,65 @@ out_virt_contig_alloc: return ret; } -/* --- Current Command management function --- */ +int a4l_init_buffer(a4l_buf_t * buf_desc) +{ + int err; + + /* No command to process yet */ + buf_desc-cur_cmd = NULL; + + /* No more (or not yet) linked with a subdevice */ + buf_desc-subd = NULL; + + /* Initializes counts and flags */ + buf_desc-end_count = 0; + buf_desc-prd_count = 0; + buf_desc-cns_count = 0; + buf_desc-tmp_count = 0; + buf_desc-mng_count = 0; + + /* Flush pending events */ + buf_desc-flags = 0; + a4l_flush_sync(buf_desc-sync); + + return err; +} + +int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) +{ + a4l_buf_t * buf_desc = cxt-buffer; + int i; + + /* Retrieve the related subdevice */ + buf_desc-subd = a4l_get_subd(cxt-dev, cmd-idx_subd); + if (buf_desc-subd == NULL) { + __a4l_err(a4l_setup_buffer: subdevice index + out of range (%d)\n, cmd-idx_subd); + goto -EINVAL; + } + + /* Checks if the transfer system has to work in bulk mode */ + if (cmd-flags A4L_CMD_BULK) + set_bit(A4L_BUF_BULK_NR, buf_desc-flags); + + /* Sets the working command */ + buf_desc-cur_cmd = cmd; + + /* Computes the count to reach, if need be */ + if (cmd-stop_src == TRIG_COUNT) { + for (i = 0; i cmd-nb_chan; i++) { + a4l_chan_t *chft; + chft = a4l_get_chfeat(buf_desc-subd, + CR_CHAN(cmd-chan_descs[i])); + buf_desc-end_count += chft-nb_bits / 8; + } + buf_desc-end_count *= cmd-stop_arg; + } + + return 0; +} + +/* --- current Command management function --- */ a4l_cmd_t *a4l_get_cmd(a4l_subd_t *subd) { ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: change the context's role (broken)
Module: xenomai-abe Branch: analogy Commit: 4480b6ebfe57954f59177e272891890e675c7a1f URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=4480b6ebfe57954f59177e272891890e675c7a1f Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun May 16 23:11:47 2010 +0200 analogy: change the context's role (broken) --- include/analogy/context.h | 27 +-- 1 files changed, 9 insertions(+), 18 deletions(-) diff --git a/include/analogy/context.h b/include/analogy/context.h index 7bd225a..d30bbba 100644 --- a/include/analogy/context.h +++ b/include/analogy/context.h @@ -25,29 +25,20 @@ #if defined(__KERNEL__) !defined(DOXYGEN_CPP) -#include analogy/os_facilities.h - struct a4l_device; +struct a4l_buffer; -struct a4l_context { - - /* This field is redundant with the following parameters; - setting it at the head of the structure may save - useless operations */ - struct a4l_device *dev; +struct a4l_device_context { + /* No need to hold user_info, thanks to container_of, we could + get it back */ rtdm_user_info_t *user_info; - struct rtdm_dev_context *rtdm_cxt; -}; -typedef struct a4l_context a4l_cxt_t; -#define a4l_get_minor(x) ((x)-rtdm_cxt-device-device_id) + struct a4l_device *dev; /* Which is retrieved thanks to minor + at open time */ -#define a4l_init_cxt(c, u, x) \ -{ \ - (x)-rtdm_cxt = c; \ - (x)-user_info = u; \ - (x)-dev = NULL;\ -} + struct buffer buffer; /* The buffer field is extracted from +the transfer structure */ +}; #endif /* __KERNEL__ !DOXYGEN_CPP */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: adapt open, r/w, select and ioctl functions ( broken)
Module: xenomai-abe Branch: analogy Commit: a9e1e43dd08c5119f5a1af4208c61d65fb458d3d URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=a9e1e43dd08c5119f5a1af4208c61d65fb458d3d Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun May 16 23:25:49 2010 +0200 analogy: adapt open, r/w, select and ioctl functions (broken) --- ksrc/drivers/analogy/rtdm_interface.c | 130 +++- 1 files changed, 61 insertions(+), 69 deletions(-) diff --git a/ksrc/drivers/analogy/rtdm_interface.c b/ksrc/drivers/analogy/rtdm_interface.c index cbc3ca6..d37ce4c 100644 --- a/ksrc/drivers/analogy/rtdm_interface.c +++ b/ksrc/drivers/analogy/rtdm_interface.c @@ -121,125 +121,117 @@ void a4l_cleanup_proc(void) #endif /* CONFIG_PROC_FS */ -int a4l_rt_open(struct rtdm_dev_context *context, - rtdm_user_info_t * user_info, int flags) +int a4l_open(struct rtdm_dev_context *context, +rtdm_user_info_t * user_info, int flags) { - a4l_cxt_t cxt; + a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; - a4l_init_cxt(context, user_info, cxt); - a4l_set_dev(cxt); - __a4l_dbg(1, core_dbg, - a4l_rt_open: minor=%d\n, a4l_get_minor(cxt)); + /* Get a pointer on the selected device + (thanks to minor index) */ + a4l_set_dev(context); + + /* Initialize the buffer structure */ + a4l_init_buffer(cxt-buffer); + + /* Allocate the asynchronous buffer + NOTE: it should be interesting to allocate the buffer only + on demand especially if the system is short of memory + NOTE2: the default buffer size could be configured via + kernel config*/ + a4l_alloc_buffer(cxt-buffer, A4L_DEFAULT_BFSIZE); return 0; } -int a4l_rt_close(struct rtdm_dev_context *context, -rtdm_user_info_t * user_info) +int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) { - a4l_cxt_t cxt; + int err; + a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + + /* Cancel the maybe occuring asynchronous transfer */ + err = a4l_cancel_buffer(cxt-buffer); + if (err 0) { + __a4l_err(close: unable to stop the asynchronous transfer\n); + return err; + } - a4l_init_cxt(context, user_info, cxt); - a4l_set_dev(cxt); - __a4l_dbg(1, core_dbg, - a4l_rt_close: minor=%d\n, a4l_get_minor(cxt)); + /* Free the buffer which was linked with this context */ + err = a4l_free_buffer(cxt-buffer); - return a4l_cancel_transfers(cxt);; + return err; } -ssize_t a4l_rt_read(struct rtdm_dev_context * context, - rtdm_user_info_t * user_info, void *buf, size_t nbytes) +ssize_t a4l_read(struct rtdm_dev_context * context, +rtdm_user_info_t * user_info, void *buf, size_t nbytes) { - a4l_cxt_t cxt; + a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + /* Jump into the RT domain if possible */ if (!rtdm_in_rt_context() rtdm_rt_capable(user_info)) return -ENOSYS; - a4l_init_cxt(context, user_info, cxt); - a4l_set_dev(cxt); - - __a4l_dbg(1, core_dbg, - a4l_rt_read: minor=%d\n, a4l_get_minor(cxt)); - if (nbytes == 0) return 0; - return a4l_read(cxt, buf, nbytes); + cxt-user_info = user_info; + + return a4l_read(cxt, buf, nbytes); } -ssize_t a4l_rt_write(struct rtdm_dev_context * context, -rtdm_user_info_t * user_info, const void *buf, -size_t nbytes) +ssize_t a4l_write(struct rtdm_dev_context * context, + rtdm_user_info_t *user_info, const void *buf, size_t nbytes) { - a4l_cxt_t cxt; + a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + /* Jump into the RT domain if possible */ if (!rtdm_in_rt_context() rtdm_rt_capable(user_info)) return -ENOSYS; - a4l_init_cxt(context, user_info, cxt); - a4l_set_dev(cxt); - - __a4l_dbg(1, core_dbg, a4l_rt_write: minor=%d\n, a4l_get_minor(cxt)); - if (nbytes == 0) return 0; - return a4l_write(cxt, buf, nbytes); + cxt-user_info = user_info; + + return a4l_write(cxt, buf, nbytes); } -int a4l_rt_ioctl(struct rtdm_dev_context *context, -rtdm_user_info_t * user_info, -unsigned int request, void *arg) +int a4l_ioctl(struct rtdm_dev_context *context, + rtdm_user_info_t *user_info, unsigned int request, void *arg) { - a4l_cxt_t cxt; + a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; - a4l_init_cxt(context, user_info, cxt); - a4l_set_dev(cxt); - __a4l_dbg(1, core_dbg, - a4l_rt_ioctl: minor=%d\n, a4l_get_minor(cxt)); + cxt-user_info = user_info; - return
[Xenomai-git] Alexis Berlemont : analogy: adapt a4l_set_dev() after a4l_context' s overhaul (broken)
Module: xenomai-abe Branch: analogy Commit: e31a28c27483615fb3b90846aabea6d358228bb9 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=e31a28c27483615fb3b90846aabea6d358228bb9 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun May 16 23:55:48 2010 +0200 analogy: adapt a4l_set_dev() after a4l_context's overhaul (broken) --- ksrc/drivers/analogy/device.c | 10 -- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ksrc/drivers/analogy/device.c b/ksrc/drivers/analogy/device.c index b3ef9bf..4a3c879 100644 --- a/ksrc/drivers/analogy/device.c +++ b/ksrc/drivers/analogy/device.c @@ -59,9 +59,15 @@ int a4l_check_cleanup_devs(void) return ret; } -void a4l_set_dev(a4l_cxt_t * cxt) +void a4l_set_dev(struct rtdm_dev_context *context) { - cxt-dev = (a4l_devs[a4l_get_minor(cxt)]); + /* Get the context's private structure */ + a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + /* Retrive the minor index */ + static int minor = context-device-device_id; + + /* Fill the dev fields accordingly */ + cxt-dev = (a4l_devs[minor]); } /* --- Device tab proc section --- */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: update comments on a4l_context (broken)
Module: xenomai-abe Branch: analogy Commit: a25a03ac28a3e6e484590debe1ce2c57f4b49218 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=a25a03ac28a3e6e484590debe1ce2c57f4b49218 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun May 16 23:57:19 2010 +0200 analogy: update comments on a4l_context (broken) --- include/analogy/context.h | 15 +-- 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/analogy/context.h b/include/analogy/context.h index d30bbba..e0cf01c 100644 --- a/include/analogy/context.h +++ b/include/analogy/context.h @@ -29,15 +29,18 @@ struct a4l_device; struct a4l_buffer; struct a4l_device_context { - /* No need to hold user_info, thanks to container_of, we could - get it back */ + + /* Needed to call rtdm_*_copy_from/to_user functions */ rtdm_user_info_t *user_info; - struct a4l_device *dev; /* Which is retrieved thanks to minor - at open time */ + /* The adequate device pointer + (retrieved thanks to minor at open time) */ + struct a4l_device *dev; - struct buffer buffer; /* The buffer field is extracted from -the transfer structure */ + /* The buffer structure contains everything to transfer data + from asynchronous acquisition operations on a specific + subdevice */ + struct buffer buffer; }; #endif /* __KERNEL__ !DOXYGEN_CPP */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: update a4l_set_dev() declaration (broken)
Module: xenomai-abe Branch: analogy Commit: cb94eb2062b771518b02b797e63b9d8f4abf109a URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=cb94eb2062b771518b02b797e63b9d8f4abf109a Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun May 16 23:56:48 2010 +0200 analogy: update a4l_set_dev() declaration (broken) --- include/analogy/device.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/analogy/device.h b/include/analogy/device.h index 27a3bd0..51b99b5 100644 --- a/include/analogy/device.h +++ b/include/analogy/device.h @@ -91,7 +91,7 @@ int a4l_rdproc_devs(char *page, off_t off, int count, int *eof, void *data); /* --- Context related function / macro --- */ -void a4l_set_dev(a4l_cxt_t * cxt); +void a4l_set_dev(struct rtdm_dev_context *context); #define a4l_get_dev(x) ((x)-dev) /* --- Upper layer functions --- */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: changes related with subdevice's status field ( broken)
Module: xenomai-abe Branch: analogy Commit: 353287226edb99dfef56abd0f986740a87b3cd94 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=353287226edb99dfef56abd0f986740a87b3cd94 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon May 17 00:08:40 2010 +0200 analogy: changes related with subdevice's status field (broken) --- include/analogy/subdevice.h |8 ksrc/drivers/analogy/subdevice.c |2 +- ksrc/drivers/analogy/transfer.c | 73 -- 3 files changed, 16 insertions(+), 67 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 11a345e..0f9e1c5 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -155,6 +155,14 @@ #define A4L_SUBD_BUSY_NR 0 #define A4L_SUBD_BUSY (1 A4L_SUBD_BUSY_NR) +/** + * The subdevice is about to be cleaned in the middle of the detach + * procedure + */ +#define A4L_SUBD_CLEAN_NR 1 +#define A4L_SUBD_CLEAN (1 A4L_SUBD_CLEAN_NR) + + /*! @} ANALOGY_SUBD_ST_xxx */ #ifdef __KERNEL__ diff --git a/ksrc/drivers/analogy/subdevice.c b/ksrc/drivers/analogy/subdevice.c index 28aa4a0..1278081 100644 --- a/ksrc/drivers/analogy/subdevice.c +++ b/ksrc/drivers/analogy/subdevice.c @@ -201,7 +201,7 @@ int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg) for (i = 0; i dev-transfer.nb_subd; i++) { subd_info[i].flags = dev-transfer.subds[i]-flags; - subd_info[i].status = dev-transfer.status[i]; + subd_info[i].status = dev-transfer.subds[i]-status; subd_info[i].nb_chan = (dev-transfer.subds[i]-chan_desc != NULL) ? dev-transfer.subds[i]-chan_desc-length : 0; diff --git a/ksrc/drivers/analogy/transfer.c b/ksrc/drivers/analogy/transfer.c index c8a7d43..b1e511d 100644 --- a/ksrc/drivers/analogy/transfer.c +++ b/ksrc/drivers/analogy/transfer.c @@ -53,31 +53,26 @@ int a4l_precleanup_transfer(a4l_cxt_t * cxt) } for (i = 0; i tsf-nb_subd; i++) { + unsigned long *status = tsf-subds[i]-status; - if (test_bit(A4L_TSF_MMAP, (tsf-status[i]))) { - __a4l_err(a4l_precleanup_transfer: - device busy, buffer must be unmapped\n); - err = -EPERM; - goto out_error; - } - - if (test_and_set_bit(A4L_TSF_BUSY, (tsf-status[i]))) { + if (test_and_set_bit(A4L_SUBD_BUSY, status)) { __a4l_err(a4l_precleanup_transfer: device busy, acquisition occuring\n); err = -EBUSY; goto out_error; } else - set_bit(A4L_TSF_CLEAN, (tsf-status[i])); + set_bit(A4L_SUBD_CLEAN, status); } return 0; out_error: for (i = 0; i tsf-nb_subd; i++) { + unsigned long *status = tsf-subds[i]-status; - if (test_bit(A4L_TSF_CLEAN, (tsf-status[i]))){ - clear_bit(A4L_TSF_BUSY, (tsf-status[i])); - clear_bit(A4L_TSF_CLEAN, (tsf-status[i])); + if (test_bit(A4L_TSF_CLEAN, status)){ + clear_bit(A4L_SUBD_BUSY, status); + clear_bit(A4L_SUBD_CLEAN, status); } } @@ -97,21 +92,6 @@ int a4l_cleanup_transfer(a4l_cxt_t * cxt) dev = a4l_get_dev(cxt); tsf = dev-transfer; - /* Releases the various buffers */ - if (tsf-status != NULL) - rtdm_free(tsf-status); - - if (tsf-bufs != NULL) { - for (i = 0; i tsf-nb_subd; i++) { - if (tsf-bufs[i] != NULL) { - a4l_free_buffer(tsf-bufs[i]); - a4l_cleanup_sync(tsf-bufs[i]-sync); - rtdm_free(tsf-bufs[i]); - } - } - rtdm_free(tsf-bufs); - } - /* Releases the pointers tab, if need be */ if (tsf-subds != NULL) { rtdm_free(tsf-subds); @@ -135,10 +115,6 @@ void a4l_presetup_transfer(a4l_cxt_t *cxt) /* Clear the structure */ memset(tsf, 0, sizeof(a4l_trf_t)); - /* We consider 0 can be valid index */ - tsf-idx_read_subd = A4L_IDX_UNUSED; - tsf-idx_write_subd = A4L_IDX_UNUSED; - /* 0 is also considered as a valid IRQ, then the IRQ number must be initialized with another value */ tsf-irq_desc.irq = A4L_IRQ_UNUSED; @@ -186,41 +162,6 @@ int a4l_setup_transfer(a4l_cxt_t * cxt) tsf-subds[i++] = subd; } - /* Allocates various buffers */ - tsf-bufs = rtdm_malloc(tsf-nb_subd * sizeof(a4l_buf_t *)); - if (tsf-bufs == NULL) { - __a4l_err(a4l_setup_transfer: call2(alloc) failed
[Xenomai-git] Alexis Berlemont : analogy: replace transfer setup functions with buffer setup ones (broken)
Module: xenomai-abe Branch: analogy Commit: 99a8b1a36361ca433d33d6d465cfb12ada674d32 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=99a8b1a36361ca433d33d6d465cfb12ada674d32 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon May 17 23:31:20 2010 +0200 analogy: replace transfer setup functions with buffer setup ones (broken) --- ksrc/drivers/analogy/buffer.c |3 + ksrc/drivers/analogy/command.c | 19 +++ ksrc/drivers/analogy/instruction.c |2 +- ksrc/drivers/analogy/transfer.c| 98 +++ 4 files changed, 22 insertions(+), 100 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index a27a1d6..92f1f4e 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -145,6 +145,9 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) } buf_desc-end_count *= cmd-stop_arg; } + + __a4l_dbg(1, core_dbg, + a4l_setup_buffer: end_count=%lu\n, buf_desc-end_count); return 0; } diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c index a6c1dec..b300d9a 100644 --- a/ksrc/drivers/analogy/command.c +++ b/ksrc/drivers/analogy/command.c @@ -299,7 +299,8 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) { int ret = 0, simul_flag = 0; a4l_cmd_t *cmd_desc = NULL; - a4l_dev_t *dev = a4l_get_dev(cxt); + a4l_subd_t *subd; + a4l_dev_t *dev = a4l_get_dev(cxt); __a4l_dbg(1, core_dbg, a4l_ioctl_cmd: minor=%d\n, a4l_get_minor(cxt)); @@ -344,11 +345,11 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) __a4l_dbg(1, core_dbg, a4l_ioctl_cmd: 1st cmd checks passed\n); + subd = dev-transfer.subds[cmd_desc-idx_subd]; + /* Tests the command with the cmdtest function */ - if (dev-transfer.subds[cmd_desc-idx_subd]-do_cmdtest != NULL) - ret = dev-transfer.subds[cmd_desc-idx_subd]- - do_cmdtest(dev-transfer.subds[cmd_desc-idx_subd], - cmd_desc); + if (subd-do_cmdtest != NULL) + ret = subd-do_cmdtest(subd, cmd_desc); if (ret != 0) { __a4l_err(a4l_ioctl_cmd: driver's cmd_test failed\n); goto out_ioctl_cmd; @@ -363,17 +364,15 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) } /* Sets the concerned subdevice as busy */ - ret = a4l_reserve_transfer(cxt, cmd_desc-idx_subd); + ret = a4l_reserve_subd(subd); if (ret 0) goto out_ioctl_cmd; /* Gets the transfer system ready */ - a4l_init_transfer(cxt, cmd_desc); + a4l_setup_buffer(cxt, cmd_desc); /* Eventually launches the command */ - ret = dev-transfer.subds[cmd_desc-idx_subd]- - do_cmd(dev-transfer.subds[cmd_desc-idx_subd], - cmd_desc); + ret = subd-do_cmd(subd, cmd_desc); if (ret != 0) { a4l_cancel_transfer(cxt, cmd_desc-idx_subd); diff --git a/ksrc/drivers/analogy/instruction.c b/ksrc/drivers/analogy/instruction.c index 64c7a04..941fa69 100644 --- a/ksrc/drivers/analogy/instruction.c +++ b/ksrc/drivers/analogy/instruction.c @@ -266,7 +266,7 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc) /* Prevents the subdevice from being used during the following operations */ - ret = a4l_reserve_transfer(cxt, dsc-idx_subd); + ret = a4l_reserve_subd(subd); if (ret 0) goto out_do_insn; diff --git a/ksrc/drivers/analogy/transfer.c b/ksrc/drivers/analogy/transfer.c index b1e511d..9fc279a 100644 --- a/ksrc/drivers/analogy/transfer.c +++ b/ksrc/drivers/analogy/transfer.c @@ -39,10 +39,6 @@ int a4l_precleanup_transfer(a4l_cxt_t * cxt) a4l_trf_t *tsf; int i, err = 0; - __a4l_dbg(1, core_dbg, - a4l_precleanup_transfer: minor=%d\n, - a4l_get_minor(cxt)); - dev = a4l_get_dev(cxt); tsf = dev-transfer; @@ -55,6 +51,10 @@ int a4l_precleanup_transfer(a4l_cxt_t * cxt) for (i = 0; i tsf-nb_subd; i++) { unsigned long *status = tsf-subds[i]-status; + __a4l_dbg(1, core_dbg, + a4l_precleanup_transfer: + subd[%d]-status=0x%08x\n, *status); + if (test_and_set_bit(A4L_SUBD_BUSY, status)) { __a4l_err(a4l_precleanup_transfer: device busy, acquisition occuring\n); @@ -70,7 +70,7 @@ out_error: for (i = 0; i tsf-nb_subd; i++) { unsigned long *status = tsf-subds[i]-status; - if (test_bit(A4L_TSF_CLEAN, status)){ + if (test_bit(A4L_SUBD_CLEAN, status)){ clear_bit(A4L_SUBD_BUSY, status);
[Xenomai-git] Alexis Berlemont : analogy: update cancel functions (broken)
Module: xenomai-abe Branch: analogy Commit: 3bd3fad57fe10639597c5dc88cc96848715b6773 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=3bd3fad57fe10639597c5dc88cc96848715b6773 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon May 17 23:58:52 2010 +0200 analogy: update cancel functions (broken) --- ksrc/drivers/analogy/buffer.c | 58 - ksrc/drivers/analogy/transfer.c | 61 --- 2 files changed, 44 insertions(+), 75 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 92f1f4e..cb4beb7 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -91,10 +91,8 @@ out_virt_contig_alloc: return ret; } -int a4l_init_buffer(a4l_buf_t * buf_desc) +void a4l_init_buffer(a4l_buf_t * buf_desc) { - int err; - /* No command to process yet */ buf_desc-cur_cmd = NULL; @@ -111,13 +109,11 @@ int a4l_init_buffer(a4l_buf_t * buf_desc) /* Flush pending events */ buf_desc-flags = 0; a4l_flush_sync(buf_desc-sync); - - return err; } int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) { - a4l_buf_t * buf_desc = cxt-buffer; + a4l_buf_t *buf_desc = cxt-buffer; int i; /* Retrieve the related subdevice */ @@ -152,6 +148,40 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) return 0; } +int a4l_cancel_buffer(a4l_cxt_t *cxt) +{ + a4l_buf_t *buf_desc = cxt-buffer; + a4l_subd_t *subd = buf_desc-subd; + + int err = 0; + + if (!subd !! !a4l_check_subd(subd)) + return 0; + + /* If a cancel function is registered, call it + (Note: this function is called before having checked + if a command is under progress; we consider that + the cancel function can be used as as to (re)initialize + some component) */ + if (subd-cancel != NULL (err = subd-cancel(subd)) 0) { + __a4l_err(a4l_cancel: + subdevice %d cancel handler failed (err=%d)\n, + idx_subd, err); + } + + a4l_release_subd(subd); + + if (buf_desc-cur_cmd != NULL) { + a4l_free_cmddesc(buf_desc-cur_cmd); + rtdm_free(buf_desc-cur_cmd); + buf_desc-cur_cmd = NULL; + } + + a4l_init_buffer(buf_desc); + + return err; +} + /* --- current Command management function --- */ a4l_cmd_t *a4l_get_cmd(a4l_subd_t *subd) @@ -646,13 +676,13 @@ int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg) if ((ret 0 ret != -ENOENT) || (ret == -ENOENT tmp_cnt == 0)) { - a4l_cancel_transfer(cxt, info.idx_subd); + a4l_cancel_buffer(cxt); return ret; } } else if (info.idx_subd == dev-transfer.idx_write_subd) { if (ret 0) { - a4l_cancel_transfer(cxt, info.idx_subd); + a4l_cancel_buffer(cxt); if (info.rw_count != 0) return ret; } @@ -744,14 +774,14 @@ ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) /* We check whether there is an error */ if (ret 0 ret != -ENOENT) { - a4l_cancel_transfer(cxt, idx_subd); + a4l_cancel_buffer(cxt); count = ret; goto out_a4l_read; } /* We check whether the acquisition is over */ if (ret == -ENOENT tmp_cnt == 0) { - a4l_cancel_transfer(cxt, idx_subd); + a4l_cancel_buffer(cxt); count = 0; goto out_a4l_read; } @@ -846,7 +876,7 @@ ssize_t a4l_write(a4l_cxt_t *cxt, tmp_cnt = nbytes - count; if (ret 0) { - a4l_cancel_transfer(cxt, idx_subd); + a4l_cancel_buffer(cxt); count = (ret == -ENOENT) ? -EINVAL : ret; goto out_a4l_write; } @@ -993,20 +1023,20 @@ int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg) /* Check if some error occured */ if (ret 0 ret != -ENOENT) { - a4l_cancel_transfer(cxt, poll.idx_subd); + a4l_cancel_buffer(cxt); return ret; } /* Check whether the acquisition is over */ if (ret == -ENOENT tmp_cnt == 0) { - a4l_cancel_transfer(cxt, poll.idx_subd); + a4l_cancel_buffer(cxt); return 0;
[Xenomai-git] Alexis Berlemont : analogy: fix bulk flag declaration in buffer.h (broken)
Module: xenomai-abe Branch: analogy Commit: f324cf68e70d5953dd9816883f7a46cfe1d37550 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=f324cf68e70d5953dd9816883f7a46cfe1d37550 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Wed May 19 00:13:36 2010 +0200 analogy: fix bulk flag declaration in buffer.h (broken) --- include/analogy/buffer.h | 10 +- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 49d2a9f..786c8e1 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -45,7 +45,7 @@ /* Status bits */ #define A4L_BUF_BULK_NR 8 -#define A4L_BUF_MAP_NR 8 +#define A4L_BUF_MAP_NR 9 /* Status flags */ #define A4L_BUF_BULK (1 A4L_BUF_BULK_NR) #define A4L_BUF_MAP (1 A4L_BUF_MAP_NR) @@ -89,8 +89,8 @@ typedef struct a4l_buffer a4l_buf_t; /* Static inline Buffer related functions */ /* Produce memcpy function */ -static inline int __produce(a4l_cxt_t * cxt, - a4l_buf_t * buf, void *pin, unsigned long count) +static inline int __produce(a4l_cxt_t *cxt, + a4l_buf_t *buf, void *pin, unsigned long count) { unsigned long start_ptr = (buf-prd_count % buf-size); unsigned long tmp_cnt = count; @@ -119,8 +119,8 @@ static inline int __produce(a4l_cxt_t * cxt, } /* Consume memcpy function */ -static inline int __consume(a4l_cxt_t * cxt, - a4l_buf_t * buf, void *pout, unsigned long count) +static inline int __consume(a4l_cxt_t *cxt, + a4l_buf_t *buf, void *pout, unsigned long count) { unsigned long start_ptr = (buf-cns_count % buf-size); unsigned long tmp_cnt = count; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: update a4l_read and a4l_write (broken)
Module: xenomai-abe Branch: analogy Commit: 9813a5e98fafa16fb7549d63ad20f49121c8f63c URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=9813a5e98fafa16fb7549d63ad20f49121c8f63c Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Wed May 19 00:15:00 2010 +0200 analogy: update a4l_read and a4l_write (broken) --- ksrc/drivers/analogy/buffer.c | 50 +--- 1 files changed, 16 insertions(+), 34 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index bc162d3..9bd9829 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -773,28 +773,21 @@ a4l_ioctl_bufinfo_out: ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) { a4l_dev_t *dev = a4l_get_dev(cxt); - int idx_subd = dev-transfer.idx_read_subd; - a4l_buf_t *buf = dev-transfer.bufs[idx_subd]; + a4l_buf_t *buf = cxt-buffer; ssize_t count = 0; /* Basic checkings */ + if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { __a4l_err(a4l_read: unattached device\n); return -EINVAL; } - if (!test_bit(A4L_TSF_BUSY, (dev-transfer.status[idx_subd]))) { - __a4l_err(a4l_read: idle subdevice\n); + if (!buf-subd || !test_bit(A4L_SUBD_BUSY, buf-subd-status)) { + __a4l_err(a4l_read: idle subdevice on this context\n); return -ENOENT; } - /* TODO: to be removed - Check the subdevice capabilities */ - if ((dev-transfer.subds[idx_subd]-flags A4L_SUBD_CMD) == 0) { - __a4l_err(a4l_read: incoherent state\n); - return -EINVAL; - } - while (count nbytes) { /* Check the events */ @@ -825,10 +818,9 @@ ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) if (tmp_cnt 0) { /* Performs the munge if need be */ - if (dev-transfer.subds[idx_subd]-munge != NULL) { - __munge(dev-transfer.subds[idx_subd], - dev-transfer.subds[idx_subd]-munge, - buf, tmp_cnt); + if (buf-subd-munge != NULL) { + __munge(buf-subd, + buf-subd-munge, buf, tmp_cnt); /* Updates munge count */ buf-mng_count += tmp_cnt; @@ -850,8 +842,7 @@ ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) /* If the driver does not work in bulk mode, we must leave this function */ - if (!test_bit(A4L_TSF_BULK, - (dev-transfer.status[idx_subd]))) + if (!test_bit(A4L_BUF_BULK, buf-flags)) goto out_a4l_read; } /* If the acquisition is not over, we must not @@ -876,28 +867,21 @@ ssize_t a4l_write(a4l_cxt_t *cxt, const void *bufdata, size_t nbytes) { a4l_dev_t *dev = a4l_get_dev(cxt); - int idx_subd = dev-transfer.idx_write_subd; - a4l_buf_t *buf = dev-transfer.bufs[idx_subd]; + a4l_buf_t *buf = cxt-buffer; ssize_t count = 0; /* Basic checkings */ + if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { __a4l_err(a4l_write: unattached device\n); return -EINVAL; } - if (!test_bit(A4L_TSF_BUSY, (dev-transfer.status[idx_subd]))) { - __a4l_err(a4l_write: idle subdevice\n); + if (!buf-subd || !test_bit(A4L_SUBD_BUSY, buf-subd-status)) { + __a4l_err(a4l_read: idle subdevice on this context\n); return -ENOENT; } - /* TODO: to be removed - Check the subdevice capabilities */ - if ((dev-transfer.subds[idx_subd]-flags A4L_SUBD_CMD) == 0) { - __a4l_err(a4l_write: incoherent state\n); - return -EINVAL; - } - while (count nbytes) { /* Check the events */ @@ -928,10 +912,9 @@ ssize_t a4l_write(a4l_cxt_t *cxt, } /* Performs the munge if need be */ - if (dev-transfer.subds[idx_subd]-munge != NULL) { - __munge(dev-transfer.subds[idx_subd], - dev-transfer.subds[idx_subd]-munge, - buf, tmp_cnt); + if (buf-subd-munge != NULL) { + __munge(buf-subd, + buf-subd-munge, buf, tmp_cnt); /* Updates munge count */ buf-mng_count += tmp_cnt; @@ -945,8 +928,7 @@ ssize_t
[Xenomai-git] Alexis Berlemont : analogy: last updates in the buffer part (broken)
Module: xenomai-abe Branch: analogy Commit: 156a26764c8ff05db4dd031165730987d08c80ee URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=156a26764c8ff05db4dd031165730987d08c80ee Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Wed May 19 23:35:12 2010 +0200 analogy: last updates in the buffer part (broken) --- ksrc/drivers/analogy/buffer.c | 13 ++--- 1 files changed, 2 insertions(+), 11 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index c9b1682..011753a 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -387,8 +387,8 @@ void a4l_unmap(struct vm_area_struct *area) } static struct vm_operations_struct a4l_vm_ops = { -open:a4l_map, -close:a4l_unmap, + .open = a4l_map, + .close = a4l_unmap, }; int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) @@ -397,9 +397,6 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) a4l_dev_t *dev; int ret; - __a4l_dbg(1, core_dbg, - a4l_ioctl_mmap: minor=%d\n, a4l_get_minor(cxt)); - /* The mmap operation cannot be performed in a real-time context */ if (rtdm_in_rt_context()) { @@ -511,9 +508,6 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) a4l_dev_t *dev = a4l_get_dev(cxt); a4l_bufcfg_t buf_cfg; - __a4l_dbg(1, core_dbg, - a4l_ioctl_bufcfg: minor=%d\n, a4l_get_minor(cxt)); - /* As Linux API is used to allocate a virtual buffer, the calling process must not be in primary mode */ if (rtdm_in_rt_context()) { @@ -580,9 +574,6 @@ int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg) unsigned long tmp_cnt; int ret; - __a4l_dbg(1, core_dbg, - a4l_ioctl_bufinfo: minor=%d\n, a4l_get_minor(cxt)); - if (!rtdm_in_rt_context() rtdm_rt_capable(cxt-user_info)) return -ENOSYS; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: update all a4l_buf_* functions (broken)
Module: xenomai-abe Branch: analogy Commit: 80ecc82b494736a660e04154f1b50be80844f2e3 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=80ecc82b494736a660e04154f1b50be80844f2e3 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Wed May 19 23:29:59 2010 +0200 analogy: update all a4l_buf_* functions (broken) --- include/analogy/buffer.h | 11 ++- ksrc/drivers/analogy/buffer.c| 157 -- ksrc/drivers/analogy/driver_facilities.c |4 +- 3 files changed, 51 insertions(+), 121 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 786c8e1..cf82811 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -329,9 +329,11 @@ static inline unsigned long __count_to_get(a4l_buf_t * buf) /* --- Buffer internal functions --- */ -int a4l_alloc_buffer(a4l_buf_t * buf_desc); +void a4l_init_buffer(a4l_buf_t * buf_desc); -void a4l_free_buffer(a4l_buf_t * buf_desc); +int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd); + +int a4l_cancel_buffer(a4l_cxt_t *cxt); int a4l_buf_prepare_absput(struct a4l_subdevice *subd, unsigned long count); @@ -369,7 +371,10 @@ unsigned long a4l_buf_count(struct a4l_subdevice *subd); /* --- Current Command management function --- */ -a4l_cmd_t *a4l_get_cmd(struct a4l_subdevice *subd); +static inline a4l_cmd_t *a4l_get_cmd(a4l_subd_t *subd) +{ + return (subd-buf) ? subd-buf-cur_cmd : NULL; +} /* --- Munge related function --- */ diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 9bd9829..c9b1682 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -182,38 +182,17 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) return err; } -/* --- current Command management function --- */ - -a4l_cmd_t *a4l_get_cmd(a4l_subd_t *subd) -{ - a4l_dev_t *dev = subd-dev; - - /* Check that subdevice supports commands */ - if (dev-transfer.bufs == NULL) - return NULL; - - return dev-transfer.bufs[subd-idx]-cur_cmd; -} - /* --- Munge related function --- */ int a4l_get_chan(a4l_subd_t *subd) { - a4l_dev_t *dev = subd-dev; int i, j, tmp_count, tmp_size = 0; a4l_cmd_t *cmd; - /* Check that subdevice supports commands */ - if (dev-transfer.bufs == NULL) - return -EINVAL; - - /* Check a command is executed */ - if (dev-transfer.bufs[subd-idx]-cur_cmd == NULL) + cmd = a4l_get_cmd(subd); + if (!cmd) return -EINVAL; - /* Retrieve the proper command descriptor */ - cmd = dev-transfer.bufs[subd-idx]-cur_cmd; - /* There is no need to check the channel idx, it has already been controlled in command_test */ @@ -252,185 +231,128 @@ int a4l_get_chan(a4l_subd_t *subd) int a4l_buf_prepare_absput(a4l_subd_t *subd, unsigned long count) { - a4l_dev_t *dev; - a4l_buf_t *buf; - - if ((subd-flags A4L_SUBD_MASK_READ) == 0) + if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) return -EINVAL; - dev = subd-dev; - buf = dev-transfer.bufs[subd-idx]; - - return __pre_abs_put(buf, count); + return __pre_abs_put(subd-buf, count); } int a4l_buf_commit_absput(a4l_subd_t *subd, unsigned long count) { - a4l_dev_t *dev; - a4l_buf_t *buf; - - if ((subd-flags A4L_SUBD_MASK_READ) == 0) + if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) return -EINVAL; - dev = subd-dev; - buf = dev-transfer.bufs[subd-idx]; - - return __abs_put(buf, count); + return __abs_put(subd-buf, count); } int a4l_buf_prepare_put(a4l_subd_t *subd, unsigned long count) { - a4l_dev_t *dev; - a4l_buf_t *buf; - - if ((subd-flags A4L_SUBD_MASK_READ) == 0) + if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) return -EINVAL; - dev = subd-dev; - buf = dev-transfer.bufs[subd-idx]; - - return __pre_put(buf, count); + return __pre_put(subd-buf, count); } int a4l_buf_commit_put(a4l_subd_t *subd, unsigned long count) { - a4l_dev_t *dev; - a4l_buf_t *buf; - - if ((subd-flags A4L_SUBD_MASK_READ) == 0) + if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) return -EINVAL; - dev = subd-dev; - buf = dev-transfer.bufs[subd-idx]; - - return __put(buf, count); + return __put(subd-buf, count); } int a4l_buf_put(a4l_subd_t *subd, void *bufdata, unsigned long count) { int err; - a4l_dev_t *dev; - a4l_buf_t *buf; - - if ((subd-flags A4L_SUBD_MASK_READ) == 0) - return -EINVAL; - dev = subd-dev; - buf = dev-transfer.bufs[subd-idx]; - - if (__count_to_put(buf) count) + if ((subd-flags
[Xenomai-git] Alexis Berlemont : analogy: cosmetic changes (broken)
Module: xenomai-abe Branch: analogy Commit: 856fe0b531d885f3044e876879c9231aaffeaf6a URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=856fe0b531d885f3044e876879c9231aaffeaf6a Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon May 24 16:44:03 2010 +0200 analogy: cosmetic changes (broken) --- ksrc/drivers/analogy/buffer.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 011753a..0ca1b4c 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -35,7 +35,7 @@ /* --- Initialization functions (init, alloc, free) --- */ -void a4l_free_buffer(a4l_buf_t * buf_desc) +void a4l_free_buffer(a4l_buf_t *buf_desc) { if (buf_desc-pg_list != NULL) { rtdm_free(buf_desc-pg_list); @@ -52,7 +52,7 @@ void a4l_free_buffer(a4l_buf_t * buf_desc) } } -int a4l_alloc_buffer(a4l_buf_t * buf_desc, int buf_size) +int a4l_alloc_buffer(a4l_buf_t *buf_desc, int buf_size) { int ret = 0; char *vaddr, *vabase; @@ -91,7 +91,7 @@ out_virt_contig_alloc: return ret; } -void a4l_init_buffer(a4l_buf_t * buf_desc) +void a4l_init_buffer(a4l_buf_t *buf_desc) { /* No command to process yet */ buf_desc-cur_cmd = NULL; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: update a4l_get_minor function (broken)
Module: xenomai-abe Branch: analogy Commit: 08825a06726cdf8c036e162c357bb539e5988c9d URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=08825a06726cdf8c036e162c357bb539e5988c9d Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon May 24 23:33:13 2010 +0200 analogy: update a4l_get_minor function (broken) --- include/analogy/context.h | 10 ++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/include/analogy/context.h b/include/analogy/context.h index e0cf01c..2442b6c 100644 --- a/include/analogy/context.h +++ b/include/analogy/context.h @@ -25,6 +25,8 @@ #if defined(__KERNEL__) !defined(DOXYGEN_CPP) +#include rtdm/rtdm_driver.h + struct a4l_device; struct a4l_buffer; @@ -43,6 +45,14 @@ struct a4l_device_context { struct buffer buffer; }; +static inline int a4l_get_minor(a4l_cxt_t *cxt) +{ + /* Get a pointer on the container structure */ + struct rtdm_dev_context * rtdm_cxt = rtdm_private_to_context(cxt); + /* Get the minor index */ + return rtdm_cxt-device-device_id; +} + #endif /* __KERNEL__ !DOXYGEN_CPP */ #endif /* __ANALOGY_CONTEXT__ */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: update a4l_set_dev and remove useless info traces (broken)
Module: xenomai-abe Branch: analogy Commit: 4a9afd7d10ebb95d5fe324f4ee390b28fc2c075e URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=4a9afd7d10ebb95d5fe324f4ee390b28fc2c075e Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon May 24 23:34:19 2010 +0200 analogy: update a4l_set_dev and remove useless info traces (broken) --- include/analogy/device.h |2 +- ksrc/drivers/analogy/device.c | 39 +-- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/include/analogy/device.h b/include/analogy/device.h index 51b99b5..6930a38 100644 --- a/include/analogy/device.h +++ b/include/analogy/device.h @@ -91,7 +91,7 @@ int a4l_rdproc_devs(char *page, off_t off, int count, int *eof, void *data); /* --- Context related function / macro --- */ -void a4l_set_dev(struct rtdm_dev_context *context); +void a4l_set_dev(a4l_cxt_t *cxt); #define a4l_get_dev(x) ((x)-dev) /* --- Upper layer functions --- */ diff --git a/ksrc/drivers/analogy/device.c b/ksrc/drivers/analogy/device.c index 4a3c879..a2d23c8 100644 --- a/ksrc/drivers/analogy/device.c +++ b/ksrc/drivers/analogy/device.c @@ -43,8 +43,6 @@ void a4l_init_devs(void) for (i = 0; i A4L_NB_DEVICES; i++) { a4l_lock_init(a4l_devs[i].lock); a4l_devs[i].transfer.irq_desc.irq = A4L_IRQ_UNUSED; - a4l_devs[i].transfer.idx_read_subd = A4L_IDX_UNUSED; - a4l_devs[i].transfer.idx_write_subd = A4L_IDX_UNUSED; } } @@ -59,13 +57,10 @@ int a4l_check_cleanup_devs(void) return ret; } -void a4l_set_dev(struct rtdm_dev_context *context) +void a4l_set_dev(a4l_cxt_t *cxt) { - /* Get the context's private structure */ - a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; - /* Retrive the minor index */ - static int minor = context-device-device_id; - + /* Retrieve the minor index */ + static int minor = a4l_get_minor(cxt); /* Fill the dev fields accordingly */ cxt-dev = (a4l_devs[minor]); } @@ -208,9 +203,6 @@ int a4l_fill_lnkdesc(a4l_cxt_t * cxt, char *tmpname = NULL; void *tmpopts = NULL; - __a4l_dbg(1, core_dbg, - a4l_fill_lnkdesc: minor=%d\n, a4l_get_minor(cxt)); - ret = rtdm_safe_copy_from_user(cxt-user_info, link_arg, arg, sizeof(a4l_lnkdesc_t)); if (ret != 0) { @@ -285,9 +277,6 @@ int a4l_fill_lnkdesc(a4l_cxt_t * cxt, void a4l_free_lnkdesc(a4l_cxt_t * cxt, a4l_lnkdesc_t * link_arg) { - __a4l_dbg(1, core_dbg, - a4l_free_lnkdesc: minor=%d\n, a4l_get_minor(cxt)); - if (link_arg-bname != NULL) rtdm_free(link_arg-bname); @@ -301,9 +290,6 @@ int a4l_assign_driver(a4l_cxt_t * cxt, int ret = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - __a4l_dbg(1, core_dbg, - a4l_assign_driver: minor=%d\n, a4l_get_minor(cxt)); - dev-driver = drv; if (drv-privdata_size == 0) @@ -355,9 +341,6 @@ int a4l_release_driver(a4l_cxt_t * cxt) int ret = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - __a4l_dbg(1, core_dbg, - a4l_release_driver: minor=%d\n, a4l_get_minor(cxt)); - if ((ret = dev-driver-detach(dev)) != 0) goto out_release_driver; @@ -388,9 +371,6 @@ int a4l_device_attach(a4l_cxt_t * cxt, void *arg) a4l_lnkdesc_t link_arg; a4l_drv_t *drv = NULL; - __a4l_dbg(1, core_dbg, - a4l_device_attach: minor=%d\n, a4l_get_minor(cxt)); - if ((ret = a4l_fill_lnkdesc(cxt, link_arg, arg)) != 0) goto out_attach; @@ -412,9 +392,6 @@ int a4l_device_detach(a4l_cxt_t * cxt) { a4l_dev_t *dev = a4l_get_dev(cxt); - __a4l_dbg(1, core_dbg, - a4l_device_detach: minor=%d\n, a4l_get_minor(cxt)); - if (dev-driver == NULL) { __a4l_err(a4l_device_detach: incoherent state, driver not reachable\n); @@ -430,9 +407,6 @@ int a4l_ioctl_devcfg(a4l_cxt_t * cxt, void *arg) { int ret = 0; - __a4l_dbg(1, core_dbg, - a4l_ioctl_devcfg: minor=%d\n, a4l_get_minor(cxt)); - if (rtdm_in_rt_context()) return -ENOSYS; @@ -487,9 +461,6 @@ int a4l_ioctl_devinfo(a4l_cxt_t * cxt, void *arg) a4l_dvinfo_t info; a4l_dev_t *dev = a4l_get_dev(cxt); - __a4l_dbg(1, core_dbg, - a4l_ioctl_devinfo: minor=%d\n, a4l_get_minor(cxt)); - memset(info, 0, sizeof(a4l_dvinfo_t)); if (test_bit(A4L_DEV_ATTACHED, dev-flags)) { @@ -498,8 +469,8 @@ int a4l_ioctl_devinfo(a4l_cxt_t * cxt, void *arg) memcpy(info.board_name, dev-driver-board_name, len); info.nb_subd = dev-transfer.nb_subd; - info.idx_read_subd = dev-transfer.idx_read_subd; -
[Xenomai-git] Alexis Berlemont : analogy: declare the reserve / release functions at the subd level (broken)
Module: xenomai-abe Branch: analogy Commit: d20cb6dc3652d7dc866b5c8a7c8281bfc7f23b32 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=d20cb6dc3652d7dc866b5c8a7c8281bfc7f23b32 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon May 24 16:46:31 2010 +0200 analogy: declare the reserve / release functions at the subd level (broken) --- include/analogy/subdevice.h|2 ++ ksrc/drivers/analogy/command.c | 33 - ksrc/drivers/analogy/instruction.c |2 +- ksrc/drivers/analogy/subdevice.c | 15 +++ 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 0f9e1c5..ded82f3 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -290,6 +290,8 @@ a4l_subd_t * a4l_get_subd(struct a4l_device *dev, int idx); a4l_subd_t * a4l_alloc_subd(int sizeof_priv, void (*setup)(a4l_subd_t *)); int a4l_add_subd(struct a4l_device *dev, a4l_subd_t * subd); +int a4l_reserve_subd(a4l_subd_t *subd); +void a4l_release_subd(a4l_subd_t *subd); int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_chaninfo(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_rnginfo(a4l_cxt_t * cxt, void *arg); diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c index b300d9a..94d6137 100644 --- a/ksrc/drivers/analogy/command.c +++ b/ksrc/drivers/analogy/command.c @@ -90,11 +90,8 @@ void a4l_free_cmddesc(a4l_cmd_t * desc) int a4l_check_cmddesc(a4l_cxt_t * cxt, a4l_cmd_t * desc) { - int ret = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - - __a4l_dbg(1, core_dbg, -a4l_check_cmddesc: minor=%d\n, a4l_get_minor(cxt)); + a4l_subd_t *subd; if (desc-idx_subd = dev-transfer.nb_subd) { __a4l_err(a4l_check_cmddesc: @@ -103,25 +100,23 @@ int a4l_check_cmddesc(a4l_cxt_t * cxt, a4l_cmd_t * desc) return -EINVAL; } - if ((dev-transfer.subds[desc-idx_subd]-flags A4L_SUBD_TYPES) == - A4L_SUBD_UNUSED) { + subd = dev-transfer.subds[desc-idx_subd]; + + if ((subd-flags A4L_SUBD_TYPES) == A4L_SUBD_UNUSED) { __a4l_err(a4l_check_cmddesc: subdevice type incoherent\n); return -EIO; } - if (!(dev-transfer.subds[desc-idx_subd]-flags A4L_SUBD_CMD)) { + if (!(subd-flags A4L_SUBD_CMD)) { __a4l_err(a4l_check_cmddesc: operation not supported, synchronous only subdevice\n); return -EIO; } - if (test_bit(A4L_TSF_BUSY, (dev-transfer.status[desc-idx_subd]))) - return -EBUSY; - - if (ret != 0) { + if (test_bit(A4L_SUBD_BUSY, subd-status)) { __a4l_err(a4l_check_cmddesc: subdevice busy\n); - return ret; + return -EBUSY; } return a4l_check_chanlist(dev-transfer.subds[desc-idx_subd], @@ -299,17 +294,13 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) { int ret = 0, simul_flag = 0; a4l_cmd_t *cmd_desc = NULL; - a4l_subd_t *subd; a4l_dev_t *dev = a4l_get_dev(cxt); - - __a4l_dbg(1, core_dbg, - a4l_ioctl_cmd: minor=%d\n, a4l_get_minor(cxt)); + a4l_subd_t *subd; /* The command launching cannot be done in real-time because of some possible buffer allocations in the drivers */ - if (rtdm_in_rt_context()) { + if (rtdm_in_rt_context()) return -ENOSYS; - } /* Basically check the device */ if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { @@ -373,13 +364,13 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) /* Eventually launches the command */ ret = subd-do_cmd(subd, cmd_desc); - + if (ret != 0) { - a4l_cancel_transfer(cxt, cmd_desc-idx_subd); + a4l_cancel_buffer(cxt); goto out_ioctl_cmd; } - out_ioctl_cmd: +out_ioctl_cmd: if (ret != 0 || simul_flag == 1) { a4l_free_cmddesc(cmd_desc); rtdm_free(cmd_desc); diff --git a/ksrc/drivers/analogy/instruction.c b/ksrc/drivers/analogy/instruction.c index 941fa69..413c0d2 100644 --- a/ksrc/drivers/analogy/instruction.c +++ b/ksrc/drivers/analogy/instruction.c @@ -281,7 +281,7 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc) out_do_insn: /* Releases the subdevice from its reserved state */ - a4l_cancel_transfer(cxt, dsc-idx_subd); + a4l_release_subd(subd); return ret; } diff --git a/ksrc/drivers/analogy/subdevice.c b/ksrc/drivers/analogy/subdevice.c index 1278081..506b742 100644 --- a/ksrc/drivers/analogy/subdevice.c +++ b/ksrc/drivers/analogy/subdevice.c @@ -180,6 +180,21 @@ a4l_subd_t *a4l_get_subd(a4l_dev_t *dev, int idx) return subd; } +int
[Xenomai-git] Alexis Berlemont : analogy: use rtdm_context_to_private (broken)
Module: xenomai-abe Branch: analogy Commit: a473d17258d0d1c7b1a2da8552248c8e2114f21d URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=a473d17258d0d1c7b1a2da8552248c8e2114f21d Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon May 24 23:35:47 2010 +0200 analogy: use rtdm_context_to_private (broken) --- ksrc/drivers/analogy/rtdm_interface.c | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ksrc/drivers/analogy/rtdm_interface.c b/ksrc/drivers/analogy/rtdm_interface.c index d37ce4c..6525425 100644 --- a/ksrc/drivers/analogy/rtdm_interface.c +++ b/ksrc/drivers/analogy/rtdm_interface.c @@ -124,11 +124,11 @@ void a4l_cleanup_proc(void) int a4l_open(struct rtdm_dev_context *context, rtdm_user_info_t * user_info, int flags) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Get a pointer on the selected device (thanks to minor index) */ - a4l_set_dev(context); + a4l_set_dev(cxt); /* Initialize the buffer structure */ a4l_init_buffer(cxt-buffer); @@ -146,7 +146,7 @@ int a4l_open(struct rtdm_dev_context *context, int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) { int err; - a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Cancel the maybe occuring asynchronous transfer */ err = a4l_cancel_buffer(cxt-buffer); @@ -164,7 +164,7 @@ int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) ssize_t a4l_read(struct rtdm_dev_context * context, rtdm_user_info_t * user_info, void *buf, size_t nbytes) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Jump into the RT domain if possible */ if (!rtdm_in_rt_context() rtdm_rt_capable(user_info)) @@ -181,7 +181,7 @@ ssize_t a4l_read(struct rtdm_dev_context * context, ssize_t a4l_write(struct rtdm_dev_context * context, rtdm_user_info_t *user_info, const void *buf, size_t nbytes) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Jump into the RT domain if possible */ if (!rtdm_in_rt_context() rtdm_rt_capable(user_info)) @@ -198,7 +198,7 @@ ssize_t a4l_write(struct rtdm_dev_context * context, int a4l_ioctl(struct rtdm_dev_context *context, rtdm_user_info_t *user_info, unsigned int request, void *arg) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); cxt-user_info = user_info; @@ -209,7 +209,7 @@ int a4l_rt_select(struct rtdm_dev_context *context, rtdm_selector_t *selector, enum rtdm_selecttype type, unsigned fd_index) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context-dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); return a4l_select(cxt, selector, type, fd_index); } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: remove useless functions in the subdevice part
Module: xenomai-abe Branch: analogy Commit: fd88364906c844562f60f7859eb6910b6199c322 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=fd88364906c844562f60f7859eb6910b6199c322 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Fri Jun 4 00:06:49 2010 +0200 analogy: remove useless functions in the subdevice part --- ksrc/drivers/analogy/subdevice.c | 15 --- 1 files changed, 0 insertions(+), 15 deletions(-) diff --git a/ksrc/drivers/analogy/subdevice.c b/ksrc/drivers/analogy/subdevice.c index 506b742..1278081 100644 --- a/ksrc/drivers/analogy/subdevice.c +++ b/ksrc/drivers/analogy/subdevice.c @@ -180,21 +180,6 @@ a4l_subd_t *a4l_get_subd(a4l_dev_t *dev, int idx) return subd; } -int a4l_reserve_subd(a4l_subd_t *subd) -{ -if (test_and_set_bit(A4L_SUBD_BUSY, subd-status)) { -__a4l_err(a4l_reserve_subd: subdevice currently busy\n); -return -EBUSY; -} - -return 0; -} - -void a4l_release_subd(a4l_subd_t *subd) -{ - clear_bit(A4L_SUBD_BUSY, subd-status)); -} - /* --- IOCTL / FOPS functions --- */ int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg) ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: minor fix in the subdevice structure declaration
Module: xenomai-abe Branch: analogy Commit: 01ba3e34020e052f37f92bab912385aba635a386 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=01ba3e34020e052f37f92bab912385aba635a386 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Fri Jun 4 00:04:41 2010 +0200 analogy: minor fix in the subdevice structure declaration --- include/analogy/buffer.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index cf82811..4846a4e 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -56,7 +56,7 @@ struct a4l_subdevice; struct a4l_buffer { /* Added by the structure update */ - a4l_subd_t *subd; + struct a4l_subdevice *subd; /* Buffer's first virtual page pointer */ void *buf; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix the declaration of the structure a4l_context (broken)
Module: xenomai-abe Branch: analogy Commit: d8ff2633bcf38114d610cb89371a0357f1cb4534 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=d8ff2633bcf38114d610cb89371a0357f1cb4534 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun Jun 6 16:21:44 2010 +0200 analogy: fix the declaration of the structure a4l_context (broken) In the structure a4l_context, replace the field buffer by a pointer to the structure a4l_buffer (a4l_buf_t - a4l_buf_t *). That fixes a bug in the headers dependencies. --- include/analogy/context.h |3 ++- ksrc/drivers/analogy/buffer.c | 12 ++-- ksrc/drivers/analogy/rtdm_interface.c | 14 ++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/analogy/context.h b/include/analogy/context.h index 2442b6c..3e61697 100644 --- a/include/analogy/context.h +++ b/include/analogy/context.h @@ -42,8 +42,9 @@ struct a4l_device_context { /* The buffer structure contains everything to transfer data from asynchronous acquisition operations on a specific subdevice */ - struct buffer buffer; + struct a4l_buffer *buffer; }; +typedef struct a4l_device_context a4l_cxt_t; static inline int a4l_get_minor(a4l_cxt_t *cxt) { diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index d3db892..1b413cc 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -493,10 +493,10 @@ int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) subd = dev-transfer.subds[idx_subd]; - if (subd != cxt-buffer.subd) { + if (subd != cxt-buffer-subd) { __a4l_err(a4l_ioctl_cancel: current context works on another subdevice - (%d!=%d)\n, cxt-buffer.subd-idx, subd-idx); + (%d!=%d)\n, cxt-buffer-subd-idx, subd-idx); return -EINVAL; } @@ -658,7 +658,7 @@ a4l_ioctl_bufinfo_out: ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) { a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = cxt-buffer; + a4l_buf_t *buf = cxt-buffer; a4l_buf_t *subd = buf-subd; ssize_t count = 0; @@ -758,7 +758,7 @@ ssize_t a4l_write(a4l_cxt_t *cxt, const void *bufdata, size_t nbytes) { a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = cxt-buffer; + a4l_buf_t *buf = cxt-buffer; a4l_subd_t *subd = buf-subd; ssize_t count = 0; @@ -849,7 +849,7 @@ int a4l_select(a4l_cxt_t *cxt, enum rtdm_selecttype type, unsigned fd_index) { a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = cxt-buffer; + a4l_buf_t *buf = cxt-buffer; a4l_subd_t *subd = buf-subd; /* Basic checkings */ @@ -894,7 +894,7 @@ int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg) int ret = 0; unsigned long tmp_cnt = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = cxt-buffer; + a4l_buf_t *buf = cxt-buffer; a4l_buf_t *subd = buf-subd; a4l_poll_t poll; diff --git a/ksrc/drivers/analogy/rtdm_interface.c b/ksrc/drivers/analogy/rtdm_interface.c index 6525425..8cfdf04 100644 --- a/ksrc/drivers/analogy/rtdm_interface.c +++ b/ksrc/drivers/analogy/rtdm_interface.c @@ -131,14 +131,15 @@ int a4l_open(struct rtdm_dev_context *context, a4l_set_dev(cxt); /* Initialize the buffer structure */ - a4l_init_buffer(cxt-buffer); + cxt-buffer = rtdm_malloc(sizeof(a4l_buf_t)); + a4l_init_buffer(cxt-buffer); /* Allocate the asynchronous buffer NOTE: it should be interesting to allocate the buffer only on demand especially if the system is short of memory NOTE2: the default buffer size could be configured via kernel config*/ - a4l_alloc_buffer(cxt-buffer, A4L_DEFAULT_BFSIZE); + a4l_alloc_buffer(cxt-buffer, A4L_DEFAULT_BFSIZE); return 0; } @@ -149,15 +150,20 @@ int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Cancel the maybe occuring asynchronous transfer */ - err = a4l_cancel_buffer(cxt-buffer); + err = a4l_cancel_buffer(cxt-buffer); if (err 0) { __a4l_err(close: unable to stop the asynchronous transfer\n); return err; } /* Free the buffer which was linked with this context */ - err = a4l_free_buffer(cxt-buffer); + err = a4l_free_buffer(cxt-buffer); + if (err 0) + goto out; + rtdm_free(cxt-buffer); + +out: return err; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix compilation issues and review the mmap ioctl handler (broken)
Module: xenomai-abe Branch: analogy Commit: ffd039850b41cb751eb5c7212c81add2bfdd44da URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=ffd039850b41cb751eb5c7212c81add2bfdd44da Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Thu Jun 10 22:35:06 2010 +0200 analogy: fix compilation issues and review the mmap ioctl handler (broken) --- ksrc/drivers/analogy/buffer.c | 200 - 1 files changed, 119 insertions(+), 81 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 1b413cc..0826a93 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -121,7 +121,7 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) if (buf_desc-subd == NULL) { __a4l_err(a4l_setup_buffer: subdevice index out of range (%d)\n, cmd-idx_subd); - goto -EINVAL; + return -EINVAL; } /* Checks if the transfer system has to work in bulk mode */ @@ -155,7 +155,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) int err = 0; - if (!subd || !a4l_check_subd(subd)) + if (!subd || !a4l_subd_is_busy(subd)) return 0; /* If a cancel function is registered, call it @@ -164,12 +164,11 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) the cancel function can be used as as to (re)initialize some component) */ if (subd-cancel != NULL (err = subd-cancel(subd)) 0) { - __a4l_err(a4l_cancel: - subdevice %d cancel handler failed (err=%d)\n, - idx_subd, err); + __a4l_err(a4l_cancel: cancel handler failed (err=%d)\n, err); } a4l_release_subd(subd); + subd-buf = NULL; if (buf_desc-cur_cmd != NULL) { a4l_free_cmddesc(buf_desc-cur_cmd); @@ -208,7 +207,7 @@ int a4l_get_chan(a4l_subd_t *subd) /* Translation bits - bytes */ tmp_size /= 8; - tmp_count = dev-transfer.bufs[subd-idx]-mng_count % tmp_size; + tmp_count = subd-buf-mng_count % tmp_size; /* Translation bytes - bits */ tmp_count *= 8; @@ -231,116 +230,174 @@ int a4l_get_chan(a4l_subd_t *subd) int a4l_buf_prepare_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_abs_put(subd-buf, count); + return __pre_abs_put(buf, count); } int a4l_buf_commit_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __abs_put(subd-buf, count); + return __abs_put(buf, count); } int a4l_buf_prepare_put(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_put(subd-buf, count); + return __pre_put(buf, count); } int a4l_buf_commit_put(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __put(subd-buf, count); + return __put(buf, count); } int a4l_buf_put(a4l_subd_t *subd, void *bufdata, unsigned long count) { + a4l_buf_t *buf = subd-buf; int err; - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - if (__count_to_put(subd-buf) count) + if (__count_to_put(buf) count) return -EAGAIN; - err = __produce(NULL, subd-buf, bufdata, count); + err = __produce(NULL, buf, bufdata, count); if (err 0) return err; - err = __put(subd-buf, count); + err = __put(buf, count); return err; } int a4l_buf_prepare_absget(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_WRITE) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_output(subd)) return -EINVAL; -
[Xenomai-git] Alexis Berlemont : analogy: prettify some subdevice tests (broken)
Module: xenomai-abe Branch: analogy Commit: f26620cb08a9bf979bd3977988de5d2a7f7ff5ab URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=f26620cb08a9bf979bd3977988de5d2a7f7ff5ab Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Thu Jun 10 22:44:21 2010 +0200 analogy: prettify some subdevice tests (broken) --- include/analogy/subdevice.h | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 0337092..8649c8a 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -277,21 +277,19 @@ typedef struct a4l_rng_info_arg a4l_rnginfo_arg_t; #ifdef __KERNEL__ -/* --- Subdevice related functions --- */ +/* --- Subdevice related functions and macros --- */ + a4l_chan_t *a4l_get_chfeat(a4l_subd_t * sb, int idx); -a4l_rng_t *a4l_get_rngfeat(a4l_subd_t * sb, - int chidx, int rngidx); +a4l_rng_t *a4l_get_rngfeat(a4l_subd_t * sb, int chidx, int rngidx); int a4l_check_chanlist(a4l_subd_t * subd, unsigned char nb_chan, unsigned int *chans); -/* --- Upper layer functions --- */ - static inline int a4l_reserve_subd(a4l_subd_t *subd) { return test_and_set_bit(A4L_SUBD_BUSY, subd-status) ? -EBUSY : 0; } -#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY, (x)-status)) -#define a4l_subd_is_busy(x) test_bit(A4L_SUBD_BUSY, (x)-status)) +#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY, ((x)-status)) +#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY, ((x)-status))) #define a4l_subd_is_input(x) ((A4L_SUBD_MASK_READ (x)-flags) != 0) /* The following macro considers that a DIO subdevice is firstly an @@ -300,6 +298,8 @@ static inline int a4l_reserve_subd(a4l_subd_t *subd) ((A4L_SUBD_MASK_WRITE (x)-flags) != 0 || \ (A4L_SUBD_DIO (x)-flags) != 0) +/* --- Upper layer functions --- */ + a4l_subd_t * a4l_get_subd(struct a4l_device *dev, int idx); a4l_subd_t * a4l_alloc_subd(int sizeof_priv, void (*setup)(a4l_subd_t *)); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: cosmetic change (broken)
Module: xenomai-abe Branch: analogy Commit: 666d35de6b61c1ca969ec7118a48eeefc6378b58 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=666d35de6b61c1ca969ec7118a48eeefc6378b58 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Thu Jun 10 22:41:53 2010 +0200 analogy: cosmetic change (broken) --- include/analogy/device.h |4 ++-- ksrc/drivers/analogy/buffer.c | 14 +++--- ksrc/drivers/analogy/command.c |2 +- ksrc/drivers/analogy/device.c | 16 ksrc/drivers/analogy/instruction.c |4 ++-- .../analogy/national_instruments/mio_common.c |2 +- ksrc/drivers/analogy/subdevice.c | 10 +- ksrc/drivers/analogy/testing/loop.c|2 +- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/include/analogy/device.h b/include/analogy/device.h index 6930a38..fca40cc 100644 --- a/include/analogy/device.h +++ b/include/analogy/device.h @@ -33,7 +33,7 @@ #define A4L_NB_DEVICES 10 -#define A4L_DEV_ATTACHED 0 +#define A4L_DEV_ATTACHED_NR 0 struct a4l_device { @@ -81,7 +81,7 @@ typedef struct a4l_dev_info a4l_dvinfo_t; #ifdef __KERNEL__ /* --- Device related macro --- */ -#define a4l_check_dev(x) test_bit(A4L_DEV_ATTACHED, (x-flags)) +#define a4l_dev_is_attached(x) test_bit(A4L_DEV_ATTACHED_NR, (x-flags)) /* --- Devices tab related functions --- */ void a4l_init_devs(void); diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 0826a93..ac1abce 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -513,7 +513,7 @@ int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) a4l_subd_t *subd; /* Basically check the device */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, dev-flags)) { __a4l_err(a4l_ioctl_cancel: operation not supported on an unattached device\n); return -EINVAL; @@ -556,7 +556,7 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) } /* Basic checking */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, dev-flags)) { __a4l_err(a4l_ioctl_bufcfg: unattached device\n); return -EINVAL; } @@ -603,7 +603,7 @@ int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg) return -ENOSYS; /* Basic checking */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, dev-flags)) { __a4l_err(a4l_ioctl_bufinfo: unattached device\n); return -EINVAL; } @@ -703,7 +703,7 @@ ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) /* Basic checkings */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, dev-flags)) { __a4l_err(a4l_read: unattached device\n); return -EINVAL; } @@ -803,7 +803,7 @@ ssize_t a4l_write(a4l_cxt_t *cxt, /* Basic checkings */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, dev-flags)) { __a4l_err(a4l_write: unattached device\n); return -EINVAL; } @@ -893,7 +893,7 @@ int a4l_select(a4l_cxt_t *cxt, /* Basic checkings */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, dev-flags)) { __a4l_err(a4l_select: unattached device\n); return -EINVAL; } @@ -942,7 +942,7 @@ int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg) /* Basic checking */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, dev-flags)) { __a4l_err(a4l_poll: unattached device\n); return -EINVAL; } diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c index 94d6137..51aad35 100644 --- a/ksrc/drivers/analogy/command.c +++ b/ksrc/drivers/analogy/command.c @@ -303,7 +303,7 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) return -ENOSYS; /* Basically check the device */ - if (!test_bit(A4L_DEV_ATTACHED, dev-flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, dev-flags)) { __a4l_err(a4l_ioctl_cmd: cannot command an unattached device\n); return -EINVAL; diff --git a/ksrc/drivers/analogy/device.c b/ksrc/drivers/analogy/device.c index a2d23c8..99b9098 100644 --- a/ksrc/drivers/analogy/device.c +++ b/ksrc/drivers/analogy/device.c @@ -51,7 +51,7 @@ int a4l_check_cleanup_devs(void) int i, ret = 0; for (i = 0; i A4L_NB_DEVICES ret == 0; i++) - if (test_bit(A4L_DEV_ATTACHED, a4l_devs[i].flags)) + if
[Xenomai-git] Alexis Berlemont : analogy: fix the last compilation problems
Module: xenomai-abe Branch: analogy Commit: 647144ce585cd727ececd44700c96735540c727f URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=647144ce585cd727ececd44700c96735540c727f Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Fri Jun 11 00:01:01 2010 +0200 analogy: fix the last compilation problems --- include/analogy/buffer.h | 22 -- include/analogy/subdevice.h |6 +++--- ksrc/drivers/analogy/buffer.c | 25 - ksrc/drivers/analogy/rtdm_interface.c | 13 + ksrc/drivers/analogy/transfer.c |3 +-- 5 files changed, 33 insertions(+), 36 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 4bd5db0..148c07f 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -35,20 +35,23 @@ #include analogy/os_facilities.h #include analogy/context.h -/* Events bits */ +/* --- Events bits / flags --- */ + #define A4L_BUF_EOBUF_NR 0 -#define A4L_BUF_ERROR_NR 1 -#define A4L_BUF_EOA_NR 2 -/* Events flags */ #define A4L_BUF_EOBUF (1 A4L_BUF_EOBUF_NR) + +#define A4L_BUF_ERROR_NR 1 #define A4L_BUF_ERROR (1 A4L_BUF_ERROR_NR) + +#define A4L_BUF_EOA_NR 2 #define A4L_BUF_EOA (1 A4L_BUF_EOA_NR) -/* Status bits */ +/* --- Status bits / flags --- */ + #define A4L_BUF_BULK_NR 8 -#define A4L_BUF_MAP_NR 9 -/* Status flags */ #define A4L_BUF_BULK (1 A4L_BUF_BULK_NR) + +#define A4L_BUF_MAP_NR 9 #define A4L_BUF_MAP (1 A4L_BUF_MAP_NR) struct a4l_subdevice; @@ -391,9 +394,8 @@ int a4l_ioctl_mmap(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg); -ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes); -ssize_t a4l_write(a4l_cxt_t * cxt, - const void *bufdata, size_t nbytes); +ssize_t a4l_read_buffer(a4l_cxt_t * cxt, void *bufdata, size_t nbytes); +ssize_t a4l_write_buffer(a4l_cxt_t * cxt, const void *bufdata, size_t nbytes); int a4l_select(a4l_cxt_t *cxt, rtdm_selector_t *selector, enum rtdm_selecttype type, unsigned fd_index); diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 8649c8a..4223748 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -286,10 +286,10 @@ int a4l_check_chanlist(a4l_subd_t * subd, static inline int a4l_reserve_subd(a4l_subd_t *subd) { -return test_and_set_bit(A4L_SUBD_BUSY, subd-status) ? -EBUSY : 0; +return test_and_set_bit(A4L_SUBD_BUSY_NR, subd-status) ? -EBUSY : 0; } -#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY, ((x)-status)) -#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY, ((x)-status))) +#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY_NR, ((x)-flags)) +#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY_NR, ((x)-flags))) #define a4l_subd_is_input(x) ((A4L_SUBD_MASK_READ (x)-flags) != 0) /* The following macro considers that a DIO subdevice is firstly an diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index ac1abce..a72b4ad 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -436,13 +436,13 @@ unsigned long a4l_buf_count(a4l_subd_t *subd) void a4l_map(struct vm_area_struct *area) { unsigned long *status = (unsigned long *)area-vm_private_data; - set_bit(A4L_TSF_MMAP, status); + set_bit(A4L_BUF_MAP_NR, status); } void a4l_unmap(struct vm_area_struct *area) { unsigned long *status = (unsigned long *)area-vm_private_data; - clear_bit(A4L_TSF_MMAP, status); + clear_bit(A4L_BUF_MAP_NR, status); } static struct vm_operations_struct a4l_vm_ops = { @@ -454,6 +454,7 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) { a4l_mmap_t map_cfg; a4l_dev_t *dev; + a4l_buf_t *buf; int ret; /* The mmap operation cannot be performed in a @@ -463,6 +464,7 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) } dev = a4l_get_dev(cxt); + buf = cxt-buffer; /* Basic checkings */ @@ -487,12 +489,10 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) /* All the magic is here */ ret = rtdm_mmap_to_user(cxt-user_info, - dev-transfer.bufs[map_cfg.idx_subd]-buf, + buf-buf, map_cfg.size, PROT_READ | PROT_WRITE, - map_cfg.ptr, - a4l_vm_ops, - (dev-transfer.status[map_cfg.idx_subd])); + map_cfg.ptr, a4l_vm_ops, buf-flags); if (ret 0) { __a4l_err(a4l_ioctl_mmap: internal error, @@ -545,7 +545,7 @@ int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) { a4l_dev_t
[Xenomai-git] Alexis Berlemont : analogy: fix the subdevice status management
Module: xenomai-abe Branch: analogy Commit: 79c7f178ad4a525d6407d7d8ea24d13d6c21e309 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=79c7f178ad4a525d6407d7d8ea24d13d6c21e309 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sun Jun 13 00:39:13 2010 +0200 analogy: fix the subdevice status management --- include/analogy/subdevice.h |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 4223748..5be036b 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -288,8 +288,8 @@ static inline int a4l_reserve_subd(a4l_subd_t *subd) { return test_and_set_bit(A4L_SUBD_BUSY_NR, subd-status) ? -EBUSY : 0; } -#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY_NR, ((x)-flags)) -#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY_NR, ((x)-flags))) +#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY_NR, ((x)-status)) +#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY_NR, ((x)-status))) #define a4l_subd_is_input(x) ((A4L_SUBD_MASK_READ (x)-flags) != 0) /* The following macro considers that a DIO subdevice is firstly an ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [loop] add a debug trace when trigger is called
Module: xenomai-abe Branch: analogy Commit: 34ce27f04b00124b1a0471904f750093a8b60ce9 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=34ce27f04b00124b1a0471904f750093a8b60ce9 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Wed Jun 16 00:34:20 2010 +0200 analogy: [loop] add a debug trace when trigger is called --- ksrc/drivers/analogy/testing/loop.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/ksrc/drivers/analogy/testing/loop.c b/ksrc/drivers/analogy/testing/loop.c index f73ad09..72748d8 100644 --- a/ksrc/drivers/analogy/testing/loop.c +++ b/ksrc/drivers/analogy/testing/loop.c @@ -124,6 +124,9 @@ int loop_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) int loop_trigger(a4l_subd_t *subd, lsampl_t trignum) { lpprv_t *priv = (lpprv_t *)subd-dev-priv; + + a4l_info(subd-dev, loop_trigger: (subd=%d)\n, subd-idx); + priv-loop_running = 1; return 0; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix test of subdevice status in a4l_write
Module: xenomai-abe Branch: analogy Commit: 608393ae379b0243ddc85410eccd9d395ef58d5a URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=608393ae379b0243ddc85410eccd9d395ef58d5a Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Wed Jun 16 00:35:03 2010 +0200 analogy: fix test of subdevice status in a4l_write --- ksrc/drivers/analogy/buffer.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 04922be..12b8b9b 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -828,7 +828,7 @@ ssize_t a4l_write_buffer(a4l_cxt_t *cxt, const void *bufdata, size_t nbytes) return -EINVAL; } - if (!subd || !test_bit(A4L_SUBD_BUSY, subd-status)) { + if (!subd || !a4l_subd_is_busy(subd)) { __a4l_err(a4l_write: idle subdevice on this context\n); return -ENOENT; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [ni_pcimio] really minor changes
Module: xenomai-abe Branch: analogy Commit: 79762b534fb0eefe5084b73ba835725b5eedaadb URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=79762b534fb0eefe5084b73ba835725b5eedaadb Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Mon Jun 21 00:36:44 2010 +0200 analogy: [ni_pcimio] really minor changes --- .../analogy/national_instruments/mio_common.c |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/mio_common.c b/ksrc/drivers/analogy/national_instruments/mio_common.c index ead64b8..de1c570 100644 --- a/ksrc/drivers/analogy/national_instruments/mio_common.c +++ b/ksrc/drivers/analogy/national_instruments/mio_common.c @@ -3413,6 +3413,7 @@ int ni_cdio_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) if (cmd-scan_begin_arg CR_INVERT) cdo_mode_bits |= CDO_Polarity_Bit; ni_writel(cdo_mode_bits, M_Offset_CDO_Mode); + if (devpriv-io_bits) { ni_writel(devpriv-dio_state, M_Offset_CDO_FIFO_Data); ni_writel(CDO_SW_Update_Bit, M_Offset_CDIO_Command); @@ -3423,10 +3424,10 @@ int ni_cdio_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) output command with no lines configured as outputs); return -EIO; } + retval = ni_request_cdo_mite_channel(dev); - if (retval 0) { + if (retval 0) return retval; - } return 0; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [fake - loop] remove volatile keywords
Module: xenomai-abe Branch: analogy Commit: a0a386a818b4ba935314d9188b9b2cb9bd264310 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=a0a386a818b4ba935314d9188b9b2cb9bd264310 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sat Jun 19 00:33:01 2010 +0200 analogy: [fake - loop] remove volatile keywords Remove the volatile keyword in front of concurrently accessed variables and use, instead, RTDM_EXECUTE_ATOMICALLY. Maybe it is a bit nicer even for some testing drivers. --- ksrc/drivers/analogy/testing/fake.c | 12 ksrc/drivers/analogy/testing/loop.c | 16 +++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/ksrc/drivers/analogy/testing/fake.c b/ksrc/drivers/analogy/testing/fake.c index 27d6d88..878a28f 100644 --- a/ksrc/drivers/analogy/testing/fake.c +++ b/ksrc/drivers/analogy/testing/fake.c @@ -29,7 +29,7 @@ struct ai_priv { /* Misc fields */ unsigned long amplitude_div; unsigned long quanta_cnt; - volatile int timer_running; + int timer_running; }; @@ -115,7 +115,11 @@ static void ai_task_proc(void *arg) uint64_t now_ns, elapsed_ns=0; while(1) { - if(priv-timer_running != 0) + int running; + + RTDM_EXECUTE_ATOMICALLY(running = priv-timer_running); + + if(running) { int i = 0; @@ -168,7 +172,7 @@ static int ai_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) priv-current_ns = ((unsigned long)priv-last_ns); priv-reminder_ns = 0; - priv-timer_running = 1; + RTDM_EXECUTE_ATOMICALLY(priv-timer_running = 1); return 0; @@ -193,7 +197,7 @@ static int ai_cancel(a4l_subd_t *subd) { struct ai_priv *priv = (struct ai_priv *)subd-priv; - priv-timer_running = 0; + RTDM_EXECUTE_ATOMICALLY(priv-timer_running = 0); return 0; } diff --git a/ksrc/drivers/analogy/testing/loop.c b/ksrc/drivers/analogy/testing/loop.c index 72748d8..f9c4bf8 100644 --- a/ksrc/drivers/analogy/testing/loop.c +++ b/ksrc/drivers/analogy/testing/loop.c @@ -44,7 +44,7 @@ struct loop_priv { a4l_task_t loop_task; /* Misc fields */ - volatile int loop_running:1; + int loop_running; uint16_t loop_insn_value; }; typedef struct loop_priv lpprv_t; @@ -78,8 +78,12 @@ static void loop_task_proc(void *arg) } while (1) { + + int running; + + RTDM_EXECUTE_ATOMICALLY(running = priv-loop_running); - if (priv-loop_running) { + if (running) { uint16_t value; int ret=0; @@ -87,7 +91,6 @@ static void loop_task_proc(void *arg) ret = a4l_buf_get(output_subd, value, sizeof(uint16_t)); - if (ret == 0) { a4l_info(dev, @@ -116,6 +119,7 @@ static void loop_task_proc(void *arg) int loop_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) { a4l_info(subd-dev, loop_cmd: (subd=%d)\n, subd-idx); + return 0; } @@ -127,7 +131,8 @@ int loop_trigger(a4l_subd_t *subd, lsampl_t trignum) a4l_info(subd-dev, loop_trigger: (subd=%d)\n, subd-idx); - priv-loop_running = 1; + RTDM_EXECUTE_ATOMICALLY(priv-loop_running = 1); + return 0; } @@ -138,7 +143,7 @@ int loop_cancel(a4l_subd_t *subd) a4l_info(subd-dev, loop_cancel: (subd=%d)\n, subd-idx); - priv-loop_running = 0; + RTDM_EXECUTE_ATOMICALLY(priv-loop_running = 0); return 0; } @@ -201,6 +206,7 @@ void setup_output_subd(a4l_subd_t *subd) subd-rng_desc = loop_rngdesc; subd-chan_desc = loop_chandesc; subd-do_cmd = loop_cmd; + subd-cancel = loop_cancel; subd-trigger = loop_trigger; subd-cmd_mask = loop_cmd_mask; subd-insn_read = loop_insn_read; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: remove calls of a4l_release/ reserve_subd in the core
Module: xenomai-abe Branch: analogy Commit: 739a91a75b6e5f52e26bb0d4db5ead0265f41647 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=739a91a75b6e5f52e26bb0d4db5ead0265f41647 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Wed Jun 23 21:11:31 2010 +0200 analogy: remove calls of a4l_release/reserve_subd in the core --- include/analogy/subdevice.h|7 --- ksrc/drivers/analogy/buffer.c |4 ++-- ksrc/drivers/analogy/instruction.c |7 --- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 5be036b..a81fcb9 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -284,13 +284,6 @@ a4l_rng_t *a4l_get_rngfeat(a4l_subd_t * sb, int chidx, int rngidx); int a4l_check_chanlist(a4l_subd_t * subd, unsigned char nb_chan, unsigned int *chans); -static inline int a4l_reserve_subd(a4l_subd_t *subd) -{ -return test_and_set_bit(A4L_SUBD_BUSY_NR, subd-status) ? -EBUSY : 0; -} -#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY_NR, ((x)-status)) -#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY_NR, ((x)-status))) - #define a4l_subd_is_input(x) ((A4L_SUBD_MASK_READ (x)-flags) != 0) /* The following macro considers that a DIO subdevice is firstly an output subdevice */ diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index b8b01d3..f9bcad7 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -136,7 +136,7 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) return -EINVAL; } - if (a4l_reserve_subd(buf_desc-subd) 0) { + if (test_and_set_bit(A4L_SUBD_BUSY_NR, buf_desc-subd-status)) { __a4l_err(a4l_setup_buffer: subdevice %d already busy\n, cmd-idx_subd); return -EBUSY; @@ -196,7 +196,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) a4l_reinit_buffer(buf_desc); - a4l_release_subd(subd); + clear_bit(A4L_SUBD_BUSY_NR, subd-status); subd-buf = NULL; return err; diff --git a/ksrc/drivers/analogy/instruction.c b/ksrc/drivers/analogy/instruction.c index 644c40c..1050753 100644 --- a/ksrc/drivers/analogy/instruction.c +++ b/ksrc/drivers/analogy/instruction.c @@ -266,9 +266,10 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc) /* Prevents the subdevice from being used during the following operations */ - ret = a4l_reserve_subd(subd); - if (ret 0) + if (test_and_set_bit(A4L_SUBD_BUSY_NR, subd-status)) { + ret = -EBUSY; goto out_do_insn; + } /* Let's the driver-specific code perform the instruction */ ret = hdlr(subd, dsc); @@ -281,7 +282,7 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc) out_do_insn: /* Releases the subdevice from its reserved state */ - a4l_release_subd(subd); + clear_bit(A4L_SUBD_BUSY_NR, subd-status); return ret; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: remove some tests which become with the buffer overhaul
Module: xenomai-abe Branch: analogy Commit: 98d96cef7457a29333ea8f022e34587fc002 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=98d96cef7457a29333ea8f022e34587fc002 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Fri Jun 25 00:14:37 2010 +0200 analogy: remove some tests which become with the buffer overhaul --- include/analogy/device.h |3 --- .../analogy/national_instruments/mio_common.c |3 --- ksrc/drivers/analogy/testing/loop.c|3 --- 3 files changed, 0 insertions(+), 9 deletions(-) diff --git a/include/analogy/device.h b/include/analogy/device.h index fca40cc..76aca28 100644 --- a/include/analogy/device.h +++ b/include/analogy/device.h @@ -80,9 +80,6 @@ typedef struct a4l_dev_info a4l_dvinfo_t; #ifdef __KERNEL__ -/* --- Device related macro --- */ -#define a4l_dev_is_attached(x) test_bit(A4L_DEV_ATTACHED_NR, (x-flags)) - /* --- Devices tab related functions --- */ void a4l_init_devs(void); int a4l_check_cleanup_devs(void); diff --git a/ksrc/drivers/analogy/national_instruments/mio_common.c b/ksrc/drivers/analogy/national_instruments/mio_common.c index 55e0bc2..67c278e 100644 --- a/ksrc/drivers/analogy/national_instruments/mio_common.c +++ b/ksrc/drivers/analogy/national_instruments/mio_common.c @@ -1027,9 +1027,6 @@ int ni_E_interrupt(unsigned int irq, void *d) unsigned long flags; struct mite_struct *mite = devpriv-mite; - if(!a4l_dev_is_attached(dev)) - return IRQ_NONE; - /* Make sure dev-attached is checked before handler does anything else. */ smp_mb(); diff --git a/ksrc/drivers/analogy/testing/loop.c b/ksrc/drivers/analogy/testing/loop.c index f9c4bf8..e304ebc 100644 --- a/ksrc/drivers/analogy/testing/loop.c +++ b/ksrc/drivers/analogy/testing/loop.c @@ -65,9 +65,6 @@ static void loop_task_proc(void *arg) a4l_dev_t *dev = (a4l_dev_t*)arg; a4l_subd_t *input_subd, *output_subd; lpprv_t *priv = (lpprv_t *)dev-priv; - - while (!a4l_dev_is_attached(dev)) - a4l_task_sleep(LOOP_TASK_PERIOD); input_subd = a4l_get_subd(dev, LOOP_INPUT_SUBD); output_subd = a4l_get_subd(dev, LOOP_OUTPUT_SUBD); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git