Re: [PATCH v3] staging: writeboost: Add dm-writeboost
Hi, Very very sad to not receive any comments from dm maintainers in the past 2 mouths. I implemented read-caching for v3 because they like to see this feature in but no comment... I still believe they reevaluate dm-writeboost because I don't think this driver isn't bad as they claim. They really dislike the 4KB splitting and that's the biggest reason dm-writeboost isn't appreciated. Now let me argue about this. Log-structured block-level caching isn't a fully brand new idea of my own although the implementation is so. Back to 1992, the concept of log-structured filesystem was invented. 3 years later, the concept of log-structured block-level caching appeared inspired by the concept of lfs. The paper shows the I/O is split into 4KB chunks and then managed as cache blocks. http://www.ele.uri.edu/research/hpcl/DCD/DCD.html Since then, no research follows DCD but the idea of log-strucutured block-level caching revives as SSD emerges. In 2010, MSR's Griffin also does 4KB split. Griffin uses HDD as the cache device to extend the lifetime of the backing device which is SSD. http://research.microsoft.com/apps/pubs/default.aspx?id=115352 (So, dm-writeboost can be applied in this way) In 2012, NetApp's Mercury is a read caching for their storage system that's quite log-structured to be durable and exploits the full throughput. It managed in 4KB cache size too. http://storageconference.us/2012/Papers/04.Flash.1.Mercury.pdf They all splits I/O into 4KB chunks (and buffer write to cache device). The history says the decision isn't wrong for log-structured block-level caching. I decided this principal design decision based on this research papers' consensus. Do you still say that I should change this design? Joe started nacking after observing a low-throughput of large-sized read in virtual environment. I reproduced the case in my KVM environment and realized that the split chunks aren't merged in host machine. KVM seems to disable its I/O scheduler and delegates merging to the host. When I run the same experiment _without_ virtual machine, the split chunks are fully merged in the I/O scheduler. So, I can conclude this is due to KVM interference and dm-writeboost isn't suitable for at least usage on VM. This isn't a big reason to nack because dm-writeboost is usually used in host machine. I will wait for ack from dm maintainers. - Akira On Sat, 17 Jan 2015 16:09:52 -0800 Greg KH gre...@linuxfoundation.org wrote: On Thu, Jan 01, 2015 at 05:44:39PM +0900, Akira Hayakawa wrote: This patch adds dm-writeboost to staging tree. dm-writeboost is a log-structured SSD-caching driver. It caches data in log-structured way on the cache device so that the performance is maximized. The merit of putting this driver in staging tree is to make it possible to get more feedback from users and polish the codes. v2-v3 - rebased onto 3.19-rc2 - Add read-caching support (disabled by default) Several tests are pushed to dmts. - An critical bug fix flush_proc shouldn't free the work_struct it's running on. I found this bug while I am testing read-caching. I am not sure why i didn't exhibit before but it's truly a bug. - Fully revised the README. Now that we have read-caching support, the old README was completely obsolete. - Update TODO Implementing read-caching is done. - bump up the copyright year to 2015 - fix up comments Signed-off-by: Akira Hayakawa ruby.w...@gmail.com I need an ack from a dm developer before I can take this. thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Drivers: hv: hv_balloon: keep locks balanced on add_memory() failure
When add_memory() fails the following BUG is observed: [ 743.646107] hv_balloon: hot_add memory failed error is -17 [ 743.679973] [ 743.680930] = [ 743.680930] [ BUG: bad unlock balance detected! ] [ 743.680930] 3.19.0-rc5_bug1131426+ #552 Not tainted [ 743.680930] - [ 743.680930] kworker/0:2/255 is trying to release lock (dm_device.ha_region_mutex) at: [ 743.680930] [81aae5fe] mutex_unlock+0xe/0x10 [ 743.680930] but there are no more locks to release! This happens as we don't acquire ha_region_mutex and hot_add_req() expects us to as it does unconditional mutex_unlock(). Acquire the lock on the error path. Signed-off-by: Vitaly Kuznetsov vkuzn...@redhat.com --- This patch is dependent on the previously posted 'Drivers: hv: hv_balloon: eliminate the trylock path in acquire/release_region_mutex'. --- drivers/hv/hv_balloon.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index 1283035..771bf84 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -654,6 +654,7 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, } has-ha_end_pfn -= HA_CHUNK; has-covered_end_pfn -= processed_pfn; + mutex_lock(dm_device.ha_region_mutex); break; } -- 1.9.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: android: ion: fix some format strings
C99 says that a precision which is simply '.' with no following digits or * should be interpreted as 0, which means that these format strings actually mean 'print 16 spaces'. However, the kernel's printf implementation treats this case as if the precision was omitted. Don't rely on that quirk. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/staging/android/ion/ion.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index b8f1c491553e..65361ca33fc9 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -1395,7 +1395,7 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused) size_t total_size = 0; size_t total_orphaned_size = 0; - seq_printf(s, %16.s %16.s %16.s\n, client, pid, size); + seq_printf(s, %16s %16s %16s\n, client, pid, size); seq_puts(s, \n); for (n = rb_first(dev-clients); n; n = rb_next(n)) { @@ -1409,10 +1409,10 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused) char task_comm[TASK_COMM_LEN]; get_task_comm(task_comm, client-task); - seq_printf(s, %16.s %16u %16zu\n, task_comm, + seq_printf(s, %16s %16u %16zu\n, task_comm, client-pid, size); } else { - seq_printf(s, %16.s %16u %16zu\n, client-name, + seq_printf(s, %16s %16u %16zu\n, client-name, client-pid, size); } } @@ -1426,7 +1426,7 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused) continue; total_size += buffer-size; if (!buffer-handle_count) { - seq_printf(s, %16.s %16u %16zu %d %d\n, + seq_printf(s, %16s %16u %16zu %d %d\n, buffer-task_comm, buffer-pid, buffer-size, buffer-kmap_cnt, atomic_read(buffer-ref.refcount)); @@ -1435,11 +1435,11 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused) } mutex_unlock(dev-buffer_lock); seq_puts(s, \n); - seq_printf(s, %16.s %16zu\n, total orphaned, + seq_printf(s, %16s %16zu\n, total orphaned, total_orphaned_size); - seq_printf(s, %16.s %16zu\n, total , total_size); + seq_printf(s, %16s %16zu\n, total , total_size); if (heap-flags ION_HEAP_FLAG_DEFER_FREE) - seq_printf(s, %16.s %16zu\n, deferred free, + seq_printf(s, %16s %16zu\n, deferred free, heap-free_list_size); seq_puts(s, \n); -- 2.1.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: emxx_udc: Replace GFP_KERNEL with GFP_ATOMIC
To avoid deadlock, do not call blocking functions with spinlocks held. Replace GFP_KERNEL with GFP_ATOMIC, as the latter will fail if the pile doesn't have enough free pages but will not sleep and hence deadlock can be avoided. Found by Coccinelle. Signed-off-by: Tapasweni Pathak tapaswenipat...@gmail.com --- Is there any other way this can be fixed as it is better to avoid GFP_ATOMIC? drivers/staging/emxx_udc/emxx_udc.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 4be646c..6c1de27 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -2794,7 +2794,7 @@ static int nbu2ss_ep_queue( if (ep-virt_buf == NULL) ep-virt_buf = (u8 *)dma_alloc_coherent( NULL, PAGE_SIZE, - ep-phys_buf, GFP_KERNEL | GFP_DMA); + ep-phys_buf, GFP_ATOMIC | GFP_DMA); if (ep-epnum 0) { if (ep-direct == USB_DIR_IN) memcpy(ep-virt_buf, req-req.buf, -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC PATCH 24/36] staging: comedi: cb_pcidas64: remove unnecessary include
The hardware supported by this driver does not have an 8254 timer. Remove the unnecessary include of 8253.h. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/drivers/cb_pcidas64.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 9836c87..551e9d9 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -87,7 +87,6 @@ TODO: #include ../comedidev.h -#include 8253.h #include 8255.h #include plx9080.h #include comedi_fc.h -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC PATCH 14/36] staging: comedi: amplc_pci230: convert driver to use the comedi_8254 module
This driver uses an 8254 timer to generate the pacer clock used for analog input data conversion. Convert it to use the comedi_8254 module to provide support for the 8254 timer. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig| 1 + drivers/staging/comedi/drivers/amplc_pci230.c | 47 --- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 6d469e0..f63626f 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -816,6 +816,7 @@ config COMEDI_AMPLC_PCI224 config COMEDI_AMPLC_PCI230 tristate Amplicon PCI230 and PCI260 support + select COMEDI_8254 select COMEDI_8255 ---help--- Enable support for Amplicon PCI230 and PCI260 Multifunction I/O diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 49806a5..a977156 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -188,7 +188,7 @@ #include ../comedidev.h #include comedi_fc.h -#include 8253.h +#include comedi_8254.h #include 8255.h /* @@ -206,10 +206,6 @@ #define PCI230_PPI_X_C 0x02/* User PPI (82C55) port C */ #define PCI230_PPI_X_CMD 0x03/* User PPI (82C55) control word */ #define PCI230_Z2_CT_BASE 0x14/* 82C54 counter/timer base */ -#define PCI230_Z2_CT0 0x14/* 82C54 counter/timer 0 */ -#define PCI230_Z2_CT1 0x15/* 82C54 counter/timer 1 */ -#define PCI230_Z2_CT2 0x16/* 82C54 counter/timer 2 */ -#define PCI230_Z2_CTC 0x17/* 82C54 counter/timer control word */ #define PCI230_ZCLK_SCE0x1A/* Group Z Clock Configuration */ #define PCI230_ZGAT_SCE0x1D/* Group Z Gate Configuration */ #define PCI230_INT_SCE 0x1E/* Interrupt source mask (w) */ @@ -377,12 +373,6 @@ #define CLK_EXT7 /* external clock */ /* Macro to construct clock input configuration register value. */ #define CLK_CONFIG(chan, src) chan) 3) 3) | ((src) 7)) -/* Timebases in ns. */ -#define TIMEBASE_10MHZ 100 -#define TIMEBASE_1MHZ 1000 -#define TIMEBASE_100KHZ1 -#define TIMEBASE_10KHZ 10 -#define TIMEBASE_1KHZ 100 /* * Counter/timer gate input configuration sources. @@ -507,11 +497,11 @@ struct pci230_private { /* PCI230 clock source periods in ns */ static const unsigned int pci230_timebase[8] = { - [CLK_10MHZ] = TIMEBASE_10MHZ, - [CLK_1MHZ] = TIMEBASE_1MHZ, - [CLK_100KHZ] = TIMEBASE_100KHZ, - [CLK_10KHZ] = TIMEBASE_10KHZ, - [CLK_1KHZ] = TIMEBASE_1KHZ, + [CLK_10MHZ] = I8254_OSC_BASE_10MHZ, + [CLK_1MHZ] = I8254_OSC_BASE_1MHZ, + [CLK_100KHZ]= I8254_OSC_BASE_100KHZ, + [CLK_10KHZ] = I8254_OSC_BASE_10KHZ, + [CLK_1KHZ] = I8254_OSC_BASE_1KHZ, }; /* PCI230 analogue input range table */ @@ -695,7 +685,7 @@ static void pci230_ct_setup_ns_mode(struct comedi_device *dev, unsigned int ct, unsigned int count; /* Set mode. */ - i8254_set_mode(dev-iobase + PCI230_Z2_CT_BASE, 0, ct, mode); + comedi_8254_set_mode(dev-pacer, ct, mode); /* Determine clock source and count. */ clk_src = pci230_choose_clk_count(ns, count, flags); /* Program clock source. */ @@ -704,13 +694,13 @@ static void pci230_ct_setup_ns_mode(struct comedi_device *dev, unsigned int ct, if (count = 65536) count = 0; - i8254_write(dev-iobase + PCI230_Z2_CT_BASE, 0, ct, count); + comedi_8254_write(dev-pacer, ct, count); } static void pci230_cancel_ct(struct comedi_device *dev, unsigned int ct) { - i8254_set_mode(dev-iobase + PCI230_Z2_CT_BASE, 0, ct, I8254_MODE1); /* Counter ct, 8254 mode 1, initial count not written. */ + comedi_8254_set_mode(dev-pacer, ct, I8254_MODE1); } static int pci230_ai_eoc(struct comedi_device *dev, @@ -760,7 +750,7 @@ static int pci230_ai_insn_read(struct comedi_device *dev, */ adccon = PCI230_ADC_TRIG_Z2CT2 | PCI230_ADC_FIFO_EN; /* Set Z2-CT2 output low to avoid any false triggers. */ - i8254_set_mode(dev-iobase + PCI230_Z2_CT_BASE, 0, 2, I8254_MODE0); + comedi_8254_set_mode(dev-pacer, 2, I8254_MODE0); devpriv-ai_bipolar = comedi_range_is_bipolar(s, range); if (aref == AREF_DIFF) { /* Differential. */ @@ -811,10 +801,8 @@ static int pci230_ai_insn_read(struct comedi_device *dev, * Trigger conversion by toggling Z2-CT2 output * (finish with output high). */ - i8254_set_mode(dev-iobase + PCI230_Z2_CT_BASE,
[RFC PATCH 13/36] staging: comedi: adv_pci1710: convert driver to use the comedi_8254 module
This driver uses an 8254 timer to generate the pacer clock used for analog input data acquisition. It also provides a comedi_subdevice to allow the user to use channel 0 of the 8254 timer. Currently the subdevice support does not work correctly due to and (*insn_config) that does not follow the comedi API. Convert it to use the comedi_8254 module to provide support for the 8254 timer and proper support for the subdevice. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/adv_pci1710.c | 206 --- 2 files changed, 61 insertions(+), 146 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 85c5c87..6d469e0 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -739,6 +739,7 @@ config COMEDI_ADL_PCI9118 config COMEDI_ADV_PCI1710 tristate Advantech PCI-171x, PCI-1720 and PCI-1731 support + select COMEDI_8254 ---help--- Enable support for Advantech PCI-1710, PCI-1710HG, PCI-1711, PCI-1713, PCI-1720 and PCI-1731 diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 9800c01..9ca9803 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -48,7 +48,7 @@ Configuration options: #include ../comedidev.h #include comedi_fc.h -#include 8253.h +#include comedi_8254.h #include amcc_s5933.h #define PCI171x_AD_DATA 0 /* R: A/D data */ @@ -67,11 +67,6 @@ Configuration options: #define PCI171X_TIMER_BASE 0x18 -#define PCI171x_CNT0 24 /* R/W: 8254 counter 0 */ -#define PCI171x_CNT1 26 /* R/W: 8254 counter 1 */ -#define PCI171x_CNT2 28 /* R/W: 8254 counter 2 */ -#define PCI171x_CNTCTRL30 /* W: 8254 counter control */ - /* upper bits from status register (PCI171x_STATUS) (lower is same with control * reg) */ #defineStatus_FE 0x0100 /* 1=FIFO is empty */ @@ -87,16 +82,6 @@ Configuration options: #define Control_EXT0x0004 /* 1=external trigger source */ #define Control_PACER 0x0002 /* 1=enable internal 8254 trigger source */ #define Control_SW 0x0001 /* 1=enable software trigger source */ -/* bits from counter control register (PCI171x_CNTCTRL) */ -#define Counter_BCD 0x0001 /* 0 = binary counter, 1 = BCD counter */ -#define Counter_M0 0x0002 /* M0-M2 select modes 0-5 */ -#define Counter_M1 0x0004 /* 000 = mode 0, 010 = mode 2 ... */ -#define Counter_M2 0x0008 -#define Counter_RW0 0x0010 /* RW0/RW1 select read/write mode */ -#define Counter_RW1 0x0020 -#define Counter_SC0 0x0040 /* Select Counter. Only 00 or 11 may */ -#define Counter_SC1 0x0080 /* be used, 00 for CNT0, -* 11 for read-back command */ #define PCI1720_DA0 0 /* W: D/A register 0 */ #define PCI1720_DA1 2 /* W: D/A register 1 */ @@ -265,15 +250,9 @@ struct pci1710_private { unsigned char ai_et; unsigned int ai_et_CntrlReg; unsigned int ai_et_MuxVal; - unsigned int next_divisor1; - unsigned int next_divisor2; - unsigned int divisor1; - unsigned int divisor2; unsigned int act_chanlist[32]; /* list of scanned channel */ unsigned char saved_seglen; /* len of the non-repeating chanlist */ unsigned char da_ranges;/* copy of D/A outpit range register */ - unsigned int cnt0_write_wait; /* after a write, wait for update of the -* internal state */ }; static int pci171x_ai_check_chanlist(struct comedi_device *dev, @@ -509,105 +488,6 @@ static int pci171x_do_insn_bits(struct comedi_device *dev, return insn-n; } -static void pci171x_start_pacer(struct comedi_device *dev, - bool load_counters) -{ - struct pci1710_private *devpriv = dev-private; - unsigned long timer_base = dev-iobase + PCI171X_TIMER_BASE; - - i8254_set_mode(timer_base, 1, 2, I8254_MODE2 | I8254_BINARY); - i8254_set_mode(timer_base, 1, 1, I8254_MODE2 | I8254_BINARY); - - if (load_counters) { - i8254_write(timer_base, 1, 2, devpriv-divisor2); - i8254_write(timer_base, 1, 1, devpriv-divisor1); - } -} - -static int pci171x_counter_insn_read(struct comedi_device *dev, -struct comedi_subdevice *s, -struct comedi_insn *insn, -unsigned int *data) -{ - unsigned int msb, lsb, ccntrl; - int i; - - ccntrl = 0xD2; /* count only */ - for (i = 0; i insn-n; i++) { - outw(ccntrl, dev-iobase + PCI171x_CNTCTRL); - -
[RFC PATCH 36/36] staging: comedi: 8253.h: remove unused header
All the comedi drivers have been converted to use the comedi_8254 module to provide support for the 8254 timers. Remove this unused header. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/drivers/8253.h | 347 -- 1 file changed, 347 deletions(-) delete mode 100644 drivers/staging/comedi/drivers/8253.h diff --git a/drivers/staging/comedi/drivers/8253.h b/drivers/staging/comedi/drivers/8253.h deleted file mode 100644 index 51b9c8d..000 --- a/drivers/staging/comedi/drivers/8253.h +++ /dev/null @@ -1,347 +0,0 @@ -/* - * comedi/drivers/8253.h - * Header file for 8253 - * - * COMEDI - Linux Control and Measurement Device Interface - * Copyright (C) 2000 David A. Schleef d...@schleef.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _8253_H -#define _8253_H - -#include ../comedi.h - -/* - * Common oscillator base values in nanoseconds - */ -#define I8254_OSC_BASE_10MHZ 100 -#define I8254_OSC_BASE_5MHZ200 -#define I8254_OSC_BASE_4MHZ250 -#define I8254_OSC_BASE_2MHZ500 -#define I8254_OSC_BASE_1MHZ1000 - -static inline void i8253_cascade_ns_to_timer(int i8253_osc_base, -unsigned int *d1, -unsigned int *d2, -unsigned int *nanosec, -unsigned int flags) -{ - unsigned int divider; - unsigned int div1, div2; - unsigned int div1_glb, div2_glb, ns_glb; - unsigned int div1_lub, div2_lub, ns_lub; - unsigned int ns; - unsigned int start; - unsigned int ns_low, ns_high; - static const unsigned int max_count = 0x1; - /* -* exit early if everything is already correct (this can save time -* since this function may be called repeatedly during command tests -* and execution) -*/ - div1 = *d1 ? *d1 : max_count; - div2 = *d2 ? *d2 : max_count; - divider = div1 * div2; - if (div1 * div2 * i8253_osc_base == *nanosec - div1 1 div1 = max_count div2 1 div2 = max_count - /* check for overflow */ - divider div1 divider div2 - divider * i8253_osc_base divider - divider * i8253_osc_base i8253_osc_base) { - return; - } - - divider = *nanosec / i8253_osc_base; - - div1_lub = div2_lub = 0; - div1_glb = div2_glb = 0; - - ns_glb = 0; - ns_lub = 0x; - - div2 = max_count; - start = divider / div2; - if (start 2) - start = 2; - for (div1 = start; div1 = divider / div1 + 1 div1 = max_count; -div1++) { - for (div2 = divider / div1; -div1 * div2 = divider + div1 + 1 div2 = max_count; -div2++) { - ns = i8253_osc_base * div1 * div2; - if (ns = *nanosec ns ns_glb) { - ns_glb = ns; - div1_glb = div1; - div2_glb = div2; - } - if (ns = *nanosec ns ns_lub) { - ns_lub = ns; - div1_lub = div1; - div2_lub = div2; - } - } - } - - switch (flags CMDF_ROUND_MASK) { - case CMDF_ROUND_NEAREST: - default: - ns_high = div1_lub * div2_lub * i8253_osc_base; - ns_low = div1_glb * div2_glb * i8253_osc_base; - if (ns_high - *nanosec *nanosec - ns_low) { - div1 = div1_lub; - div2 = div2_lub; - } else { - div1 = div1_glb; - div2 = div2_glb; - } - break; - case CMDF_ROUND_UP: - div1 = div1_lub; - div2 = div2_lub; - break; - case CMDF_ROUND_DOWN: - div1 = div1_glb; - div2 = div2_glb; - break; - } - - *nanosec = div1 * div2 * i8253_osc_base; - /* masking is done since counter maps zero to 0x1 */ - *d1 = div1 0x; - *d2 = div2 0x; -} - -#ifndef
[RFC PATCH 34/36] staging: comedi: amplc_dio200_common: convert driver to use the comedi_8254 module
Convert this driver to use the comedi_8254 module to provide the 8254 timer support. Add 'clock_src' and 'gate_src' members to the comedi_8254 data for convienence. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + .../staging/comedi/drivers/amplc_dio200_common.c | 263 ++--- drivers/staging/comedi/drivers/comedi_8254.h | 4 + 3 files changed, 72 insertions(+), 196 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 6ee50b4..ebda03c 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -1275,6 +1275,7 @@ config COMEDI_KCOMEDILIB called kcomedilib. config COMEDI_AMPLC_DIO200 + select COMEDI_8254 tristate config COMEDI_AMPLC_PC236 diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 08dab1f..89e19d6 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -26,7 +26,7 @@ #include amplc_dio200.h #include comedi_fc.h -#include 8253.h +#include comedi_8254.h #include 8255.h /* only for register defines */ /* 200 series registers */ @@ -97,12 +97,6 @@ static const unsigned int ts_clock_period[TS_CONFIG_MAX_CLK_SRC + 1] = { 100,/* 1 millisecond. */ }; -struct dio200_subdev_8254 { - unsigned int ofs; /* Counter base offset */ - unsigned int clock_src[3]; /* Current clock sources */ - unsigned int gate_src[3]; /* Current gate sources */ -}; - struct dio200_subdev_8255 { unsigned int ofs; /* DIO base offset */ }; @@ -474,159 +468,37 @@ static irqreturn_t dio200_interrupt(int irq, void *d) return IRQ_RETVAL(handled); } -static unsigned int dio200_subdev_8254_read_chan(struct comedi_device *dev, -struct comedi_subdevice *s, -unsigned int chan) -{ - struct dio200_subdev_8254 *subpriv = s-private; - unsigned int val; - - /* latch counter */ - val = chan 6; - dio200_write8(dev, subpriv-ofs + i8254_control_reg, val); - /* read lsb, msb */ - val = dio200_read8(dev, subpriv-ofs + chan); - val += dio200_read8(dev, subpriv-ofs + chan) 8; - return val; -} - -static void dio200_subdev_8254_write_chan(struct comedi_device *dev, - struct comedi_subdevice *s, - unsigned int chan, - unsigned int count) -{ - struct dio200_subdev_8254 *subpriv = s-private; - - /* write lsb, msb */ - dio200_write8(dev, subpriv-ofs + chan, count 0xff); - dio200_write8(dev, subpriv-ofs + chan, (count 8) 0xff); -} - -static void dio200_subdev_8254_set_mode(struct comedi_device *dev, - struct comedi_subdevice *s, - unsigned int chan, - unsigned int mode) -{ - struct dio200_subdev_8254 *subpriv = s-private; - unsigned int byte; - - byte = chan 6; - byte |= 0x30; /* access order: lsb, msb */ - byte |= (mode 0xf); /* counter mode and BCD|binary */ - dio200_write8(dev, subpriv-ofs + i8254_control_reg, byte); -} - -static unsigned int dio200_subdev_8254_status(struct comedi_device *dev, - struct comedi_subdevice *s, - unsigned int chan) -{ - struct dio200_subdev_8254 *subpriv = s-private; - - /* latch status */ - dio200_write8(dev, subpriv-ofs + i8254_control_reg, - 0xe0 | (2 chan)); - /* read status */ - return dio200_read8(dev, subpriv-ofs + chan); -} - -static int dio200_subdev_8254_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - int chan = CR_CHAN(insn-chanspec); - unsigned int n; - - for (n = 0; n insn-n; n++) - data[n] = dio200_subdev_8254_read_chan(dev, s, chan); - - return insn-n; -} - -static int dio200_subdev_8254_write(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - int chan = CR_CHAN(insn-chanspec); - unsigned int n; - - for (n = 0; n insn-n; n++) - dio200_subdev_8254_write_chan(dev, s, chan,
[RFC PATCH 01/36] staging: comedi: comedi_8254: introduce module for 8254 timer support
A 8254 timer/counter is commonly used on data acquisition boards to provide the internal pacer clock used to acquire analog input samples. Some boards also to allow the timers to be used externally. Currently the 8254 timers are supported by comedi using the 8253.h header and a number of inline functions. This works for the internal pacer clock but requires the drivers to implement subdevice code necessary to use the timers externally. Introduce a new module to support both the internal pacer clock and the external counter subdevice. This will allow removing a bunch of duplicated code in the drivers and standardizes the comedi 8254 timer support. This implementation is based on the 8253.h inline functions and the various subdevice functionality in the comedi drivers. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 3 + drivers/staging/comedi/drivers/Makefile | 1 + drivers/staging/comedi/drivers/comedi_8254.c | 665 +++ drivers/staging/comedi/drivers/comedi_8254.h | 129 ++ 4 files changed, 798 insertions(+) create mode 100644 drivers/staging/comedi/drivers/comedi_8254.c create mode 100644 drivers/staging/comedi/drivers/comedi_8254.h diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 593fcb1..a2577ba 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -1222,6 +1222,9 @@ config COMEDI_VMK80XX endif # COMEDI_USB_DRIVERS +config COMEDI_8254 + tristate + config COMEDI_8255 tristate Generic 8255 support ---help--- diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile index 7d1fbd5..d6d8340 100644 --- a/drivers/staging/comedi/drivers/Makefile +++ b/drivers/staging/comedi/drivers/Makefile @@ -3,6 +3,7 @@ ccflags-$(CONFIG_COMEDI_DEBUG) := -DDEBUG # Comedi helper modules +obj-$(CONFIG_COMEDI_8254) += comedi_8254.o obj-$(CONFIG_COMEDI_ISADMA)+= comedi_isadma.o # Comedi misc drivers diff --git a/drivers/staging/comedi/drivers/comedi_8254.c b/drivers/staging/comedi/drivers/comedi_8254.c new file mode 100644 index 000..51fe043 --- /dev/null +++ b/drivers/staging/comedi/drivers/comedi_8254.c @@ -0,0 +1,665 @@ +/* + * comedi_8254.c + * Generic 8254 timer/counter support + * Copyright (C) 2014 H Hartley Sweeten hswee...@visionengravers.com + * + * Based on 8253.h and various subdevice implementations in comedi drivers. + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 2000 David A. Schleef d...@schleef.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/* + * Module: comedi_8254 + * Description: Generic 8254 timer/counter support + * Author: H Hartley Sweeten hswee...@visionengravers.com + * Updated: Thu Jan 8 16:45:45 MST 2015 + * Status: works + * + * This module is not used directly by end-users. Rather, it is used by other + * drivers to provide support for an 8254 Programmable Interval Timer. These + * counters are typically used to generate the pacer clock used for data + * acquisition. Some drivers also expose the counters for general purpose use. + * + * This module provides the following basic functions: + * + * comedi_8254_init() / comedi_8254_mm_init() + * Initializes this module to access the 8254 registers. The _mm version + * sets up the module for MMIO register access the other for PIO access. + * The pointer returned from these functions is normally stored in the + * comedi_device dev-pacer and will be freed by the comedi core during + * the driver (*detach). If a driver has multiple 8254 devices, they need + * to be stored in the drivers private data and freed when the driver is + * detached. + * + * NOTE: The counters are reset by setting them to I8254_MODE0 as part of + * this initialization. + * + * comedi_8254_set_mode() + * Sets a counters operation mode: + * I8254_MODE0 Interrupt on terminal count + * I8254_MODE1 Hardware retriggerable one-shot + * I8254_MODE2 Rate generator + * I8254_MODE3 Square wave mode + * I8254_MODE4 Software triggered strobe + * I8254_MODE5 Hardware triggered strobe (retriggerable) + * + * In addition I8254_BCD and I8254_BINARY specify the counting mode: + *
[RFC PATCH 20/36] staging: comedi: adv_pci_dio: simplify counter subdevice I/O
Only two of the boards supported by this driver have an 8254 counter/timer. Both of these boards have a single 8254 device. Currently the counter subdevice functions are coded to support multiple 8254 devices. This is unnecessary and just complicates the codde. Simplfy the subdevice functions to work for a single 8254 counter/timer and refactor the driver (*attach) accordingly. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/drivers/adv_pci_dio.c | 47 +--- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 09609d6..8824450 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -60,12 +60,6 @@ enum hw_io_access { #define MAX_DO_SUBDEVS 2 /* max number of DO subdevices per card */ #define MAX_DIO_SUBDEVG2 /* max number of DIO subdevices group per * card */ -#define MAX_8254_SUBDEVS 1 /* max number of 8254 counter subdevs per -* card */ - /* (could be more than one 8254 per -* subdevice) */ - -#define SIZE_8254 4/* 8254 IO space length */ #define PCIDIO_MAINREG2/* main I/O region for all Advantech cards? */ @@ -243,7 +237,7 @@ struct dio_boardtype { struct diosubd_data sdo[MAX_DO_SUBDEVS];/* DO chans */ struct diosubd_data sdio[MAX_DIO_SUBDEVG]; /* DIO 8255 chans */ struct diosubd_data boardid;/* card supports board ID switch */ - struct diosubd_data s8254[MAX_8254_SUBDEVS];/* 8254 subdevices */ + struct diosubd_data s8254[1]; /* 8254 subdevices */ enum hw_io_access io_access; }; @@ -492,15 +486,11 @@ static int pci_8254_insn_read(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { const struct diosubd_data *d = (const struct diosubd_data *)s-private; - unsigned int chan, chip, chipchan; + unsigned int chan = CR_CHAN(insn-chanspec); unsigned long flags; - chan = CR_CHAN(insn-chanspec); /* channel on subdevice */ - chip = chan / 3;/* chip on subdevice */ - chipchan = chan - (3 * chip); /* channel on chip on subdevice */ spin_lock_irqsave(s-spin_lock, flags); - data[0] = i8254_read(dev-iobase + d-addr + (SIZE_8254 * chip), - 0, chipchan); + data[0] = i8254_read(dev-iobase + d-addr, 0, chan); spin_unlock_irqrestore(s-spin_lock, flags); return 1; } @@ -513,15 +503,11 @@ static int pci_8254_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { const struct diosubd_data *d = (const struct diosubd_data *)s-private; - unsigned int chan, chip, chipchan; + unsigned int chan = CR_CHAN(insn-chanspec); unsigned long flags; - chan = CR_CHAN(insn-chanspec); /* channel on subdevice */ - chip = chan / 3;/* chip on subdevice */ - chipchan = chan - (3 * chip); /* channel on chip on subdevice */ spin_lock_irqsave(s-spin_lock, flags); - i8254_write(dev-iobase + d-addr + (SIZE_8254 * chip), - 0, chipchan, data[0]); + i8254_write(dev-iobase + d-addr, 0, chan, data[0]); spin_unlock_irqrestore(s-spin_lock, flags); return 1; } @@ -534,24 +520,20 @@ static int pci_8254_insn_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { const struct diosubd_data *d = (const struct diosubd_data *)s-private; - unsigned int chan, chip, chipchan; - unsigned long iobase; + unsigned int chan = CR_CHAN(insn-chanspec); + unsigned long iobase = dev-iobase + d-addr; int ret = 0; unsigned long flags; - chan = CR_CHAN(insn-chanspec); /* channel on subdevice */ - chip = chan / 3;/* chip on subdevice */ - chipchan = chan - (3 * chip); /* channel on chip on subdevice */ - iobase = dev-iobase + d-addr + (SIZE_8254 * chip); spin_lock_irqsave(s-spin_lock, flags); switch (data[0]) { case INSN_CONFIG_SET_COUNTER_MODE: - ret = i8254_set_mode(iobase, 0, chipchan, data[1]); + ret = i8254_set_mode(iobase, 0, chan, data[1]); if (ret 0) ret = -EINVAL; break; case INSN_CONFIG_8254_READ_STATUS: - data[1] = i8254_status(iobase, 0, chipchan); + data[1] = i8254_status(iobase, 0, chan); break; default: ret = -EINVAL; @@
[RFC PATCH 15/36] staging: comedi: das08: convert driver to use the comedi_8254 module
Some of the hardware supported by this driver include an 8254 timer that is exposed to the user as a comedi_subdevice. Convert it to use the comedi_8254 module to provide support for the 8254 timer. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/das08.c | 77 +- 2 files changed, 11 insertions(+), 67 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index f63626f..8d636ec 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -1275,6 +1275,7 @@ config COMEDI_AMPLC_PC236 config COMEDI_DAS08 tristate + select COMEDI_8254 select COMEDI_8255 config COMEDI_ISADMA diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index c78c0df..ecd3639 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -23,7 +23,7 @@ #include ../comedidev.h #include 8255.h -#include 8253.h +#include comedi_8254.h #include das08.h /* @@ -359,62 +359,6 @@ static int das08_ao_insn_write(struct comedi_device *dev, return insn-n; } -static void i8254_initialize(struct comedi_device *dev) -{ - const struct das08_board_struct *thisboard = dev-board_ptr; - unsigned long i8254_iobase = dev-iobase + thisboard-i8254_offset; - unsigned int mode = I8254_MODE0 | I8254_BINARY; - int i; - - for (i = 0; i 3; ++i) - i8254_set_mode(i8254_iobase, 0, i, mode); -} - -static int das08_counter_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - const struct das08_board_struct *thisboard = dev-board_ptr; - unsigned long i8254_iobase = dev-iobase + thisboard-i8254_offset; - int chan = insn-chanspec; - - data[0] = i8254_read(i8254_iobase, 0, chan); - return 1; -} - -static int das08_counter_write(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - const struct das08_board_struct *thisboard = dev-board_ptr; - unsigned long i8254_iobase = dev-iobase + thisboard-i8254_offset; - int chan = insn-chanspec; - - i8254_write(i8254_iobase, 0, chan, data[0]); - return 1; -} - -static int das08_counter_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - const struct das08_board_struct *thisboard = dev-board_ptr; - unsigned long i8254_iobase = dev-iobase + thisboard-i8254_offset; - int chan = insn-chanspec; - - switch (data[0]) { - case INSN_CONFIG_SET_COUNTER_MODE: - i8254_set_mode(i8254_iobase, 0, chan, data[1]); - break; - case INSN_CONFIG_8254_READ_STATUS: - data[1] = i8254_status(i8254_iobase, 0, chan); - break; - default: - return -EINVAL; - } - return 2; -} - int das08_common_attach(struct comedi_device *dev, unsigned long iobase) { const struct das08_board_struct *thisboard = dev-board_ptr; @@ -511,17 +455,16 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) s-type = COMEDI_SUBD_UNUSED; } + /* Counter subdevice (8254) */ s = dev-subdevices[5]; - /* 8254 */ - if (thisboard-i8254_offset != 0) { - s-type = COMEDI_SUBD_COUNTER; - s-subdev_flags = SDF_WRITABLE | SDF_READABLE; - s-n_chan = 3; - s-maxdata = 0x; - s-insn_read = das08_counter_read; - s-insn_write = das08_counter_write; - s-insn_config = das08_counter_config; - i8254_initialize(dev); + if (thisboard-i8254_offset) { + dev-pacer = comedi_8254_init(dev-iobase + + thisboard-i8254_offset, + 0, I8254_IO8, 0); + if (!dev-pacer) + return -ENOMEM; + + comedi_8254_subdevice_init(s, dev-pacer); } else { s-type = COMEDI_SUBD_UNUSED; } -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC PATCH 29/36] staging: comedi: amplc_dio200_common: remove 'clk_sce_ofs' from struct dio200_subdev_8254
This member is only used one place in the driver. Remove it and calculate the register offset when needed. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/drivers/amplc_dio200_common.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 709fe1a..1786ea2 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -99,7 +99,6 @@ static const unsigned int ts_clock_period[TS_CONFIG_MAX_CLK_SRC + 1] = { struct dio200_subdev_8254 { unsigned int ofs; /* Counter base offset */ - unsigned int clk_sce_ofs; /* CLK_SCE base address */ unsigned int gat_sce_ofs; /* GAT_SCE base address */ int which; /* Bit 5 of CLK_SCE or GAT_SCE */ unsigned int clock_src[3]; /* Current clock sources */ @@ -625,7 +624,7 @@ static int dio200_subdev_8254_set_clock_src(struct comedi_device *dev, subpriv-clock_src[counter_number] = clock_src; byte = clk_sce(subpriv-which, counter_number, clock_src); - dio200_write8(dev, subpriv-clk_sce_ofs, byte); + dio200_write8(dev, DIO200_CLK_SCE(subpriv-ofs 3), byte); return 0; } @@ -729,7 +728,6 @@ static int dio200_subdev_8254_init(struct comedi_device *dev, if (board-has_clk_gat_sce) { /* Derive CLK_SCE and GAT_SCE register offsets from * 8254 offset. */ - subpriv-clk_sce_ofs = DIO200_CLK_SCE(offset 3); subpriv-gat_sce_ofs = DIO200_GAT_SCE(offset 3); subpriv-which = (offset 2) 1; } -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC PATCH 25/36] staging: comedi: das16: convert driver to use the comedi_8254 module
This driver uses an 8254 timer to generate the pacer clock used for analog input data conversion. Convert it to use the comedi_8254 module to provide support for the 8254 timer. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/das16.c | 44 -- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 77c1c99..30951a3 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -287,6 +287,7 @@ config COMEDI_DAS08_ISA config COMEDI_DAS16 tristate DAS-16 compatible ISA and PC/104 card support select COMEDI_ISADMA if ISA_DMA_API + select COMEDI_8254 select COMEDI_8255 ---help--- Enable support for Keithley Metrabyte/ComputerBoards DAS16 diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 2c20311..4b3bdad 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -77,7 +77,7 @@ #include comedi_isadma.h #include comedi_fc.h -#include 8253.h +#include comedi_8254.h #include 8255.h #define DAS16_DMA_SIZE 0xff00 /* size in bytes of allocated dma buffer */ @@ -663,18 +663,12 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, /* step 4: fix up arguments */ if (cmd-scan_begin_src == TRIG_TIMER) { arg = cmd-scan_begin_arg; - i8253_cascade_ns_to_timer(devpriv-clockbase, - devpriv-divisor1, - devpriv-divisor2, - arg, cmd-flags); + comedi_8254_cascade_ns_to_timer(dev-pacer, arg, cmd-flags); err |= cfc_check_trigger_arg_is(cmd-scan_begin_arg, arg); } if (cmd-convert_src == TRIG_TIMER) { arg = cmd-convert_arg; - i8253_cascade_ns_to_timer(devpriv-clockbase, - devpriv-divisor1, - devpriv-divisor2, - arg, cmd-flags); + comedi_8254_cascade_ns_to_timer(dev-pacer, arg, cmd-flags); err |= cfc_check_trigger_arg_is(cmd-convert_arg, arg); } if (err) @@ -693,17 +687,9 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns, unsigned int flags) { - struct das16_private_struct *devpriv = dev-private; - unsigned long timer_base = dev-iobase + DAS16_TIMER_BASE_REG; - - i8253_cascade_ns_to_timer(devpriv-clockbase, - devpriv-divisor1, devpriv-divisor2, - ns, flags); - - i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); - i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); - i8254_write(timer_base, 0, 1, devpriv-divisor1); - i8254_write(timer_base, 0, 2, devpriv-divisor2); + comedi_8254_cascade_ns_to_timer(dev-pacer, ns, flags); + comedi_8254_update_divisors(dev-pacer); + comedi_8254_pacer_enable(dev-pacer, 1, 2, true); return ns; } @@ -935,7 +921,6 @@ static void das16_reset(struct comedi_device *dev) outb(0, dev-iobase + DAS16_STATUS_REG); outb(0, dev-iobase + DAS16_CTRL_REG); outb(0, dev-iobase + DAS16_PACER_REG); - outb(0, dev-iobase + DAS16_TIMER_BASE_REG + i8254_control_reg); } static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan) @@ -1039,6 +1024,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) const struct das16_board *board = dev-board_ptr; struct das16_private_struct *devpriv; struct comedi_subdevice *s; + unsigned int osc_base; unsigned int status; int ret; @@ -1078,21 +1064,21 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) return -EINVAL; /* get master clock speed */ + osc_base = I8254_OSC_BASE_1MHZ; if (devpriv-can_burst) { status = inb(dev-iobase + DAS1600_STATUS_REG); - if (status DAS1600_STATUS_CLK_10MHZ) - devpriv-clockbase = I8254_OSC_BASE_10MHZ; - else - devpriv-clockbase = I8254_OSC_BASE_1MHZ; + osc_base = I8254_OSC_BASE_10MHZ; } else { if (it-options[3]) - devpriv-clockbase = I8254_OSC_BASE_1MHZ / -it-options[3]; -
[RFC PATCH 21/36] staging: comedi: adv_pci_dio: refactor 's8254' boardinfo
The boardinfo for the 8254 timer is overly complex. The 8254 timer always has 3 channels and the 'regs' and 'specflags' members of diosubd_data are not used. The only necessary information is the base 'addr' offset to the 8254 registers. Replace the 's8254' member with an unsigned long 'timer_regbase'. Use that to determine if the board has an 8254 timer during the attach of the driver. Save the 'timer_regbase' in the subdevice 'private' pointer to use in the subdevice functions. For aesthetics, absorb pci_dio_add_8254() into the driver attach function. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/drivers/adv_pci_dio.c | 51 +++- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 8824450..fb9de3a 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -224,7 +224,7 @@ struct diosubd_data { int chans; /* num of chans */ int addr; /* PCI address ofset */ int regs; /* number of registers to read or 8255 - subdevices or 8254 chips */ + subdevices */ unsigned int specflags; /* addon subdevice flags */ }; @@ -237,7 +237,7 @@ struct dio_boardtype { struct diosubd_data sdo[MAX_DO_SUBDEVS];/* DO chans */ struct diosubd_data sdio[MAX_DIO_SUBDEVG]; /* DIO 8255 chans */ struct diosubd_data boardid;/* card supports board ID switch */ - struct diosubd_data s8254[1]; /* 8254 subdevices */ + unsigned long timer_regbase; enum hw_io_access io_access; }; @@ -280,7 +280,7 @@ static const struct dio_boardtype boardtypes[] = { .sdi[0] = { 32, PCI1735_DI, 4, 0, }, .sdo[0] = { 32, PCI1735_DO, 4, 0, }, .boardid= { 4, PCI1735_BOARDID, 1, SDF_INTERNAL, }, - .s8254[0] = { 3, PCI1735_C8254, 1, 0, }, + .timer_regbase = PCI1735_C8254, .io_access = IO_8b, }, [TYPE_PCI1736] = { @@ -316,7 +316,7 @@ static const struct dio_boardtype boardtypes[] = { .cardtype = TYPE_PCI1751, .nsubdevs = 3, .sdio[0]= { 48, PCI1751_DIO, 2, 0, }, - .s8254[0] = { 3, PCI1751_CNT, 1, 0, }, + .timer_regbase = PCI1751_CNT, .io_access = IO_8b, }, [TYPE_PCI1752] = { @@ -485,12 +485,12 @@ static int pci_8254_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - const struct diosubd_data *d = (const struct diosubd_data *)s-private; + unsigned long timer_regbase = (unsigned long)s-private; unsigned int chan = CR_CHAN(insn-chanspec); unsigned long flags; spin_lock_irqsave(s-spin_lock, flags); - data[0] = i8254_read(dev-iobase + d-addr, 0, chan); + data[0] = i8254_read(dev-iobase + timer_regbase, 0, chan); spin_unlock_irqrestore(s-spin_lock, flags); return 1; } @@ -502,12 +502,12 @@ static int pci_8254_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - const struct diosubd_data *d = (const struct diosubd_data *)s-private; + unsigned long timer_regbase = (unsigned long)s-private; unsigned int chan = CR_CHAN(insn-chanspec); unsigned long flags; spin_lock_irqsave(s-spin_lock, flags); - i8254_write(dev-iobase + d-addr, 0, chan, data[0]); + i8254_write(dev-iobase + timer_regbase, 0, chan, data[0]); spin_unlock_irqrestore(s-spin_lock, flags); return 1; } @@ -519,9 +519,9 @@ static int pci_8254_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - const struct diosubd_data *d = (const struct diosubd_data *)s-private; + unsigned long timer_regbase = (unsigned long)s-private; + unsigned long iobase = dev-iobase + timer_regbase; unsigned int chan = CR_CHAN(insn-chanspec); - unsigned long iobase = dev-iobase + d-addr; int ret = 0; unsigned long flags; @@ -1011,26 +1011,6 @@ static int pci_dio_add_do(struct comedi_device *dev, return 0; } -/* -== -*/ -static int pci_dio_add_8254(struct comedi_device *dev, -
[RFC PATCH 31/36] staging: comedi: amplc_dio200_common: remove 'which' from struct dio200_subdev_8254
This member is only used in the set gate and set clock helper functions. Remove it and calculate the value when needed. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/drivers/amplc_dio200_common.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 2c9c8dd..6ef70a5 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -99,7 +99,6 @@ static const unsigned int ts_clock_period[TS_CONFIG_MAX_CLK_SRC + 1] = { struct dio200_subdev_8254 { unsigned int ofs; /* Counter base offset */ - int which; /* Bit 5 of CLK_SCE or GAT_SCE */ unsigned int clock_src[3]; /* Current clock sources */ unsigned int gate_src[3]; /* Current gate sources */ spinlock_t spinlock; @@ -584,7 +583,7 @@ static int dio200_subdev_8254_set_gate_src(struct comedi_device *dev, return -1; subpriv-gate_src[counter_number] = gate_src; - byte = gat_sce(subpriv-which, counter_number, gate_src); + byte = gat_sce((subpriv-ofs 2) 1, counter_number, gate_src); dio200_write8(dev, DIO200_GAT_SCE(subpriv-ofs 3), byte); return 0; @@ -622,7 +621,7 @@ static int dio200_subdev_8254_set_clock_src(struct comedi_device *dev, return -1; subpriv-clock_src[counter_number] = clock_src; - byte = clk_sce(subpriv-which, counter_number, clock_src); + byte = clk_sce((subpriv-ofs 2) 1, counter_number, clock_src); dio200_write8(dev, DIO200_CLK_SCE(subpriv-ofs 3), byte); return 0; @@ -724,8 +723,6 @@ static int dio200_subdev_8254_init(struct comedi_device *dev, spin_lock_init(subpriv-spinlock); subpriv-ofs = offset; - if (board-has_clk_gat_sce) - subpriv-which = (offset 2) 1; /* Initialize channels. */ for (chan = 0; chan 3; chan++) { -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC PATCH 02/36] staging: comedi: add 'pacer' member to struct comedi_device
Add a new member to the comedi_device struct for a comedi_8254 'pacer'. This provides a convient place to store the data allocated by the comedi_8254 module for boards that use an 8254 device to create the data acquisition pacer clock. Automatically free this pointer in comedi_device_detach_cleanup() so that the drivers don't need to do it when then are detached. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/comedidev.h | 1 + drivers/staging/comedi/drivers.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index e138eb0..30595c0 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -256,6 +256,7 @@ struct comedi_driver { struct comedi_device { int use_count; struct comedi_driver *driver; + struct comedi_8254 *pacer; void *private; struct device *class_dev; diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index f32e714..e87c68c 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -139,7 +139,9 @@ static void comedi_device_detach_cleanup(struct comedi_device *dev) dev-n_subdevices = 0; } kfree(dev-private); + kfree(dev-pacer); dev-private = NULL; + dev-pacer = NULL; dev-driver = NULL; dev-board_name = NULL; dev-board_ptr = NULL; -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC PATCH 33/36] staging: comedi: amplc_dio200_common: remove 'spinlock' from struct dio200_subdev_8254
Currently this driver uses a spinlock in the 8254 subdevice (*insn_read), (*insn_write), and (*insn_config) functions. The comedi core checks if the subdevice is 'busy', in parse_insn(), before any of the subdevice functions are attempted. Remove the unnecessary spinlock. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- .../staging/comedi/drivers/amplc_dio200_common.c | 23 +- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 48cdddc..08dab1f 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -101,7 +101,6 @@ struct dio200_subdev_8254 { unsigned int ofs; /* Counter base offset */ unsigned int clock_src[3]; /* Current clock sources */ unsigned int gate_src[3]; /* Current gate sources */ - spinlock_t spinlock; }; struct dio200_subdev_8255 { @@ -535,16 +534,12 @@ static int dio200_subdev_8254_read(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct dio200_subdev_8254 *subpriv = s-private; int chan = CR_CHAN(insn-chanspec); unsigned int n; - unsigned long flags; - for (n = 0; n insn-n; n++) { - spin_lock_irqsave(subpriv-spinlock, flags); + for (n = 0; n insn-n; n++) data[n] = dio200_subdev_8254_read_chan(dev, s, chan); - spin_unlock_irqrestore(subpriv-spinlock, flags); - } + return insn-n; } @@ -553,16 +548,12 @@ static int dio200_subdev_8254_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct dio200_subdev_8254 *subpriv = s-private; int chan = CR_CHAN(insn-chanspec); unsigned int n; - unsigned long flags; - for (n = 0; n insn-n; n++) { - spin_lock_irqsave(subpriv-spinlock, flags); + for (n = 0; n insn-n; n++) dio200_subdev_8254_write_chan(dev, s, chan, data[n]); - spin_unlock_irqrestore(subpriv-spinlock, flags); - } + return insn-n; } @@ -643,12 +634,9 @@ static int dio200_subdev_8254_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct dio200_subdev_8254 *subpriv = s-private; int ret = 0; int chan = CR_CHAN(insn-chanspec); - unsigned long flags; - spin_lock_irqsave(subpriv-spinlock, flags); switch (data[0]) { case INSN_CONFIG_SET_COUNTER_MODE: if (data[1] (I8254_MODE5 | I8254_BCD)) @@ -689,7 +677,7 @@ static int dio200_subdev_8254_config(struct comedi_device *dev, ret = -EINVAL; break; } - spin_unlock_irqrestore(subpriv-spinlock, flags); + return ret 0 ? ret : insn-n; } @@ -713,7 +701,6 @@ static int dio200_subdev_8254_init(struct comedi_device *dev, s-insn_write = dio200_subdev_8254_write; s-insn_config = dio200_subdev_8254_config; - spin_lock_init(subpriv-spinlock); subpriv-ofs = offset; /* Initialize channels. */ -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC PATCH 27/36] staging: comedi: amplc_dio200_common: introduce DIO200_CLK_SEL() macro
Replace the DIO200_[XYZ]CLK_SEL defines with a macro that returns the correct register offset. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/drivers/amplc_dio200_common.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 26aad70..ab87f2e 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -32,9 +32,7 @@ /* 200 series registers */ #define DIO200_IO_SIZE 0x20 #define DIO200_PCIE_IO_SIZE0x4000 -#define DIO200_XCLK_SCE0x18/* Group X clock selection register */ -#define DIO200_YCLK_SCE0x19/* Group Y clock selection register */ -#define DIO200_ZCLK_SCE0x1a/* Group Z clock selection register */ +#define DIO200_CLK_SCE(x) (0x18 + (x))/* Group X/Y/Z clock sel reg */ #define DIO200_XGAT_SCE0x1b/* Group X gate selection register */ #define DIO200_YGAT_SCE0x1c/* Group Y gate selection register */ #define DIO200_ZGAT_SCE0x1d/* Group Z gate selection register */ @@ -733,7 +731,7 @@ static int dio200_subdev_8254_init(struct comedi_device *dev, if (board-has_clk_gat_sce) { /* Derive CLK_SCE and GAT_SCE register offsets from * 8254 offset. */ - subpriv-clk_sce_ofs = DIO200_XCLK_SCE + (offset 3); + subpriv-clk_sce_ofs = DIO200_CLK_SCE(offset 3); subpriv-gat_sce_ofs = DIO200_XGAT_SCE + (offset 3); subpriv-which = (offset 2) 1; } -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC PATCH 17/36] staging: comedi: ni_at_a2150: convert driver to use the comedi_8254 module
The hardware supported by this driver includes an 8254 timer. For aesthetics, convert it to use the comedi_8254 module to provide support for the 8254 timer. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/ni_at_a2150.c | 17 +++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 20a906d..b90b8a8 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -469,6 +469,7 @@ config COMEDI_ADQ12B config COMEDI_NI_AT_A2150 tristate NI AT-A2150 ISA card support select COMEDI_ISADMA if ISA_DMA_API + select COMEDI_8254 ---help--- Enable support for National Instruments AT-A2150 cards diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index a1ce0b0..66c0e65 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -68,7 +68,7 @@ TRIG_WAKE_EOS #include comedi_isadma.h #include comedi_fc.h -#include 8253.h +#include comedi_8254.h #define A2150_DMA_BUFFER_SIZE 0xff00 /* size in bytes of dma buffer */ @@ -110,8 +110,6 @@ TRIG_WAKE_EOS #define DMA_INTR_EN_BIT 0x800 /* enable interrupt on dma terminal count */ #define DMA_DEM_EN_BIT 0x1000 /* enables demand mode dma */ #define I8253_BASE_REG 0x14 -#define I8253_MODE_REG 0x17 -#define HW_COUNT_DISABLE 0x30/* disable hardware counting of conversions */ struct a2150_board { const char *name; @@ -488,7 +486,6 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) struct comedi_isadma_desc *desc = dma-desc[0]; struct comedi_async *async = s-async; struct comedi_cmd *cmd = async-cmd; - unsigned long timer_base = dev-iobase + I8253_BASE_REG; unsigned int old_config_bits = devpriv-config_bits; unsigned int trigger_bits; @@ -547,8 +544,7 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) outw(devpriv-irq_dma_bits, dev-iobase + IRQ_DMA_CNTRL_REG); /* may need to wait 72 sampling periods if timing was changed */ - i8254_set_mode(timer_base, 0, 2, I8254_MODE0 | I8254_BINARY); - i8254_write(timer_base, 0, 2, 72); + comedi_8254_load(dev-pacer, 2, 72, I8254_MODE0 | I8254_BINARY); /* setup start triggering */ trigger_bits = 0; @@ -726,6 +722,11 @@ static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* an IRQ and DMA are required to support async commands */ a2150_alloc_irq_and_dma(dev, it); + dev-pacer = comedi_8254_init(dev-iobase + I8253_BASE_REG, + 0, I8254_IO8, 0); + if (!dev-pacer) + return -ENOMEM; + ret = comedi_alloc_subdevices(dev, 1); if (ret) return ret; @@ -747,10 +748,6 @@ static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it) s-cancel = a2150_cancel; } - /* need to do this for software counting of completed conversions, to -* prevent hardware count from stopping acquisition */ - outw(HW_COUNT_DISABLE, dev-iobase + I8253_MODE_REG); - /* set card's irq and dma levels */ outw(devpriv-irq_dma_bits, dev-iobase + IRQ_DMA_CNTRL_REG); -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC PATCH 11/36] staging: comedi: das16m1: convert driver to use the comedi_8254 module
This driver uses two 8254 timers. One to generate the analog input pacer clock and one to count the number of samples. Convert it to use the comedi_8254 module to provide support for the 8254 timers. Use the comedi_device 'pacer' member for the 8254 timer used for analog input. This data is freed automatically by the core during the detach of the driver. Store the data for the 8254 timer used to count samples in the private data. This data needs to be freed by the driver when it is detached. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/das16m1.c | 79 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 8de03c8..9b7a0d7 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -263,6 +263,7 @@ config COMEDI_DAC02 config COMEDI_DAS16M1 tristate MeasurementComputing CIO-DAS16/M1DAS-16 ISA card support + select COMEDI_8254 select COMEDI_8255 ---help--- Enable support for Measurement Computing CIO-DAS16/M1 ISA cards. diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 3666a68..219746b 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -53,11 +53,12 @@ irq can be omitted, although the cmd interface will not work without it. */ #include linux/module.h +#include linux/slab.h #include linux/interrupt.h #include ../comedidev.h #include 8255.h -#include 8253.h +#include comedi_8254.h #include comedi_fc.h #define DAS16M1_SIZE2 8 @@ -103,8 +104,6 @@ irq can be omitted, although the cmd interface will not work without it. #define Q_RANGE(x) (((x) 0xf) 4) #define UNIPOLAR 0x40 #define DAS16M1_8254_FIRST 0x8 -#define DAS16M1_8254_FIRST_CNTRL 0xb -#define TOTAL_CLEAR0x30 #define DAS16M1_8254_SECOND0xc #define DAS16M1_82C55 0x400 #define DAS16M1_8254_THIRD 0x404 @@ -124,6 +123,7 @@ static const struct comedi_lrange range_das16m1 = { }; struct das16m1_private_struct { + struct comedi_8254 *counter; unsigned int control_state; unsigned int adc_count; /* number of samples completed */ /* initial value in lower half of hardware conversion counter, @@ -131,8 +131,6 @@ struct das16m1_private_struct { * counter yet (loaded by first sample conversion) */ u16 initial_hw_count; unsigned short ai_buffer[FIFO_SIZE]; - unsigned int divisor1; /* divides master clock to obtain conversion speed */ - unsigned int divisor2; /* divides master clock to obtain conversion speed */ unsigned long extra_iobase; }; @@ -180,9 +178,7 @@ static int das16m1_ai_check_chanlist(struct comedi_device *dev, static int das16m1_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - struct das16m1_private_struct *devpriv = dev-private; int err = 0; - unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -229,11 +225,9 @@ static int das16m1_cmd_test(struct comedi_device *dev, /* step 4: fix up arguments */ if (cmd-convert_src == TRIG_TIMER) { - arg = cmd-convert_arg; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - devpriv-divisor1, - devpriv-divisor2, - arg, cmd-flags); + unsigned int arg = cmd-convert_arg; + + comedi_8254_cascade_ns_to_timer(dev-pacer, arg, cmd-flags); err |= cfc_check_trigger_arg_is(cmd-convert_arg, arg); } @@ -250,25 +244,12 @@ static int das16m1_cmd_test(struct comedi_device *dev, return 0; } -static void das16m1_set_pacer(struct comedi_device *dev) -{ - struct das16m1_private_struct *devpriv = dev-private; - unsigned long timer_base = dev-iobase + DAS16M1_8254_SECOND; - - i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); - i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); - - i8254_write(timer_base, 0, 1, devpriv-divisor1); - i8254_write(timer_base, 0, 2, devpriv-divisor2); -} - static int das16m1_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) { struct das16m1_private_struct *devpriv = dev-private; struct comedi_async *async = s-async; struct comedi_cmd *cmd = async-cmd; - unsigned long timer_base = dev-iobase + DAS16M1_8254_FIRST; unsigned int byte, i;
[RFC PATCH 28/36] staging: comedi: amplc_dio200_common: introduce DIO200_GAT_SEL() macro
Replace the DIO200_[XYZ]GAT_SEL defines with a macro that returns the correct register offset. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/drivers/amplc_dio200_common.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index ab87f2e..709fe1a 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -33,9 +33,7 @@ #define DIO200_IO_SIZE 0x20 #define DIO200_PCIE_IO_SIZE0x4000 #define DIO200_CLK_SCE(x) (0x18 + (x))/* Group X/Y/Z clock sel reg */ -#define DIO200_XGAT_SCE0x1b/* Group X gate selection register */ -#define DIO200_YGAT_SCE0x1c/* Group Y gate selection register */ -#define DIO200_ZGAT_SCE0x1d/* Group Z gate selection register */ +#define DIO200_GAT_SCE(x) (0x1b + (x))/* Group X/Y/Z gate sel reg */ #define DIO200_INT_SCE 0x1e/* Interrupt enable/status register */ /* Extra registers for new PCIe boards */ #define DIO200_ENHANCE 0x20/* 1 to enable enhanced features */ @@ -732,7 +730,7 @@ static int dio200_subdev_8254_init(struct comedi_device *dev, /* Derive CLK_SCE and GAT_SCE register offsets from * 8254 offset. */ subpriv-clk_sce_ofs = DIO200_CLK_SCE(offset 3); - subpriv-gat_sce_ofs = DIO200_XGAT_SCE + (offset 3); + subpriv-gat_sce_ofs = DIO200_GAT_SCE(offset 3); subpriv-which = (offset 2) 1; } -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC PATCH 26/36] staging: comedi: adl_pci9118: convert driver to use the comedi_8254 module
This driver uses an 8254 timer to generate the pacer clock used for analog input data conversion. Convert it to use the comedi_8254 module to provide support for the 8254 timer. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/adl_pci9118.c | 93 +--- 2 files changed, 29 insertions(+), 65 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 30951a3..6ee50b4 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -736,6 +736,7 @@ config COMEDI_ADL_PCI9111 config COMEDI_ADL_PCI9118 tristate ADLink PCI-9118DG, PCI-9118HG, PCI-9118HR support depends on HAS_DMA + select COMEDI_8254 ---help--- Enable support for ADlink PCI-9118DG, PCI-9118HG, PCI-9118HR cards diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index f61e392..86efddd 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -82,7 +82,7 @@ #include ../comedidev.h #include amcc_s5933.h -#include 8253.h +#include comedi_8254.h #include comedi_fc.h #define IORANGE_9118 64 /* I hope */ @@ -94,8 +94,7 @@ /* * PCI BAR2 Register map (dev-iobase) */ -#define PCI9118_TIMER_REG(x) (0x00 + ((x) * 4)) -#define PCI9118_TIMER_CTRL_REG 0x0c +#define PCI9118_TIMER_BASE 0x00 #define PCI9118_AI_FIFO_REG0x10 #define PCI9118_AO_REG(x) (0x10 + ((x) * 4)) #define PCI9118_AI_STATUS_REG 0x18 @@ -239,10 +238,6 @@ struct pci9118_private { * measure can start/stop * on external trigger */ - unsigned int ai_divisor1, ai_divisor2; /* -* divisors for start of measure -* on external start -*/ unsigned int dma_actbuf;/* which buffer is used now */ struct pci9118_dmabuf dmabuf[2]; int softsshdelay; /* @@ -297,24 +292,6 @@ static void pci9118_amcc_int_ena(struct comedi_device *dev, bool enable) outl(intcsr, devpriv-iobase_a + AMCC_OP_REG_INTCSR); } -static void pci9118_timer_write(struct comedi_device *dev, - unsigned int timer, unsigned int val) -{ - outl(val 0xff, dev-iobase + PCI9118_TIMER_REG(timer)); - outl((val 8) 0xff, dev-iobase + PCI9118_TIMER_REG(timer)); -} - -static void pci9118_timer_set_mode(struct comedi_device *dev, - unsigned int timer, unsigned int mode) -{ - unsigned int val; - - val = timer 6; /* select timer */ - val |= 0x30;/* load low then high byte */ - val |= mode;/* set timer mode and BCD|binary */ - outl(val, dev-iobase + PCI9118_TIMER_CTRL_REG); -} - static void pci9118_ai_reset_fifo(struct comedi_device *dev) { /* writing any value resets the A/D FIFO */ @@ -440,8 +417,8 @@ static void interrupt_pci9118_ai_mode4_switch(struct comedi_device *dev, devpriv-ai_cfg = PCI9118_AI_CFG_PDTRG | PCI9118_AI_CFG_PETRG | PCI9118_AI_CFG_AM; outl(devpriv-ai_cfg, dev-iobase + PCI9118_AI_CFG_REG); - pci9118_timer_set_mode(dev, 0, I8254_MODE0); - pci9118_timer_write(dev, 0, dmabuf-hw 1); + comedi_8254_load(dev-pacer, 0, dmabuf-hw 1, +I8254_MODE0 | I8254_BINARY); devpriv-ai_cfg |= PCI9118_AI_CFG_START; outl(devpriv-ai_cfg, dev-iobase + PCI9118_AI_CFG_REG); } @@ -577,15 +554,16 @@ static void pci9118_calc_divisors(struct comedi_device *dev, unsigned int *div1, unsigned int *div2, unsigned int chnsshfront) { + struct comedi_8254 *pacer = dev-pacer; struct comedi_cmd *cmd = s-async-cmd; - *div1 = *tim2 / I8254_OSC_BASE_4MHZ;/* convert timer (burst) */ - *div2 = *tim1 / I8254_OSC_BASE_4MHZ;/* scan timer */ + *div1 = *tim2 / pacer-osc_base;/* convert timer (burst) */ + *div2 = *tim1 / pacer-osc_base;/* scan timer */ *div2 = *div2 / *div1; /* major timer is c1*c2 */ if (*div2 chans) *div2 = chans; - *tim2 = *div1 * I8254_OSC_BASE_4MHZ;/* real convert timer */ + *tim2 = *div1 * pacer-osc_base;/* real convert timer */ if (cmd-convert_src == TRIG_NOW !chnsshfront) { /* use BSSH signal */ @@ -593,21 +571,13 @@ static void pci9118_calc_divisors(struct
[RFC PATCH 22/36] staging: comedi: adv_pci_dio: convert driver to use the comedi_8254 module
Some of the hardware supported by this driver includes an 8254 timer. For aesthetics, convert it to use the comedi_8254 module to provide support for the 8254 timer. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/adv_pci_dio.c | 87 2 files changed, 11 insertions(+), 77 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index f088685..e4ef12b 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -771,6 +771,7 @@ config COMEDI_ADV_PCI1724 config COMEDI_ADV_PCI_DIO tristate Advantech PCI DIO card support + select COMEDI_8254 select COMEDI_8255 ---help--- Enable support for Advantech PCI DIO cards diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index fb9de3a..a46cffe 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -36,7 +36,7 @@ Configuration options: #include ../comedidev.h #include 8255.h -#include 8253.h +#include comedi_8254.h /* hardware types of the cards */ enum hw_cards_id { @@ -481,71 +481,6 @@ static int pci_dio_insn_bits_do_w(struct comedi_device *dev, /* == */ -static int pci_8254_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - unsigned long timer_regbase = (unsigned long)s-private; - unsigned int chan = CR_CHAN(insn-chanspec); - unsigned long flags; - - spin_lock_irqsave(s-spin_lock, flags); - data[0] = i8254_read(dev-iobase + timer_regbase, 0, chan); - spin_unlock_irqrestore(s-spin_lock, flags); - return 1; -} - -/* -== -*/ -static int pci_8254_insn_write(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - unsigned long timer_regbase = (unsigned long)s-private; - unsigned int chan = CR_CHAN(insn-chanspec); - unsigned long flags; - - spin_lock_irqsave(s-spin_lock, flags); - i8254_write(dev-iobase + timer_regbase, 0, chan, data[0]); - spin_unlock_irqrestore(s-spin_lock, flags); - return 1; -} - -/* -== -*/ -static int pci_8254_insn_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - unsigned long timer_regbase = (unsigned long)s-private; - unsigned long iobase = dev-iobase + timer_regbase; - unsigned int chan = CR_CHAN(insn-chanspec); - int ret = 0; - unsigned long flags; - - spin_lock_irqsave(s-spin_lock, flags); - switch (data[0]) { - case INSN_CONFIG_SET_COUNTER_MODE: - ret = i8254_set_mode(iobase, 0, chan, data[1]); - if (ret 0) - ret = -EINVAL; - break; - case INSN_CONFIG_8254_READ_STATUS: - data[1] = i8254_status(iobase, 0, chan); - break; - default: - ret = -EINVAL; - break; - } - spin_unlock_irqrestore(s-spin_lock, flags); - return ret 0 ? ret : insn-n; -} - -/* -== -*/ static int pci1760_unchecked_mbxrequest(struct comedi_device *dev, unsigned char *omb, unsigned char *imb, int repeats) @@ -827,9 +762,6 @@ static int pci_dio_reset(struct comedi_device *dev) outb(0, dev-iobase + PCI1735_DO + 1); outb(0, dev-iobase + PCI1735_DO + 2); outb(0, dev-iobase + PCI1735_DO + 3); - i8254_set_mode(dev-iobase + PCI1735_C8254, 0, 0, I8254_MODE0); - i8254_set_mode(dev-iobase + PCI1735_C8254, 0, 1, I8254_MODE0); - i8254_set_mode(dev-iobase + PCI1735_C8254, 0, 2, I8254_MODE0); break; case TYPE_PCI1736: @@ -1108,14 +1040,15 @@ static int pci_dio_auto_attach(struct comedi_device *dev, if (this_board-timer_regbase) { s = dev-subdevices[subdev]; - s-type = COMEDI_SUBD_COUNTER; - s-subdev_flags = SDF_WRITABLE | SDF_READABLE; - s-n_chan = 3; - s-maxdata = 65535; - s-insn_read = pci_8254_insn_read; - s-insn_write =
[RFC PATCH 05/36] staging: comedi: pcl818: convert driver to use the comedi_8254 module
This driver uses an 8254 timer to generate the pacer clock used for analog input data acquisition. Convert it to use the comedi_8254 module to provide support for the 8254 timer. Note that the pacer does not have to be stopped when starting a new async command in pcl818_ai_cmd() or when the card is initialy reset by pcl818_reset(). The counters are all reset when the driver is initially attached and the counters used by the pacer are stopped when a command is canceled. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/pcl818.c | 80 - 2 files changed, 30 insertions(+), 51 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index ff8cb3a..3698f68 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -191,6 +191,7 @@ config COMEDI_PCL816 config COMEDI_PCL818 tristate Advantech PCL-718 and PCL-818 ISA card support select COMEDI_ISADMA if ISA_DMA_API + select COMEDI_8254 ---help--- Enable support for Advantech PCL-818 ISA cards PCL-818L, PCL-818H, PCL-818HD, PCL-818HG, PCL-818 and PCL-718 diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 7e4cdea..8d933dc 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -101,7 +101,7 @@ #include comedi_isadma.h #include comedi_fc.h -#include 8253.h +#include comedi_8254.h /* boards constants */ @@ -299,33 +299,15 @@ struct pcl818_private { struct comedi_isadma *dma; /* manimal allowed delay between samples (in us) for actual card */ unsigned int ns_min; - int i8253_osc_base; /* 1/frequency of on board oscilator in ns */ /* MUX setting for actual AI operations */ unsigned int act_chanlist[16]; unsigned int act_chanlist_len; /* how long is actual MUX list */ unsigned int act_chanlist_pos; /* actual position in MUX list */ - unsigned int divisor1; - unsigned int divisor2; unsigned int usefifo:1; unsigned int ai_cmd_running:1; unsigned int ai_cmd_canceled:1; }; -static void pcl818_start_pacer(struct comedi_device *dev, bool load_counters) -{ - struct pcl818_private *devpriv = dev-private; - unsigned long timer_base = dev-iobase + PCL818_TIMER_BASE; - - i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); - i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); - udelay(1); - - if (load_counters) { - i8254_write(timer_base, 0, 2, devpriv-divisor2); - i8254_write(timer_base, 0, 1, devpriv-divisor1); - } -} - static void pcl818_ai_setup_dma(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int unread_samples) @@ -663,9 +645,7 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { const struct pcl818_board *board = dev-board_ptr; - struct pcl818_private *devpriv = dev-private; int err = 0; - unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -712,11 +692,9 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, /* step 4: fix up any arguments */ if (cmd-convert_src == TRIG_TIMER) { - arg = cmd-convert_arg; - i8253_cascade_ns_to_timer(devpriv-i8253_osc_base, - devpriv-divisor1, - devpriv-divisor2, - arg, cmd-flags); + unsigned int arg = cmd-convert_arg; + + comedi_8254_cascade_ns_to_timer(dev-pacer, arg, cmd-flags); err |= cfc_check_trigger_arg_is(cmd-convert_arg, arg); } @@ -746,8 +724,6 @@ static int pcl818_ai_cmd(struct comedi_device *dev, if (devpriv-ai_cmd_running) return -EBUSY; - pcl818_start_pacer(dev, false); - seglen = check_channel_list(dev, s, cmd-chanlist, cmd-chanlist_len); if (seglen 1) return -EINVAL; @@ -779,8 +755,10 @@ static int pcl818_ai_cmd(struct comedi_device *dev, } outb(ctrl, dev-iobase + PCL818_CTRL_REG); - if (cmd-convert_src == TRIG_TIMER) - pcl818_start_pacer(dev, true); + if (cmd-convert_src == TRIG_TIMER) { + comedi_8254_update_divisors(dev-pacer); + comedi_8254_pacer_enable(dev-pacer, 1, 2, true); + } return 0; } @@ -812,7 +790,7 @@ static int pcl818_ai_cancel(struct comedi_device *dev, }
[RFC PATCH 19/36] staging: comedi: das1800: convert driver to use the comedi_8254 module
This driver uses an 8254 timer to generate the pacer clock used for analog input data conversion. Convert it to use the comedi_8254 module to provide support for the 8254 timer. Tidy up the (*do_cmdtest) validation of the timer arguments. Absorb the converted das1800_setup_counters() code into the (*do_cmd). Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/das1800.c | 81 2 files changed, 30 insertions(+), 52 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index fbff2fa..f088685 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -316,6 +316,7 @@ config COMEDI_DAS800 config COMEDI_DAS1800 tristate DAS1800 and compatible ISA card support select COMEDI_ISADMA if ISA_DMA_API + select COMEDI_8254 ---help--- Enable support for DAS1800 and compatible ISA cards Keithley Metrabyte DAS-1701ST, DAS-1701ST-DA, DAS-1701/AO, diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 0790a28..3eb02e8 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -103,7 +103,7 @@ TODO: #include comedi_isadma.h #include comedi_fc.h -#include 8253.h +#include comedi_8254.h /* misc. defines */ #define DAS1800_SIZE 16 /* uses 16 io addresses */ @@ -422,8 +422,6 @@ static const struct das1800_board das1800_boards[] = { struct das1800_private { struct comedi_isadma *dma; - unsigned int divisor1; /* value to load into board's counter 1 for timed conversions */ - unsigned int divisor2; /* value to load into board's counter 2 for timed conversions */ int irq_dma_bits; /* bits for control register b */ /* dma bits for control register b, stored so that dma can be * turned on and off */ @@ -731,7 +729,6 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_cmd *cmd) { const struct das1800_board *thisboard = dev-board_ptr; - struct das1800_private *devpriv = dev-private; int err = 0; unsigned int arg; @@ -795,35 +792,23 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev, cmd-convert_src == TRIG_TIMER) { /* we are not in burst mode */ arg = cmd-convert_arg; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ, - devpriv-divisor1, - devpriv-divisor2, - cmd-convert_arg, cmd-flags); - if (arg != cmd-convert_arg) - err++; + comedi_8254_cascade_ns_to_timer(dev-pacer, arg, cmd-flags); + err |= cfc_check_trigger_arg_is(cmd-convert_arg, arg); } else if (cmd-convert_src == TRIG_TIMER) { /* we are in burst mode */ - arg = cmd-convert_arg; - cmd-convert_arg = burst_convert_arg(cmd-convert_arg, -cmd-flags); - if (arg != cmd-convert_arg) - err++; + arg = burst_convert_arg(cmd-convert_arg, cmd-flags); + err |= cfc_check_trigger_arg_is(cmd-convert_arg, arg); if (cmd-scan_begin_src == TRIG_TIMER) { arg = cmd-convert_arg * cmd-chanlist_len; - if (arg cmd-scan_begin_arg) { - cmd-scan_begin_arg = arg; - err++; - } + err |= cfc_check_trigger_arg_max(cmd-scan_begin_arg, +arg); arg = cmd-scan_begin_arg; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ, - devpriv-divisor1, - devpriv-divisor2, - cmd-scan_begin_arg, - cmd-flags); - if (arg != cmd-scan_begin_arg) - err++; + comedi_8254_cascade_ns_to_timer(dev-pacer, arg, + cmd-flags); + err |= cfc_check_trigger_arg_is(cmd-scan_begin_arg, + arg); } } @@ -910,31 +895,6 @@ static int control_c_bits(const struct comedi_cmd *cmd) return control_c; } -static void das1800_setup_counters(struct comedi_device *dev, -
[RFC PATCH 00/36] staging: comedi: cleanup 8254 timer code
This series introduces a new module. comedi_8254, to support the 8254 timer devices that are commonly found on data acquisition card. This module replaces the current support provided by the inline functions in 8253.h and consolidates the subdevice support code found in the comedi drivers. H Hartley Sweeten (36): staging: comedi: comedi_8254: introduce module for 8254 timer support staging: comedi: add 'pacer' member to struct comedi_device staging: comedi: pcl812: convert driver to use the comedi_8254 module staging: comedi: pcl816: convert driver to use the comedi_8254 module staging: comedi: pcl818: convert driver to use the comedi_8254 module staging: comedi: pcl711: convert driver to use the comedi_8254 module staging: comedi: adl_pci9111: convert driver to use the comedi_8254 module staging: comedi: amplc_pci224: convert driver to use the comedi_8254 module staging: comedi: cb_pcidas: convert driver to use the comedi_8254 module staging: comedi: das800: convert driver to use the comedi_8254 module staging: comedi: das16m1: convert driver to use the comedi_8254 module staging: comedi: cb_das16_cs: convert driver to use the comedi_8254 module staging: comedi: adv_pci1710: convert driver to use the comedi_8254 module staging: comedi: amplc_pci230: convert driver to use the comedi_8254 module staging: comedi: das08: convert driver to use the comedi_8254 module staging: comedi: ni_at_ao: convert driver to use the comedi_8254 module staging: comedi: ni_at_a2150: convert driver to use the comedi_8254 module staging: comedi: das6402: convert driver to use the comedi_8254 module staging: comedi: das1800: convert driver to use the comedi_8254 module staging: comedi: adv_pci_dio: simplify counter subdevice I/O staging: comedi: adv_pci_dio: refactor 's8254' boardinfo staging: comedi: adv_pci_dio: convert driver to use the comedi_8254 module staging: comedi: me4000: convert driver to use the comedi_8254 module staging: comedi: cb_pcidas64: remove unnecessary include staging: comedi: das16: convert driver to use the comedi_8254 module staging: comedi: adl_pci9118: convert driver to use the comedi_8254 module staging: comedi: amplc_dio200_common: introduce DIO200_CLK_SEL() macro staging: comedi: amplc_dio200_common: introduce DIO200_GAT_SEL() macro staging: comedi: amplc_dio200_common: remove 'clk_sce_ofs' from struct dio200_subdev_8254 staging: comedi: amplc_dio200_common: remove 'gat_sce_ofs' from struct dio200_subdev_8254 staging: comedi: amplc_dio200_common: remove 'which' from struct dio200_subdev_8254 staging: comedi: amplc_dio200_common: remove unnecessary 'counter_number' checks staging: comedi: amplc_dio200_common: remove 'spinlock' from struct dio200_subdev_8254 staging: comedi: amplc_dio200_common: convert driver to use the comedi_8254 module staging: comedi: ni_labpc_common: convert driver to use the comedi_8254 module staging: comedi: 8253.h: remove unused header drivers/staging/comedi/Kconfig | 26 + drivers/staging/comedi/comedidev.h | 1 + drivers/staging/comedi/drivers.c | 2 + drivers/staging/comedi/drivers/8253.h | 347 --- drivers/staging/comedi/drivers/Makefile| 1 + drivers/staging/comedi/drivers/adl_pci9111.c | 39 +- drivers/staging/comedi/drivers/adl_pci9118.c | 93 +-- drivers/staging/comedi/drivers/adv_pci1710.c | 206 ++- drivers/staging/comedi/drivers/adv_pci_dio.c | 135 + .../staging/comedi/drivers/amplc_dio200_common.c | 304 +++--- drivers/staging/comedi/drivers/amplc_pci224.c | 34 +- drivers/staging/comedi/drivers/amplc_pci230.c | 47 +- drivers/staging/comedi/drivers/cb_das16_cs.c | 12 +- drivers/staging/comedi/drivers/cb_pcidas.c | 86 +-- drivers/staging/comedi/drivers/cb_pcidas64.c | 1 - drivers/staging/comedi/drivers/comedi_8254.c | 665 + drivers/staging/comedi/drivers/comedi_8254.h | 133 + drivers/staging/comedi/drivers/das08.c | 77 +-- drivers/staging/comedi/drivers/das16.c | 44 +- drivers/staging/comedi/drivers/das16m1.c | 79 ++- drivers/staging/comedi/drivers/das1800.c | 81 +-- drivers/staging/comedi/drivers/das6402.c | 51 +- drivers/staging/comedi/drivers/das800.c| 38 +- drivers/staging/comedi/drivers/me4000.c| 108 +--- drivers/staging/comedi/drivers/ni_at_a2150.c | 17 +- drivers/staging/comedi/drivers/ni_at_ao.c | 14 +- drivers/staging/comedi/drivers/ni_labpc.c | 1 + drivers/staging/comedi/drivers/ni_labpc.h | 16 +- drivers/staging/comedi/drivers/ni_labpc_common.c | 182 +++--- drivers/staging/comedi/drivers/ni_labpc_cs.c | 14 +- drivers/staging/comedi/drivers/ni_labpc_pci.c | 8 +- drivers/staging/comedi/drivers/pcl711.c|
[RFC PATCH 07/36] staging: comedi: adl_pci9111: convert driver to use the comedi_8254 module
This driver uses an 8254 timer to generate the pacer clock used for analog input data acquisition. Convert it to use the comedi_8254 module to provide support for the 8254 timer. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/adl_pci9111.c | 39 +++- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index b92fa05..de1d7ad 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -719,6 +719,7 @@ config COMEDI_ADL_PCI8164 config COMEDI_ADL_PCI9111 tristate ADLink PCI-9111HR support + select COMEDI_8254 ---help--- Enable support for ADlink PCI9111 cards diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index f68dc99..26cd860 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -71,9 +71,9 @@ TODO: #include ../comedidev.h -#include 8253.h #include plx9052.h #include comedi_fc.h +#include comedi_8254.h #define PCI9111_FIFO_HALF_SIZE 512 @@ -137,9 +137,6 @@ struct pci9111_private_data { unsigned int chunk_counter; unsigned int chunk_num_samples; - unsigned int div1; - unsigned int div2; - unsigned short ai_bounce_buffer[2 * PCI9111_FIFO_HALF_SIZE]; }; @@ -167,21 +164,6 @@ static void plx9050_interrupt_control(unsigned long io_base, outb(flags, io_base + PLX9052_INTCSR); } -static void pci9111_timer_set(struct comedi_device *dev) -{ - struct pci9111_private_data *dev_private = dev-private; - unsigned long timer_base = dev-iobase + PCI9111_8254_BASE_REG; - - i8254_set_mode(timer_base, 1, 0, I8254_MODE0 | I8254_BINARY); - i8254_set_mode(timer_base, 1, 1, I8254_MODE2 | I8254_BINARY); - i8254_set_mode(timer_base, 1, 2, I8254_MODE2 | I8254_BINARY); - - udelay(1); - - i8254_write(timer_base, 1, 2, dev_private-div2); - i8254_write(timer_base, 1, 1, dev_private-div1); -} - enum pci9111_ISC0_sources { irq_on_eoc, irq_on_fifo_half_full @@ -281,7 +263,6 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - struct pci9111_private_data *dev_private = dev-private; int err = 0; unsigned int arg; @@ -345,10 +326,7 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev, if (cmd-convert_src == TRIG_TIMER) { arg = cmd-convert_arg; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ, - dev_private-div1, - dev_private-div2, - arg, cmd-flags); + comedi_8254_cascade_ns_to_timer(dev-pacer, arg, cmd-flags); err |= cfc_check_trigger_arg_is(cmd-convert_arg, arg); } @@ -406,7 +384,8 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, dev_private-scan_delay = 0; if (cmd-convert_src == TRIG_TIMER) { trig |= PCI9111_AI_TRIG_CTRL_TPST; - pci9111_timer_set(dev); + comedi_8254_update_divisors(dev-pacer); + comedi_8254_pacer_enable(dev-pacer, 1, 2, true); pci9111_fifo_reset(dev); pci9111_interrupt_source_set(dev, irq_on_fifo_half_full, irq_on_timer_tick); @@ -667,11 +646,6 @@ static int pci9111_reset(struct comedi_device *dev) /* disable A/D triggers (software trigger mode) and auto scan off */ outb(0, dev-iobase + PCI9111_AI_TRIG_CTRL_REG); - /* Reset 8254 chip */ - dev_private-div1 = 0; - dev_private-div2 = 0; - pci9111_timer_set(dev); - return 0; } @@ -702,6 +676,11 @@ static int pci9111_auto_attach(struct comedi_device *dev, dev-irq = pcidev-irq; } + dev-pacer = comedi_8254_init(dev-iobase + PCI9111_8254_BASE_REG, + I8254_OSC_BASE_2MHZ, I8254_IO16, 1); + if (!dev-pacer) + return -ENOMEM; + ret = comedi_alloc_subdevices(dev, 4); if (ret) return ret; -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC PATCH 09/36] staging: comedi: cb_pcidas: convert driver to use the comedi_8254 module
This driver uses two 8254 timers to generate the pacer clocks. One for analog input acquisition and one for analog output data conversion. Convert it to use the comedi_8254 module to provide support for the 8254 timers. Use the comedi_device 'pacer' member for the 8254 timer used for analog input. This data is freed automatically by the core during the detach of the driver. Store the data for the 8254 timer used for analog output in the private data. This data needs to be freed by the driver when it is detached. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/cb_pcidas.c | 86 -- 2 files changed, 34 insertions(+), 53 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 98a62e3..c15cce4 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -918,6 +918,7 @@ config COMEDI_CB_PCIDAS64 config COMEDI_CB_PCIDAS tristate MeasurementComputing PCI-DAS support + select COMEDI_8254 select COMEDI_8255 ---help--- Enable support for ComputerBoards/MeasurementComputing PCI-DAS with diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index dd0c65a..b6ef4b4 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -68,7 +68,7 @@ analog triggering on 1602 series #include ../comedidev.h -#include 8253.h +#include comedi_8254.h #include 8255.h #include amcc_s5933.h #include comedi_fc.h @@ -338,14 +338,12 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = { }; struct cb_pcidas_private { + struct comedi_8254 *ao_pacer; /* base addresses */ unsigned long s5933_config; unsigned long control_status; unsigned long adc_fifo; unsigned long ao_registers; - /* divisors of master clock for analog input pacing */ - unsigned int divisor1; - unsigned int divisor2; /* bits to write to registers */ unsigned int adc_fifo_bits; unsigned int s5933_intcsr_bits; @@ -353,9 +351,6 @@ struct cb_pcidas_private { /* fifo buffers */ unsigned short ai_buffer[AI_BUFFER_SIZE]; unsigned short ao_buffer[AO_BUFFER_SIZE]; - /* divisors of master clock for analog output pacing */ - unsigned int ao_divisor1; - unsigned int ao_divisor2; unsigned int calibration_source; }; @@ -778,7 +773,6 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, struct comedi_cmd *cmd) { const struct cb_pcidas_board *thisboard = dev-board_ptr; - struct cb_pcidas_private *devpriv = dev-private; int err = 0; unsigned int arg; @@ -858,18 +852,12 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, if (cmd-scan_begin_src == TRIG_TIMER) { arg = cmd-scan_begin_arg; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - devpriv-divisor1, - devpriv-divisor2, - arg, cmd-flags); + comedi_8254_cascade_ns_to_timer(dev-pacer, arg, cmd-flags); err |= cfc_check_trigger_arg_is(cmd-scan_begin_arg, arg); } if (cmd-convert_src == TRIG_TIMER) { arg = cmd-convert_arg; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - devpriv-divisor1, - devpriv-divisor2, - arg, cmd-flags); + comedi_8254_cascade_ns_to_timer(dev-pacer, arg, cmd-flags); err |= cfc_check_trigger_arg_is(cmd-convert_arg, arg); } @@ -886,18 +874,6 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, return 0; } -static void cb_pcidas_ai_load_counters(struct comedi_device *dev) -{ - struct cb_pcidas_private *devpriv = dev-private; - unsigned long timer_base = dev-iobase + ADC8254; - - i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); - i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); - - i8254_write(timer_base, 0, 1, devpriv-divisor1); - i8254_write(timer_base, 0, 2, devpriv-divisor2); -} - static int cb_pcidas_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -933,8 +909,11 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev, outw(bits, devpriv-control_status + ADCMUX_CONT); /* load counters */ - if (cmd-scan_begin_src == TRIG_TIMER || cmd-convert_src == TRIG_TIMER) - cb_pcidas_ai_load_counters(dev); + if
[RFC PATCH 12/36] staging: comedi: cb_das16_cs: convert driver to use the comedi_8254 module
The hardware supported by this drive has an 8254 timer. Currently this driver does not use the timer functions. For aesthetics, use the comedi_8254 module to provide support for the 8254 timer. This will ensure that the counters are all reset and make it easier to add functionality later. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/cb_das16_cs.c | 12 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 9b7a0d7..85c5c87 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -1100,6 +1100,7 @@ if COMEDI_PCMCIA_DRIVERS config COMEDI_CB_DAS16_CS tristate CB DAS16 series PCMCIA support + select COMEDI_8254 ---help--- Enable support for the ComputerBoards/MeasurementComputing PCMCIA cards DAS16/16, PCM-DAS16D/12 and PCM-DAS16s/16 diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index 1079b6c..e7612cb 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -41,16 +41,13 @@ Status: experimental #include ../comedi_pcmcia.h #include comedi_fc.h -#include 8253.h +#include comedi_8254.h #define DAS16CS_ADC_DATA 0 #define DAS16CS_DIO_MUX2 #define DAS16CS_MISC1 4 #define DAS16CS_MISC2 6 -#define DAS16CS_CTR0 8 -#define DAS16CS_CTR1 10 -#define DAS16CS_CTR2 12 -#define DAS16CS_CTR_CONTROL14 +#define DAS16CS_TIMER_BASE 8 #define DAS16CS_DIO16 struct das16cs_board { @@ -279,6 +276,11 @@ static int das16cs_auto_attach(struct comedi_device *dev, if (!devpriv) return -ENOMEM; + dev-pacer = comedi_8254_init(dev-iobase + DAS16CS_TIMER_BASE, + I8254_OSC_BASE_10MHZ, I8254_IO16, 1); + if (!dev-pacer) + return -ENOMEM; + ret = comedi_alloc_subdevices(dev, 3); if (ret) return ret; -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC PATCH 04/36] staging: comedi: pcl816: convert driver to use the comedi_8254 module
This driver uses an 8254 timer to generate the pacer clock used for analog input data conversion. Convert it to use the comedi_8254 module to provide support for the 8254 timer. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/pcl816.c | 59 + 2 files changed, 16 insertions(+), 44 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 4691355..ff8cb3a 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -181,6 +181,7 @@ config COMEDI_PCL812 config COMEDI_PCL816 tristate Advantech PCL-814 and PCL-816 ISA card support select COMEDI_ISADMA if ISA_DMA_API + select COMEDI_8254 ---help--- Enable support for Advantech PCL-814 and PCL-816 ISA cards diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index da35edf..9cc6933 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -42,7 +42,7 @@ Configuration Options: #include comedi_isadma.h #include comedi_fc.h -#include 8253.h +#include comedi_8254.h /* * Register I/O map @@ -116,31 +116,10 @@ static const struct pcl816_board boardtypes[] = { struct pcl816_private { struct comedi_isadma *dma; unsigned int ai_poll_ptr; /* how many sampes transfer poll */ - unsigned int divisor1; - unsigned int divisor2; unsigned int ai_cmd_running:1; unsigned int ai_cmd_canceled:1; }; -static void pcl816_start_pacer(struct comedi_device *dev, bool load_counters) -{ - struct pcl816_private *devpriv = dev-private; - unsigned long timer_base = dev-iobase + PCL816_TIMER_BASE; - - i8254_set_mode(timer_base, 0, 0, I8254_MODE1 | I8254_BINARY); - i8254_write(timer_base, 0, 0, 0x00ff); - udelay(1); - - i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); - i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); - udelay(1); - - if (load_counters) { - i8254_write(timer_base, 0, 2, devpriv-divisor2); - i8254_write(timer_base, 0, 1, devpriv-divisor1); - } -} - static void pcl816_ai_setup_dma(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int unread_samples) @@ -367,9 +346,7 @@ static int check_channel_list(struct comedi_device *dev, static int pcl816_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - struct pcl816_private *devpriv = dev-private; int err = 0; - unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -416,11 +393,9 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd-convert_src == TRIG_TIMER) { - arg = cmd-convert_arg; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - devpriv-divisor1, - devpriv-divisor2, - arg, cmd-flags); + unsigned int arg = cmd-convert_arg; + + comedi_8254_cascade_ns_to_timer(dev-pacer, arg, cmd-flags); err |= cfc_check_trigger_arg_is(cmd-convert_arg, arg); } @@ -450,8 +425,6 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (devpriv-ai_cmd_running) return -EBUSY; - pcl816_start_pacer(dev, false); - seglen = check_channel_list(dev, s, cmd-chanlist, cmd-chanlist_len); if (seglen 1) return -EINVAL; @@ -466,7 +439,11 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) dma-cur_dma = 0; pcl816_ai_setup_dma(dev, s, 0); - pcl816_start_pacer(dev, true); + comedi_8254_set_mode(dev-pacer, 0, I8254_MODE1 | I8254_BINARY); + comedi_8254_write(dev-pacer, 0, 0x0ff); + udelay(1); + comedi_8254_update_divisors(dev-pacer); + comedi_8254_pacer_enable(dev-pacer, 1, 2, true); ctrl = PCL816_CTRL_INTEN | PCL816_CTRL_DMAEN | PCL816_CTRL_DMASRC_SLOT0; if (cmd-convert_src == TRIG_TIMER) @@ -525,11 +502,7 @@ static int pcl816_ai_cancel(struct comedi_device *dev, outb(PCL816_CTRL_DISABLE_TRIG, dev-iobase + PCL816_CTRL_REG); pcl816_ai_clear_eoc(dev); - /* Stop pacer */ - i8254_set_mode(dev-iobase + PCL816_TIMER_BASE, 0, - 2, I8254_MODE0 | I8254_BINARY); - i8254_set_mode(dev-iobase + PCL816_TIMER_BASE, 0, - 1, I8254_MODE0 | I8254_BINARY); +
[RFC PATCH 18/36] staging: comedi: das6402: convert driver to use the comedi_8254 module
This driver uses an 8254 timer to generate the pacer clock used for analog input data conversion. Convert it to use the comedi_8254 module to provide support for the 8254 timer. Remove the unnecessary programming of timer 0. The private data 'count' value is never set by the driver and the timer is reset to MODE0 when the timers are initialized during the attach of the driver. Remove the unnecessart convert_src check in the (*do_cmdtest). The only valid convert_src is TRIG_TIMER. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/das6402.c | 51 2 files changed, 13 insertions(+), 39 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index b90b8a8..fbff2fa 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -329,6 +329,7 @@ config COMEDI_DAS1800 config COMEDI_DAS6402 tristate DAS6402 and compatible ISA card support + select COMEDI_8254 ---help--- Enable support for DAS6402 and compatible ISA cards Computerboards, Keithley Metrabyte DAS6402 and compatibles diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c index b8755b5..3aa6b13 100644 --- a/drivers/staging/comedi/drivers/das6402.c +++ b/drivers/staging/comedi/drivers/das6402.c @@ -35,8 +35,9 @@ #include linux/interrupt.h #include ../comedidev.h + #include comedi_fc.h -#include 8253.h +#include comedi_8254.h /* * Register I/O map @@ -138,11 +139,6 @@ static struct das6402_boardinfo das6402_boards[] = { struct das6402_private { unsigned int irq; - - unsigned int count; - unsigned int divider1; - unsigned int divider2; - unsigned int ao_range; }; @@ -172,27 +168,6 @@ static void das6402_ai_clear_eoc(struct comedi_device *dev) outb(DAS6402_STATUS_W_CLRINT, dev-iobase + DAS6402_STATUS_REG); } -static void das6402_enable_counter(struct comedi_device *dev, bool load) -{ - struct das6402_private *devpriv = dev-private; - unsigned long timer_iobase = dev-iobase + DAS6402_TIMER_BASE; - - if (load) { - i8254_set_mode(timer_iobase, 0, 0, I8254_MODE0 | I8254_BINARY); - i8254_set_mode(timer_iobase, 0, 1, I8254_MODE2 | I8254_BINARY); - i8254_set_mode(timer_iobase, 0, 2, I8254_MODE2 | I8254_BINARY); - - i8254_write(timer_iobase, 0, 0, devpriv-count); - i8254_write(timer_iobase, 0, 1, devpriv-divider1); - i8254_write(timer_iobase, 0, 2, devpriv-divider2); - - } else { - i8254_set_mode(timer_iobase, 0, 0, I8254_MODE0 | I8254_BINARY); - i8254_set_mode(timer_iobase, 0, 1, I8254_MODE0 | I8254_BINARY); - i8254_set_mode(timer_iobase, 0, 2, I8254_MODE0 | I8254_BINARY); - } -} - static unsigned int das6402_ai_read_sample(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -267,7 +242,8 @@ static int das6402_ai_cmd(struct comedi_device *dev, outw(DAS6402_AI_MUX_HI(chan_hi) | DAS6402_AI_MUX_LO(chan_lo), dev-iobase + DAS6402_AI_MUX_REG); - das6402_enable_counter(dev, true); + comedi_8254_update_divisors(dev-pacer); + comedi_8254_pacer_enable(dev-pacer, 1, 2, true); /* enable interrupt and pacer trigger */ outb(DAS6402_CTRL_INTE | @@ -322,7 +298,6 @@ static int das6402_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - struct das6402_private *devpriv = dev-private; int err = 0; unsigned int arg; @@ -364,14 +339,9 @@ static int das6402_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ - if (cmd-convert_src == TRIG_TIMER) { - arg = cmd-convert_arg; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - devpriv-divider1, - devpriv-divider2, - arg, cmd-flags); - err |= cfc_check_trigger_arg_is(cmd-convert_arg, arg); - } + arg = cmd-convert_arg; + comedi_8254_cascade_ns_to_timer(dev-pacer, arg, cmd-flags); + err |= cfc_check_trigger_arg_is(cmd-convert_arg, arg); if (err) return 4; @@ -581,8 +551,6 @@ static void das6402_reset(struct comedi_device *dev) outw(0, dev-iobase + DAS6402_AO_DATA_REG(0)); inw(dev-iobase + DAS6402_AO_LSB_REG(0)); - das6402_enable_counter(dev, false); - /* set all digital outputs low */ outb(0, dev-iobase + DAS6402_DI_DO_REG); @@ -631,6 +599,11 @@ static int
[RFC PATCH 03/36] staging: comedi: pcl812: convert driver to use the comedi_8254 module
This driver uses an 8254 timer to generate the pacer clock used for analog input data acquisition. Convert it to use the comedi_8254 module to provide support for the 8254 timer. Note that the pacer does not have to be stopped when starting a new async command in pcl812_ai_cmd() or when the card is initialy reset by pcl812_reset(). The counters are all reset when the driver is initially attached and the counters used by the pacer are stopped when a command is canceled. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/pcl812.c | 57 - 2 files changed, 21 insertions(+), 37 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index a2577ba..4691355 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -169,6 +169,7 @@ config COMEDI_PCL730 config COMEDI_PCL812 tristate Advantech PCL-812/813 and ADlink ACL-8112/8113/8113/8216 select COMEDI_ISADMA if ISA_DMA_API + select COMEDI_8254 ---help--- Enable support for Advantech PCL-812/PG, PCL-813/B, ADLink ACL-8112DG/HG/PG, ACL-8113, ACL-8216, ICP DAS A-821PGH/PGL/PGL-NDA, diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 3ffb1ea..1bb67aa 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -118,7 +118,7 @@ #include comedi_isadma.h #include comedi_fc.h -#include 8253.h +#include comedi_8254.h /* hardware types of the cards */ #define boardPCL812PG0 /* and ACL-8112PG */ @@ -513,8 +513,6 @@ struct pcl812_private { unsigned char mode_reg_int; /* there is stored INT number for some card */ unsigned int ai_poll_ptr; /* how many sampes transfer poll */ unsigned int max_812_ai_mode0_rangewait;/* setling time for gain */ - unsigned int divisor1; - unsigned int divisor2; unsigned int use_diff:1; unsigned int use_mpc508:1; unsigned int use_ext_trg:1; @@ -522,21 +520,6 @@ struct pcl812_private { unsigned int ai_eos:1; }; -static void pcl812_start_pacer(struct comedi_device *dev, bool load_timers) -{ - struct pcl812_private *devpriv = dev-private; - unsigned long timer_base = dev-iobase + PCL812_TIMER_BASE; - - i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); - i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); - udelay(1); - - if (load_timers) { - i8254_write(timer_base, 0, 2, devpriv-divisor2); - i8254_write(timer_base, 0, 1, devpriv-divisor1); - } -} - static void pcl812_ai_setup_dma(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int unread_samples) @@ -650,7 +633,6 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, struct pcl812_private *devpriv = dev-private; int err = 0; unsigned int flags; - unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -703,11 +685,9 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd-convert_src == TRIG_TIMER) { - arg = cmd-convert_arg; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ, - devpriv-divisor1, - devpriv-divisor2, - arg, cmd-flags); + unsigned int arg = cmd-convert_arg; + + comedi_8254_cascade_ns_to_timer(dev-pacer, arg, cmd-flags); err |= cfc_check_trigger_arg_is(cmd-convert_arg, arg); } @@ -725,8 +705,6 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) unsigned int ctrl = 0; unsigned int i; - pcl812_start_pacer(dev, false); - pcl812_ai_set_chan_range(dev, cmd-chanlist[0], 1); if (dma) { /* check if we can use DMA transfer */ @@ -760,7 +738,8 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) switch (cmd-convert_src) { case TRIG_TIMER: - pcl812_start_pacer(dev, true); + comedi_8254_update_divisors(dev-pacer); + comedi_8254_pacer_enable(dev-pacer, 1, 2, true); break; } @@ -918,7 +897,7 @@ static int pcl812_ai_cancel(struct comedi_device *dev, outb(devpriv-mode_reg_int | PCL812_CTRL_DISABLE_TRIG, dev-iobase + PCL812_CTRL_REG); - pcl812_start_pacer(dev, false); + comedi_8254_pacer_enable(dev-pacer, 1, 2, false); pcl812_ai_clear_eoc(dev); return 0; }
[RFC PATCH 16/36] staging: comedi: ni_at_ao: convert driver to use the comedi_8254 module
The hardware supported by this driver includes an 8254 timer. This timer is not currently used, other than setting counters 1 and 2 to MODE4 to ensure that the outputs are high. For aesthetics, convert it to use the comedi_8254 module to provide support for the 8254 timer. This will make it easier to add features later. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig| 1 + drivers/staging/comedi/drivers/ni_at_ao.c | 14 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 8d636ec..20a906d 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -477,6 +477,7 @@ config COMEDI_NI_AT_A2150 config COMEDI_NI_AT_AO tristate NI AT-AO-6/10 EISA card support + select COMEDI_8254 ---help--- Enable support for National Instruments AT-AO-6/10 cards diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c index 9eeaf3c..f27aa0e 100644 --- a/drivers/staging/comedi/drivers/ni_at_ao.c +++ b/drivers/staging/comedi/drivers/ni_at_ao.c @@ -37,7 +37,7 @@ #include ../comedidev.h -#include 8253.h +#include comedi_8254.h /* * Register map @@ -274,7 +274,6 @@ static int atao_calib_insn_write(struct comedi_device *dev, static void atao_reset(struct comedi_device *dev) { struct atao_private *devpriv = dev-private; - unsigned long timer_base = dev-iobase + ATAO_82C53_BASE; /* This is the reset sequence described in the manual */ @@ -282,9 +281,9 @@ static void atao_reset(struct comedi_device *dev) outw(devpriv-cfg1, dev-iobase + ATAO_CFG1_REG); /* Put outputs of counter 1 and counter 2 in a high state */ - i8254_set_mode(timer_base, 0, 0, I8254_MODE4 | I8254_BINARY); - i8254_set_mode(timer_base, 0, 1, I8254_MODE4 | I8254_BINARY); - i8254_write(timer_base, 0, 0, 0x0003); + comedi_8254_set_mode(dev-pacer, 0, I8254_MODE4 | I8254_BINARY); + comedi_8254_set_mode(dev-pacer, 1, I8254_MODE4 | I8254_BINARY); + comedi_8254_write(dev-pacer, 0, 0x0003); outw(ATAO_CFG2_CALLD_NOP, dev-iobase + ATAO_CFG2_REG); @@ -315,6 +314,11 @@ static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (!devpriv) return -ENOMEM; + dev-pacer = comedi_8254_init(dev-iobase + ATAO_82C53_BASE, + 0, I8254_IO8, 0); + if (!dev-pacer) + return -ENOMEM; + ret = comedi_alloc_subdevices(dev, 4); if (ret) return ret; -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC PATCH 10/36] staging: comedi: das800: convert driver to use the comedi_8254 module
This driver uses an 8254 timer to generate the pacer clock used for analog input data acquisition. Convert it to use the comedi_8254 module to provide support for the 8254 timer. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/das800.c | 38 +++-- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index c15cce4..8de03c8 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -302,6 +302,7 @@ config COMEDI_DAS16 config COMEDI_DAS800 tristate DAS800 and compatible ISA card support + select COMEDI_8254 ---help--- Enable support for Keithley Metrabyte DAS800 and compatible ISA cards Keithley Metrabyte DAS-800, DAS-801, DAS-802 diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index ff7f4be..50ca03b 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -58,12 +58,12 @@ cmd triggers supported: #include linux/module.h #include linux/interrupt.h -#include ../comedidev.h - #include linux/delay.h -#include 8253.h +#include ../comedidev.h + #include comedi_fc.h +#include comedi_8254.h #define N_CHAN_AI 8/* number of analog input channels */ @@ -219,8 +219,6 @@ static const struct das800_board das800_boards[] = { }; struct das800_private { - unsigned int divisor1; /* counter 1 value for timed conversions */ - unsigned int divisor2; /* counter 2 value for timed conversions */ unsigned int do_bits; /* digital output bits */ }; @@ -272,17 +270,6 @@ static void das800_disable(struct comedi_device *dev) spin_unlock_irqrestore(dev-spinlock, irq_flags); } -static void das800_set_frequency(struct comedi_device *dev) -{ - struct das800_private *devpriv = dev-private; - unsigned long timer_base = dev-iobase + DAS800_8254; - - i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); - i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); - i8254_write(timer_base, 0, 1, devpriv-divisor1); - i8254_write(timer_base, 0, 2, devpriv-divisor2); -} - static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { das800_disable(dev); @@ -322,9 +309,7 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_cmd *cmd) { const struct das800_board *thisboard = dev-board_ptr; - struct das800_private *devpriv = dev-private; int err = 0; - unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -370,11 +355,9 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd-convert_src == TRIG_TIMER) { - arg = cmd-convert_arg; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_1MHZ, - devpriv-divisor1, - devpriv-divisor2, - arg, cmd-flags); + unsigned int arg = cmd-convert_arg; + + comedi_8254_cascade_ns_to_timer(dev-pacer, arg, cmd-flags); err |= cfc_check_trigger_arg_is(cmd-convert_arg, arg); } @@ -426,8 +409,8 @@ static int das800_ai_do_cmd(struct comedi_device *dev, conv_bits |= DTEN; if (cmd-convert_src == TRIG_TIMER) { conv_bits |= CASC | ITE; - /* set conversion frequency */ - das800_set_frequency(dev); + comedi_8254_update_divisors(dev-pacer); + comedi_8254_pacer_enable(dev-pacer, 1, 2, true); } spin_lock_irqsave(dev-spinlock, irq_flags); @@ -697,6 +680,11 @@ static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it) dev-irq = irq; } + dev-pacer = comedi_8254_init(dev-iobase + DAS800_8254, + I8254_OSC_BASE_1MHZ, I8254_IO8, 0); + if (!dev-pacer) + return -ENOMEM; + ret = comedi_alloc_subdevices(dev, 3); if (ret) return ret; -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC PATCH 35/36] staging: comedi: ni_labpc_common: convert driver to use the comedi_8254 module
This driver uses an 8254 timer to generate the pacer clock used for analog input data conversion. Convert it to use the comedi_8254 module to provide support for the 8254 timer. The hardware actually has two 8254 devices. Timer B0 is the master for timed conversions, timer B1 sets the scan pacing, and tmer A0 sets the conversion pacing. For the conversion, dev-pacer is used for the B timers and a new private data member, dev-counter, is used for the A timers. All the divisor values are stored in the dev-pacer. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/ni_labpc.c| 1 + drivers/staging/comedi/drivers/ni_labpc.h| 16 +- drivers/staging/comedi/drivers/ni_labpc_common.c | 182 +++ drivers/staging/comedi/drivers/ni_labpc_cs.c | 14 +- drivers/staging/comedi/drivers/ni_labpc_pci.c| 8 +- 6 files changed, 111 insertions(+), 111 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index ebda03c..737994a 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -1292,6 +1292,7 @@ config COMEDI_ISADMA config COMEDI_NI_LABPC tristate + select COMEDI_8254 select COMEDI_8255 config COMEDI_NI_LABPC_ISADMA diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index a916047..51e5e94 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -105,6 +105,7 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) static void labpc_detach(struct comedi_device *dev) { labpc_free_dma_chan(dev); + labpc_common_detach(dev); comedi_legacy_detach(dev); } diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/staging/comedi/drivers/ni_labpc.h index be89ae4..83f878a 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.h +++ b/drivers/staging/comedi/drivers/ni_labpc.h @@ -36,6 +36,7 @@ struct labpc_boardinfo { struct labpc_private { struct comedi_isadma *dma; + struct comedi_8254 *counter; /* number of data points left to be taken */ unsigned long long count; @@ -49,20 +50,6 @@ struct labpc_private { /* store last read of board status registers */ unsigned int stat1; unsigned int stat2; - /* -* value to load into board's counter a0 (conversion pacing) for timed -* conversions -*/ - unsigned int divisor_a0; - /* -* value to load into board's counter b0 (master) for timed conversions -*/ - unsigned int divisor_b0; - /* -* value to load into board's counter b1 (scan pacing) for timed -* conversions -*/ - unsigned int divisor_b1; /* we are using dma/fifo-half-full/etc. */ enum transfer_type current_transfer; @@ -77,5 +64,6 @@ struct labpc_private { int labpc_common_attach(struct comedi_device *dev, unsigned int irq, unsigned long isr_flags); +void labpc_common_detach(struct comedi_device *dev); #endif /* _NI_LABPC_H */ diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c b/drivers/staging/comedi/drivers/ni_labpc_common.c index 084c89c..74518c5 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_common.c +++ b/drivers/staging/comedi/drivers/ni_labpc_common.c @@ -20,10 +20,11 @@ #include linux/interrupt.h #include linux/io.h #include linux/delay.h +#include linux/slab.h #include ../comedidev.h -#include 8253.h +#include comedi_8254.h #include 8255.h #include comedi_fc.h #include ni_labpc.h @@ -108,32 +109,6 @@ static void labpc_writeb(struct comedi_device *dev, writeb(byte, dev-mmio + reg); } -static void labpc_counter_load(struct comedi_device *dev, - unsigned long reg, - unsigned int counter_number, - unsigned int count, - unsigned int mode) -{ - if (dev-mmio) { - i8254_mm_set_mode(dev-mmio + reg, 0, counter_number, mode); - i8254_mm_write(dev-mmio + reg, 0, counter_number, count); - } else { - i8254_set_mode(dev-iobase + reg, 0, counter_number, mode); - i8254_write(dev-iobase + reg, 0, counter_number, count); - } -} - -static void labpc_counter_set_mode(struct comedi_device *dev, - unsigned long reg, - unsigned int counter_number, - unsigned int mode) -{ - if (dev-mmio) - i8254_mm_set_mode(dev-mmio + reg, 0, counter_number, mode); - else - i8254_set_mode(dev-iobase + reg, 0,
[RFC PATCH 23/36] staging: comedi: me4000: convert driver to use the comedi_8254 module
Some of the hardware supported by this driver include an 8254 timer. For aesthetics, convert it to use the comedi_8254 module to provide support for the 8254 timer. This also fixes the (*insn_read) and (*insn_write) to work like the comedi API expects. Currently they only read or write a single value. It also fixes the (*insn_config). Currently the driver is attempting to handle the configuration instructions GPCT_RESET and GPCT_SET_OPERATION. These are just arbitrary valuse and are not real comedi configuration_ids. They actually coorespond to: GPCT_RESET - INSN_CONFIG_DIO_OUTPUT GPCT_SET_OPERATION - INSN_CONFIG_ANALOG_TRIG The number of parameters for the instructions is validated by the comedi core in check_insn_config_length(). GPCT_RESET happens to work (insn-n == 1) but GPCT_SET_OPERATION would fail. The INSN_CONFIG_ANALOG_TRIG expects insn-n == 5 but GPCT_SET_OPERATION in this driver expects insn-n == 2. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/me4000.c | 108 2 files changed, 14 insertions(+), 95 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index e4ef12b..77c1c99 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -970,6 +970,7 @@ config COMEDI_CB_PCIMDDA config COMEDI_ME4000 tristate Meilhaus ME-4000 support + select COMEDI_8254 ---help--- Enable support for Meilhaus PCI data acquisition cards ME-4650, ME-4670i, ME-4680, ME-4680i and ME-4680is diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index d120aa2..2d0e60d 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -48,7 +48,7 @@ broken. #include ../comedidev.h #include comedi_fc.h -#include 8253.h +#include comedi_8254.h #include plx9052.h #define ME4000_FIRMWAREme4000_firmware.bin @@ -170,7 +170,6 @@ broken. struct me4000_info { unsigned long plx_regbase; - unsigned long timer_regbase; }; enum me4000_boardid { @@ -1259,85 +1258,6 @@ static int me4000_dio_insn_config(struct comedi_device *dev, return insn-n; } -/*= - Counter section - ===*/ - -static int me4000_cnt_insn_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct me4000_info *info = dev-private; - unsigned int chan = CR_CHAN(insn-chanspec); - int err; - - switch (data[0]) { - case GPCT_RESET: - if (insn-n != 1) - return -EINVAL; - - err = i8254_set_mode(info-timer_regbase, 0, chan, -I8254_MODE0 | I8254_BINARY); - if (err) - return err; - i8254_write(info-timer_regbase, 0, chan, 0); - break; - case GPCT_SET_OPERATION: - if (insn-n != 2) - return -EINVAL; - - err = i8254_set_mode(info-timer_regbase, 0, chan, - (data[1] 1) | I8254_BINARY); - if (err) - return err; - break; - default: - return -EINVAL; - } - - return insn-n; -} - -static int me4000_cnt_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct me4000_info *info = dev-private; - - if (insn-n == 0) - return 0; - - if (insn-n 1) { - dev_err(dev-class_dev, Invalid instruction length %d\n, - insn-n); - return -EINVAL; - } - - data[0] = i8254_read(info-timer_regbase, 0, insn-chanspec); - - return 1; -} - -static int me4000_cnt_insn_write(struct comedi_device *dev, -struct comedi_subdevice *s, -struct comedi_insn *insn, unsigned int *data) -{ - struct me4000_info *info = dev-private; - - if (insn-n == 0) { - return 0; - } else if (insn-n 1) { - dev_err(dev-class_dev, Invalid instruction length %d\n, - insn-n); - return -EINVAL; - } - - i8254_write(info-timer_regbase, 0, insn-chanspec, data[0]); - - return 1; -} - static int me4000_auto_attach(struct comedi_device *dev,
[RFC PATCH 32/36] staging: comedi: amplc_dio200_common: remove unnecessary 'counter_number' checks
The 'counter_number' in these functions is the comedi channel number from the chanspec. The comedi core validates the chanspec before calling the driver functions. Remove the unnecessary checks. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/drivers/amplc_dio200_common.c | 8 1 file changed, 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 6ef70a5..48cdddc 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -577,8 +577,6 @@ static int dio200_subdev_8254_set_gate_src(struct comedi_device *dev, if (!board-has_clk_gat_sce) return -1; - if (counter_number 2) - return -1; if (gate_src (board-is_pcie ? 31 : 7)) return -1; @@ -598,8 +596,6 @@ static int dio200_subdev_8254_get_gate_src(struct comedi_device *dev, if (!board-has_clk_gat_sce) return -1; - if (counter_number 2) - return -1; return subpriv-gate_src[counter_number]; } @@ -615,8 +611,6 @@ static int dio200_subdev_8254_set_clock_src(struct comedi_device *dev, if (!board-has_clk_gat_sce) return -1; - if (counter_number 2) - return -1; if (clock_src (board-is_pcie ? 31 : 7)) return -1; @@ -638,8 +632,6 @@ static int dio200_subdev_8254_get_clock_src(struct comedi_device *dev, if (!board-has_clk_gat_sce) return -1; - if (counter_number 2) - return -1; clock_src = subpriv-clock_src[counter_number]; *period_ns = clock_period[clock_src]; -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC PATCH 30/36] staging: comedi: amplc_dio200_common: remove 'gat_sce_ofs' from struct dio200_subdev_8254
This member is only used one place in the driver. Remove it and calculate the register offset when needed. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/drivers/amplc_dio200_common.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 1786ea2..2c9c8dd 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -99,7 +99,6 @@ static const unsigned int ts_clock_period[TS_CONFIG_MAX_CLK_SRC + 1] = { struct dio200_subdev_8254 { unsigned int ofs; /* Counter base offset */ - unsigned int gat_sce_ofs; /* GAT_SCE base address */ int which; /* Bit 5 of CLK_SCE or GAT_SCE */ unsigned int clock_src[3]; /* Current clock sources */ unsigned int gate_src[3]; /* Current gate sources */ @@ -586,7 +585,7 @@ static int dio200_subdev_8254_set_gate_src(struct comedi_device *dev, subpriv-gate_src[counter_number] = gate_src; byte = gat_sce(subpriv-which, counter_number, gate_src); - dio200_write8(dev, subpriv-gat_sce_ofs, byte); + dio200_write8(dev, DIO200_GAT_SCE(subpriv-ofs 3), byte); return 0; } @@ -725,12 +724,8 @@ static int dio200_subdev_8254_init(struct comedi_device *dev, spin_lock_init(subpriv-spinlock); subpriv-ofs = offset; - if (board-has_clk_gat_sce) { - /* Derive CLK_SCE and GAT_SCE register offsets from -* 8254 offset. */ - subpriv-gat_sce_ofs = DIO200_GAT_SCE(offset 3); + if (board-has_clk_gat_sce) subpriv-which = (offset 2) 1; - } /* Initialize channels. */ for (chan = 0; chan 3; chan++) { -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC PATCH 08/36] staging: comedi: amplc_pci224: convert driver to use the comedi_8254 module
This driver uses an 8254 timer to generate the pacer clock used for analog output data conversion. Convert it to use the comedi_8254 module to provide support for the 8254 timer. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig| 1 + drivers/staging/comedi/drivers/amplc_pci224.c | 34 ++- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index de1d7ad..98a62e3 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -804,6 +804,7 @@ config COMEDI_AMPLC_PC263_PCI config COMEDI_AMPLC_PCI224 tristate Amplicon PCI224 and PCI234 support + select COMEDI_8254 ---help--- Enable support for Amplicon PCI224 and PCI234 AO boards diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 924c829..88b8c01 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -110,15 +110,12 @@ #include ../comedidev.h #include comedi_fc.h -#include 8253.h +#include comedi_8254.h /* * PCI224/234 i/o space 1 (PCIBAR2) registers. */ -#define PCI224_Z2_CT0 0x14/* 82C54 counter/timer 0 */ -#define PCI224_Z2_CT1 0x15/* 82C54 counter/timer 1 */ -#define PCI224_Z2_CT2 0x16/* 82C54 counter/timer 2 */ -#define PCI224_Z2_CTC 0x17/* 82C54 counter/timer control word */ +#define PCI224_Z2_BASE 0x14/* 82C54 counter/timer */ #define PCI224_ZCLK_SCE0x1A/* Group Z Clock Configuration Register */ #define PCI224_ZGAT_SCE0x1D/* Group Z Gate Configuration Register */ #define PCI224_INT_SCE 0x1E/* ISR Interrupt source mask register */ @@ -379,8 +376,6 @@ struct pci224_private { int intr_cpuid; short intr_running; unsigned short daccon; - unsigned int cached_div1; - unsigned int cached_div2; unsigned short ao_enab; /* max 16 channels so 'short' will do */ unsigned char intsce; }; @@ -668,7 +663,6 @@ static int pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - struct pci224_private *devpriv = dev-private; int err = 0; unsigned int arg; @@ -793,10 +787,7 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, if (cmd-scan_begin_src == TRIG_TIMER) { arg = cmd-scan_begin_arg; /* Use two timers. */ - i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - devpriv-cached_div1, - devpriv-cached_div2, - arg, cmd-flags); + comedi_8254_cascade_ns_to_timer(dev-pacer, arg, cmd-flags); err |= cfc_check_trigger_arg_is(cmd-scan_begin_arg, arg); } @@ -817,7 +808,6 @@ static void pci224_ao_start_pacer(struct comedi_device *dev, struct comedi_subdevice *s) { struct pci224_private *devpriv = dev-private; - unsigned long timer_base = devpriv-iobase1 + PCI224_Z2_CT0; /* * The output of timer Z2-0 will be used as the scan trigger @@ -830,14 +820,10 @@ static void pci224_ao_start_pacer(struct comedi_device *dev, outb(GAT_CONFIG(2, GAT_VCC), devpriv-iobase1 + PCI224_ZGAT_SCE); /* Z2-2 needs 10 MHz clock. */ outb(CLK_CONFIG(2, CLK_10MHZ), devpriv-iobase1 + PCI224_ZCLK_SCE); - /* Load Z2-2 mode (2) and counter (div1). */ - i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); - i8254_write(timer_base, 0, 2, devpriv-cached_div1); /* Z2-0 is clocked from Z2-2's output. */ outb(CLK_CONFIG(0, CLK_OUTNM1), devpriv-iobase1 + PCI224_ZCLK_SCE); - /* Load Z2-0 mode (2) and counter (div2). */ - i8254_set_mode(timer_base, 0, 0, I8254_MODE2 | I8254_BINARY); - i8254_write(timer_base, 0, 0, devpriv-cached_div2); + + comedi_8254_pacer_enable(dev-pacer, 2, 0, false); } static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) @@ -855,7 +841,6 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd-chanlist == NULL || cmd-chanlist_len == 0) return -EINVAL; - /* Determine which channels are enabled and their load order. */ devpriv-ao_enab = 0; @@ -893,8 +878,10 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) outw(devpriv-daccon | PCI224_DACCON_FIFORESET, dev-iobase + PCI224_DACCON); - if (cmd-scan_begin_src == TRIG_TIMER) + if (cmd-scan_begin_src == TRIG_TIMER) { +
[RFC PATCH 06/36] staging: comedi: pcl711: convert driver to use the comedi_8254 module
This driver uses an 8254 timer to generate the pacer clock used for analog input data acquisition. Convert it to use the comedi_8254 module to provide support for the 8254 timer. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/pcl711.c | 42 + 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 3698f68..b92fa05 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -108,6 +108,7 @@ if COMEDI_ISA_DRIVERS config COMEDI_PCL711 tristate Advantech PCL-711/711b and ADlink ACL-8112 ISA card support + select COMEDI_8254 ---help--- Enable support for Advantech PCL-711 and 711b, ADlink ACL-8112 diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index cb7e4c3..ef7db12 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -42,7 +42,7 @@ #include ../comedidev.h #include comedi_fc.h -#include 8253.h +#include comedi_8254.h /* * I/O port register map @@ -153,11 +153,6 @@ static const struct pcl711_board boardtypes[] = { }, }; -struct pcl711_private { - unsigned int divisor1; - unsigned int divisor2; -}; - static void pcl711_ai_set_mode(struct comedi_device *dev, unsigned int mode) { /* @@ -287,9 +282,7 @@ static int pcl711_ai_insn_read(struct comedi_device *dev, static int pcl711_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - struct pcl711_private *devpriv = dev-private; int err = 0; - unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -339,11 +332,9 @@ static int pcl711_ai_cmdtest(struct comedi_device *dev, /* step 4 */ if (cmd-scan_begin_src == TRIG_TIMER) { - arg = cmd-scan_begin_arg; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ, - devpriv-divisor1, - devpriv-divisor2, - arg, cmd-flags); + unsigned int arg = cmd-scan_begin_arg; + + comedi_8254_cascade_ns_to_timer(dev-pacer, arg, cmd-flags); err |= cfc_check_trigger_arg_is(cmd-scan_begin_arg, arg); } @@ -353,18 +344,6 @@ static int pcl711_ai_cmdtest(struct comedi_device *dev, return 0; } -static void pcl711_ai_load_counters(struct comedi_device *dev) -{ - struct pcl711_private *devpriv = dev-private; - unsigned long timer_base = dev-iobase + PCL711_TIMER_BASE; - - i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); - i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); - - i8254_write(timer_base, 0, 1, devpriv-divisor1); - i8254_write(timer_base, 0, 2, devpriv-divisor2); -} - static int pcl711_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = s-async-cmd; @@ -372,7 +351,8 @@ static int pcl711_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) pcl711_set_changain(dev, s, cmd-chanlist[0]); if (cmd-scan_begin_src == TRIG_TIMER) { - pcl711_ai_load_counters(dev); + comedi_8254_update_divisors(dev-pacer); + comedi_8254_pacer_enable(dev-pacer, 1, 2, true); outb(PCL711_INT_STAT_CLR, dev-iobase + PCL711_INT_STAT_REG); pcl711_ai_set_mode(dev, PCL711_MODE_PACER_IRQ); } else { @@ -445,14 +425,9 @@ static int pcl711_do_insn_bits(struct comedi_device *dev, static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it) { const struct pcl711_board *board = dev-board_ptr; - struct pcl711_private *devpriv; struct comedi_subdevice *s; int ret; - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); - if (!devpriv) - return -ENOMEM; - ret = comedi_request_region(dev, it-options[0], 0x10); if (ret) return ret; @@ -464,6 +439,11 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it) dev-irq = it-options[1]; } + dev-pacer = comedi_8254_init(dev-iobase + PCL711_TIMER_BASE, + I8254_OSC_BASE_2MHZ, I8254_IO8, 0); + if (!dev-pacer) + return -ENOMEM; + ret = comedi_alloc_subdevices(dev, 4); if (ret) return ret; -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org
Re: [PATCH 4/4] Staging: rtl8192u: r819xU_firmware: added space after comma
On Fri, Feb 20, 2015 at 11:47 AM, Tolga Ceylan tolga.cey...@gmail.com wrote: On Thu, Feb 19, 2015 at 11:30 PM, Joe Perches j...@perches.com wrote: Might as well remove the unnecessary cast too: memcpy(skb-cb, dev, sizeof(dev)); but it might be better to avoid the memcpy and use an assign *(struct net_device *)skb-cb = dev; Should I sent a new set of patches (including memcpy change)? Or reply to the series with a single memcpy change patch? ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: dma-buf: cleanup dma_buf_export() to make it easily extensible
Hi Dan, On 21 February 2015 at 00:56, Dan Carpenter dan.carpen...@oracle.com wrote: Hello Sumit Semwal, The patch 817bd7253291: dma-buf: cleanup dma_buf_export() to make it easily extensible from Jan 23, 2015, leads to the following static checker warning: drivers/staging/android/ion/ion.c:1112 ion_share_dma_buf() error: potentially dereferencing uninitialized 'buffer'. Thanks for catching this! I am preparing a patch which I will submit asap. drivers/staging/android/ion/ion.c 1103 struct dma_buf *ion_share_dma_buf(struct ion_client *client, 1104 struct ion_handle *handle) 1105 { 1106 struct ion_buffer *buffer; ^^ 1107 struct dma_buf *dmabuf; 1108 bool valid_handle; 1109 DEFINE_DMA_BUF_EXPORT_INFO(exp_info); 1110 exp_info.ops = dma_buf_ops; 1112 exp_info.size = buffer-size; ^^ 1113 exp_info.flags = O_RDWR; 1114 exp_info.priv = buffer; ^^ And here also. 1115 regards, dan carpenter -- Thanks and regards, Sumit Semwal Kernel Team Lead - Linaro Mobile Group Linaro.org │ Open source software for ARM SoCs ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3] staging: writeboost: Add dm-writeboost
To be clear, bio's semantics doesn't require a io is written on persistent medium before any ack. The border line is that ios that's acked are persitent before ack to REQ_FLUSH request. So, writing on the volatile buffer (log chunk in this case) and then ack is safe if the data gets persistent before some future REQ_FLUSH request is acked. That's dm-writeboost does. And in general, ack should be quick as possible otherwise may incur some problems such as upper layer may suspend any other requests. The bio_vecs solution works only for a tiny prototype. If I apply the solution there will appear the following problems 1. The write to the cache device isn't one single write. This causes atomicity problem. And may cause performance degradation. 2. We need to compute checksum of the entire log chunk before write. Without this, the user isn't safe from partial write problem. Like the 1 above, atomicity is to be cared. (btw, I don't think dm-cache that has separete data device and metadata device can guarantee this level of safetiness) 3. Don't ack any bios until the full buffer is written is harmful. We should ack as quick as possible as explained above. 4. Read caching becomes infeasible. It needs copying of the read data. My conclusion is write buffer in practice should be a single buffer and copying is inevitable. From a engineering point of view, memory copy can't be the bottleneck (before that, SSD's throughput hits) so we shouldn't hack for the little improvement. - Akira On 2015/02/21 1:17, Joe Thornber wrote: On Sat, Feb 21, 2015 at 01:06:08AM +0900, Akira Hayakawa wrote: The size is configurable but typically 512KB (that's the default). Refer to bio payload sounds really dangerous but it may be possible in some tricky way. but at the moment I am not sure how the implementation would be. Is there some fancy function that is like memcpy but actually move the ownership? When building up your log chunk bio copy the bio_vecs (not the data) from the original bios. You can't complete the original bios until your log chunk has been written. - Joe ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 4/4] Staging: rtl8192u: r819xU_firmware: added space after comma
On Fri, 2015-02-20 at 16:31 -0800, Tolga Ceylan wrote: On Fri, Feb 20, 2015 at 11:47 AM, Tolga Ceylan tolga.cey...@gmail.com wrote: On Thu, Feb 19, 2015 at 11:30 PM, Joe Perches j...@perches.com wrote: Might as well remove the unnecessary cast too: memcpy(skb-cb, dev, sizeof(dev)); but it might be better to avoid the memcpy and use an assign *(struct net_device *)skb-cb = dev; [] Should I sent a new set of patches (including memcpy change)? Or reply to the series with a single memcpy change patch? Let Larry Finger decide if he wants the patches at all first. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/3] Staging: rtl8192u: ieee80211: rtl819x_TS: replaced C99 comments with C89
Replaced C99 comments with C89 while maintaining less than 80 char lines. Removed commented out struct member: DLRecord. Signed-off-by: Tolga Ceylan tolga.cey...@gmail.com --- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 7ed7243..811e6e3 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -1,14 +1,14 @@ #ifndef _TSTYPE_H_ #define _TSTYPE_H_ #include rtl819x_Qos.h -#define TS_SETUP_TIMEOUT 60 // In millisecond +#define TS_SETUP_TIMEOUT 60 /* In millisecond */ #define TS_INACT_TIMEOUT 60 #define TS_ADDBA_DELAY 60 #define TOTAL_TS_NUM 16 #define TCLAS_NUM 4 -// This define the Tx/Rx directions +/* This define the Tx/Rx directions */ typedef enum _TR_SELECT { TX_DIR = 0, RX_DIR = 1, @@ -28,9 +28,10 @@ typedef struct _TS_COMMON_INFO{ typedef struct _TX_TS_RECORD{ TS_COMMON_INFO TsCommonInfo; u16 TxCurSeq; - BA_RECORD TxPendingBARecord; // For BA Originator - BA_RECORD TxAdmittedBARecord; // For BA Originator -// QOS_DL_RECORD DLRecord; + /* For BA Originator */ + BA_RECORD TxPendingBARecord; + /* For BA Originator */ + BA_RECORD TxAdmittedBARecord; u8 bAddBaReqInProgress; u8 bAddBaReqDelayed; u8 bUsingBa; @@ -44,11 +45,11 @@ typedef struct _RX_TS_RECORD { u16 RxTimeoutIndicateSeq; struct list_headRxPendingPktList; struct timer_list RxPktPendingTimer; - BA_RECORD RxAdmittedBARecord; // For BA Recipient + /* For BA Recipient */ + BA_RECORD RxAdmittedBARecord; u16 RxLastSeqNum; u8 RxLastFragNum; u8 num; -// QOS_DL_RECORD DLRecord; } RX_TS_RECORD, *PRX_TS_RECORD; -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/3] Staging: rtl8192u: ieee80211: dot11d: added parenthesis to RESET_CIE_WATCHDOG macro
Added parenthesis to RESET_CIE_WATCHDOG macro to resolve checkpatch error. Signed-off-by: Tolga Ceylan tolga.cey...@gmail.com --- drivers/staging/rtl8192u/ieee80211/dot11d.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index bd75e29..8ae673b 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -53,7 +53,7 @@ typedef struct _RT_DOT11D_INFO { #define CIE_WATCHDOG_TH 1 #define GET_CIE_WATCHDOG(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)-CountryIeWatchdog) -#define RESET_CIE_WATCHDOG(__pIeeeDev) GET_CIE_WATCHDOG(__pIeeeDev) = 0 +#define RESET_CIE_WATCHDOG(__pIeeeDev) (GET_CIE_WATCHDOG(__pIeeeDev) = 0) #define UPDATE_CIE_WATCHDOG(__pIeeeDev) (++GET_CIE_WATCHDOG(__pIeeeDev)) #define IS_DOT11D_STATE_DONE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)-State == DOT11D_STATE_DONE) -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/3] Staging: rtl8192u: ieee80211: ieee80211_crypt: removed commented out include
Removed a commented out header include Signed-off-by: Tolga Ceylan tolga.cey...@gmail.com --- drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.c index 5533221..b41aec1 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.c @@ -11,7 +11,6 @@ * */ -//#include linux/config.h #include linux/module.h #include linux/init.h #include linux/slab.h -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3] staging: writeboost: Add dm-writeboost
On Sat, Feb 21, 2015 at 12:25:53AM +0900, Akira Hayakawa wrote: Yes. How big are your log chunks? Presumably they're relatively small (eg, 256k). In which case you can optimise for the common case where you have enough bios to hand to build your log chunk by just referencing the bio payloads, rather than copying. It's only the last bit of io in a burst that should be using this copying slow path. - Joe ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3] staging: writeboost: Add dm-writeboost
The size is configurable but typically 512KB (that's the default). Refer to bio payload sounds really dangerous but it may be possible in some tricky way. but at the moment I am not sure how the implementation would be. Is there some fancy function that is like memcpy but actually move the ownership? - Akira On 2015/02/21 0:50, Joe Thornber wrote: On Sat, Feb 21, 2015 at 12:25:53AM +0900, Akira Hayakawa wrote: Yes. How big are your log chunks? Presumably they're relatively small (eg, 256k). In which case you can optimise for the common case where you have enough bios to hand to build your log chunk by just referencing the bio payloads, rather than copying. It's only the last bit of io in a burst that should be using this copying slow path. - Joe ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3] staging: writeboost: Add dm-writeboost
On Sat, Feb 21, 2015 at 01:06:08AM +0900, Akira Hayakawa wrote: The size is configurable but typically 512KB (that's the default). Refer to bio payload sounds really dangerous but it may be possible in some tricky way. but at the moment I am not sure how the implementation would be. Is there some fancy function that is like memcpy but actually move the ownership? When building up your log chunk bio copy the bio_vecs (not the data) from the original bios. You can't complete the original bios until your log chunk has been written. - Joe ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3] staging: writeboost: Add dm-writeboost
On Fri, Feb 20, 2015 at 05:44:01PM +0900, Akira Hayakawa wrote: I will wait for ack from dm maintainers. Are you still copying the contents of every bio to your own memory buffer before writing it to disk? - Joe ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] [RFC] drivers/staging/fbtft: fix sparse warnings
See below how sparse output changed with these changes. In few words: - fixed printf specifiers for size_t; - trying to fix address space specifiers issues, not sure what's correct approach, ASKING FOR COMMENTS AND HELP; - didn't touch was not declared. Should it be static? yet. -drivers/staging/fbtft/fbtft-core.c: In function ‘fbtft_register_framebuffer’: -drivers/staging/fbtft/fbtft-core.c:1004:4: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ [-Wformat=] -drivers/staging/fbtft/fbtft-io.c: In function ‘fbtft_write_spi_emulate_9’: -drivers/staging/fbtft/fbtft-io.c:63:4: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=] -drivers/staging/fbtft/fbtft-io.c: In function ‘fbtft_read_spi’: -drivers/staging/fbtft/fbtft-io.c:110:5: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=] -drivers/staging/fbtft/fbtft-core.c:928:19: warning: incorrect type in argument 1 (different address spaces) -drivers/staging/fbtft/fbtft-core.c:928:19:expected void const *addr -drivers/staging/fbtft/fbtft-core.c:928:19:got char [noderef] asn:2*screen_base drivers/staging/fbtft/fbtft-sysfs.c:24:5: warning: symbol 'fbtft_gamma_parse_str' was not declared. Should it be static? drivers/staging/fbtft/fbtft-sysfs.c:154:6: warning: symbol 'fbtft_expand_debug_value' was not declared. Should it be static? drivers/staging/fbtft/fbtft-sysfs.c:210:6: warning: symbol 'fbtft_sysfs_init' was not declared. Should it be static? drivers/staging/fbtft/fbtft-sysfs.c:217:6: warning: symbol 'fbtft_sysfs_exit' was not declared. Should it be static? -drivers/staging/fbtft/fbtft-bus.c:145:19: warning: cast removes address space of expression -drivers/staging/fbtft/fbtft-bus.c:204:15: warning: incorrect type in assignment (different address spaces) -drivers/staging/fbtft/fbtft-bus.c:204:15:expected unsigned char [usertype] *vmem8 -drivers/staging/fbtft/fbtft-bus.c:204:15:got char [noderef] asn:2* -drivers/staging/fbtft/fbtft-bus.c:248:19: warning: cast removes address space of expression -drivers/staging/fbtft/fb_agm1264k-fl.c:276:24: warning: cast removes address space of expression +drivers/staging/fbtft/fbtft-bus.c:152:49: warning: incorrect type in argument 2 (different address spaces) +drivers/staging/fbtft/fbtft-bus.c:152:49:expected void *buf +drivers/staging/fbtft/fbtft-bus.c:152:49:got unsigned short [noderef] [usertype] asn:2*[assigned] vmem16 +drivers/staging/fbtft/fbtft-bus.c:254:41: warning: incorrect type in argument 2 (different address spaces) +drivers/staging/fbtft/fbtft-bus.c:254:41:expected void *buf +drivers/staging/fbtft/fbtft-bus.c:254:41:got unsigned short [noderef] [usertype] asn:2*[assigned] vmem16 +drivers/staging/fbtft/fbtft-core.c:928:16: warning: cast removes address space of expression drivers/staging/fbtft/fb_hx8340bn.c:111:6: warning: symbol 'set_addr_win' was not declared. Should it be static? -drivers/staging/fbtft/fb_pcd8544.c:113:24: warning: cast removes address space of expression -drivers/staging/fbtft/fb_ra8875.c:286:19: warning: cast removes address space of expression -drivers/staging/fbtft/fb_ssd1306.c:175:24: warning: cast removes address space of expression -drivers/staging/fbtft/fb_tls8204.c:102:24: warning: cast removes address space of expression -drivers/staging/fbtft/fb_uc1701.c:153:24: warning: cast removes address space of expression -drivers/staging/fbtft/fb_watterott.c:76:24: warning: cast removes address space of expression +drivers/staging/fbtft/fb_uc1701.c:153:32: warning: cast removes address space of expression +drivers/staging/fbtft/fb_uc1701.c:153:32: warning: incorrect type in initializer (different address spaces) +drivers/staging/fbtft/fb_uc1701.c:153:32:expected unsigned short [noderef] [usertype] asn:2*vmem16 +drivers/staging/fbtft/fb_uc1701.c:153:32:got unsigned short [usertype] *noident +drivers/staging/fbtft/fb_watterott.c:76:32: warning: cast removes address space of expression +drivers/staging/fbtft/fb_watterott.c:76:32: warning: incorrect type in initializer (different address spaces) +drivers/staging/fbtft/fb_watterott.c:76:32:expected unsigned short [noderef] [usertype] asn:2*vmem16 +drivers/staging/fbtft/fb_watterott.c:76:32:got unsigned short [usertype] *noident drivers/staging/fbtft/fb_watterott.c:115:24: warning: cast removes address space of expression drivers/staging/fbtft/fbtft_device.c:32:19: warning: symbol 'spi_device' was not declared. Should it be static? drivers/staging/fbtft/fbtft_device.c:33:24: warning: symbol 'p_device' was not declared. Should it be static? This is for Eudyptulla challenge. If you want me to help with any other staging driver, I am open. Signed-off-by: Andrey Utkin andrey.krieger.ut...@gmail.com --- drivers/staging/fbtft/fb_agm1264k-fl.c | 4 ++-- drivers/staging/fbtft/fb_pcd8544.c | 4 ++--
Re: [PATCH v8 2/4] fpga manager: add sysfs interface document
On Thu, 19 Feb 2015, Michal Simek wrote: On 02/17/2015 08:17 PM, Pavel Machek wrote: On Tue 2015-02-17 11:07:53, Rob Landley wrote: On 02/15/2015 04:40 PM, Pavel Machek wrote: On Wed 2015-01-21 13:27:00, Jason Gunthorpe wrote: On Wed, Jan 21, 2015 at 06:33:12PM +0200, Pantelis Antoniou wrote: My point is that the current firmware layer is overly cautious and FPGAs are very big. My current project on small Xilinx device has a 10MB programming file. The biggest Xilinx device today has a max bitfile size around 122MB. So keeping that much memory pinned in the kernel when I can prove it is uncessary for my system (either because there is no suspend/resume possibility, or because I know the CPU can always access the filesytem) is very undesirable. Well, your current device aalso has 1GB RAM, no? Unnecessarily pinning 10% of your ram is a good solution? Never said that. But I'd rather have _some_ API proposed, then try to design in everthing including kitchen sink and do nothing. I propose an extension to the firmware class: int request_firmware_streamed(const struct firmware **firmware_p, const char *name, struct device *device, int (*consumer)(char *buf, size_t size, void *priv)) This is a new function that streams the firmware file in 4k chunks to a callback function. So firmware is not limited to the allocation size of vmalloc. This new function would have the same parameters as request_firmware except adding a pointer to a consumer function. In the case of fpga's, the consumer function is writing the 4k chunks to the fpga. The new function will: * open the file * read 4k * hand that buffer to the consumer * sleep until the consumer returns * give up if consumer has a nonzero exit, continue reading otherwise Admittedly this is really different from the current firmeware class's structures. The real problem this is trying to solve is that bitstreams can be huge, especially as fpga's can be daisychained. And the CPU doing the loading could be embedded (limited resources). IFAIK fpga's don't need to have the whole image in a ram buffer. This gives us the convenience of request_firmware() and gives the kernel an extension of the firmware class that others might useful instead of solving this problem that we keep hovering around for fpga's only. Alan Tull ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
re: dma-buf: cleanup dma_buf_export() to make it easily extensible
Hello Sumit Semwal, The patch 817bd7253291: dma-buf: cleanup dma_buf_export() to make it easily extensible from Jan 23, 2015, leads to the following static checker warning: drivers/staging/android/ion/ion.c:1112 ion_share_dma_buf() error: potentially dereferencing uninitialized 'buffer'. drivers/staging/android/ion/ion.c 1103 struct dma_buf *ion_share_dma_buf(struct ion_client *client, 1104 struct ion_handle *handle) 1105 { 1106 struct ion_buffer *buffer; ^^ 1107 struct dma_buf *dmabuf; 1108 bool valid_handle; 1109 DEFINE_DMA_BUF_EXPORT_INFO(exp_info); 1110 exp_info.ops = dma_buf_ops; 1112 exp_info.size = buffer-size; ^^ 1113 exp_info.flags = O_RDWR; 1114 exp_info.priv = buffer; ^^ And here also. 1115 regards, dan carpenter ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 4/4] Staging: rtl8192u: r819xU_firmware: added space after comma
On Thu, Feb 19, 2015 at 11:30 PM, Joe Perches j...@perches.com wrote: Might as well remove the unnecessary cast too: memcpy(skb-cb, dev, sizeof(dev)); but it might be better to avoid the memcpy and use an assign *(struct net_device *)skb-cb = dev; I'll submit another patch for the memcpy change. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 0/4] staging: comedi: fix some coverity reported issues
H Hartley Sweeten (4): staging: comedi: vmk80xx: fix out-of-bounds write staging: comedi: ni_labpc_common: fix logically dead code issue staging: comedi: cb_pcidas64: fix possible integer overflow staging: comedi: rtd520: remove unnecessary interrupt disable drivers/staging/comedi/drivers/cb_pcidas64.c | 4 ++-- drivers/staging/comedi/drivers/ni_labpc_common.c | 3 --- drivers/staging/comedi/drivers/rtd520.c | 6 +- drivers/staging/comedi/drivers/vmk80xx.c | 2 +- 4 files changed, 4 insertions(+), 11 deletions(-) -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/4] staging: comedi: cb_pcidas64: fix possible integer overflow
The {min,max}_scan_divisor values could overflow due to the unsigned int * insigned int calculation. Change the type of the local variable 'convert_divisor' to unsigned long long to avoid the possible overflow. Reported-by: coverity (CID 200653) Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/drivers/cb_pcidas64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 5b43e4e..9836c87 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -2001,7 +2001,8 @@ static unsigned int get_divisor(unsigned int ns, unsigned int flags) static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd) { const struct pcidas64_board *thisboard = dev-board_ptr; - unsigned int convert_divisor = 0, scan_divisor; + unsigned long long convert_divisor = 0; + unsigned int scan_divisor; static const int min_convert_divisor = 3; static const int max_convert_divisor = max_counter_value + min_convert_divisor; @@ -2027,7 +2028,6 @@ static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd) if (cmd-scan_begin_src == TRIG_TIMER) { scan_divisor = get_divisor(cmd-scan_begin_arg, cmd-flags); if (cmd-convert_src == TRIG_TIMER) { - /* XXX check for integer overflows */ min_scan_divisor = convert_divisor * cmd-chanlist_len; max_scan_divisor = (convert_divisor * cmd-chanlist_len - 1) + -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/4] staging: comedi: rtd520: remove unnecessary interrupt disable
The read/write of the PLX_INTRCS_REG during the driver detach is not necessary. The rtd_reset() function writes 0 to this register which will disable all interrupts. This also fixes a dereference after null check reported by coverity. Reported-by: coverity (CID 751066) Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/drivers/rtd520.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index c94ad12..f9473f9 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -1299,12 +1299,8 @@ static void rtd_detach(struct comedi_device *dev) /* Shut down any board ops by resetting it */ if (dev-mmio devpriv-lcfg) rtd_reset(dev); - if (dev-irq) { - writel(readl(devpriv-lcfg + PLX_INTRCS_REG) - ~(ICS_PLIE | ICS_DMA0_E | ICS_DMA1_E), - devpriv-lcfg + PLX_INTRCS_REG); + if (dev-irq) free_irq(dev-irq, dev); - } if (dev-mmio) iounmap(dev-mmio); if (devpriv-las1) -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/4] staging: comedi: vmk80xx: fix out-of-bounds write
usb_blk_msg() will return the passed 'len' (64) as the 'actual_len' (cnt) of the transfer. The addition of the '\0' to the end of the returned string will overrun the 'rx' array. Increase the array size by 1 to fix the out-of-bounds write. Reported-by: coverity (CID 711413) Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/drivers/vmk80xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c index e371183..e0656d1 100644 --- a/drivers/staging/comedi/drivers/vmk80xx.c +++ b/drivers/staging/comedi/drivers/vmk80xx.c @@ -195,7 +195,7 @@ static void vmk80xx_read_eeprom(struct comedi_device *dev, int flag) unsigned int tx_pipe; unsigned int rx_pipe; unsigned char tx[1]; - unsigned char rx[64]; + unsigned char rx[65]; int cnt; tx_pipe = usb_sndbulkpipe(usb, 0x01); -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/4] staging: comedi: ni_labpc_common: fix logically dead code issue
The quick exit check of (mode == MODE_SINGLE_CHAN) results in coverity reporting a logically dead code issue in the switch code in labpc_ai_check_chanlist(). Remove the quick exit check and allow the function to handle the MODE_SINGLE_CHAN normally (the for loop will only happen 1 time and the function will return 0). Reported-by: coverity (CID 1222108) Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ian Abbott abbo...@mev.co.uk Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/staging/comedi/drivers/ni_labpc_common.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c b/drivers/staging/comedi/drivers/ni_labpc_common.c index b88ee26..084c89c 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_common.c +++ b/drivers/staging/comedi/drivers/ni_labpc_common.c @@ -482,9 +482,6 @@ static int labpc_ai_check_chanlist(struct comedi_device *dev, unsigned int aref0 = CR_AREF(cmd-chanlist[0]); int i; - if (mode == MODE_SINGLE_CHAN) - return 0; - for (i = 0; i cmd-chanlist_len; i++) { unsigned int chan = CR_CHAN(cmd-chanlist[i]); unsigned int range = CR_RANGE(cmd-chanlist[i]); -- 2.3.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel