[PATCH] Staging: most: Remove __cplusplus check in header files
From: PrasannaKumar Muralidharan Remove unnecessary __cplusplus check in header files as it is not required. Signed-off-by: PrasannaKumar Muralidharan --- drivers/staging/most/hdm-dim2/dim2_errors.h | 8 drivers/staging/most/hdm-dim2/dim2_hal.h| 8 drivers/staging/most/hdm-dim2/dim2_reg.h| 8 3 files changed, 24 deletions(-) diff --git a/drivers/staging/most/hdm-dim2/dim2_errors.h b/drivers/staging/most/hdm-dim2/dim2_errors.h index 5a713df..66343ba 100644 --- a/drivers/staging/most/hdm-dim2/dim2_errors.h +++ b/drivers/staging/most/hdm-dim2/dim2_errors.h @@ -15,10 +15,6 @@ #ifndef _MOST_DIM_ERRORS_H #define _MOST_DIM_ERRORS_H -#ifdef __cplusplus -extern "C" { -#endif - /** * MOST DIM errors. */ @@ -58,8 +54,4 @@ enum dim_errors_t { DIM_ERR_OVERFLOW, }; -#ifdef __cplusplus -} -#endif - #endif /* _MOST_DIM_ERRORS_H */ diff --git a/drivers/staging/most/hdm-dim2/dim2_hal.h b/drivers/staging/most/hdm-dim2/dim2_hal.h index fc73d4f..8e9d5ea 100644 --- a/drivers/staging/most/hdm-dim2/dim2_hal.h +++ b/drivers/staging/most/hdm-dim2/dim2_hal.h @@ -18,10 +18,6 @@ #include #include "dim2_reg.h" -#ifdef __cplusplus -extern "C" { -#endif - /* * The values below are specified in the hardware specification. * So, they should not be changed until the hardware specification changes. @@ -110,8 +106,4 @@ void dimcb_io_write(u32 __iomem *ptr32, u32 value); void dimcb_on_error(u8 error_id, const char *error_message); -#ifdef __cplusplus -} -#endif - #endif /* _DIM2_HAL_H */ diff --git a/drivers/staging/most/hdm-dim2/dim2_reg.h b/drivers/staging/most/hdm-dim2/dim2_reg.h index bcf6a79..e0837b6 100644 --- a/drivers/staging/most/hdm-dim2/dim2_reg.h +++ b/drivers/staging/most/hdm-dim2/dim2_reg.h @@ -17,10 +17,6 @@ #include -#ifdef __cplusplus -extern "C" { -#endif - struct dim2_regs { /* 0x00 */ u32 MLBC0; /* 0x01 */ u32 rsvd0[1]; @@ -166,8 +162,4 @@ enum { CAT_CL_MASK = DIM2_MASK(6) }; -#ifdef __cplusplus -} -#endif - #endif /* DIM2_OS62420_H */ -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Staging: most: Remove __cplusplus check in heade files
> Your subject line contains a spelling mistake :( I have sent an email with this fixed. Regards, PrasannaKumar ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Staging: most: Remove volatile usage
> Since it is _not_ assured that the code will run under all circumstances, > I don't want this patch to be applied at this point. > > To be able to decide on the removal of the volatile keyword, we need to run > some tests on real hardware. This ain't something we can tell by just > looking at the code. > > We'll add this to our todo list. Thanks Christian, it will be really helpful. Thanks, PrasannaKumar ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: dgnc: fix CamelCase in dgnc_driver.c
Hi Daeseok, [auto build test ERROR on staging/staging-testing] [also build test ERROR on next-20160323] [cannot apply to v4.5] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system] url: https://github.com/0day-ci/linux/commits/Daeseok-Youn/staging-dgnc-fix-CamelCase-in-dgnc_driver-c/20160323-131708 config: x86_64-randconfig-s1-03231424 (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): drivers/built-in.o: In function `dgnc_mgmt_ioctl': >> (.text+0x7ca676): undefined reference to `dgnc_NumBoards' drivers/built-in.o: In function `dgnc_mgmt_ioctl': (.text+0x7ca71d): undefined reference to `dgnc_NumBoards' drivers/built-in.o: In function `dgnc_mgmt_ioctl': >> (.text+0x7ca73e): undefined reference to `dgnc_Board' drivers/built-in.o: In function `dgnc_mgmt_ioctl': (.text+0x7ca759): undefined reference to `dgnc_Board' drivers/built-in.o: In function `dgnc_mgmt_ioctl': (.text+0x7ca83a): undefined reference to `dgnc_NumBoards' drivers/built-in.o: In function `dgnc_mgmt_ioctl': (.text+0x7ca85c): undefined reference to `dgnc_Board' drivers/built-in.o: In function `dgnc_driver_boards_show': >> dgnc_sysfs.c:(.text+0x7d2bda): undefined reference to `dgnc_NumBoards' --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 1/3] staging: comedi: dt282x: remove unnecessary comedi_check_trigger_arg_max()
On 22/03/16 17:01, H Hartley Sweeten wrote: Step 4 of the (*do_cmdtest) calls dt282x_ns_to_timer() to work out the divisor needed to generate the 'convert_arg' timing. If the 'convert_arg' timing can not be generated, the function returns the max timing that can be generated. The Step 3 'max' check of the 'convert_arg' isn't necessary. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt282x.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 06a87a1..be6a0bc 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -689,8 +689,6 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev, err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 4000); -#define SLOWEST_TIMER (250*(1<<15)*255) - err |= comedi_check_trigger_arg_max(&cmd->convert_arg, SLOWEST_TIMER); err |= comedi_check_trigger_arg_min(&cmd->convert_arg, board->ai_speed); err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); I'd be inclined to keep the existing check in place, as it goes with the arg_min test (although one of the arg_min tests on convert_arg is redundant, as you point out in patch 2). -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: comedi: drivers: remove bogus ni_mio_c_common.c
The zero-length file "ni_mio_c_common.c" was inadvertantly created by commit e563637b5fef ("staging: comedi: Use ARRAY_SIZE for sizes of arrays"). Remove it. Signed-off-by: Ian Abbott --- drivers/staging/comedi/drivers/ni_mio_c_common.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 drivers/staging/comedi/drivers/ni_mio_c_common.c diff --git a/drivers/staging/comedi/drivers/ni_mio_c_common.c b/drivers/staging/comedi/drivers/ni_mio_c_common.c deleted file mode 100644 index e69de29..000 -- 2.7.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: comedi: z8536: tidy up bit defines
On 22/03/16 18:29, H Hartley Sweeten wrote: Fix the checkpatch.pl issues: CHECK: Prefer using the BIT macro Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/z8536.h | 89 ++ 1 file changed, 48 insertions(+), 41 deletions(-) Reviewed-by: Ian Abbott -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 0/2] staging: comedi: plx9052.h: minor cleanup
On 22/03/16 18:51, H Hartley Sweeten wrote: Fix the checkpatch.pl issues. H Hartley Sweeten (2): staging: comedi: plx9052.h: tidy up bit defines staging: comedi: plx9052.h: fix block comment issues drivers/staging/comedi/drivers/plx9052.h | 122 +++ 1 file changed, 61 insertions(+), 61 deletions(-) Thanks! Reviewed-by: Ian Abbott -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 0/6] staging: comedi: ni_labpc: minor cleanup
On 22/03/16 18:21, H Hartley Sweeten wrote: Fix all the checkpatch.pl issues. v2: remove the changes to z8536.h H Hartley Sweeten (6): staging: comedi: ni_labpc: remove some unnecessary defines staging: comedi: ni_labpc_regs.h: tidy up bit defines staging: comedi: ni_labpc_common: tidy up block comments staging: comedi: ni_labpc_cs: fix block comment issues staging: comedi: ni_labpc_pci: tidy up bit define staging: comedi: ni_labpc.h: fix block comment issues drivers/staging/comedi/drivers/ni_labpc.h| 33 drivers/staging/comedi/drivers/ni_labpc_common.c | 65 +--- drivers/staging/comedi/drivers/ni_labpc_cs.c | 95 +++- drivers/staging/comedi/drivers/ni_labpc_pci.c| 4 +- drivers/staging/comedi/drivers/ni_labpc_regs.h | 82 ++-- 5 files changed, 141 insertions(+), 138 deletions(-) Thanks! Reviewed-by: Ian Abbott -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: iio: Fix sparse endian warning
Fix following sparse warning: warning: cast to restricted __be16 Signed-off-by: Ksenija Stanojevic --- drivers/staging/iio/adc/ad7606_spi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/adc/ad7606_spi.c b/drivers/staging/iio/adc/ad7606_spi.c index d873a51..825da07 100644 --- a/drivers/staging/iio/adc/ad7606_spi.c +++ b/drivers/staging/iio/adc/ad7606_spi.c @@ -21,7 +21,8 @@ static int ad7606_spi_read_block(struct device *dev, { struct spi_device *spi = to_spi_device(dev); int i, ret; - unsigned short *data = buf; + unsigned short *data; + __be16 *bdata = buf; ret = spi_read(spi, buf, count * 2); if (ret < 0) { @@ -30,7 +31,7 @@ static int ad7606_spi_read_block(struct device *dev, } for (i = 0; i < count; i++) - data[i] = be16_to_cpu(data[i]); + data[i] = be16_to_cpu(bdata[i]); return 0; } -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 00/43] staging: comedi: ni_660x: big driver cleanup
On 22/03/16 18:10, H Hartley Sweeten wrote: This driver has a lot of checkpatch.pl issues: total: 0 errors, 71 warnings, 27 checks, 1222 lines checked There is also a lot of cruft that bloats the driver and makes it harder to follow. This series fixes all the checkpatch.pl issues: total: 0 errors, 0 warnings, 0 checks, 944 lines checked And, even better, removes the cruft: textdata bss dec hex filename 10249 344 0 105932961 ni_660x.o.original 4719 344 0506313c7 ni_660x.o v2: add patch to make ni_gpct_device_destroy() NULL pointer safe. H Hartley Sweeten (43): staging: comedi: ni_660x: change IOConfigReg() into a macro staging: comedi: ni_660x: remove struct NI_660xRegisterData 'name' staging: comedi: ni_660x: remove enum ni_register_width staging: comedi: ni_660x: remove enum ni_660x_register_direction staging: comedi: ni_660x: rename CamelCase 'NI_660xRegisterData' staging: comedi: ni_660x: cleanup the NI660X_IO_CFG register helpers staging: comedi: ni_660x: tidy up multi-line comment staging: comedi: ni_660x: remove enum clock_config_register_bits staging: comedi: ni_660x: cleanup the NI660X_DMA_CFG register helpers staging: comedi: ni_660x: cleanup the NI660X_GLOBAL_INT_{STATUS,CFG} staging: comedi: ni_660x: tidy up ni_660x_write_register() staging: comedi: ni_660x: tidy up ni_660x_read_register() staging: comedi: ni_660x: tidy up ni_gpct_{write,read}_register() staging: comedi: ni_660x: tidy up ni_660x_select_pfi_output() staging: comedi: ni_660x: remove BUG_ON() in ni_660x_request_mite_channel() staging: comedi: ni_660x: fix block comment issues staging: comedi: ni_660x: remove enum ni_660x_subdevices staging: comedi: ni_660x: remove ni_660x_num_counters() staging: comedi: ni_660x: Prefer 'unsigned int' to bare use of 'unsigned' staging: comedi: ni_660x: Prefer kernel type 'u64' over 'uint64_t' staging: comedi: ni_660x: tidy up Digital I/O subdevice init staging: comedi: ni_660x: tidy up ni_660x_dio_insn_bits() staging: comedi: ni_660x: tidy up ni_660x_set_pfi_routing() staging: comedi: ni_660x: add a comment about the initial DIO state staging: comedi: ni_660x: refactor ni_gpct_to_660x_register() staging: comedi: ni_660x: add comments for the spinlock_t definitions staging: comedi: ni_660x: fix memory barrier without comment staging: comedi: ni_660x: tidy up the misc. constants staging: comedi: ni_660x: tidy up the counter subdevices init staging: comedi: ni_tio: make ni_gpct_device_destroy() NULL pointer safe staging: comedi: ni_660x: ni_gpct_device_destroy() can handle a NULL pointer staging: comedi: ni_mio_common: ni_gpct_device_destroy() can handle a NULL pointer staging: comedi: ni_660x: disable interrupts when detaching driver staging: comedi: ni_660x: init TIO chips before subdevice init staging: comedi: ni_660x: allocate counters early in (*auto_attach) staging: comedi: ni_660x: initialize the counter with the subdevice init staging: comedi: ni_660x: default DIO channels with subdevice init staging: comedi: ni_660x: remove inline mite_ring() staging: comedi: ni_660x: sort enum ni_660x_register staging: comedi: ni_660x: remove ni_gpct_to_660x_register[] staging: comedi: ni_660x: remove spinlock 'dma_cfg_lock' staging: comedi: ni_660x: refactor GPCT_OFFSET staging: comedi: ni_660x: update the MODULE_DESCRIPTION drivers/staging/comedi/drivers/ni_660x.c | 1156 +--- drivers/staging/comedi/drivers/ni_mio_common.c |6 +- drivers/staging/comedi/drivers/ni_tio.c|2 +- 3 files changed, 442 insertions(+), 722 deletions(-) Thanks! Reviewed-by: Ian Abbott -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] dma-buf: Update docs for SYNC ioctl
Hey On Mon, Mar 21, 2016 at 6:14 PM, Daniel Vetter wrote: > On Mon, Mar 21, 2016 at 01:26:58PM +0100, David Herrmann wrote: >> Hi >> >> On Mon, Mar 21, 2016 at 8:51 AM, Daniel Vetter >> wrote: >> > Just a bit of wording polish plus mentioning that it can fail and must >> > be restarted. >> > >> > Requested by Sumit. >> > >> > v2: Fix them typos (Hans). >> > >> > Cc: Chris Wilson >> > Cc: Tiago Vignatti >> > Cc: Stéphane Marchesin >> > Cc: David Herrmann >> > Cc: Sumit Semwal >> > Cc: Daniel Vetter >> > CC: linux-me...@vger.kernel.org >> > Cc: dri-de...@lists.freedesktop.org >> > Cc: linaro-mm-...@lists.linaro.org >> > Cc: intel-...@lists.freedesktop.org >> > Cc: de...@driverdev.osuosl.org >> > Cc: Hans Verkuil >> > Acked-by: Sumit Semwal >> > Signed-off-by: Daniel Vetter >> > --- >> > Documentation/dma-buf-sharing.txt | 11 ++- >> > drivers/dma-buf/dma-buf.c | 2 +- >> > 2 files changed, 7 insertions(+), 6 deletions(-) >> > >> > diff --git a/Documentation/dma-buf-sharing.txt >> > b/Documentation/dma-buf-sharing.txt >> > index 32ac32e773e1..ca44c5820585 100644 >> > --- a/Documentation/dma-buf-sharing.txt >> > +++ b/Documentation/dma-buf-sharing.txt >> > @@ -352,7 +352,8 @@ Being able to mmap an export dma-buf buffer object has >> > 2 main use-cases: >> > >> > No special interfaces, userspace simply calls mmap on the dma-buf fd, >> > making >> > sure that the cache synchronization ioctl (DMA_BUF_IOCTL_SYNC) is >> > *always* >> > - used when the access happens. This is discussed next paragraphs. >> > + used when the access happens. Note that DMA_BUF_IOCTL_SYNC can fail >> > with >> > + -EAGAIN or -EINTR, in which case it must be restarted. >> >> What is "restart on EAGAIN" supposed to mean? Or more generally, what >> does EAGAIN tell the caller? > > Do what drmIoctl does essentially. > > while (ret == -1 && (errno == EAGAIN || errno == EINTR) > ret = ioctl(); > > Typed from memery, too lazy to look it up in the source ;-) I'm trying to > sell the idea of a real dma-buf manpage to Sumit, we should clarify this > in detail there. My question was rather about why we do this? Semantics for EINTR are well defined, and with SA_RESTART (default on linux) user-space can ignore it. However, looping on EAGAIN is very uncommon, and it is not at all clear why it is needed? Returning an error to user-space makes sense if user-space has a reason to react to it. I fail to see how EAGAIN on a cache-flush/sync operation helps user-space at all? As someone without insight into the driver implementation, it is hard to tell why.. Any hints? Thanks David ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH V2] staging: dgnc: fix CamelCase in dgnc_driver.c
fix checkpatch.pl warning about CamelCase. Signed-off-by: Daeseok Youn --- V2: fix build errors reported by kbuild test robot. And also save the attached .config file to my linux build tree. build successfully without any errors. drivers/staging/dgnc/dgnc_driver.c | 52 +++--- drivers/staging/dgnc/dgnc_driver.h | 6 ++--- drivers/staging/dgnc/dgnc_mgmt.c | 28 ++-- drivers/staging/dgnc/dgnc_sysfs.c | 2 +- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index 4eb410e..af2e835 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -48,7 +48,7 @@ static void dgnc_do_remap(struct dgnc_board *brd); /* * File operations permitted on Control/Management major. */ -static const struct file_operations dgnc_BoardFops = { +static const struct file_operations dgnc_board_fops = { .owner = THIS_MODULE, .unlocked_ioctl = dgnc_mgmt_ioctl, .open = dgnc_mgmt_open, @@ -58,11 +58,11 @@ static const struct file_operations dgnc_BoardFops = { /* * Globals */ -uint dgnc_NumBoards; -struct dgnc_board *dgnc_Board[MAXBOARDS]; +uint dgnc_num_boards; +struct dgnc_board *dgnc_board[MAXBOARDS]; DEFINE_SPINLOCK(dgnc_global_lock); DEFINE_SPINLOCK(dgnc_poll_lock); /* Poll scheduling lock */ -uint dgnc_Major; +uint dgnc_major; intdgnc_poll_tick = 20;/* Poll interval - 20 ms */ /* @@ -92,7 +92,7 @@ struct board_id { unsigned int is_pci_express; }; -static struct board_id dgnc_Ids[] = { +static struct board_id dgnc_ids[] = { { PCI_DEVICE_CLASSIC_4_PCI_NAME, 4, 0 }, { PCI_DEVICE_CLASSIC_4_422_PCI_NAME, 4, 0 }, { PCI_DEVICE_CLASSIC_8_PCI_NAME, 8, 0 }, @@ -140,14 +140,14 @@ static void cleanup(bool sysfiles) if (sysfiles) dgnc_remove_driver_sysfiles(&dgnc_driver); - device_destroy(dgnc_class, MKDEV(dgnc_Major, 0)); + device_destroy(dgnc_class, MKDEV(dgnc_major, 0)); class_destroy(dgnc_class); - unregister_chrdev(dgnc_Major, "dgnc"); + unregister_chrdev(dgnc_major, "dgnc"); - for (i = 0; i < dgnc_NumBoards; ++i) { - dgnc_remove_ports_sysfiles(dgnc_Board[i]); - dgnc_tty_uninit(dgnc_Board[i]); - dgnc_cleanup_board(dgnc_Board[i]); + for (i = 0; i < dgnc_num_boards; ++i) { + dgnc_remove_ports_sysfiles(dgnc_board[i]); + dgnc_tty_uninit(dgnc_board[i]); + dgnc_cleanup_board(dgnc_board[i]); } dgnc_tty_post_uninit(); @@ -217,12 +217,12 @@ static int dgnc_start(void) * * Register management/dpa devices */ - rc = register_chrdev(0, "dgnc", &dgnc_BoardFops); + rc = register_chrdev(0, "dgnc", &dgnc_board_fops); if (rc < 0) { pr_err(DRVSTR ": Can't register dgnc driver device (%d)\n", rc); return rc; } - dgnc_Major = rc; + dgnc_major = rc; dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt"); if (IS_ERR(dgnc_class)) { @@ -232,7 +232,7 @@ static int dgnc_start(void) } dev = device_create(dgnc_class, NULL, - MKDEV(dgnc_Major, 0), + MKDEV(dgnc_major, 0), NULL, "dgnc_mgmt"); if (IS_ERR(dev)) { rc = PTR_ERR(dev); @@ -262,11 +262,11 @@ static int dgnc_start(void) return 0; failed_tty: - device_destroy(dgnc_class, MKDEV(dgnc_Major, 0)); + device_destroy(dgnc_class, MKDEV(dgnc_major, 0)); failed_device: class_destroy(dgnc_class); failed_class: - unregister_chrdev(dgnc_Major, "dgnc"); + unregister_chrdev(dgnc_major, "dgnc"); return rc; } @@ -283,7 +283,7 @@ static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) rc = dgnc_found_board(pdev, ent->driver_data); if (rc == 0) - dgnc_NumBoards++; + dgnc_num_boards++; return rc; } @@ -346,7 +346,7 @@ static void dgnc_cleanup_board(struct dgnc_board *brd) } } - dgnc_Board[brd->boardnum] = NULL; + dgnc_board[brd->boardnum] = NULL; kfree(brd); } @@ -365,8 +365,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) unsigned long flags; /* get the board structure and prep it */ - dgnc_Board[dgnc_NumBoards] = kzalloc(sizeof(*brd), GFP_KERNEL); - brd = dgnc_Board[dgnc_NumBoards]; + dgnc_board[dgnc_num_boards] = kzalloc(sizeof(*brd), GFP_KERNEL); + brd = dgnc_board[dgnc_num_boards]; if (!brd
Re: [PATCH] dma-buf: Update docs for SYNC ioctl
On Wed, Mar 23, 2016 at 12:30:42PM +0100, David Herrmann wrote: > My question was rather about why we do this? Semantics for EINTR are > well defined, and with SA_RESTART (default on linux) user-space can > ignore it. However, looping on EAGAIN is very uncommon, and it is not > at all clear why it is needed? > > Returning an error to user-space makes sense if user-space has a > reason to react to it. I fail to see how EAGAIN on a cache-flush/sync > operation helps user-space at all? As someone without insight into the > driver implementation, it is hard to tell why.. Any hints? The reason we return EAGAIN is to workaround a deadlock we face when blocking on the GPU holding the struct_mutex (inside the client's process), but the GPU is dead. As our locking is very, very coarse we cannot restart the GPU without acquiring the struct_mutex being held by the client so we wake the client up and tell them the resource they are waiting on (the flush of the object from the GPU into the CPU domain) is temporarily unavailable. If they try to immediately wait upon the ioctl again, they are blocked waiting for the reset to occur before they may complete their flush. There are a few other possible deadlocks that are also avoided with EAGAIN (again, the issue is more or less the lack of fine grained locking). -Chris -- Chris Wilson, Intel Open Source Technology Centre ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/2] staging: wilc1000: use completion instead of struct semaphore hif_sema_thread
struct semaphore hif_sema_thread is used to signal completion of host interface thread. This patch replaces struct semaphore hif_sema_thread with struct completion hif_thread_comp. It is better to use completion than semaphore for this case. Signed-off-by: Chaehyun Lim --- drivers/staging/wilc1000/host_interface.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index b1ffa91..3d17972 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -231,7 +231,7 @@ bool wilc_optaining_ip; static u8 P2P_LISTEN_STATE; static struct task_struct *hif_thread_handler; static struct message_queue hif_msg_q; -static struct semaphore hif_sema_thread; +static struct completion hif_thread_comp; static struct semaphore hif_sema_driver; static struct completion hif_wait_response; static struct mutex hif_deinit_lock; @@ -2668,7 +2668,7 @@ static int hostIFthread(void *pvArg) } } - up(&hif_sema_thread); + complete(&hif_thread_comp); return 0; } @@ -3400,7 +3400,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) wilc_optaining_ip = false; if (clients_count == 0) { - sema_init(&hif_sema_thread, 0); + init_completion(&hif_thread_comp); sema_init(&hif_sema_driver, 0); mutex_init(&hif_deinit_lock); } @@ -3503,7 +3503,7 @@ int wilc_deinit(struct wilc_vif *vif) if (result != 0) netdev_err(vif->ndev, "deinit : Error(%d)\n", result); - down(&hif_sema_thread); + wait_for_completion(&hif_thread_comp); wilc_mq_destroy(&hif_msg_q); } -- 2.7.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/2] staging: wilc1000: use completion instead of struct semaphore hif_sema_driver
struct semaphore hif_sema_driver is used to signal completion of host interface message. This patch replaces struct semaphore hif_sema_driver with struct completion hif_driver_comp. It is better to use completion than semaphore for this case. Signed-off-by: Chaehyun Lim --- drivers/staging/wilc1000/host_interface.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 3d17972..29d4d8a 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -232,7 +232,7 @@ static u8 P2P_LISTEN_STATE; static struct task_struct *hif_thread_handler; static struct message_queue hif_msg_q; static struct completion hif_thread_comp; -static struct semaphore hif_sema_driver; +static struct completion hif_driver_comp; static struct completion hif_wait_response; static struct mutex hif_deinit_lock; static struct timer_list periodic_rssi; @@ -321,7 +321,7 @@ static s32 handle_set_wfi_drv_handler(struct wilc_vif *vif, hif_drv_handler->handler); if (!hif_drv_handler->handler) - up(&hif_sema_driver); + complete(&hif_driver_comp); if (result) { netdev_err(vif->ndev, "Failed to set driver handler\n"); @@ -346,7 +346,7 @@ static s32 handle_set_operation_mode(struct wilc_vif *vif, wilc_get_vif_idx(vif)); if ((hif_op_mode->mode) == IDLE_MODE) - up(&hif_sema_driver); + complete(&hif_driver_comp); if (result) { netdev_err(vif->ndev, "Failed to set driver handler\n"); @@ -3401,7 +3401,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) if (clients_count == 0) { init_completion(&hif_thread_comp); - sema_init(&hif_sema_driver, 0); + init_completion(&hif_driver_comp); mutex_init(&hif_deinit_lock); } @@ -3480,7 +3480,7 @@ int wilc_deinit(struct wilc_vif *vif) del_timer_sync(&hif_drv->remain_on_ch_timer); wilc_set_wfi_drv_handler(vif, 0, 0); - down(&hif_sema_driver); + wait_for_completion(&hif_driver_comp); if (hif_drv->usr_scan_req.scan_result) { hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL, -- 2.7.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: android: ion_test: fix check of platform_device_register_simple() error code
Hi Vladimir Zapolskiy, On 03/23/2016 05:38 AM, Vladimir Zapolskiy wrote: On error platform_device_register_simple() returns ERR_PTR() value, check for NULL always fails. The change corrects the check itself and propagates the returned error upwards. Thank for the fix. I agree with you. Fixes: 81fb0b901397 ("staging: android: ion_test: unregister the platform device") Signed-off-by: Vladimir Zapolskiy --- drivers/staging/android/ion/ion_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/ion/ion_test.c b/drivers/staging/android/ion/ion_test.c index da34bc12..83a3af0 100644 --- a/drivers/staging/android/ion/ion_test.c +++ b/drivers/staging/android/ion/ion_test.c @@ -285,8 +285,8 @@ static int __init ion_test_init(void) { ion_test_pdev = platform_device_register_simple("ion-test", -1, NULL, 0); - if (!ion_test_pdev) - return -ENODEV; + if (IS_ERR(ion_test_pdev)) + return PTR_ERR(ion_test_pdev); return platform_driver_probe(&ion_test_platform_driver, ion_test_probe); } Regards, Phong. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [lustre-devel] [PATCH] Revert "Staging: lustre: o2iblnd: Use sizeof type *pointer instead of sizeof type."
On Wed, Mar 23, 2016 at 05:39:36AM +, Dilger, Andreas wrote: > On 2016/03/22, 19:49, "lustre-devel on behalf of Greg Kroah-Hartman" > gre...@linuxfoundation.org> wrote: > > >On Tue, Mar 22, 2016 at 06:21:04PM -0400, James Simmons wrote: > >> Latest testing fails when using ko2iblnd. It was tracked down > >> to commit 4671a026616df26000f7d8ad2f2ea4b6de79263c. > >> > >> This reverts commit 4671a026616df26000f7d8ad2f2ea4b6de79263c. > >> --- > >> .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|4 ++-- > >> 1 files changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > >>b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > >> index 89f9390..0d32e65 100644 > >> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > >> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > >> @@ -1968,7 +1968,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, > >>__u32 *cpts, int ncpts) > >> */ > >> > >>net->ibn_fmr_ps = cfs_percpt_alloc(lnet_cpt_table(), > >> - sizeof(*net->ibn_fmr_ps)); > >> + sizeof(kib_fmr_poolset_t)); > > > >Ok, why is this revert needed? Please give me a big huge comment about > >why this is not the same size of the variable being assigned to it, > >otherwise someone else is going to come along and make the exact same > >change again. > > > >>if (!net->ibn_fmr_ps) { > >>CERROR("Failed to allocate FMR pool array\n"); > >>rc = -ENOMEM; > >> @@ -1992,7 +1992,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, > >>__u32 *cpts, int ncpts) > >> > >> create_tx_pool: > >>net->ibn_tx_ps = cfs_percpt_alloc(lnet_cpt_table(), > >> -sizeof(*net->ibn_tx_ps)); > >> +sizeof(kib_tx_poolset_t)); > > > >Same here, why is this code wrong? > > Looks like the declarations are: > > kib_tx_poolset_t **ibn_tx_ps;/* tx pool-set */ > kib_fmr_poolset_t **ibn_fmr_ps; /* fmr pool-set */ > > > > so the right code should be: > > sizeof(**net->ibn_tx_ps); > > > and the same for sizeof(**net->ibn_fmr_ps) That's a mess, isn't there some other way to fix this up to be more "obvious"? thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] dma-buf/sync_file: de-stage sync_file
Hi Sumit, 2016-03-21 Sumit Semwal : > Thanks for the patch, Gustavo! > > On 18 March 2016 at 19:49, Gustavo Padovan wrote: > > From: Gustavo Padovan > > > > sync_file is useful to connect one or more fences to the file. The file is > > used by userspace to track fences. > > > I think it is worthwhile to add relevant bits to the Documentation as > well - care to add relevant stuff to either Documentation/dma_buf.txt, > or to a file of its own? (I'd prefer the former, but would leave it > upto you.) Sure, that is part of my plan. I'm currently trying to have a working version of fences on DRM then I think I'll be able to add Documentation for everything I have done. Gustavo ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH net-next, 2/2] hv_netvsc: Fix the array sizes to be max supported channels
The VRSS_CHANNEL_MAX is the max number of channels supported by Hyper-V hosts. We use it for the related array sizes instead of using NR_CPUS, which may be set to several thousands. This patch reduces possible memory allocation failures. Signed-off-by: Haiyang Zhang Reviewed-by: K. Y. Srinivasan --- drivers/net/hyperv/hyperv_net.h |7 --- drivers/net/hyperv/rndis_filter.c |4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index b4c6878..8b3bd8e 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -619,6 +619,7 @@ struct nvsp_message { #define NETVSC_PACKET_SIZE 4096 #define VRSS_SEND_TAB_SIZE 16 +#define VRSS_CHANNEL_MAX 64 #define RNDIS_MAX_PKT_DEFAULT 8 #define RNDIS_PKT_ALIGN_DEFAULT 8 @@ -700,13 +701,13 @@ struct netvsc_device { struct net_device *ndev; - struct vmbus_channel *chn_table[NR_CPUS]; + struct vmbus_channel *chn_table[VRSS_CHANNEL_MAX]; u32 send_table[VRSS_SEND_TAB_SIZE]; u32 max_chn; u32 num_chn; spinlock_t sc_lock; /* Protects num_sc_offered variable */ u32 num_sc_offered; - atomic_t queue_sends[NR_CPUS]; + atomic_t queue_sends[VRSS_CHANNEL_MAX]; /* Holds rndis device info */ void *extension; @@ -718,7 +719,7 @@ struct netvsc_device { /* The sub channel callback buffer */ unsigned char *sub_cb_buf; - struct multi_send_data msd[NR_CPUS]; + struct multi_send_data msd[VRSS_CHANNEL_MAX]; u32 max_pkt; /* max number of pkt in one send, e.g. 8 */ u32 pkt_align; /* alignment bytes, e.g. 8 */ diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index 47d07c5..d5a54da 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -1113,9 +1113,9 @@ int rndis_filter_device_add(struct hv_device *dev, if (ret || rsscap.num_recv_que < 2) goto out; - num_rss_qs = min(device_info->max_num_vrss_chns, rsscap.num_recv_que); + net_device->max_chn = min_t(u32, VRSS_CHANNEL_MAX, rsscap.num_recv_que); - net_device->max_chn = rsscap.num_recv_que; + num_rss_qs = min(device_info->max_num_vrss_chns, net_device->max_chn); /* * We will limit the VRSS channels to the number CPUs in the NUMA node -- 1.7.4.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH net-next, 1/2] hv_netvsc: Fix accessing freed memory in netvsc_change_mtu()
struct netvsc_device is freed in rndis_filter_device_remove(). So we save the nvdev->num_chn into a temp variable for later usage. (Please also include this patch into stable branch.) Signed-off-by: Haiyang Zhang Reviewed-by: K. Y. Srinivasan --- drivers/net/hyperv/netvsc_drv.c |5 - 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 0860849..b8121eb 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -858,6 +858,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) struct netvsc_device *nvdev = hv_get_drvdata(hdev); struct netvsc_device_info device_info; int limit = ETH_DATA_LEN; + u32 num_chn; int ret = 0; if (nvdev == NULL || nvdev->destroy) @@ -873,6 +874,8 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) if (ret) goto out; + num_chn = nvdev->num_chn; + nvdev->start_remove = true; rndis_filter_device_remove(hdev); @@ -883,7 +886,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) memset(&device_info, 0, sizeof(device_info)); device_info.ring_size = ring_size; - device_info.num_chn = nvdev->num_chn; + device_info.num_chn = num_chn; device_info.max_num_vrss_chns = max_num_vrss_chns; rndis_filter_device_add(hdev, &device_info); -- 1.7.4.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [RFC 00/29] De-stage android's sync framework
On 19 January 2016 at 17:12, John Harrison wrote: > On 19/01/2016 15:23, Gustavo Padovan wrote: >> >> Hi Daniel, >> >> 2016-01-19 Daniel Vetter : >> >>> On Fri, Jan 15, 2016 at 12:55:10PM -0200, Gustavo Padovan wrote: From: Gustavo Padovan This patch series de-stage the sync framework, and in order to accomplish that a bunch of cleanups/improvements on the sync and fence were made. The sync framework contained some abstractions around struct fence and those were removed in the de-staging process among other changes: Userspace visible changes - * The sw_sync file was moved from /dev/sw_sync to /sync/sw_sync. No other change. Kernel API changes -- * struct sync_timeline is now struct fence_timeline * sync_timeline_ops is now fence_timeline_ops and they now carry struct fence as parameter instead of struct sync_pt * a .cleanup() fence op was added to allow sync_fence to run a cleanup when the fence_timeline is destroyed * added fence_add_used_data() to pass a private point to struct fence. This pointer is sent back on the .cleanup op. * The sync timeline function were moved to be fence_timeline functions: - sync_timeline_create() -> fence_timeline_create() - sync_timeline_get() -> fence_timeline_get() - sync_timeline_put() -> fence_timeline_put() - sync_timeline_destroy() -> fence_timeline_destroy() - sync_timeline_signal() -> fence_timeline_signal() * sync_pt_create() was replaced be fence_create_on_timeline() Internal changes * fence_timeline_ops was removed in favor of direct use fence_ops * fence default functions were created for fence_ops * removed structs sync_pt, sw_sync_timeline and sw_sync_pt >>> >>> Bunch of fairly random comments all over: >>> >>> - include/uapi/linux/sw_sync.h imo should be dropped, it's just a private >>>debugfs interface between fence fds and the testsuite. Since the plan >>> is >>>to have the testcases integrated into the kernel tree too we don't >>> need >>>a public header. >>> >>> - similar for include/linux/sw_sync.h Imo that should all be moved into >>>sync_debug.c. Same for sw_sync.c, that should all land in sync_debug >>>imo, and made optional with a Kconfig option. At least we should reuse >>>CONFIG_DEBUGFS. >> >> These two items sounds reasonable to me. > > > I have just posted our in-progress IGT for testing i915 syncs (with a CC of > Gustavo). It uses the sw_sync mechanisms. Can you take a quick look and see > if it is the kind of thing you would expect us to be doing? Or is it using > interfaces that you are planning to remove and/or make kernel only? > > I'm not sure having a kernel only test is the best way to go. Having user > land tests like IGT would be much more versatile. Hi John, I'm working on making the tests in igt useful for drivers other than i915 and would love to have tests for the fence functionality. Have you made any progress since you posted that RFC? Thanks, Tomeu ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] dma-buf: Update docs for SYNC ioctl
Hi On Wed, Mar 23, 2016 at 12:56 PM, Chris Wilson wrote: > On Wed, Mar 23, 2016 at 12:30:42PM +0100, David Herrmann wrote: >> My question was rather about why we do this? Semantics for EINTR are >> well defined, and with SA_RESTART (default on linux) user-space can >> ignore it. However, looping on EAGAIN is very uncommon, and it is not >> at all clear why it is needed? >> >> Returning an error to user-space makes sense if user-space has a >> reason to react to it. I fail to see how EAGAIN on a cache-flush/sync >> operation helps user-space at all? As someone without insight into the >> driver implementation, it is hard to tell why.. Any hints? > > The reason we return EAGAIN is to workaround a deadlock we face when > blocking on the GPU holding the struct_mutex (inside the client's > process), but the GPU is dead. As our locking is very, very coarse we > cannot restart the GPU without acquiring the struct_mutex being held by > the client so we wake the client up and tell them the resource they are > waiting on (the flush of the object from the GPU into the CPU domain) is > temporarily unavailable. If they try to immediately wait upon the ioctl > again, they are blocked waiting for the reset to occur before they may > complete their flush. There are a few other possible deadlocks that are > also avoided with EAGAIN (again, the issue is more or less the lack of > fine grained locking). ...so you hijacked EAGAIN for all DRM ioctls just for a driver workaround? EAGAIN is universally used to signal the caller about a blocking resource. It is very much linked to O_NONBLOCK. Why not use EBUSY, ECANCELED, ECOMM, EDEADLOCK, EIO, EL3RST, ... Anyhow, I guess that ship has sailed. But just mentioning EAGAIN in a kernel-doc is way to vague for user-space to figure out they should loop on it. Thanks David ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] dma-buf: Update docs for SYNC ioctl
On Wed, Mar 23, 2016 at 04:32:59PM +0100, David Herrmann wrote: > Hi > > On Wed, Mar 23, 2016 at 12:56 PM, Chris Wilson > wrote: > > On Wed, Mar 23, 2016 at 12:30:42PM +0100, David Herrmann wrote: > >> My question was rather about why we do this? Semantics for EINTR are > >> well defined, and with SA_RESTART (default on linux) user-space can > >> ignore it. However, looping on EAGAIN is very uncommon, and it is not > >> at all clear why it is needed? > >> > >> Returning an error to user-space makes sense if user-space has a > >> reason to react to it. I fail to see how EAGAIN on a cache-flush/sync > >> operation helps user-space at all? As someone without insight into the > >> driver implementation, it is hard to tell why.. Any hints? > > > > The reason we return EAGAIN is to workaround a deadlock we face when > > blocking on the GPU holding the struct_mutex (inside the client's > > process), but the GPU is dead. As our locking is very, very coarse we > > cannot restart the GPU without acquiring the struct_mutex being held by > > the client so we wake the client up and tell them the resource they are > > waiting on (the flush of the object from the GPU into the CPU domain) is > > temporarily unavailable. If they try to immediately wait upon the ioctl > > again, they are blocked waiting for the reset to occur before they may > > complete their flush. There are a few other possible deadlocks that are > > also avoided with EAGAIN (again, the issue is more or less the lack of > > fine grained locking). > > ...so you hijacked EAGAIN for all DRM ioctls just for a driver > workaround? No, we utilized the fact that EAGAIN was already enshrined by libdrm as the defacto mechanism for repeating the ioctl in order to repeat the ioctl for a driver workaround. -Chris -- Chris Wilson, Intel Open Source Technology Centre ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH 1/3] staging: comedi: dt282x: remove unnecessary comedi_check_trigger_arg_max()
On Wednesday, March 23, 2016 3:47 AM, Ian Abbott wrote: > On 22/03/16 17:01, H Hartley Sweeten wrote: >> Step 4 of the (*do_cmdtest) calls dt282x_ns_to_timer() to work out the >> divisor needed to generate the 'convert_arg' timing. If the 'convert_arg' >> timing can not be generated, the function returns the max timing that can >> be generated. >> >> The Step 3 'max' check of the 'convert_arg' isn't necessary. >> >> Signed-off-by: H Hartley Sweeten >> Cc: Ian Abbott >> Cc: Greg Kroah-Hartman >> --- >> drivers/staging/comedi/drivers/dt282x.c | 2 -- >> 1 file changed, 2 deletions(-) >> >> diff --git a/drivers/staging/comedi/drivers/dt282x.c >> b/drivers/staging/comedi/drivers/dt282x.c >> index 06a87a1..be6a0bc 100644 >> --- a/drivers/staging/comedi/drivers/dt282x.c >> +++ b/drivers/staging/comedi/drivers/dt282x.c >> @@ -689,8 +689,6 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev, >> >> err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 4000); >> >> -#define SLOWEST_TIMER (250*(1<<15)*255) >> -err |= comedi_check_trigger_arg_max(&cmd->convert_arg, SLOWEST_TIMER); >> err |= comedi_check_trigger_arg_min(&cmd->convert_arg, board->ai_speed); >> err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg, >> cmd->chanlist_len); >> > > I'd be inclined to keep the existing check in place, as it goes with the > arg_min test (although one of the arg_min tests on convert_arg is > redundant, as you point out in patch 2). It's just unnecessary. And the #define in the function is a bit ugly in my opinion. If it's removed the net effect is still the same. Only instead of the arg_max test happening in the trivial validation (step 3) it will happen as a side effect of the divisor calculation (step 4). If the user passes a convert_arg larger than 250*(1<<15)*255 (2,088,960,000 ns) it will still get changed to the acceptable max value. But, if you prefer to keep it in I will modify this patch to just fix the checkpatch.pl issue. Regards, Hartley ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH] staging: comedi: drivers: remove bogus ni_mio_c_common.c
On Wednesday, March 23, 2016 3:55 AM, Ian Abbott wrote: > The zero-length file "ni_mio_c_common.c" was inadvertantly created by > commit e563637b5fef ("staging: comedi: Use ARRAY_SIZE for sizes of > arrays"). Remove it. > > Signed-off-by: Ian Abbott > --- > drivers/staging/comedi/drivers/ni_mio_c_common.c | 0 > 1 file changed, 0 insertions(+), 0 deletions(-) > delete mode 100644 drivers/staging/comedi/drivers/ni_mio_c_common.c > > diff --git a/drivers/staging/comedi/drivers/ni_mio_c_common.c > b/drivers/staging/comedi/drivers/ni_mio_c_common.c > deleted file mode 100644 > index e69de29..000 Weird. Good catch. Reviewed-by: H Hartley Sweeten ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 1/3] staging: comedi: dt282x: remove unnecessary comedi_check_trigger_arg_max()
On 23/03/16 16:50, Hartley Sweeten wrote: On Wednesday, March 23, 2016 3:47 AM, Ian Abbott wrote: On 22/03/16 17:01, H Hartley Sweeten wrote: Step 4 of the (*do_cmdtest) calls dt282x_ns_to_timer() to work out the divisor needed to generate the 'convert_arg' timing. If the 'convert_arg' timing can not be generated, the function returns the max timing that can be generated. The Step 3 'max' check of the 'convert_arg' isn't necessary. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt282x.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 06a87a1..be6a0bc 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -689,8 +689,6 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev, err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 4000); -#define SLOWEST_TIMER (250*(1<<15)*255) - err |= comedi_check_trigger_arg_max(&cmd->convert_arg, SLOWEST_TIMER); err |= comedi_check_trigger_arg_min(&cmd->convert_arg, board->ai_speed); err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); I'd be inclined to keep the existing check in place, as it goes with the arg_min test (although one of the arg_min tests on convert_arg is redundant, as you point out in patch 2). It's just unnecessary. And the #define in the function is a bit ugly in my opinion. The upper and lower bounds on the timings are usually checked at step 3. That's the case in amplc_pci230, cb_das16_cs, comedi_rt_timer, dmm32at, dt2814, ni_pcidio, etc. If it's removed the net effect is still the same. Only instead of the arg_max test happening in the trivial validation (step 3) it will happen as a side effect of the divisor calculation (step 4). If the user passes a convert_arg larger than 250*(1<<15)*255 (2,088,960,000 ns) it will still get changed to the acceptable max value. It could affect the number of test operations that need to be performed on a particular command to get it to pass. For example, if convert_arg is out of bounds and there is some other problem at step 3, but no other problems at step 4, the old code would fail at step 3 and a subsequent call would pass step 4, but the new code would fail at step 3 and a subsequent call would also fail at step 4 (because convert_arg wasn't adjusted by step 3). But, if you prefer to keep it in I will modify this patch to just fix the checkpatch.pl issue. I prefer to keep the test for consistency, but you can make it less ugly if you want. -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [lustre-devel] [PATCH] Revert "Staging: lustre: o2iblnd: Use sizeof type *pointer instead of sizeof type."
>On Wed, Mar 23, 2016 at 05:39:36AM +, Dilger, Andreas wrote: >> On 2016/03/22, 19:49, "lustre-devel on behalf of Greg Kroah-Hartman" >> > gre...@linuxfoundation.org> wrote: >> >> >On Tue, Mar 22, 2016 at 06:21:04PM -0400, James Simmons wrote: >> >> Latest testing fails when using ko2iblnd. It was tracked down >> >> to commit 4671a026616df26000f7d8ad2f2ea4b6de79263c. >> >> >> >> This reverts commit 4671a026616df26000f7d8ad2f2ea4b6de79263c. >> >> --- >> >> .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|4 ++-- >> >> 1 files changed, 2 insertions(+), 2 deletions(-) >> >> >> >> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c >> >>b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c >> >> index 89f9390..0d32e65 100644 >> >> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c >> >> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c >> >> @@ -1968,7 +1968,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, >> >>__u32 *cpts, int ncpts) >> >>*/ >> >> >> >> net->ibn_fmr_ps = cfs_percpt_alloc(lnet_cpt_table(), >> >> -sizeof(*net->ibn_fmr_ps)); >> >> +sizeof(kib_fmr_poolset_t)); >> > >> >Ok, why is this revert needed? Please give me a big huge comment about >> >why this is not the same size of the variable being assigned to it, >> >otherwise someone else is going to come along and make the exact same >> >change again. >> > >> >> if (!net->ibn_fmr_ps) { >> >> CERROR("Failed to allocate FMR pool array\n"); >> >> rc = -ENOMEM; >> >> @@ -1992,7 +1992,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, >> >>__u32 *cpts, int ncpts) >> >> >> >> create_tx_pool: >> >> net->ibn_tx_ps = cfs_percpt_alloc(lnet_cpt_table(), >> >> - sizeof(*net->ibn_tx_ps)); >> >> + sizeof(kib_tx_poolset_t)); >> > >> >Same here, why is this code wrong? >> >> Looks like the declarations are: >> >> kib_tx_poolset_t **ibn_tx_ps;/* tx pool-set */ >> kib_fmr_poolset_t **ibn_fmr_ps; /* fmr pool-set */ >> >> >> >> so the right code should be: >> >> sizeof(**net->ibn_tx_ps); >> >> >> and the same for sizeof(**net->ibn_fmr_ps) > >That's a mess, isn't there some other way to fix this up to be more >"obvious"? This must have been encountered in the past. How was it handle in those other cases? ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: wlan-ng: wiphy_free() is not called in case wiphy_register() fails
This patch covers wiphy_register() failures in wlan_create_wiphy() from cfg80211.c by calling wiphy_free() for the correspondent struct wiphy allocated structure. Signed-off-by: Claudiu Beznea --- drivers/staging/wlan-ng/cfg80211.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c index 8bad018..ee989d1 100644 --- a/drivers/staging/wlan-ng/cfg80211.c +++ b/drivers/staging/wlan-ng/cfg80211.c @@ -771,8 +771,10 @@ static struct wiphy *wlan_create_wiphy(struct device *dev, wlandevice_t *wlandev wiphy->n_cipher_suites = PRISM2_NUM_CIPHER_SUITES; wiphy->cipher_suites = prism2_cipher_suites; - if (wiphy_register(wiphy) < 0) + if (wiphy_register(wiphy) < 0) { + wiphy_free(wiphy); return NULL; + } return wiphy; } -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [lustre-devel] [PATCH] Revert "Staging: lustre: o2iblnd: Use sizeof type *pointer instead of sizeof type."
On Wed, 2016-03-23 at 18:31 +, Simmons, James A. wrote: > > On Wed, Mar 23, 2016 at 05:39:36AM +, Dilger, Andreas wrote: > > > On 2016/03/22, 19:49, "lustre-devel on behalf of Greg Kroah-Hartman" > > > > > gre...@linuxfoundation.org> wrote: > > > > On Tue, Mar 22, 2016 at 06:21:04PM -0400, James Simmons wrote: > > > > > > > > > > Latest testing fails when using ko2iblnd. It was tracked down > > > > > to commit 4671a026616df26000f7d8ad2f2ea4b6de79263c. > > > > > > > > > > This reverts commit 4671a026616df26000f7d8ad2f2ea4b6de79263c. [] > > > > > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c [] > > > > > @@ -1968,7 +1968,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, > > > > > __u32 *cpts, int ncpts) > > > > > */ > > > > > > > > > > net->ibn_fmr_ps = cfs_percpt_alloc(lnet_cpt_table(), > > > > > - sizeof(*net->ibn_fmr_ps)); > > > > > + sizeof(kib_fmr_poolset_t)); > > > > Ok, why is this revert needed? Please give me a big huge comment about > > > > why this is not the same size of the variable being assigned to it, > > > > otherwise someone else is going to come along and make the exact same > > > > change again. [] > > > Looks like the declarations are: > > > > > > kib_tx_poolset_t **ibn_tx_ps;/* tx pool-set */ > > > kib_fmr_poolset_t **ibn_fmr_ps; /* fmr pool-set */ [] > > > so the right code should be: > > > > > > sizeof(**net->ibn_tx_ps); > > > and the same for sizeof(**net->ibn_fmr_ps) > > That's a mess, isn't there some other way to fix this up to be more > > "obvious"? > This must have been encountered in the past. How was it handle in those > other cases? I fail to see why it's a mess. It's just ** and someone making a mistake. Removing the "typedef struct" uses from lustre would probably make a lot of this clearer though. $ git grep -En "typedef\s+struct" drivers/staging/lustre/ drivers/staging/lustre/include/linux/libcfs/libcfs_workitem.h:76:typedef struct cfs_workitem { drivers/staging/lustre/include/linux/lnet/lib-types.h:56:typedef struct lnet_msg { drivers/staging/lustre/include/linux/lnet/lib-types.h:110:typedef struct lnet_libhandle { drivers/staging/lustre/include/linux/lnet/lib-types.h:118:typedef struct lnet_eq { drivers/staging/lustre/include/linux/lnet/lib-types.h:129:typedef struct lnet_me { drivers/staging/lustre/include/linux/lnet/lib-types.h:141:typedef struct lnet_libmd { drivers/staging/lustre/include/linux/lnet/lib-types.h:166:typedef struct { drivers/staging/lustre/include/linux/lnet/lib-types.h:181:typedef struct lnet_lnd { drivers/staging/lustre/include/linux/lnet/lib-types.h:256:typedef struct lnet_ni { drivers/staging/lustre/include/linux/lnet/lib-types.h:297:typedef struct { drivers/staging/lustre/include/linux/lnet/lib-types.h:305:typedef struct lnet_peer { drivers/staging/lustre/include/linux/lnet/lib-types.h:369:typedef struct { drivers/staging/lustre/include/linux/lnet/lib-types.h:384:typedef struct { drivers/staging/lustre/include/linux/lnet/lib-types.h:396:typedef struct { drivers/staging/lustre/include/linux/lnet/lib-types.h:410:typedef struct { drivers/staging/lustre/include/linux/lnet/lib-types.h:497:typedef struct lnet_portal { drivers/staging/lustre/include/linux/lnet/lib-types.h:545:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:71:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:78:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:88:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:93:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:101:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:108:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:115:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:127:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:140:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:242:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:254:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:265:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:275:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:296:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:302:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:313:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:325:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:337:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:344:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:357:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:363:typedef struct { drivers/staging/lustre/include/linux/lnet/lnetst.h:369:typedef struct { drivers/staging/lustre/include/linux/lnet
[PATCH v2 0/3] staging: comedi: dt282x: minor cleanup
Refactor dt282x_ns_to_timer() to remove the magic numbers used to calculate the divisor needed to generate the pacer clock ns timing. Remove some unnecessary/redundant cruft from the driver. v2: Ian Abbott prefered to keep the comedi_check_trigger_arg_max() check of the convert_arg (patch 1). H Hartley Sweeten (3): staging: comedi: dt282x: refactor dt282x_ns_to_timer() staging: comedi: dt282x: remove redundant comedi_check_trigger_arg_min() staging: comedi: dt282x: remove unnecessary comment drivers/staging/comedi/drivers/dt282x.c | 54 +++-- 1 file changed, 24 insertions(+), 30 deletions(-) -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 2/3] staging: comedi: dt282x: remove redundant comedi_check_trigger_arg_min()
The 'convert_arg' sets the acquisition timing of the analog input command. The maximum speed (the minimum timing) depends on the board 'ai_speed' which if always >= 4000. Remove the redundant 'min' check, Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt282x.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index e6958ea..661c3ad 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -697,11 +697,7 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev, /* Step 3: check if arguments are trivially valid */ err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0); - err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0); - - err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 4000); - err |= comedi_check_trigger_arg_max(&cmd->convert_arg, DT2821_OSC_MAX); err |= comedi_check_trigger_arg_min(&cmd->convert_arg, board->ai_speed); err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg, -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 3/3] staging: comedi: dt282x: remove unnecessary comment
The "Configuration options" are documented in the comedi driver comment block. Remove the redundant comment before the drivers (*attach) function. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt282x.c | 14 -- 1 file changed, 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 661c3ad..d5295bb 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -1093,20 +1093,6 @@ static int dt282x_initialize(struct comedi_device *dev) return 0; } -/* - options: - 0 i/o base - 1 irq - 2 dma1 - 3 dma2 - 4 0=single ended, 1=differential - 5 ai 0=straight binary, 1=2's comp - 6 ao0 0=straight binary, 1=2's comp - 7 ao1 0=straight binary, 1=2's comp - 8 ai 0=±10 V, 1=0-10 V, 2=±5 V, 3=0-5 V - 9 ao0 0=±10 V, 1=0-10 V, 2=±5 V, 3=0-5 V, 4=±2.5 V - 10 ao1 0=±10 V, 1=0-10 V, 2=±5 V, 3=0-5 V, 4=±2.5 V - */ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it) { const struct dt282x_board *board = dev->board_ptr; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 1/3] staging: comedi: dt282x: refactor dt282x_ns_to_timer()
Define the pacer clock limits and remove the magic numbers. Refactor the code to use a common path to return the actual 'ns' timing and the timer divisor value. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt282x.c | 36 ++--- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 06a87a1..e6958ea 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -113,6 +113,17 @@ #define DT2821_SUPCSR_XCLK BIT(1) #define DT2821_SUPCSR_BDINIT BIT(0) #define DT2821_TMRCTR_REG 0x0e +#define DT2821_TMRCTR_PRESCALE(x) (((x) & 0xf) << 8) +#define DT2821_TMRCTR_DIVIDER(x) ((255 - ((x) & 0xff)) << 0) + +/* Pacer Clock */ +#define DT2821_OSC_BASE250 /* 4 MHz (in nanoseconds) */ +#define DT2821_PRESCALE(x) BIT(x) +#define DT2821_PRESCALE_MAX15 +#define DT2821_DIVIDER_MAX 255 +#define DT2821_OSC_MAX (DT2821_OSC_BASE * \ +DT2821_PRESCALE(DT2821_PRESCALE_MAX) * \ +DT2821_DIVIDER_MAX) static const struct comedi_lrange range_dt282x_ai_lo_bipolar = { 4, { @@ -365,10 +376,10 @@ static unsigned int dt282x_ns_to_timer(unsigned int *ns, unsigned int flags) { unsigned int prescale, base, divider; - for (prescale = 0; prescale < 16; prescale++) { - if (prescale == 1) + for (prescale = 0; prescale <= DT2821_PRESCALE_MAX; prescale++) { + if (prescale == 1) /* 0 and 1 are both divide by 1 */ continue; - base = 250 * (1 << prescale); + base = DT2821_OSC_BASE * DT2821_PRESCALE(prescale); switch (flags & CMDF_ROUND_MASK) { case CMDF_ROUND_NEAREST: default: @@ -381,15 +392,17 @@ static unsigned int dt282x_ns_to_timer(unsigned int *ns, unsigned int flags) divider = DIV_ROUND_UP(*ns, base); break; } - if (divider < 256) { - *ns = divider * base; - return (prescale << 8) | (255 - divider); - } + if (divider <= DT2821_DIVIDER_MAX) + break; + } + if (divider > DT2821_DIVIDER_MAX) { + prescale = DT2821_PRESCALE_MAX; + divider = DT2821_DIVIDER_MAX; + base = DT2821_OSC_BASE * DT2821_PRESCALE(prescale); } - base = 250 * (1 << 15); - divider = 255; *ns = divider * base; - return (15 << 8) | (255 - divider); + return DT2821_TMRCTR_PRESCALE(prescale) | + DT2821_TMRCTR_DIVIDER(divider); } static void dt282x_munge(struct comedi_device *dev, @@ -689,8 +702,7 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev, err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 4000); -#define SLOWEST_TIMER (250*(1<<15)*255) - err |= comedi_check_trigger_arg_max(&cmd->convert_arg, SLOWEST_TIMER); + err |= comedi_check_trigger_arg_max(&cmd->convert_arg, DT2821_OSC_MAX); err |= comedi_check_trigger_arg_min(&cmd->convert_arg, board->ai_speed); err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: vt6656: Fixed multiple logical comparisions warnings in main_usb.c
Using comparison to false and true is error prone. Fixed multiple warnings as per checkpatch guidelines. Signed-off-by: Parth Sane --- drivers/staging/vt6656/main_usb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index f9afab7..5e77496 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -238,7 +238,7 @@ static int vnt_init_registers(struct vnt_private *priv) priv->tx_antenna_mode = ANT_B; priv->rx_antenna_sel = 1; - if (priv->tx_rx_ant_inv == true) + if (priv->tx_rx_ant_inv) priv->rx_antenna_mode = ANT_A; else priv->rx_antenna_mode = ANT_B; @@ -248,14 +248,14 @@ static int vnt_init_registers(struct vnt_private *priv) if (antenna & EEP_ANTENNA_AUX) { priv->tx_antenna_mode = ANT_A; - if (priv->tx_rx_ant_inv == true) + if (priv->tx_rx_ant_inv) priv->rx_antenna_mode = ANT_B; else priv->rx_antenna_mode = ANT_A; } else { priv->tx_antenna_mode = ANT_B; - if (priv->tx_rx_ant_inv == true) + if (priv->tx_rx_ant_inv) priv->rx_antenna_mode = ANT_A; else priv->rx_antenna_mode = ANT_B; -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH 0/5] Drivers: hv: vmbus
> -Original Message- > From: K. Y. Srinivasan [mailto:k...@microsoft.com] > Sent: Friday, March 18, 2016 6:14 PM > To: gre...@linuxfoundation.org; linux-ker...@vger.kernel.org; > de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com; > vkuzn...@redhat.com; jasow...@redhat.com > Cc: KY Srinivasan > Subject: [PATCH 0/5] Drivers: hv: vmbus > > Cleanup the Hyper-V ring buffer code. Also Implement APIs for > supporting copy-free operations on the read side. > > K. Y. Srinivasan (5): > Drivers: hv: vmbus: Introduce functions for estimating room in the > ring buffer > Drivers: hv: vmbus: Use READ_ONCE() to read variables that are > volatile > Drivers: hv: vmbus: Fix a bug in hv_need_to_signal_on_read() > Drivers: hv: vmbus: Use the new virt_xx barrier code > Drivers: hv: vmbus: Implement copy-free read APIs > > drivers/hv/ring_buffer.c | 99 - > > include/linux/hyperv.h | 33 +++ > 2 files changed, 103 insertions(+), 29 deletions(-) Greg, Please drop this series. I am going to send a new patch-set and looking at the changes I have made, I feel it may not be appropriate to simply bump the version. Regards, K. Y > > -- > 1.7.4.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH net-next] hv_netvsc: Fix the order of num_sc_offered decrement
Reorder the code in netvsc_sc_open(), so num_sc_offered is only decremented after vmbus_open() is called. This avoid pontential race of removing device before all channels are setup. Signed-off-by: Haiyang Zhang Reviewed-by: K. Y. Srinivasan --- drivers/net/hyperv/rndis_filter.c | 12 ++-- 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index d5a54da..c4e1e04 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -986,12 +986,6 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc) nvscdev = hv_get_drvdata(new_sc->primary_channel->device_obj); - spin_lock_irqsave(&nvscdev->sc_lock, flags); - nvscdev->num_sc_offered--; - spin_unlock_irqrestore(&nvscdev->sc_lock, flags); - if (nvscdev->num_sc_offered == 0) - complete(&nvscdev->channel_init_wait); - if (chn_index >= nvscdev->num_chn) return; @@ -1004,6 +998,12 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc) if (ret == 0) nvscdev->chn_table[chn_index] = new_sc; + + spin_lock_irqsave(&nvscdev->sc_lock, flags); + nvscdev->num_sc_offered--; + spin_unlock_irqrestore(&nvscdev->sc_lock, flags); + if (nvscdev->num_sc_offered == 0) + complete(&nvscdev->channel_init_wait); } int rndis_filter_device_add(struct hv_device *dev, -- 1.7.4.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [lustre-devel] [PATCH] Revert "Staging: lustre: o2iblnd: Use sizeof type *pointer instead of sizeof type."
>> > > so the right code should be: >> > > >> > > sizeof(**net->ibn_tx_ps); >> > > and the same for sizeof(**net->ibn_fmr_ps) >> > That's a mess, isn't there some other way to fix this up to be more >> > "obvious"? >> This must have been encountered in the past. How was it handle in those >> other cases? > >I fail to see why it's a mess. It's just ** >and someone making a mistake. I have no trouble with **. If we revert it someone else will come along and do the same mistake so I think we are stuck with the change to **. >Removing the "typedef struct" uses from lustre >would probably make a lot of this clearer though. That along with a few hundred more patches heading Greg's way :-) ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [lustre-devel] [PATCH] Revert "Staging: lustre: o2iblnd: Use sizeof type *pointer instead of sizeof type."
On Wed, Mar 23, 2016 at 08:29:49PM +, Simmons, James A. wrote: > > >> > > so the right code should be: > >> > > > >> > > sizeof(**net->ibn_tx_ps); > >> > > and the same for sizeof(**net->ibn_fmr_ps) > >> > That's a mess, isn't there some other way to fix this up to be more > >> > "obvious"? > >> This must have been encountered in the past. How was it handle in those > >> other cases? > > > >I fail to see why it's a mess. It's just ** > >and someone making a mistake. > > I have no trouble with **. If we revert it someone else will come along and > do the same mistake so I think we are stuck with the change to **. That's fine, but if you do that, just comment it well so that no one tries to change it again. That's why I can't accept the original patch in this email thread. thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: rtl8188eu: remove return at end of void function call
Remove unnecessary return statements from last lines of void function call (several) Signed-off-by: Nicholas Sim --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 17 - 1 file changed, 17 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 439c035..7f32b39 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -601,8 +601,6 @@ static void issue_probersp(struct adapter *padapter, unsigned char *da) pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); - - return; } static int issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da, bool wait_ack) @@ -883,8 +881,6 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, rtw_wep_encrypt(padapter, (u8 *)pmgntframe); DBG_88E("%s\n", __func__); dump_mgntframe(padapter, pmgntframe); - - return; } @@ -1207,8 +1203,6 @@ exit: rtw_buf_update(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len, (u8 *)pwlanhdr, pattrib->pktlen); else rtw_buf_free(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len); - - return; } /* when wait_ack is true, this function should be called at process context */ @@ -4326,8 +4320,6 @@ void report_survey_event(struct adapter *padapter, rtw_enqueue_cmd(pcmdpriv, pcmd_obj); pmlmeext->sitesurvey_res.bss_cnt++; - - return; } void report_surveydone_event(struct adapter *padapter) @@ -4371,8 +4363,6 @@ void report_surveydone_event(struct adapter *padapter) DBG_88E("survey done event(%x)\n", psurveydone_evt->bss_cnt); rtw_enqueue_cmd(pcmdpriv, pcmd_obj); - - return; } void report_join_res(struct adapter *padapter, int res) @@ -4423,8 +4413,6 @@ void report_join_res(struct adapter *padapter, int res) rtw_enqueue_cmd(pcmdpriv, pcmd_obj); - - return; } void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason) @@ -4480,8 +4468,6 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi DBG_88E("report_del_sta_event: delete STA, mac_id =%d\n", mac_id); rtw_enqueue_cmd(pcmdpriv, pcmd_obj); - - return; } void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int cam_idx) @@ -4526,8 +4512,6 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int DBG_88E("report_add_sta_event: add STA\n"); rtw_enqueue_cmd(pcmdpriv, pcmd_obj); - - return; } @@ -4963,7 +4947,6 @@ void link_timer_hdl(unsigned long data) issue_assocreq(padapter); set_link_timer(pmlmeext, REASSOC_TO); } - return; } void addba_timer_hdl(unsigned long data) -- 2.4.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 16/28] staging: comedi: ni_tio: fix block comments
Fix the checkpatch.pl issues: WARNING: Block comments use * on subsequent lines Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 36 +++-- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index e4fd221..e7af98d 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -1,19 +1,18 @@ /* - comedi/drivers/ni_tio.c - Support for NI general purpose counters - - Copyright (C) 2006 Frank Mori Hess - - 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. -*/ + * Support for NI general purpose counters + * + * Copyright (C) 2006 Frank Mori Hess + * + * 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: ni_tio @@ -36,13 +35,10 @@ * DAQ 660x Register-Level Programmer Manual (NI 370505A-01) * DAQ 6601/6602 User Manual (NI 322137B-01) * 340934b.pdf DAQ-STC reference manual + * + * TODO: Support use of both banks X and Y */ -/* -TODO: - Support use of both banks X and Y -*/ - #include #include -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 07/28] staging: comedi: ni_tio_internal: simplify ni_tio_counting_mode_registers_present()
Only the e series gpct variant does not have counting mode registers. Simplfy this function. For aesthetics, return bool instead of int. This fixes the checkpatch.pl issues: CHECK: spaces preferred around that '*' (ctx:ExV) CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 2 +- drivers/staging/comedi/drivers/ni_tio_internal.h | 18 -- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index 5343fce..44dea4c 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -451,7 +451,7 @@ static void ni_tio_set_sync_mode(struct ni_gpct *counter, int force_alt_sync) unsigned mode; uint64_t clock_period_ps; - if (ni_tio_counting_mode_registers_present(counter_dev) == 0) + if (!ni_tio_counting_mode_registers_present(counter_dev)) return; mode = ni_tio_get_soft_copy(counter, counting_mode_reg); diff --git a/drivers/staging/comedi/drivers/ni_tio_internal.h b/drivers/staging/comedi/drivers/ni_tio_internal.h index c8ad66a..1e795fd 100644 --- a/drivers/staging/comedi/drivers/ni_tio_internal.h +++ b/drivers/staging/comedi/drivers/ni_tio_internal.h @@ -174,21 +174,11 @@ static inline unsigned read_register(struct ni_gpct *counter, return counter->counter_dev->read_register(counter, reg); } -static inline int ni_tio_counting_mode_registers_present(const struct -ni_gpct_device -*counter_dev) +static inline bool +ni_tio_counting_mode_registers_present(const struct ni_gpct_device *counter_dev) { - switch (counter_dev->variant) { - case ni_gpct_variant_e_series: - return 0; - case ni_gpct_variant_m_series: - case ni_gpct_variant_660x: - return 1; - default: - BUG(); - break; - } - return 0; + /* m series and 660x variants have counting mode registers */ + return counter_dev->variant != ni_gpct_variant_e_series; } void ni_tio_set_bits(struct ni_gpct *, enum ni_gpct_register reg, -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 10/28] staging: comedi: ni_tio.h: tidy up struct ni_gpct_device
Fix the checkpatch.pl issues: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' CHECK: spinlock_t definition without comment Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.h b/drivers/staging/comedi/drivers/ni_tio.h index 63cec3e..2f36dc1 100644 --- a/drivers/staging/comedi/drivers/ni_tio.h +++ b/drivers/staging/comedi/drivers/ni_tio.h @@ -120,9 +120,9 @@ struct ni_gpct_device { unsigned int (*read)(struct ni_gpct *, enum ni_gpct_register); enum ni_gpct_variant variant; struct ni_gpct *counters; - unsigned num_counters; - unsigned regs[NITIO_NUM_REGS]; - spinlock_t regs_lock; + unsigned int num_counters; + unsigned int regs[NITIO_NUM_REGS]; + spinlock_t regs_lock; /* protects 'regs' */ }; struct ni_gpct_device * -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 03/28] staging: comedi: ni_tio: fix ni_tio_set_gate_src() params/vars
As suggested by checkpatch.pl: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 28 drivers/staging/comedi/drivers/ni_tio_internal.h | 3 +-- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index 623fc6c..abbc8b7 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -891,16 +891,16 @@ static int ni_m_set_gate2(struct ni_gpct *counter, unsigned int gate_source) return 0; } -int ni_tio_set_gate_src(struct ni_gpct *counter, unsigned gate_index, - unsigned int gate_source) +int ni_tio_set_gate_src(struct ni_gpct *counter, + unsigned int gate, unsigned int src) { struct ni_gpct_device *counter_dev = counter->counter_dev; - unsigned cidx = counter->counter_index; - unsigned int chan = CR_CHAN(gate_source); - unsigned gate2_reg = NITIO_GATE2_REG(cidx); - unsigned mode = 0; + unsigned int cidx = counter->counter_index; + unsigned int chan = CR_CHAN(src); + unsigned int gate2_reg = NITIO_GATE2_REG(cidx); + unsigned int mode = 0; - switch (gate_index) { + switch (gate) { case 0: if (chan == NI_GPCT_DISABLED_GATE_SELECT) { ni_tio_set_bits(counter, NITIO_MODE_REG(cidx), @@ -908,9 +908,9 @@ int ni_tio_set_gate_src(struct ni_gpct *counter, unsigned gate_index, GI_GATING_DISABLED); return 0; } - if (gate_source & CR_INVERT) + if (src & CR_INVERT) mode |= GI_GATE_POL_INVERT; - if (gate_source & CR_EDGE) + if (src & CR_EDGE) mode |= GI_RISING_EDGE_GATING; else mode |= GI_LEVEL_GATING; @@ -921,9 +921,9 @@ int ni_tio_set_gate_src(struct ni_gpct *counter, unsigned gate_index, case ni_gpct_variant_e_series: case ni_gpct_variant_m_series: default: - return ni_m_set_gate(counter, gate_source); + return ni_m_set_gate(counter, src); case ni_gpct_variant_660x: - return ni_660x_set_gate(counter, gate_source); + return ni_660x_set_gate(counter, src); } break; case 1: @@ -936,15 +936,15 @@ int ni_tio_set_gate_src(struct ni_gpct *counter, unsigned gate_index, gate2_reg); return 0; } - if (gate_source & CR_INVERT) + if (src & CR_INVERT) counter_dev->regs[gate2_reg] |= GI_GATE2_POL_INVERT; else counter_dev->regs[gate2_reg] &= ~GI_GATE2_POL_INVERT; switch (counter_dev->variant) { case ni_gpct_variant_m_series: - return ni_m_set_gate2(counter, gate_source); + return ni_m_set_gate2(counter, src); case ni_gpct_variant_660x: - return ni_660x_set_gate2(counter, gate_source); + return ni_660x_set_gate2(counter, src); default: BUG(); break; diff --git a/drivers/staging/comedi/drivers/ni_tio_internal.h b/drivers/staging/comedi/drivers/ni_tio_internal.h index b659f05..ee02b36 100644 --- a/drivers/staging/comedi/drivers/ni_tio_internal.h +++ b/drivers/staging/comedi/drivers/ni_tio_internal.h @@ -245,7 +245,6 @@ static inline unsigned ni_tio_get_soft_copy(const struct ni_gpct *counter, } int ni_tio_arm(struct ni_gpct *counter, int arm, unsigned start_trigger); -int ni_tio_set_gate_src(struct ni_gpct *counter, unsigned gate_index, - unsigned int gate_source); +int ni_tio_set_gate_src(struct ni_gpct *, unsigned int gate, unsigned int src); #endif /* _COMEDI_NI_TIO_INTERNAL_H */ -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 00/28] staging: comedi: ni_tio: big driver cleanup
The NI TIO support is split into 2 driver modules, ni_tio and ni_tiocmd. Theses drivers, and the headers have a lot of checkpatch.pl issues. drivers/staging/comedi/drivers/ni_tio_internal.h total: 0 errors, 13 warnings, 61 checks, 245 lines checked drivers/staging/comedi/drivers/ni_tio.h total: 0 errors, 10 warnings, 3 checks, 154 lines checked drivers/staging/comedi/drivers/ni_tio.c total: 0 errors, 101 warnings, 15 checks, 1436 lines checked drivers/staging/comedi/drivers/ni_tiocmd.c total: 0 errors, 19 warnings, 1 checks, 478 lines checked This includes 15: CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() This series fixes all the checkpatch.pl issues. H Hartley Sweeten (28): staging: comedi: ni_tio_internal.h: tidy up bit defines staging: comedi: ni_tio_internal.h: fix block comment issues staging: comedi: ni_tio: fix ni_tio_set_gate_src() params/vars staging: comedi: ni_tio: fix ni_tio_arm() params/vars staging: comedi: ni_tio: export and fix ni_tio_get_soft_copy() staging: comedi: ni_tio: export and fix ni_tio_set_bits() staging: comedi: ni_tio_internal: simplify ni_tio_counting_mode_registers_present() staging: comedi: ni_tio_internal: export {read,write)_register() staging: comedi: ni_tio: tidy up struct ni_gpct_device (*{write,read}_register) staging: comedi: ni_tio.h: tidy up struct ni_gpct_device staging: comedi: ni_tio.h: tidy up struct ni_gpct staging: comedi: ni_tio.h: fix block comment staging: comedi: ni_tio.h: remove unnecessary forward declarations staging: comedi: ni_tio: Prefer 'unsigned int' to bare use of 'unsigned' staging: comedi: ni_tio: Prefer kernel type 'u64' over 'uint64_t' staging: comedi: ni_tio: fix block comments staging: comedi: ni_tio: tidy up ni_tio_get_gate_src() staging: comedi: ni_tio: tidy up ni_tio_set_sync_mode() staging: comedi: ni_tio: tidy up ni_tio_arm() staging: comedi: ni_tiocmd: Prefer 'unsigned int' to bare use of 'unsigned' staging: comedi: ni_tiocmd: fix block comments staging: comedi: ni_tiocmd: remove unsed param from ni_tio_acknowledge_and_confirm() staging: comedi: ni_tiocmd: remove BUG() which can never occur staging: comedi: ni_tio: validate clock source staging: comedi: ni_tio: remove BUG() checks for ni_tio_get_gate_src() staging: comedi: ni_tio: fix ni_tio_insn_config() staging: comedi: ni_tio: remove BUG() in ni_tio_set_gate_src() staging: comedi: ni_tio: remove BUG() checks for ni_tio_get_clock_src() drivers/staging/comedi/drivers/ni_tio.c | 805 +-- drivers/staging/comedi/drivers/ni_tio.h | 66 +- drivers/staging/comedi/drivers/ni_tio_internal.h | 322 - drivers/staging/comedi/drivers/ni_tiocmd.c | 116 ++-- 4 files changed, 683 insertions(+), 626 deletions(-) -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 06/28] staging: comedi: ni_tio: export and fix ni_tio_set_bits()
Move the inline function from the header and export it instead. Fix the checkpatch.pl issue: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' The 'unsigned' vars can safely be changed to 'unsigned int'. This allows moving ni_tio_set_bits_transient() into the driver and making it static. Fix the checkpatch.pl issue: CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() The BUG_ON() is overkill. All the drivers that call this function pass 'register_index' values that are valid. Just check the 'register_index' before updating the software copy and writing the register. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 37 drivers/staging/comedi/drivers/ni_tio_internal.h | 35 ++ 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index abbdad5..5343fce 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -228,6 +228,43 @@ static uint64_t ni_tio_clock_period_ps(const struct ni_gpct *counter, return clock_period_ps; } +static void ni_tio_set_bits_transient(struct ni_gpct *counter, + enum ni_gpct_register reg, + unsigned int mask, unsigned int value, + unsigned int transient) +{ + struct ni_gpct_device *counter_dev = counter->counter_dev; + unsigned long flags; + + if (reg < NITIO_NUM_REGS) { + spin_lock_irqsave(&counter_dev->regs_lock, flags); + counter_dev->regs[reg] &= ~mask; + counter_dev->regs[reg] |= (value & mask); + write_register(counter, counter_dev->regs[reg] | transient, + reg); + mmiowb(); + spin_unlock_irqrestore(&counter_dev->regs_lock, flags); + } +} + +/** + * ni_tio_set_bits() - Safely write a counter register. + * @counter: struct ni_gpct counter. + * @reg: the register to write. + * @mask: the bits to change. + * @value: the new bits value. + * + * Used to write to, and update the software copy, a register whose bits may + * be twiddled in interrupt context, or whose software copy may be read in + * interrupt context. + */ +void ni_tio_set_bits(struct ni_gpct *counter, enum ni_gpct_register reg, +unsigned int mask, unsigned int value) +{ + ni_tio_set_bits_transient(counter, reg, mask, value, 0x0); +} +EXPORT_SYMBOL_GPL(ni_tio_set_bits); + /** * ni_tio_get_soft_copy() - Safely read the software copy of a counter register. * @counter: struct ni_gpct counter. diff --git a/drivers/staging/comedi/drivers/ni_tio_internal.h b/drivers/staging/comedi/drivers/ni_tio_internal.h index 8c90276..c8ad66a 100644 --- a/drivers/staging/comedi/drivers/ni_tio_internal.h +++ b/drivers/staging/comedi/drivers/ni_tio_internal.h @@ -191,39 +191,8 @@ static inline int ni_tio_counting_mode_registers_present(const struct return 0; } -static inline void ni_tio_set_bits_transient(struct ni_gpct *counter, -enum ni_gpct_register -register_index, unsigned bit_mask, -unsigned bit_values, -unsigned transient_bit_values) -{ - struct ni_gpct_device *counter_dev = counter->counter_dev; - unsigned long flags; - - BUG_ON(register_index >= NITIO_NUM_REGS); - spin_lock_irqsave(&counter_dev->regs_lock, flags); - counter_dev->regs[register_index] &= ~bit_mask; - counter_dev->regs[register_index] |= (bit_values & bit_mask); - write_register(counter, - counter_dev->regs[register_index] | transient_bit_values, - register_index); - mmiowb(); - spin_unlock_irqrestore(&counter_dev->regs_lock, flags); -} - -/* - * ni_tio_set_bits( ) is for safely writing to registers whose bits may be - * twiddled in interrupt context, or whose software copy may be read in - * interrupt context. - */ -static inline void ni_tio_set_bits(struct ni_gpct *counter, - enum ni_gpct_register register_index, - unsigned bit_mask, unsigned bit_values) -{ - ni_tio_set_bits_transient(counter, register_index, bit_mask, bit_values, - 0x0); -} - +void ni_tio_set_bits(struct ni_gpct *, enum ni_gpct_register reg, +unsigned int mask, unsigned int value); unsigned int ni_tio_get_soft_copy(const struct ni_gpct *, enum ni_gpct_register reg); -- 2.6.3 ___ devel mailing list de...@linux
[PATCH 14/28] staging: comedi: ni_tio: Prefer 'unsigned int' to bare use of 'unsigned'
Fix the checkpatch.pl issues. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 166 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index 28bec3c..ecf8527 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -115,7 +115,7 @@ TODO: #define NI_660X_LOGIC_LOW_GATE2_SEL0x1f #define NI_660X_MAX_UP_DOWN_PIN7 -static inline unsigned GI_ALT_SYNC(enum ni_gpct_variant variant) +static inline unsigned int GI_ALT_SYNC(enum ni_gpct_variant variant) { switch (variant) { case ni_gpct_variant_e_series: @@ -128,7 +128,7 @@ static inline unsigned GI_ALT_SYNC(enum ni_gpct_variant variant) } } -static inline unsigned GI_PRESCALE_X2(enum ni_gpct_variant variant) +static inline unsigned int GI_PRESCALE_X2(enum ni_gpct_variant variant) { switch (variant) { case ni_gpct_variant_e_series: @@ -141,7 +141,7 @@ static inline unsigned GI_PRESCALE_X2(enum ni_gpct_variant variant) } } -static inline unsigned GI_PRESCALE_X8(enum ni_gpct_variant variant) +static inline unsigned int GI_PRESCALE_X8(enum ni_gpct_variant variant) { switch (variant) { case ni_gpct_variant_e_series: @@ -154,7 +154,7 @@ static inline unsigned GI_PRESCALE_X8(enum ni_gpct_variant variant) } } -static inline unsigned GI_HW_ARM_SEL_MASK(enum ni_gpct_variant variant) +static inline unsigned int GI_HW_ARM_SEL_MASK(enum ni_gpct_variant variant) { switch (variant) { case ni_gpct_variant_e_series: @@ -208,13 +208,13 @@ EXPORT_SYMBOL_GPL(ni_tio_read); static void ni_tio_reset_count_and_disarm(struct ni_gpct *counter) { - unsigned cidx = counter->counter_index; + unsigned int cidx = counter->counter_index; ni_tio_write(counter, GI_RESET(cidx), NITIO_RESET_REG(cidx)); } static uint64_t ni_tio_clock_period_ps(const struct ni_gpct *counter, - unsigned generic_clock_source) + unsigned int generic_clock_source) { uint64_t clock_period_ps; @@ -316,13 +316,13 @@ unsigned int ni_tio_get_soft_copy(const struct ni_gpct *counter, } EXPORT_SYMBOL_GPL(ni_tio_get_soft_copy); -static unsigned ni_tio_clock_src_modifiers(const struct ni_gpct *counter) +static unsigned int ni_tio_clock_src_modifiers(const struct ni_gpct *counter) { struct ni_gpct_device *counter_dev = counter->counter_dev; - unsigned cidx = counter->counter_index; - const unsigned counting_mode_bits = + unsigned int cidx = counter->counter_index; + unsigned int counting_mode_bits = ni_tio_get_soft_copy(counter, NITIO_CNT_MODE_REG(cidx)); - unsigned bits = 0; + unsigned int bits = 0; if (ni_tio_get_soft_copy(counter, NITIO_INPUT_SEL_REG(cidx)) & GI_SRC_POL_INVERT) @@ -334,14 +334,14 @@ static unsigned ni_tio_clock_src_modifiers(const struct ni_gpct *counter) return bits; } -static unsigned ni_m_series_clock_src_select(const struct ni_gpct *counter) +static unsigned int ni_m_series_clock_src_select(const struct ni_gpct *counter) { struct ni_gpct_device *counter_dev = counter->counter_dev; - unsigned cidx = counter->counter_index; - const unsigned second_gate_reg = NITIO_GATE2_REG(cidx); - unsigned clock_source = 0; - unsigned src; - unsigned i; + unsigned int cidx = counter->counter_index; + unsigned int second_gate_reg = NITIO_GATE2_REG(cidx); + unsigned int clock_source = 0; + unsigned int src; + unsigned int i; src = GI_BITS_TO_SRC(ni_tio_get_soft_copy(counter, NITIO_INPUT_SEL_REG(cidx))); @@ -399,12 +399,12 @@ static unsigned ni_m_series_clock_src_select(const struct ni_gpct *counter) return clock_source; } -static unsigned ni_660x_clock_src_select(const struct ni_gpct *counter) +static unsigned int ni_660x_clock_src_select(const struct ni_gpct *counter) { - unsigned clock_source = 0; - unsigned cidx = counter->counter_index; - unsigned src; - unsigned i; + unsigned int clock_source = 0; + unsigned int cidx = counter->counter_index; + unsigned int src; + unsigned int i; src = GI_BITS_TO_SRC(ni_tio_get_soft_copy(counter, NITIO_INPUT_SEL_REG(cidx))); @@ -456,7 +456,8 @@ static unsigned ni_660x_clock_src_select(const struct ni_gpct *counter) return clock_source; } -static unsigned ni_tio_generic_clock_src_select(const struct ni_gpct *counter) +static unsigned int +ni_tio_generic_clock_src_select(const struct ni_gpct *counter) { switch (counter->counter_dev->variant) {
[PATCH 11/28] staging: comedi: ni_tio.h: tidy up struct ni_gpct
Fix the checkpatch.pl issues: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' CHECK: Prefer kernel type 'u64' over 'uint64_t' CHECK: spinlock_t definition without comment Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.h | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.h b/drivers/staging/comedi/drivers/ni_tio.h index 2f36dc1..5d03743 100644 --- a/drivers/staging/comedi/drivers/ni_tio.h +++ b/drivers/staging/comedi/drivers/ni_tio.h @@ -106,11 +106,11 @@ enum ni_gpct_variant { struct ni_gpct { struct ni_gpct_device *counter_dev; - unsigned counter_index; - unsigned chip_index; - uint64_t clock_period_ps; /* clock period in picoseconds */ + unsigned int counter_index; + unsigned int chip_index; + u64 clock_period_ps;/* clock period in picoseconds */ struct mite_channel *mite_chan; - spinlock_t lock; + spinlock_t lock;/* protects 'mite_chan' */ }; struct ni_gpct_device { -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 04/28] staging: comedi: ni_tio: fix ni_tio_arm() params/vars
As suggested by checkpatch.pl: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' The 'arm' parameter is really a true/false flag. For aesthetics, change it to a bool. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 14 +++--- drivers/staging/comedi/drivers/ni_tio_internal.h | 2 +- drivers/staging/comedi/drivers/ni_tiocmd.c | 8 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index abbc8b7..35596b1 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -484,11 +484,11 @@ static int ni_tio_set_counter_mode(struct ni_gpct *counter, unsigned mode) return 0; } -int ni_tio_arm(struct ni_gpct *counter, int arm, unsigned start_trigger) +int ni_tio_arm(struct ni_gpct *counter, bool arm, unsigned int start_trigger) { struct ni_gpct_device *counter_dev = counter->counter_dev; - unsigned cidx = counter->counter_index; - unsigned command_transient_bits = 0; + unsigned int cidx = counter->counter_index; + unsigned int command_transient_bits = 0; if (arm) { switch (start_trigger) { @@ -502,8 +502,8 @@ int ni_tio_arm(struct ni_gpct *counter, int arm, unsigned start_trigger) break; } if (ni_tio_counting_mode_registers_present(counter_dev)) { - unsigned bits = 0; - unsigned sel_mask; + unsigned int bits = 0; + unsigned int sel_mask; sel_mask = GI_HW_ARM_SEL_MASK(counter_dev->variant); @@ -1180,9 +1180,9 @@ int ni_tio_insn_config(struct comedi_device *dev, case INSN_CONFIG_SET_COUNTER_MODE: return ni_tio_set_counter_mode(counter, data[1]); case INSN_CONFIG_ARM: - return ni_tio_arm(counter, 1, data[1]); + return ni_tio_arm(counter, true, data[1]); case INSN_CONFIG_DISARM: - ni_tio_arm(counter, 0, 0); + ni_tio_arm(counter, false, 0); return 0; case INSN_CONFIG_GET_COUNTER_STATUS: data[1] = 0; diff --git a/drivers/staging/comedi/drivers/ni_tio_internal.h b/drivers/staging/comedi/drivers/ni_tio_internal.h index ee02b36..1e91633 100644 --- a/drivers/staging/comedi/drivers/ni_tio_internal.h +++ b/drivers/staging/comedi/drivers/ni_tio_internal.h @@ -244,7 +244,7 @@ static inline unsigned ni_tio_get_soft_copy(const struct ni_gpct *counter, return value; } -int ni_tio_arm(struct ni_gpct *counter, int arm, unsigned start_trigger); +int ni_tio_arm(struct ni_gpct *, bool arm, unsigned int start_trigger); int ni_tio_set_gate_src(struct ni_gpct *, unsigned int gate, unsigned int src); #endif /* _COMEDI_NI_TIO_INTERNAL_H */ diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c index 823e479..0546a55 100644 --- a/drivers/staging/comedi/drivers/ni_tiocmd.c +++ b/drivers/staging/comedi/drivers/ni_tiocmd.c @@ -103,7 +103,7 @@ static int ni_tio_input_inttrig(struct comedi_device *dev, spin_unlock_irqrestore(&counter->lock, flags); if (ret < 0) return ret; - ret = ni_tio_arm(counter, 1, NI_GPCT_ARM_IMMEDIATE); + ret = ni_tio_arm(counter, true, NI_GPCT_ARM_IMMEDIATE); s->async->inttrig = NULL; return ret; @@ -143,9 +143,9 @@ static int ni_tio_input_cmd(struct comedi_subdevice *s) mite_dma_arm(counter->mite_chan); if (cmd->start_src == TRIG_NOW) - ret = ni_tio_arm(counter, 1, NI_GPCT_ARM_IMMEDIATE); + ret = ni_tio_arm(counter, true, NI_GPCT_ARM_IMMEDIATE); else if (cmd->start_src == TRIG_EXT) - ret = ni_tio_arm(counter, 1, cmd->start_arg); + ret = ni_tio_arm(counter, true, cmd->start_arg); } return ret; } @@ -292,7 +292,7 @@ int ni_tio_cancel(struct ni_gpct *counter) unsigned cidx = counter->counter_index; unsigned long flags; - ni_tio_arm(counter, 0, 0); + ni_tio_arm(counter, false, 0); spin_lock_irqsave(&counter->lock, flags); if (counter->mite_chan) mite_dma_disarm(counter->mite_chan); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 18/28] staging: comedi: ni_tio: tidy up ni_tio_set_sync_mode()
The 'force_alt_sync' paramater is always 0. Remove it. Absorb the GI_ALT_SYNC() inline helper and use some local variables to clarify this function. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 65 +++-- 1 file changed, 30 insertions(+), 35 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index ce64cc3..2c33b28 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -111,19 +111,6 @@ #define NI_660X_LOGIC_LOW_GATE2_SEL0x1f #define NI_660X_MAX_UP_DOWN_PIN7 -static inline unsigned int GI_ALT_SYNC(enum ni_gpct_variant variant) -{ - switch (variant) { - case ni_gpct_variant_e_series: - default: - return 0; - case ni_gpct_variant_m_series: - return GI_M_ALT_SYNC; - case ni_gpct_variant_660x: - return GI_660X_ALT_SYNC; - } -} - static inline unsigned int GI_PRESCALE_X2(enum ni_gpct_variant variant) { switch (variant) { @@ -465,48 +452,56 @@ ni_tio_generic_clock_src_select(const struct ni_gpct *counter) } } -static void ni_tio_set_sync_mode(struct ni_gpct *counter, int force_alt_sync) +static void ni_tio_set_sync_mode(struct ni_gpct *counter) { struct ni_gpct_device *counter_dev = counter->counter_dev; unsigned int cidx = counter->counter_index; - unsigned int counting_mode_reg = NITIO_CNT_MODE_REG(cidx); static const u64 min_normal_sync_period_ps = 25000; + unsigned int mask = 0; + unsigned int bits = 0; + unsigned int reg; unsigned int mode; - u64 clock_period_ps; + u64 ps; + bool force_alt_sync; - if (!ni_tio_counting_mode_registers_present(counter_dev)) + /* only m series and 660x variants have counting mode registers */ + switch (counter_dev->variant) { + case ni_gpct_variant_e_series: + default: return; + case ni_gpct_variant_m_series: + mask = GI_M_ALT_SYNC; + break; + case ni_gpct_variant_660x: + mask = GI_660X_ALT_SYNC; + break; + } - mode = ni_tio_get_soft_copy(counter, counting_mode_reg); + reg = NITIO_CNT_MODE_REG(cidx); + mode = ni_tio_get_soft_copy(counter, reg); switch (mode & GI_CNT_MODE_MASK) { case GI_CNT_MODE_QUADX1: case GI_CNT_MODE_QUADX2: case GI_CNT_MODE_QUADX4: case GI_CNT_MODE_SYNC_SRC: - force_alt_sync = 1; + force_alt_sync = true; break; default: + force_alt_sync = false; break; } - clock_period_ps = ni_tio_clock_period_ps(counter, - ni_tio_generic_clock_src_select(counter)); + ps = ni_tio_clock_period_ps(counter, + ni_tio_generic_clock_src_select(counter)); /* * It's not clear what we should do if clock_period is unknown, so we -* are not using the alt sync bit in that case, but allow the caller -* to decide by using the force_alt_sync parameter. +* are not using the alt sync bit in that case. */ - if (force_alt_sync || - (clock_period_ps && clock_period_ps < min_normal_sync_period_ps)) { - ni_tio_set_bits(counter, counting_mode_reg, - GI_ALT_SYNC(counter_dev->variant), - GI_ALT_SYNC(counter_dev->variant)); - } else { - ni_tio_set_bits(counter, counting_mode_reg, - GI_ALT_SYNC(counter_dev->variant), - 0x0); - } + if (force_alt_sync || (ps && ps < min_normal_sync_period_ps)) + bits = mask; + + ni_tio_set_bits(counter, reg, mask, bits); } static int ni_tio_set_counter_mode(struct ni_gpct *counter, unsigned int mode) @@ -552,7 +547,7 @@ static int ni_tio_set_counter_mode(struct ni_gpct *counter, unsigned int mode) ni_tio_set_bits(counter, NITIO_CNT_MODE_REG(cidx), GI_CNT_MODE_MASK | GI_INDEX_PHASE_MASK | GI_INDEX_MODE, bits); - ni_tio_set_sync_mode(counter, 0); + ni_tio_set_sync_mode(counter); } ni_tio_set_bits(counter, NITIO_CMD_REG(cidx), GI_CNT_DIR_MASK, @@ -807,7 +802,7 @@ static int ni_tio_set_clock_src(struct ni_gpct *counter, GI_PRESCALE_X8(counter_dev->variant), bits); } counter->clock_period_ps = period_ns * 1000; - ni_tio_set_sync_mode(counter, 0); + ni_tio_set_sync_mode(counter); return 0; } -- 2.6.3 ___ devel mailing list de...@linuxdriv
[PATCH 27/28] staging: comedi: ni_tio: remove BUG() in ni_tio_set_gate_src()
This BUG() can never happen. The previous ni_tio_has_gate2_registers() check will have already caused the function to return -EINVAL. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index 10d4585..9ce3a9a 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -1020,8 +1020,7 @@ int ni_tio_set_gate_src(struct ni_gpct *counter, case ni_gpct_variant_660x: return ni_660x_set_gate2(counter, src); default: - BUG(); - break; + return -EINVAL; } break; default: -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 26/28] staging: comedi: ni_tio: fix ni_tio_insn_config()
The (*insn_config) functions are supposed to return an errno or the number of 'data' values used for the instruction (insn->n). Currently this function returns an errno or 0. Fix the function to work like the core expects. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 33 - 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index 51dd368..10d4585 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -1295,15 +1295,18 @@ int ni_tio_insn_config(struct comedi_device *dev, struct ni_gpct *counter = s->private; unsigned int cidx = counter->counter_index; unsigned int status; + int ret = 0; switch (data[0]) { case INSN_CONFIG_SET_COUNTER_MODE: - return ni_tio_set_counter_mode(counter, data[1]); + ret = ni_tio_set_counter_mode(counter, data[1]); + break; case INSN_CONFIG_ARM: - return ni_tio_arm(counter, true, data[1]); + ret = ni_tio_arm(counter, true, data[1]); + break; case INSN_CONFIG_DISARM: - ni_tio_arm(counter, false, 0); - return 0; + ret = ni_tio_arm(counter, false, 0); + break; case INSN_CONFIG_GET_COUNTER_STATUS: data[1] = 0; status = ni_tio_read(counter, NITIO_SHARED_STATUS_REG(cidx)); @@ -1313,25 +1316,29 @@ int ni_tio_insn_config(struct comedi_device *dev, data[1] |= COMEDI_COUNTER_COUNTING; } data[2] = COMEDI_COUNTER_ARMED | COMEDI_COUNTER_COUNTING; - return 0; + break; case INSN_CONFIG_SET_CLOCK_SRC: - return ni_tio_set_clock_src(counter, data[1], data[2]); + ret = ni_tio_set_clock_src(counter, data[1], data[2]); + break; case INSN_CONFIG_GET_CLOCK_SRC: ni_tio_get_clock_src(counter, &data[1], &data[2]); - return 0; + break; case INSN_CONFIG_SET_GATE_SRC: - return ni_tio_set_gate_src(counter, data[1], data[2]); + ret = ni_tio_set_gate_src(counter, data[1], data[2]); + break; case INSN_CONFIG_GET_GATE_SRC: - return ni_tio_get_gate_src(counter, data[1], &data[2]); + ret = ni_tio_get_gate_src(counter, data[1], &data[2]); + break; case INSN_CONFIG_SET_OTHER_SRC: - return ni_tio_set_other_src(counter, data[1], data[2]); + ret = ni_tio_set_other_src(counter, data[1], data[2]); + break; case INSN_CONFIG_RESET: ni_tio_reset_count_and_disarm(counter); - return 0; - default: break; + default: + return -EINVAL; } - return -EINVAL; + return ret ? ret : insn->n; } EXPORT_SYMBOL_GPL(ni_tio_insn_config); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 20/28] staging: comedi: ni_tiocmd: Prefer 'unsigned int' to bare use of 'unsigned'
Fix the checkpatch.pl issues. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tiocmd.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c index d5ffbb1..df4ffdb 100644 --- a/drivers/staging/comedi/drivers/ni_tiocmd.c +++ b/drivers/staging/comedi/drivers/ni_tiocmd.c @@ -51,9 +51,9 @@ static void ni_tio_configure_dma(struct ni_gpct *counter, bool enable, bool read) { struct ni_gpct_device *counter_dev = counter->counter_dev; - unsigned cidx = counter->counter_index; - unsigned mask; - unsigned bits; + unsigned int cidx = counter->counter_index; + unsigned int mask; + unsigned int bits; mask = GI_READ_ACKS_IRQ | GI_WRITE_ACKS_IRQ; bits = 0; @@ -113,7 +113,7 @@ static int ni_tio_input_cmd(struct comedi_subdevice *s) { struct ni_gpct *counter = s->private; struct ni_gpct_device *counter_dev = counter->counter_dev; - unsigned cidx = counter->counter_index; + unsigned int cidx = counter->counter_index; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; int ret = 0; @@ -163,9 +163,9 @@ static int ni_tio_cmd_setup(struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; struct ni_gpct *counter = s->private; - unsigned cidx = counter->counter_index; + unsigned int cidx = counter->counter_index; int set_gate_source = 0; - unsigned gate_source; + unsigned int gate_source; int retval = 0; if (cmd->scan_begin_src == TRIG_EXT) { @@ -289,7 +289,7 @@ EXPORT_SYMBOL_GPL(ni_tio_cmdtest); int ni_tio_cancel(struct ni_gpct *counter) { - unsigned cidx = counter->counter_index; + unsigned int cidx = counter->counter_index; unsigned long flags; ni_tio_arm(counter, false, 0); @@ -341,12 +341,12 @@ static void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, int *perm_stale_data, int *stale_data) { - unsigned cidx = counter->counter_index; + unsigned int cidx = counter->counter_index; const unsigned short gxx_status = ni_tio_read(counter, NITIO_SHARED_STATUS_REG(cidx)); const unsigned short gi_status = ni_tio_read(counter, NITIO_STATUS_REG(cidx)); - unsigned ack = 0; + unsigned int ack = 0; if (gate_error) *gate_error = 0; @@ -407,8 +407,8 @@ EXPORT_SYMBOL_GPL(ni_tio_acknowledge); void ni_tio_handle_interrupt(struct ni_gpct *counter, struct comedi_subdevice *s) { - unsigned cidx = counter->counter_index; - unsigned gpct_mite_status; + unsigned int cidx = counter->counter_index; + unsigned int gpct_mite_status; unsigned long flags; int gate_error; int tc_error; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 05/28] staging: comedi: ni_tio: export and fix ni_tio_get_soft_copy()
Move the inline function from the header and export it instead. For the checkpatch.pl issues: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() The 'unsigned' vars can safely be changed to 'unsigned int'. The BUG_ON() is overkill. All the drivers that call this function pass 'register_index' values that are valid. Just check the 'register_index' and return 0 if it's not valid. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 25 drivers/staging/comedi/drivers/ni_tio_internal.h | 21 ++-- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index 35596b1..abbdad5 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -228,6 +228,31 @@ static uint64_t ni_tio_clock_period_ps(const struct ni_gpct *counter, return clock_period_ps; } +/** + * ni_tio_get_soft_copy() - Safely read the software copy of a counter register. + * @counter: struct ni_gpct counter. + * @reg: the register to read. + * + * Used to get the software copy of a register whose bits might be modified + * in interrupt context, or whose software copy might need to be read in + * interrupt context. + */ +unsigned int ni_tio_get_soft_copy(const struct ni_gpct *counter, + enum ni_gpct_register reg) +{ + struct ni_gpct_device *counter_dev = counter->counter_dev; + unsigned int value = 0; + unsigned long flags; + + if (reg < NITIO_NUM_REGS) { + spin_lock_irqsave(&counter_dev->regs_lock, flags); + value = counter_dev->regs[reg]; + spin_unlock_irqrestore(&counter_dev->regs_lock, flags); + } + return value; +} +EXPORT_SYMBOL_GPL(ni_tio_get_soft_copy); + static unsigned ni_tio_clock_src_modifiers(const struct ni_gpct *counter) { struct ni_gpct_device *counter_dev = counter->counter_dev; diff --git a/drivers/staging/comedi/drivers/ni_tio_internal.h b/drivers/staging/comedi/drivers/ni_tio_internal.h index 1e91633..8c90276 100644 --- a/drivers/staging/comedi/drivers/ni_tio_internal.h +++ b/drivers/staging/comedi/drivers/ni_tio_internal.h @@ -224,25 +224,8 @@ static inline void ni_tio_set_bits(struct ni_gpct *counter, 0x0); } -/* - * ni_tio_get_soft_copy( ) is for safely reading the software copy of a - * register whose bits might be modified in interrupt context, or whose - * software copy might need to be read in interrupt context. - */ -static inline unsigned ni_tio_get_soft_copy(const struct ni_gpct *counter, - enum ni_gpct_register - register_index) -{ - struct ni_gpct_device *counter_dev = counter->counter_dev; - unsigned long flags; - unsigned value; - - BUG_ON(register_index >= NITIO_NUM_REGS); - spin_lock_irqsave(&counter_dev->regs_lock, flags); - value = counter_dev->regs[register_index]; - spin_unlock_irqrestore(&counter_dev->regs_lock, flags); - return value; -} +unsigned int ni_tio_get_soft_copy(const struct ni_gpct *, + enum ni_gpct_register reg); int ni_tio_arm(struct ni_gpct *, bool arm, unsigned int start_trigger); int ni_tio_set_gate_src(struct ni_gpct *, unsigned int gate, unsigned int src); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 22/28] staging: comedi: ni_tiocmd: remove unsed param from ni_tio_acknowledge_and_confirm()
The 'stale_data' pointer is always NULL. Just remove it. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tiocmd.c | 13 +++-- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c index 1400b1f..2d801bf9 100644 --- a/drivers/staging/comedi/drivers/ni_tiocmd.c +++ b/drivers/staging/comedi/drivers/ni_tiocmd.c @@ -338,8 +338,7 @@ static int should_ack_gate(struct ni_gpct *counter) static void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, int *gate_error, int *tc_error, - int *perm_stale_data, - int *stale_data) + int *perm_stale_data) { unsigned int cidx = counter->counter_index; const unsigned short gxx_status = ni_tio_read(counter, @@ -354,8 +353,6 @@ static void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, *tc_error = 0; if (perm_stale_data) *perm_stale_data = 0; - if (stale_data) - *stale_data = 0; if (gxx_status & GI_GATE_ERROR(cidx)) { ack |= GI_GATE_ERROR_CONFIRM(cidx); @@ -385,10 +382,6 @@ static void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, ni_tio_write(counter, ack, NITIO_INT_ACK_REG(cidx)); if (ni_tio_get_soft_copy(counter, NITIO_MODE_REG(cidx)) & GI_LOADING_ON_GATE) { - if (gxx_status & GI_STALE_DATA(cidx)) { - if (stale_data) - *stale_data = 1; - } if (ni_tio_read(counter, NITIO_STATUS2_REG(cidx)) & GI_PERMANENT_STALE(cidx)) { dev_info(counter->counter_dev->dev->class_dev, @@ -402,7 +395,7 @@ static void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, void ni_tio_acknowledge(struct ni_gpct *counter) { - ni_tio_acknowledge_and_confirm(counter, NULL, NULL, NULL, NULL); + ni_tio_acknowledge_and_confirm(counter, NULL, NULL, NULL); } EXPORT_SYMBOL_GPL(ni_tio_acknowledge); @@ -417,7 +410,7 @@ void ni_tio_handle_interrupt(struct ni_gpct *counter, int perm_stale_data; ni_tio_acknowledge_and_confirm(counter, &gate_error, &tc_error, - &perm_stale_data, NULL); + &perm_stale_data); if (gate_error) { dev_notice(counter->counter_dev->dev->class_dev, "%s: Gi_Gate_Error detected.\n", __func__); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 28/28] staging: comedi: ni_tio: remove BUG() checks for ni_tio_get_clock_src()
This function calls some helper functions to convert the counter variant specific clock select bits into the generic enum ni_gpct_clock_source_bits equivelent. These helper functions currently BUG() if the clock select bits are invalid. It then calls ni_tio_clock_period_ps() to figure out the clock period based on the generic clock source. This function could also BUG() if the prescale bits are invalid. In reality this should never happen but refactor the code to return -EINVAL instead and remove the BUG() checks. These functions are also called by ni_tio_set_sync_mode(). When this function is called by ni_tio_set_clock_src() the counter select bits have already been validated. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 60 +++-- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index 9ce3a9a..7043eb0 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -183,8 +183,9 @@ static void ni_tio_reset_count_and_disarm(struct ni_gpct *counter) ni_tio_write(counter, GI_RESET(cidx), NITIO_RESET_REG(cidx)); } -static u64 ni_tio_clock_period_ps(const struct ni_gpct *counter, - unsigned int generic_clock_source) +static int ni_tio_clock_period_ps(const struct ni_gpct *counter, + unsigned int generic_clock_source, + u64 *period_ps) { u64 clock_period_ps; @@ -219,10 +220,10 @@ static u64 ni_tio_clock_period_ps(const struct ni_gpct *counter, clock_period_ps *= 8; break; default: - BUG(); - break; + return -EINVAL; } - return clock_period_ps; + *period_ps = clock_period_ps; + return 0; } static void ni_tio_set_bits_transient(struct ni_gpct *counter, @@ -304,7 +305,8 @@ static unsigned int ni_tio_clock_src_modifiers(const struct ni_gpct *counter) return bits; } -static unsigned int ni_m_series_clock_src_select(const struct ni_gpct *counter) +static int ni_m_series_clock_src_select(const struct ni_gpct *counter, + unsigned int *clk_src) { struct ni_gpct_device *counter_dev = counter->counter_dev; unsigned int cidx = counter->counter_index; @@ -362,14 +364,15 @@ static unsigned int ni_m_series_clock_src_select(const struct ni_gpct *counter) } if (i <= NI_M_MAX_PFI_CHAN) break; - BUG(); - break; + return -EINVAL; } clock_source |= ni_tio_clock_src_modifiers(counter); - return clock_source; + *clk_src = clock_source; + return 0; } -static unsigned int ni_660x_clock_src_select(const struct ni_gpct *counter) +static int ni_660x_clock_src_select(const struct ni_gpct *counter, + unsigned int *clk_src) { unsigned int clock_source = 0; unsigned int cidx = counter->counter_index; @@ -419,23 +422,23 @@ static unsigned int ni_660x_clock_src_select(const struct ni_gpct *counter) } if (i <= NI_660X_MAX_SRC_PIN) break; - BUG(); - break; + return -EINVAL; } clock_source |= ni_tio_clock_src_modifiers(counter); - return clock_source; + *clk_src = clock_source; + return 0; } -static unsigned int -ni_tio_generic_clock_src_select(const struct ni_gpct *counter) +static int ni_tio_generic_clock_src_select(const struct ni_gpct *counter, + unsigned int *clk_src) { switch (counter->counter_dev->variant) { case ni_gpct_variant_e_series: case ni_gpct_variant_m_series: default: - return ni_m_series_clock_src_select(counter); + return ni_m_series_clock_src_select(counter, clk_src); case ni_gpct_variant_660x: - return ni_660x_clock_src_select(counter); + return ni_660x_clock_src_select(counter, clk_src); } } @@ -448,6 +451,7 @@ static void ni_tio_set_sync_mode(struct ni_gpct *counter) unsigned int bits = 0; unsigned int reg; unsigned int mode; + unsigned int clk_src; u64 ps; bool force_alt_sync; @@ -478,8 +482,8 @@ static void ni_tio_set_sync_mode(struct ni_gpct *counter) break; } - ps = ni_tio_clock_period_ps(counter, - ni_tio_generic_clock_src_select(counter)); + ni_tio_generic_clock_src_select(counter, &clk_src); + ni_tio_clock_period_ps(counter, clk_src, &ps); /* * It's not clear what we should do if c
[PATCH 12/28] staging: comedi: ni_tio.h: fix block comment
Fix the checkpatch.pl issue: WARNING: Block comments use * on subsequent lines Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.h | 29 ++--- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.h b/drivers/staging/comedi/drivers/ni_tio.h index 5d03743..7ddafdd 100644 --- a/drivers/staging/comedi/drivers/ni_tio.h +++ b/drivers/staging/comedi/drivers/ni_tio.h @@ -1,19 +1,18 @@ /* -drivers/ni_tio.h -Header file for NI general purpose counter support code (ni_tio.c) - -COMEDI - Linux Control and Measurement Device Interface - -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. -*/ + * Header file for NI general purpose counter support code (ni_tio.c) + * + * COMEDI - Linux Control and Measurement Device Interface + * + * 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 _COMEDI_NI_TIO_H #define _COMEDI_NI_TIO_H -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 24/28] staging: comedi: ni_tio: validate clock source
Refactor the functions that determine the clock source bits so that they return -EINVAL if the clock source is invalid. Pass the errno back to ni_tio_insn_config(). Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 34 ++--- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index e7209c1..564ec9b 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -608,7 +608,7 @@ int ni_tio_arm(struct ni_gpct *counter, bool arm, unsigned int start_trigger) } EXPORT_SYMBOL_GPL(ni_tio_arm); -static unsigned int ni_660x_clk_src(unsigned int clock_source) +static int ni_660x_clk_src(unsigned int clock_source, unsigned int *bits) { unsigned int clk_src = clock_source & NI_GPCT_CLOCK_SRC_SELECT_MASK; unsigned int ni_660x_clock; @@ -653,14 +653,13 @@ static unsigned int ni_660x_clk_src(unsigned int clock_source) } if (i <= NI_660X_MAX_SRC_PIN) break; - ni_660x_clock = 0; - BUG(); - break; + return -EINVAL; } - return GI_SRC_SEL(ni_660x_clock); + *bits = GI_SRC_SEL(ni_660x_clock); + return 0; } -static unsigned int ni_m_clk_src(unsigned int clock_source) +static int ni_m_clk_src(unsigned int clock_source, unsigned int *bits) { unsigned int clk_src = clock_source & NI_GPCT_CLOCK_SRC_SELECT_MASK; unsigned int ni_m_series_clock; @@ -711,13 +710,10 @@ static unsigned int ni_m_clk_src(unsigned int clock_source) } if (i <= NI_M_MAX_PFI_CHAN) break; - pr_err("invalid clock source 0x%lx\n", - (unsigned long)clock_source); - BUG(); - ni_m_series_clock = 0; - break; + return -EINVAL; } - return GI_SRC_SEL(ni_m_series_clock); + *bits = GI_SRC_SEL(ni_m_series_clock); + return 0; }; static void ni_tio_set_source_subselect(struct ni_gpct *counter, @@ -755,18 +751,26 @@ static int ni_tio_set_clock_src(struct ni_gpct *counter, struct ni_gpct_device *counter_dev = counter->counter_dev; unsigned int cidx = counter->counter_index; unsigned int bits = 0; + int ret; - /* FIXME: validate clock source */ switch (counter_dev->variant) { case ni_gpct_variant_660x: - bits |= ni_660x_clk_src(clock_source); + ret = ni_660x_clk_src(clock_source, &bits); break; case ni_gpct_variant_e_series: case ni_gpct_variant_m_series: default: - bits |= ni_m_clk_src(clock_source); + ret = ni_m_clk_src(clock_source, &bits); break; } + if (ret) { + struct comedi_device *dev = counter_dev->dev; + + dev_err(dev->class_dev, "invalid clock source 0x%x\n", + clock_source); + return ret; + } + if (clock_source & NI_GPCT_INVERT_CLOCK_SRC_BIT) bits |= GI_SRC_POL_INVERT; ni_tio_set_bits(counter, NITIO_INPUT_SEL_REG(cidx), -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 09/28] staging: comedi: ni_tio: tidy up struct ni_gpct_device (*{write, read}_register)
For aesthetics, rename these callbacks to simply read/write. Change the 'unsigned' parameters to 'unsigned int'. This fixes a number of checkpatch.pl issues: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 22 +++--- drivers/staging/comedi/drivers/ni_tio.h | 19 +-- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index a225279..28bec3c 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -189,7 +189,7 @@ void ni_tio_write(struct ni_gpct *counter, unsigned int value, enum ni_gpct_register reg) { if (reg < NITIO_NUM_REGS) - counter->counter_dev->write_register(counter, value, reg); + counter->counter_dev->write(counter, value, reg); } EXPORT_SYMBOL_GPL(ni_tio_write); @@ -201,7 +201,7 @@ EXPORT_SYMBOL_GPL(ni_tio_write); unsigned int ni_tio_read(struct ni_gpct *counter, enum ni_gpct_register reg) { if (reg < NITIO_NUM_REGS) - return counter->counter_dev->read_register(counter, reg); + return counter->counter_dev->read(counter, reg); return 0; } EXPORT_SYMBOL_GPL(ni_tio_read); @@ -1455,17 +1455,17 @@ EXPORT_SYMBOL_GPL(ni_tio_init_counter); struct ni_gpct_device * ni_gpct_device_construct(struct comedi_device *dev, -void (*write_register)(struct ni_gpct *counter, - unsigned bits, - enum ni_gpct_register reg), -unsigned (*read_register)(struct ni_gpct *counter, - enum ni_gpct_register reg), +void (*write)(struct ni_gpct *counter, + unsigned int value, + enum ni_gpct_register reg), +unsigned int (*read)(struct ni_gpct *counter, + enum ni_gpct_register reg), enum ni_gpct_variant variant, -unsigned num_counters) +unsigned int num_counters) { struct ni_gpct_device *counter_dev; struct ni_gpct *counter; - unsigned i; + unsigned int i; if (num_counters == 0) return NULL; @@ -1475,8 +1475,8 @@ ni_gpct_device_construct(struct comedi_device *dev, return NULL; counter_dev->dev = dev; - counter_dev->write_register = write_register; - counter_dev->read_register = read_register; + counter_dev->write = write; + counter_dev->read = read; counter_dev->variant = variant; spin_lock_init(&counter_dev->regs_lock); diff --git a/drivers/staging/comedi/drivers/ni_tio.h b/drivers/staging/comedi/drivers/ni_tio.h index 25aedd0..63cec3e 100644 --- a/drivers/staging/comedi/drivers/ni_tio.h +++ b/drivers/staging/comedi/drivers/ni_tio.h @@ -115,10 +115,9 @@ struct ni_gpct { struct ni_gpct_device { struct comedi_device *dev; - void (*write_register)(struct ni_gpct *counter, unsigned bits, - enum ni_gpct_register reg); - unsigned (*read_register)(struct ni_gpct *counter, - enum ni_gpct_register reg); + void (*write)(struct ni_gpct *, unsigned int value, + enum ni_gpct_register); + unsigned int (*read)(struct ni_gpct *, enum ni_gpct_register); enum ni_gpct_variant variant; struct ni_gpct *counters; unsigned num_counters; @@ -128,13 +127,13 @@ struct ni_gpct_device { struct ni_gpct_device * ni_gpct_device_construct(struct comedi_device *, -void (*write_register)(struct ni_gpct *, - unsigned bits, - enum ni_gpct_register), -unsigned (*read_register)(struct ni_gpct *, - enum ni_gpct_register), +void (*write)(struct ni_gpct *, + unsigned int value, + enum ni_gpct_register), +unsigned int (*read)(struct ni_gpct *, + enum ni_gpct_register), enum ni_gpct_variant, -unsigned num_counters); +unsigned int num_counters); void ni_gpct_device_destroy(struct ni_gpct_device *); void ni_tio_init_counter(struct ni_gpct *); int ni_tio_insn_read(struct comedi_device *, struct comedi_subdevice *, -- 2.6.3 _
[PATCH 08/28] staging: comedi: ni_tio_internal: export {read, write)_register()
Move these inline functions out of the header and export them instead. These functions have pretty generic names, rename them. Fix the checkpatch.pl issues: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 72 drivers/staging/comedi/drivers/ni_tio_internal.h | 15 + drivers/staging/comedi/drivers/ni_tiocmd.c | 10 ++-- 3 files changed, 56 insertions(+), 41 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index 44dea4c..a225279 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -179,11 +179,38 @@ static bool ni_tio_has_gate2_registers(const struct ni_gpct_device *counter_dev) } } +/** + * ni_tio_write() - Write a TIO register using the driver provided callback. + * @counter: struct ni_gpct counter. + * @value: the value to write + * @reg: the register to write. + */ +void ni_tio_write(struct ni_gpct *counter, unsigned int value, + enum ni_gpct_register reg) +{ + if (reg < NITIO_NUM_REGS) + counter->counter_dev->write_register(counter, value, reg); +} +EXPORT_SYMBOL_GPL(ni_tio_write); + +/** + * ni_tio_read() - Read a TIO register using the driver provided callback. + * @counter: struct ni_gpct counter. + * @reg: the register to read. + */ +unsigned int ni_tio_read(struct ni_gpct *counter, enum ni_gpct_register reg) +{ + if (reg < NITIO_NUM_REGS) + return counter->counter_dev->read_register(counter, reg); + return 0; +} +EXPORT_SYMBOL_GPL(ni_tio_read); + static void ni_tio_reset_count_and_disarm(struct ni_gpct *counter) { unsigned cidx = counter->counter_index; - write_register(counter, GI_RESET(cidx), NITIO_RESET_REG(cidx)); + ni_tio_write(counter, GI_RESET(cidx), NITIO_RESET_REG(cidx)); } static uint64_t ni_tio_clock_period_ps(const struct ni_gpct *counter, @@ -240,8 +267,7 @@ static void ni_tio_set_bits_transient(struct ni_gpct *counter, spin_lock_irqsave(&counter_dev->regs_lock, flags); counter_dev->regs[reg] &= ~mask; counter_dev->regs[reg] |= (value & mask); - write_register(counter, counter_dev->regs[reg] | transient, - reg); + ni_tio_write(counter, counter_dev->regs[reg] | transient, reg); mmiowb(); spin_unlock_irqrestore(&counter_dev->regs_lock, flags); } @@ -736,8 +762,8 @@ static void ni_tio_set_source_subselect(struct ni_gpct *counter, default: return; } - write_register(counter, counter_dev->regs[second_gate_reg], - second_gate_reg); + ni_tio_write(counter, counter_dev->regs[second_gate_reg], +second_gate_reg); } static int ni_tio_set_clock_src(struct ni_gpct *counter, @@ -925,7 +951,7 @@ static int ni_660x_set_gate2(struct ni_gpct *counter, unsigned int gate_source) counter_dev->regs[gate2_reg] |= GI_GATE2_MODE; counter_dev->regs[gate2_reg] &= ~GI_GATE2_SEL_MASK; counter_dev->regs[gate2_reg] |= GI_GATE2_SEL(gate2_sel); - write_register(counter, counter_dev->regs[gate2_reg], gate2_reg); + ni_tio_write(counter, counter_dev->regs[gate2_reg], gate2_reg); return 0; } @@ -949,7 +975,7 @@ static int ni_m_set_gate2(struct ni_gpct *counter, unsigned int gate_source) counter_dev->regs[gate2_reg] |= GI_GATE2_MODE; counter_dev->regs[gate2_reg] &= ~GI_GATE2_SEL_MASK; counter_dev->regs[gate2_reg] |= GI_GATE2_SEL(gate2_sel); - write_register(counter, counter_dev->regs[gate2_reg], gate2_reg); + ni_tio_write(counter, counter_dev->regs[gate2_reg], gate2_reg); return 0; } @@ -994,8 +1020,8 @@ int ni_tio_set_gate_src(struct ni_gpct *counter, if (chan == NI_GPCT_DISABLED_GATE_SELECT) { counter_dev->regs[gate2_reg] &= ~GI_GATE2_MODE; - write_register(counter, counter_dev->regs[gate2_reg], - gate2_reg); + ni_tio_write(counter, counter_dev->regs[gate2_reg], +gate2_reg); return 0; } if (src & CR_INVERT) @@ -1049,7 +1075,7 @@ static int ni_tio_set_other_src(struct ni_gpct *counter, unsigned index, counter_dev->regs[abz_reg] &= ~mask; counter_dev->regs[abz_reg] |= (source << shift) & mask; - write_register(counter, counter_dev->regs[abz_reg], abz_reg); + ni_tio_write(counter, counter_dev->regs[abz_reg], abz_reg); return 0; } @@ -1248,7 +1274,7 @@ int ni_tio_
[PATCH 17/28] staging: comedi: ni_tio: tidy up ni_tio_get_gate_src()
Clarify the code a bit by handling the NI_GPCT_DISABLED_GATE_SELECT source in the common code path. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 32 +++- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index e7af98d..ce64cc3 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -1192,19 +1192,22 @@ static int ni_tio_get_gate_src(struct ni_gpct *counter, unsigned int gate_index, { struct ni_gpct_device *counter_dev = counter->counter_dev; unsigned int cidx = counter->counter_index; - unsigned int mode = ni_tio_get_soft_copy(counter, NITIO_MODE_REG(cidx)); - unsigned int gate2_reg = NITIO_GATE2_REG(cidx); + unsigned int mode; + unsigned int reg; unsigned int gate; + mode = ni_tio_get_soft_copy(counter, NITIO_MODE_REG(cidx)); + if (((mode & GI_GATING_MODE_MASK) == GI_GATING_DISABLED) || + (gate_index == 1 && +!(counter_dev->regs[NITIO_GATE2_REG(cidx)] & GI_GATE2_MODE))) { + *gate_source = NI_GPCT_DISABLED_GATE_SELECT; + return 0; + } + switch (gate_index) { case 0: - if ((mode & GI_GATING_MODE_MASK) == GI_GATING_DISABLED) { - *gate_source = NI_GPCT_DISABLED_GATE_SELECT; - return 0; - } - - gate = GI_BITS_TO_GATE(ni_tio_get_soft_copy(counter, - NITIO_INPUT_SEL_REG(cidx))); + reg = NITIO_INPUT_SEL_REG(cidx); + gate = GI_BITS_TO_GATE(ni_tio_get_soft_copy(counter, reg)); switch (counter_dev->variant) { case ni_gpct_variant_e_series: @@ -1222,13 +1225,8 @@ static int ni_tio_get_gate_src(struct ni_gpct *counter, unsigned int gate_index, *gate_source |= CR_EDGE; break; case 1: - if ((mode & GI_GATING_MODE_MASK) == GI_GATING_DISABLED || - !(counter_dev->regs[gate2_reg] & GI_GATE2_MODE)) { - *gate_source = NI_GPCT_DISABLED_GATE_SELECT; - return 0; - } - - gate = GI_BITS_TO_GATE2(counter_dev->regs[gate2_reg]); + reg = NITIO_GATE2_REG(cidx); + gate = GI_BITS_TO_GATE2(counter_dev->regs[reg]); switch (counter_dev->variant) { case ni_gpct_variant_e_series: @@ -1240,7 +1238,7 @@ static int ni_tio_get_gate_src(struct ni_gpct *counter, unsigned int gate_index, *gate_source = ni_660x_gate2_to_generic_gate(gate); break; } - if (counter_dev->regs[gate2_reg] & GI_GATE2_POL_INVERT) + if (counter_dev->regs[reg] & GI_GATE2_POL_INVERT) *gate_source |= CR_INVERT; /* second gate can't have edge/level mode set independently */ if ((mode & GI_GATING_MODE_MASK) != GI_LEVEL_GATING) -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 23/28] staging: comedi: ni_tiocmd: remove BUG() which can never occur
All the counter_dev->variant options are handled by the switch. Remove the BUG() which can never occur. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tiocmd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c index 2d801bf9..3c3f543 100644 --- a/drivers/staging/comedi/drivers/ni_tiocmd.c +++ b/drivers/staging/comedi/drivers/ni_tiocmd.c @@ -125,9 +125,6 @@ static int ni_tio_input_cmd(struct comedi_subdevice *s) case ni_gpct_variant_e_series: mite_prep_dma(counter->mite_chan, 16, 32); break; - default: - BUG(); - break; } ni_tio_set_bits(counter, NITIO_CMD_REG(cidx), GI_SAVE_TRACE, 0); ni_tio_configure_dma(counter, true, true); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 02/28] staging: comedi: ni_tio_internal.h: fix block comment issues
Fix the checkpatch.pl issues: WARNING: Block comments use * on subsequent lines Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio_internal.h | 43 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio_internal.h b/drivers/staging/comedi/drivers/ni_tio_internal.h index c51e01e..b659f05 100644 --- a/drivers/staging/comedi/drivers/ni_tio_internal.h +++ b/drivers/staging/comedi/drivers/ni_tio_internal.h @@ -1,20 +1,19 @@ /* -drivers/ni_tio_internal.h -Header file for NI general purpose counter support code (ni_tio.c and -ni_tiocmd.c) - -COMEDI - Linux Control and Measurement Device Interface - -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. -*/ + * Header file for NI general purpose counter support code (ni_tio.c and + * ni_tiocmd.c) + * + * COMEDI - Linux Control and Measurement Device Interface + * + * 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 _COMEDI_NI_TIO_INTERNAL_H #define _COMEDI_NI_TIO_INTERNAL_H @@ -212,7 +211,8 @@ static inline void ni_tio_set_bits_transient(struct ni_gpct *counter, spin_unlock_irqrestore(&counter_dev->regs_lock, flags); } -/* ni_tio_set_bits( ) is for safely writing to registers whose bits may be +/* + * ni_tio_set_bits( ) is for safely writing to registers whose bits may be * twiddled in interrupt context, or whose software copy may be read in * interrupt context. */ @@ -224,10 +224,11 @@ static inline void ni_tio_set_bits(struct ni_gpct *counter, 0x0); } -/* ni_tio_get_soft_copy( ) is for safely reading the software copy of a register -whose bits might be modified in interrupt context, or whose software copy -might need to be read in interrupt context. -*/ +/* + * ni_tio_get_soft_copy( ) is for safely reading the software copy of a + * register whose bits might be modified in interrupt context, or whose + * software copy might need to be read in interrupt context. + */ static inline unsigned ni_tio_get_soft_copy(const struct ni_gpct *counter, enum ni_gpct_register register_index) -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 13/28] staging: comedi: ni_tio.h: remove unnecessary forward declarations
These struct forward declarations are not needed. Remove them. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.h | 4 1 file changed, 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.h b/drivers/staging/comedi/drivers/ni_tio.h index 7ddafdd..4978358 100644 --- a/drivers/staging/comedi/drivers/ni_tio.h +++ b/drivers/staging/comedi/drivers/ni_tio.h @@ -19,10 +19,6 @@ #include "../comedidev.h" -/* forward declarations */ -struct mite_struct; -struct ni_gpct_device; - enum ni_gpct_register { NITIO_G0_AUTO_INC, NITIO_G1_AUTO_INC, -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 15/28] staging: comedi: ni_tio: Prefer kernel type 'u64' over 'uint64_t'
Fix the checkpatch.pl issues. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index ecf8527..e4fd221 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -213,10 +213,10 @@ static void ni_tio_reset_count_and_disarm(struct ni_gpct *counter) ni_tio_write(counter, GI_RESET(cidx), NITIO_RESET_REG(cidx)); } -static uint64_t ni_tio_clock_period_ps(const struct ni_gpct *counter, - unsigned int generic_clock_source) +static u64 ni_tio_clock_period_ps(const struct ni_gpct *counter, + unsigned int generic_clock_source) { - uint64_t clock_period_ps; + u64 clock_period_ps; switch (generic_clock_source & NI_GPCT_CLOCK_SRC_SELECT_MASK) { case NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS: @@ -474,9 +474,9 @@ static void ni_tio_set_sync_mode(struct ni_gpct *counter, int force_alt_sync) struct ni_gpct_device *counter_dev = counter->counter_dev; unsigned int cidx = counter->counter_index; unsigned int counting_mode_reg = NITIO_CNT_MODE_REG(cidx); - static const uint64_t min_normal_sync_period_ps = 25000; + static const u64 min_normal_sync_period_ps = 25000; unsigned int mode; - uint64_t clock_period_ps; + u64 clock_period_ps; if (!ni_tio_counting_mode_registers_present(counter_dev)) return; @@ -819,7 +819,7 @@ static void ni_tio_get_clock_src(struct ni_gpct *counter, unsigned int *clock_source, unsigned int *period_ns) { - uint64_t temp64; + u64 temp64; *clock_source = ni_tio_generic_clock_src_select(counter); temp64 = ni_tio_clock_period_ps(counter, *clock_source); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 19/28] staging: comedi: ni_tio: tidy up ni_tio_arm()
Make this function a bit more consise by absorbing the GI_HW_ARM_SEL_MASK() inline helper and combine the two switch (start_trigger) code paths. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 78 ++--- 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index 2c33b28..e7209c1 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -137,19 +137,6 @@ static inline unsigned int GI_PRESCALE_X8(enum ni_gpct_variant variant) } } -static inline unsigned int GI_HW_ARM_SEL_MASK(enum ni_gpct_variant variant) -{ - switch (variant) { - case ni_gpct_variant_e_series: - default: - return 0; - case ni_gpct_variant_m_series: - return GI_M_HW_ARM_SEL_MASK; - case ni_gpct_variant_660x: - return GI_660X_HW_ARM_SEL_MASK; - } -} - static bool ni_tio_has_gate2_registers(const struct ni_gpct_device *counter_dev) { switch (counter_dev->variant) { @@ -568,52 +555,55 @@ int ni_tio_arm(struct ni_gpct *counter, bool arm, unsigned int start_trigger) { struct ni_gpct_device *counter_dev = counter->counter_dev; unsigned int cidx = counter->counter_index; - unsigned int command_transient_bits = 0; + unsigned int transient_bits = 0; if (arm) { + unsigned int mask = 0; + unsigned int bits = 0; + + /* only m series and 660x have counting mode registers */ + switch (counter_dev->variant) { + case ni_gpct_variant_e_series: + default: + break; + case ni_gpct_variant_m_series: + mask = GI_M_HW_ARM_SEL_MASK; + break; + case ni_gpct_variant_660x: + mask = GI_660X_HW_ARM_SEL_MASK; + break; + } + switch (start_trigger) { case NI_GPCT_ARM_IMMEDIATE: - command_transient_bits |= GI_ARM; + transient_bits |= GI_ARM; break; case NI_GPCT_ARM_PAIRED_IMMEDIATE: - command_transient_bits |= GI_ARM | GI_ARM_COPY; + transient_bits |= GI_ARM | GI_ARM_COPY; break; default: + /* +* for m series and 660x, pass-through the least +* significant bits so we can figure out what select +* later +*/ + if (mask && (start_trigger & NI_GPCT_ARM_UNKNOWN)) { + bits |= GI_HW_ARM_ENA | + (GI_HW_ARM_SEL(start_trigger) & mask); + } else { + return -EINVAL; + } break; } - if (ni_tio_counting_mode_registers_present(counter_dev)) { - unsigned int bits = 0; - unsigned int sel_mask; - sel_mask = GI_HW_ARM_SEL_MASK(counter_dev->variant); - - switch (start_trigger) { - case NI_GPCT_ARM_IMMEDIATE: - case NI_GPCT_ARM_PAIRED_IMMEDIATE: - break; - default: - if (start_trigger & NI_GPCT_ARM_UNKNOWN) { - /* -* pass-through the least significant -* bits so we can figure out what -* select later -*/ - bits |= GI_HW_ARM_ENA | - (GI_HW_ARM_SEL(start_trigger) & -sel_mask); - } else { - return -EINVAL; - } - break; - } + if (mask) ni_tio_set_bits(counter, NITIO_CNT_MODE_REG(cidx), - GI_HW_ARM_ENA | sel_mask, bits); - } + GI_HW_ARM_ENA | mask, bits); } else { - command_transient_bits |= GI_DISARM; + transient_bits |= GI_DISARM; } ni_tio_set_bits_transient(counter, NITIO_CMD_REG(cidx), - 0, 0, command_transient_bits); + 0, 0, transient_bits);
[PATCH 21/28] staging: comedi: ni_tiocmd: fix block comments
Fix the checkpatch.pl issues: WARNING: Block comments use * on subsequent lines Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tiocmd.c | 60 +++--- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c index df4ffdb..1400b1f 100644 --- a/drivers/staging/comedi/drivers/ni_tiocmd.c +++ b/drivers/staging/comedi/drivers/ni_tiocmd.c @@ -1,19 +1,18 @@ /* - comedi/drivers/ni_tiocmd.c - Command support for NI general purpose counters - - Copyright (C) 2006 Frank Mori Hess - - 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. -*/ + * Command support for NI general purpose counters + * + * Copyright (C) 2006 Frank Mori Hess + * + * 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: ni_tiocmd @@ -36,13 +35,10 @@ * DAQ 660x Register-Level Programmer Manual (NI 370505A-01) * DAQ 6601/6602 User Manual (NI 322137B-01) * 340934b.pdf DAQ-STC reference manual + * + * TODO: Support use of both banks X and Y */ -/* -TODO: - Support use of both banks X and Y -*/ - #include #include "ni_tio_internal.h" #include "mite.h" @@ -305,9 +301,6 @@ int ni_tio_cancel(struct ni_gpct *counter) } EXPORT_SYMBOL_GPL(ni_tio_cancel); - /* During buffered input counter operation for e-series, the gate - interrupt is acked automatically by the dma controller, due to the - Gi_Read/Write_Acknowledges_IRQ bits in the input select register. */ static int should_ack_gate(struct ni_gpct *counter) { unsigned long flags; @@ -315,12 +308,19 @@ static int should_ack_gate(struct ni_gpct *counter) switch (counter->counter_dev->variant) { case ni_gpct_variant_m_series: - /* not sure if 660x really supports gate - interrupts (the bits are not listed - in register-level manual) */ case ni_gpct_variant_660x: + /* +* not sure if 660x really supports gate interrupts +* (the bits are not listed in register-level manual) +*/ return 1; case ni_gpct_variant_e_series: + /* +* During buffered input counter operation for e-series, +* the gate interrupt is acked automatically by the dma +* controller, due to the Gi_Read/Write_Acknowledges_IRQ +* bits in the input select register. +*/ spin_lock_irqsave(&counter->lock, flags); { if (!counter->mite_chan || @@ -360,9 +360,11 @@ static void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, if (gxx_status & GI_GATE_ERROR(cidx)) { ack |= GI_GATE_ERROR_CONFIRM(cidx); if (gate_error) { - /*660x don't support automatic acknowledgment - of gate interrupt via dma read/write - and report bogus gate errors */ + /* +* 660x don't support automatic acknowledgment +* of gate interrupt via dma read/write +* and report bogus gate errors +*/ if (counter->counter_dev->variant != ni_gpct_variant_660x) *gate_error = 1; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 01/28] staging: comedi: ni_tio_internal.h: tidy up bit defines
Fix the checkpatch.pl issues: CHECK: Prefer using the BIT macro Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio_internal.h | 199 --- 1 file changed, 102 insertions(+), 97 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio_internal.h b/drivers/staging/comedi/drivers/ni_tio_internal.h index 2bceae4..c51e01e 100644 --- a/drivers/staging/comedi/drivers/ni_tio_internal.h +++ b/drivers/staging/comedi/drivers/ni_tio_internal.h @@ -24,68 +24,73 @@ #define NITIO_AUTO_INC_REG(x) (NITIO_G0_AUTO_INC + (x)) #define GI_AUTO_INC_MASK 0xff #define NITIO_CMD_REG(x) (NITIO_G0_CMD + (x)) -#define GI_ARM (1 << 0) -#define GI_SAVE_TRACE (1 << 1) -#define GI_LOAD(1 << 2) -#define GI_DISARM (1 << 4) +#define GI_ARM BIT(0) +#define GI_SAVE_TRACE BIT(1) +#define GI_LOADBIT(2) +#define GI_DISARM BIT(4) #define GI_CNT_DIR(x) (((x) & 0x3) << 5) -#define GI_CNT_DIR_MASK(3 << 5) -#define GI_WRITE_SWITCH(1 << 7) -#define GI_SYNC_GATE (1 << 8) -#define GI_LITTLE_BIG_ENDIAN (1 << 9) -#define GI_BANK_SWITCH_START (1 << 10) -#define GI_BANK_SWITCH_MODE(1 << 11) -#define GI_BANK_SWITCH_ENABLE (1 << 12) -#define GI_ARM_COPY(1 << 13) -#define GI_SAVE_TRACE_COPY (1 << 14) -#define GI_DISARM_COPY (1 << 15) +#define GI_CNT_DIR_MASKGI_CNT_DIR(3) +#define GI_WRITE_SWITCHBIT(7) +#define GI_SYNC_GATE BIT(8) +#define GI_LITTLE_BIG_ENDIAN BIT(9) +#define GI_BANK_SWITCH_START BIT(10) +#define GI_BANK_SWITCH_MODEBIT(11) +#define GI_BANK_SWITCH_ENABLE BIT(12) +#define GI_ARM_COPYBIT(13) +#define GI_SAVE_TRACE_COPY BIT(14) +#define GI_DISARM_COPY BIT(15) #define NITIO_HW_SAVE_REG(x) (NITIO_G0_HW_SAVE + (x)) #define NITIO_SW_SAVE_REG(x) (NITIO_G0_SW_SAVE + (x)) #define NITIO_MODE_REG(x) (NITIO_G0_MODE + (x)) -#define GI_GATING_DISABLED (0 << 0) -#define GI_LEVEL_GATING(1 << 0) -#define GI_RISING_EDGE_GATING (2 << 0) -#define GI_FALLING_EDGE_GATING (3 << 0) -#define GI_GATING_MODE_MASK(3 << 0) -#define GI_GATE_ON_BOTH_EDGES (1 << 2) -#define GI_EDGE_GATE_STARTS_STOPS (0 << 3) -#define GI_EDGE_GATE_STOPS_STARTS (1 << 3) -#define GI_EDGE_GATE_STARTS(2 << 3) -#define GI_EDGE_GATE_NO_STARTS_OR_STOPS(3 << 3) -#define GI_EDGE_GATE_MODE_MASK (3 << 3) -#define GI_STOP_ON_GATE(0 << 5) -#define GI_STOP_ON_GATE_OR_TC (1 << 5) -#define GI_STOP_ON_GATE_OR_SECOND_TC (2 << 5) -#define GI_STOP_MODE_MASK (3 << 5) -#define GI_LOAD_SRC_SEL(1 << 7) -#define GI_OUTPUT_TC_PULSE (1 << 8) -#define GI_OUTPUT_TC_TOGGLE(2 << 8) -#define GI_OUTPUT_TC_OR_GATE_TOGGLE(3 << 8) -#define GI_OUTPUT_MODE_MASK(3 << 8) -#define GI_NO_HARDWARE_DISARM (0 << 10) -#define GI_DISARM_AT_TC(1 << 10) -#define GI_DISARM_AT_GATE (2 << 10) -#define GI_DISARM_AT_TC_OR_GATE(3 << 10) -#define GI_COUNTING_ONCE_MASK (3 << 10) -#define GI_LOADING_ON_TC (1 << 12) -#define GI_GATE_POL_INVERT (1 << 13) -#define GI_LOADING_ON_GATE (1 << 14) -#define GI_RELOAD_SRC_SWITCHING(1 << 15) +#define GI_GATING_MODE(x) (((x) & 0x3) << 0) +#define GI_GATING_DISABLED GI_GATING_MODE(0) +#define GI_LEVEL_GATINGGI_GATING_MODE(1) +#define GI_RISING_EDGE_GATING GI_GATING_MODE(2) +#define GI_FALLING_EDGE_GATING GI_GATING_MODE(3) +#define GI_GATING_MODE_MASKGI_GATING_MODE(3) +#define GI_GATE_ON_BOTH_EDGES BIT(2) +#define GI_EDGE_GATE_MODE(x) (((x) & 0x3) << 3) +#define GI_EDGE_GATE_STARTS_STOPS GI_EDGE_GATE_MODE(0) +#define GI_EDGE_GATE_STOPS_STARTS GI_EDGE_GATE_MODE(1) +#define GI_EDGE_GATE_STARTSGI_EDGE_GATE_MODE(2) +#define GI_EDGE_GATE_NO_STARTS_OR_STOPSGI_EDGE_GATE_MODE(3) +#define GI_EDGE_GATE_MODE_MASK GI_EDGE_GATE_MODE(3) +#define GI_STOP_MODE(x)(((x) & 0x3) << 5) +#define GI_STOP_ON_GATEGI_STOP_MODE(0) +#define GI_STOP_ON_GATE_OR_TC GI_STOP_MODE(1) +#define GI_STOP_ON_GATE_OR_SECOND_TC GI_STOP_MODE(2) +#define GI_STOP_MODE_MASK GI_STOP_MODE(3) +#define GI_LOAD_SRC_SELBIT(7)
[PATCH 25/28] staging: comedi: ni_tio: remove BUG() checks for ni_tio_get_gate_src()
This function calls some helper functions to convert the counter variant specific gate select bits into the generic enum ni_gpct_clock_source_bits equivelent. These helper functions currently BUG() if the gate select bits are invalid. This should never happen but refactor the code to return -EINVAL instead and remove the BUG() checks. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 146 +--- 1 file changed, 97 insertions(+), 49 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index 564ec9b..51dd368 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -1065,114 +1065,157 @@ static int ni_tio_set_other_src(struct ni_gpct *counter, unsigned int index, return 0; } -static unsigned int ni_660x_gate_to_generic_gate(unsigned int gate) +static int ni_660x_gate_to_generic_gate(unsigned int gate, unsigned int *src) { + unsigned int source; unsigned int i; switch (gate) { case NI_660X_SRC_PIN_I_GATE_SEL: - return NI_GPCT_SOURCE_PIN_i_GATE_SELECT; + source = NI_GPCT_SOURCE_PIN_i_GATE_SELECT; + break; case NI_660X_GATE_PIN_I_GATE_SEL: - return NI_GPCT_GATE_PIN_i_GATE_SELECT; + source = NI_GPCT_GATE_PIN_i_GATE_SELECT; + break; case NI_660X_NEXT_SRC_GATE_SEL: - return NI_GPCT_NEXT_SOURCE_GATE_SELECT; + source = NI_GPCT_NEXT_SOURCE_GATE_SELECT; + break; case NI_660X_NEXT_OUT_GATE_SEL: - return NI_GPCT_NEXT_OUT_GATE_SELECT; + source = NI_GPCT_NEXT_OUT_GATE_SELECT; + break; case NI_660X_LOGIC_LOW_GATE_SEL: - return NI_GPCT_LOGIC_LOW_GATE_SELECT; + source = NI_GPCT_LOGIC_LOW_GATE_SELECT; + break; default: for (i = 0; i <= NI_660X_MAX_RTSI_CHAN; ++i) { - if (gate == NI_660X_RTSI_GATE_SEL(i)) - return NI_GPCT_RTSI_GATE_SELECT(i); + if (gate == NI_660X_RTSI_GATE_SEL(i)) { + source = NI_GPCT_RTSI_GATE_SELECT(i); + break; + } } + if (i <= NI_660X_MAX_RTSI_CHAN) + break; for (i = 0; i <= NI_660X_MAX_GATE_PIN; ++i) { - if (gate == NI_660X_PIN_GATE_SEL(i)) - return NI_GPCT_GATE_PIN_GATE_SELECT(i); + if (gate == NI_660X_PIN_GATE_SEL(i)) { + source = NI_GPCT_GATE_PIN_GATE_SELECT(i); + break; + } } - BUG(); - break; + if (i <= NI_660X_MAX_GATE_PIN) + break; + return -EINVAL; } + *src = source; return 0; }; -static unsigned int ni_m_gate_to_generic_gate(unsigned int gate) +static int ni_m_gate_to_generic_gate(unsigned int gate, unsigned int *src) { + unsigned int source; unsigned int i; switch (gate) { case NI_M_TIMESTAMP_MUX_GATE_SEL: - return NI_GPCT_TIMESTAMP_MUX_GATE_SELECT; + source = NI_GPCT_TIMESTAMP_MUX_GATE_SELECT; + break; case NI_M_AI_START2_GATE_SEL: - return NI_GPCT_AI_START2_GATE_SELECT; + source = NI_GPCT_AI_START2_GATE_SELECT; + break; case NI_M_PXI_STAR_TRIGGER_GATE_SEL: - return NI_GPCT_PXI_STAR_TRIGGER_GATE_SELECT; + source = NI_GPCT_PXI_STAR_TRIGGER_GATE_SELECT; + break; case NI_M_NEXT_OUT_GATE_SEL: - return NI_GPCT_NEXT_OUT_GATE_SELECT; + source = NI_GPCT_NEXT_OUT_GATE_SELECT; + break; case NI_M_AI_START1_GATE_SEL: - return NI_GPCT_AI_START1_GATE_SELECT; + source = NI_GPCT_AI_START1_GATE_SELECT; + break; case NI_M_NEXT_SRC_GATE_SEL: - return NI_GPCT_NEXT_SOURCE_GATE_SELECT; + source = NI_GPCT_NEXT_SOURCE_GATE_SELECT; + break; case NI_M_ANALOG_TRIG_OUT_GATE_SEL: - return NI_GPCT_ANALOG_TRIGGER_OUT_GATE_SELECT; + source = NI_GPCT_ANALOG_TRIGGER_OUT_GATE_SELECT; + break; case NI_M_LOGIC_LOW_GATE_SEL: - return NI_GPCT_LOGIC_LOW_GATE_SELECT; + source = NI_GPCT_LOGIC_LOW_GATE_SELECT; + break; default: for (i = 0; i <= NI_M_MAX_RTSI_CHAN; ++i) { - if (gate == NI_M_RTSI_GATE_SEL(i)) - return NI_GPCT_RTSI_GATE_SELECT(i); +
[PATCH] staging: xgifb: ensure braces on all arms of if stmt
Added braces on else arm of if statement where if arm already has braces as suggested for clarity in Documentation/CodingStyle Signed-off-by: Nicholas Sim --- drivers/staging/xgifb/vb_setmode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index f97c77d..14230c2 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -3450,8 +3450,9 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, if (!(pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))) tempbx >>= 1; - } else + } else { tempbx >>= 1; + } } tempbx -= 2; -- 2.4.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: xgifb: remove extra braces from if stmt (single branch)
Remove braces from one branch of if statement where both branches only have a single line of code, as suggested in Documentation/CodingStyle Signed-off-by: Nicholas Sim --- drivers/staging/xgifb/vb_setmode.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 14230c2..40939c8 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -3840,9 +3840,9 @@ static void XGI_SetLCDRegs(unsigned short ModeIdIndex, if (pVBInfo->VGAVDE == 525) { if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV | VB_SIS302LV - | VB_XGI301C)) { + | VB_XGI301C)) temp = 0xC6; - } else + else temp = 0xC4; xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); @@ -3852,9 +3852,9 @@ static void XGI_SetLCDRegs(unsigned short ModeIdIndex, if (pVBInfo->VGAVDE == 420) { if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV | VB_SIS302LV - | VB_XGI301C)) { + | VB_XGI301C)) temp = 0x4F; - } else + else temp = 0x4E; xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); } -- 2.4.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 5/7] Drivers: hv: vmbus: Export the vmbus_set_event() API
In preparation for moving some ring buffer functionality out of the vmbus driver, export the API for signaling the host. Signed-off-by: K. Y. Srinivasan --- drivers/hv/connection.c |1 + drivers/hv/hyperv_vmbus.h |2 -- include/linux/hyperv.h|1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index d02f137..fcf8a02 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -495,3 +495,4 @@ void vmbus_set_event(struct vmbus_channel *channel) hv_do_hypercall(HVCALL_SIGNAL_EVENT, channel->sig_event, NULL); } +EXPORT_SYMBOL_GPL(vmbus_set_event); diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h index 28e9df9..8cbd630 100644 --- a/drivers/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -678,8 +678,6 @@ void vmbus_disconnect(void); int vmbus_post_msg(void *buffer, size_t buflen); -void vmbus_set_event(struct vmbus_channel *channel); - void vmbus_on_event(unsigned long data); void vmbus_on_msg_dpc(unsigned long data); diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index a6b053c..4adeb6e 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -1365,4 +1365,5 @@ extern __u32 vmbus_proto_version; int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id, const uuid_le *shv_host_servie_id); +void vmbus_set_event(struct vmbus_channel *channel); #endif /* _HYPERV_H */ -- 1.7.4.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 0/7] Drivers: hv: vmbus: Cleanup the ring buffer code
Cleanup and fix a bug in the ring buffer code. Also implement APIs for in place consumption of received packets. K. Y. Srinivasan (7): Drivers: hv: vmbus: Introduce functions for estimating room in the ring buffer Drivers: hv: vmbus: Use READ_ONCE() to read variables that are volatile Drivers: hv: vmbus: Fix a bug in hv_need_to_signal_on_read() Drivers: hv: vmbus: Use the new virt_xx barrier code Drivers: hv: vmbus: Export the vmbus_set_event() API Drivers: hv: vmbus: Move some ring buffer functions to hyperv.h Drivers: hv: vmbus: Implement APIs to support "in place" consumption of vmbus packets drivers/hv/connection.c |1 + drivers/hv/hyperv_vmbus.h |2 - drivers/hv/ring_buffer.c | 79 --- include/linux/hyperv.h| 156 + 4 files changed, 169 insertions(+), 69 deletions(-) -- 1.7.4.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/7] Drivers: hv: vmbus: Move some ring buffer functions to hyperv.h
In preparation for implementing APIs for in-place consumption of VMBUS packets, movve some ring buffer functionality into hyperv.h Signed-off-by: K. Y. Srinivasan --- drivers/hv/ring_buffer.c | 42 -- include/linux/hyperv.h | 42 ++ 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index c2c2b2e..253311b 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -84,40 +84,6 @@ static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi) return false; } -/* - * To optimize the flow management on the send-side, - * when the sender is blocked because of lack of - * sufficient space in the ring buffer, potential the - * consumer of the ring buffer can signal the producer. - * This is controlled by the following parameters: - * - * 1. pending_send_sz: This is the size in bytes that the - *producer is trying to send. - * 2. The feature bit feat_pending_send_sz set to indicate if - *the consumer of the ring will signal when the ring - *state transitions from being full to a state where - *there is room for the producer to send the pending packet. - */ - -static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi) -{ - u32 cur_write_sz; - u32 pending_sz; - - virt_mb(); - pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz); - /* If the other end is not blocked on write don't bother. */ - if (pending_sz == 0) - return false; - - cur_write_sz = hv_get_bytes_to_write(rbi); - - if (cur_write_sz >= pending_sz) - return true; - - return false; -} - /* Get the next write location for the specified ring buffer. */ static inline u32 hv_get_next_write_location(struct hv_ring_buffer_info *ring_info) @@ -169,14 +135,6 @@ hv_set_next_read_location(struct hv_ring_buffer_info *ring_info, } -/* Get the start of the ring buffer. */ -static inline void * -hv_get_ring_buffer(struct hv_ring_buffer_info *ring_info) -{ - return (void *)ring_info->ring_buffer->buffer; -} - - /* Get the size of the ring buffer. */ static inline u32 hv_get_ring_buffersize(struct hv_ring_buffer_info *ring_info) diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 4adeb6e..8fc9b09 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -1366,4 +1366,46 @@ extern __u32 vmbus_proto_version; int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id, const uuid_le *shv_host_servie_id); void vmbus_set_event(struct vmbus_channel *channel); + +/* Get the start of the ring buffer. */ +static inline void * +hv_get_ring_buffer(struct hv_ring_buffer_info *ring_info) +{ + return (void *)ring_info->ring_buffer->buffer; +} + +/* + * To optimize the flow management on the send-side, + * when the sender is blocked because of lack of + * sufficient space in the ring buffer, potential the + * consumer of the ring buffer can signal the producer. + * This is controlled by the following parameters: + * + * 1. pending_send_sz: This is the size in bytes that the + *producer is trying to send. + * 2. The feature bit feat_pending_send_sz set to indicate if + *the consumer of the ring will signal when the ring + *state transitions from being full to a state where + *there is room for the producer to send the pending packet. + */ + +static inline bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi) +{ + u32 cur_write_sz; + u32 pending_sz; + + virt_mb(); + pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz); + /* If the other end is not blocked on write don't bother. */ + if (pending_sz == 0) + return false; + + cur_write_sz = hv_get_bytes_to_write(rbi); + + if (cur_write_sz >= pending_sz) + return true; + + return false; +} + #endif /* _HYPERV_H */ -- 1.7.4.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/7] Drivers: hv: vmbus: Use the new virt_xx barrier code
Use the virt_xx barriers that have been defined for use in virtual machines. Signed-off-by: K. Y. Srinivasan --- drivers/hv/ring_buffer.c | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index 67dc245..c2c2b2e 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -33,14 +33,14 @@ void hv_begin_read(struct hv_ring_buffer_info *rbi) { rbi->ring_buffer->interrupt_mask = 1; - mb(); + virt_mb(); } u32 hv_end_read(struct hv_ring_buffer_info *rbi) { rbi->ring_buffer->interrupt_mask = 0; - mb(); + virt_mb(); /* * Now check to see if the ring buffer is still empty. @@ -68,12 +68,12 @@ u32 hv_end_read(struct hv_ring_buffer_info *rbi) static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi) { - mb(); + virt_mb(); if (READ_ONCE(rbi->ring_buffer->interrupt_mask)) return false; /* check interrupt_mask before read_index */ - rmb(); + virt_rmb(); /* * This is the only case we need to signal when the * ring transitions from being empty to non-empty. @@ -104,7 +104,7 @@ static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi) u32 cur_write_sz; u32 pending_sz; - mb(); + virt_mb(); pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz); /* If the other end is not blocked on write don't bother. */ if (pending_sz == 0) @@ -359,7 +359,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info, sizeof(u64)); /* Issue a full memory barrier before updating the write index */ - mb(); + virt_mb(); /* Now, update the write location */ hv_set_next_write_location(outring_info, next_write_location); @@ -435,7 +435,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, * the writer may start writing to the read area once the read index * is updated. */ - mb(); + virt_mb(); /* Update the read index */ hv_set_next_read_location(inring_info, next_read_location); -- 1.7.4.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/7] Drivers: hv: vmbus: Use READ_ONCE() to read variables that are volatile
Use the READ_ONCE macro to access variabes that can change asynchronously. Signed-off-by: K. Y. Srinivasan --- drivers/hv/ring_buffer.c |7 --- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index 902375b..2919395 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -69,7 +69,7 @@ u32 hv_end_read(struct hv_ring_buffer_info *rbi) static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi) { mb(); - if (rbi->ring_buffer->interrupt_mask) + if (READ_ONCE(rbi->ring_buffer->interrupt_mask)) return false; /* check interrupt_mask before read_index */ @@ -78,7 +78,7 @@ static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi) * This is the only case we need to signal when the * ring transitions from being empty to non-empty. */ - if (old_write == rbi->ring_buffer->read_index) + if (old_write == READ_ONCE(rbi->ring_buffer->read_index)) return true; return false; @@ -102,8 +102,9 @@ static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi) static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi) { u32 cur_write_sz; - u32 pending_sz = rbi->ring_buffer->pending_send_sz; + u32 pending_sz; + pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz); /* If the other end is not blocked on write don't bother. */ if (pending_sz == 0) return false; -- 1.7.4.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 7/7] Drivers: hv: vmbus: Implement APIs to support "in place" consumption of vmbus packets
Implement APIs for in-place consumption of vmbus packets. Currently, each packet is copied and processed one at a time and as part of processing each packet we potentially may signal the host (if it is waiting for room to produce a packet). These APIs help batched in-place processing of vmbus packets. We also optimize host signaling by having a separate API to signal the end of in-place consumption. With netvsc using these APIs, on an iperf run on average I see about 20X reduction in checks to signal the host. Signed-off-by: K. Y. Srinivasan --- drivers/hv/ring_buffer.c |1 + include/linux/hyperv.h | 86 ++ 2 files changed, 87 insertions(+), 0 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index 253311b..a2a38ab 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -132,6 +132,7 @@ hv_set_next_read_location(struct hv_ring_buffer_info *ring_info, u32 next_read_location) { ring_info->ring_buffer->read_index = next_read_location; + ring_info->priv_read_index = next_read_location; } diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 8fc9b09..3fadbaf 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -126,6 +126,8 @@ struct hv_ring_buffer_info { u32 ring_datasize; /* < ring_size */ u32 ring_data_startoffset; + u32 priv_write_index; + u32 priv_read_index; }; /* @@ -1408,4 +1410,88 @@ static inline bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi) return false; } +/* + * An API to support in-place processing of incoming VMBUS packets. + */ +#define VMBUS_PKT_TRAILER 8 + +static inline struct vmpacket_descriptor * +get_next_pkt_raw(struct vmbus_channel *channel) +{ + struct hv_ring_buffer_info *ring_info = &channel->inbound; + u32 read_loc = ring_info->priv_read_index; + void *ring_buffer = hv_get_ring_buffer(ring_info); + struct vmpacket_descriptor *cur_desc; + u32 packetlen; + u32 dsize = ring_info->ring_datasize; + u32 delta = read_loc - ring_info->ring_buffer->read_index; + u32 bytes_avail_toread = (hv_get_bytes_to_read(ring_info) - delta); + + if (bytes_avail_toread < sizeof(struct vmpacket_descriptor)) + return NULL; + + if ((read_loc + sizeof(*cur_desc)) > dsize) + return NULL; + + cur_desc = ring_buffer + read_loc; + packetlen = cur_desc->len8 << 3; + + /* +* If the packet under consideration is wrapping around, +* return failure. +*/ + if ((read_loc + packetlen + VMBUS_PKT_TRAILER) > (dsize - 1)) + return NULL; + + return cur_desc; +} + +/* + * A helper function to step through packets "in-place" + * This API is to be called after each successful call + * get_next_pkt_raw(). + */ +static inline void put_pkt_raw(struct vmbus_channel *channel, + struct vmpacket_descriptor *desc) +{ + struct hv_ring_buffer_info *ring_info = &channel->inbound; + u32 read_loc = ring_info->priv_read_index; + u32 packetlen = desc->len8 << 3; + u32 dsize = ring_info->ring_datasize; + + if ((read_loc + packetlen + VMBUS_PKT_TRAILER) > dsize) + BUG(); + /* +* Include the packet trailer. +*/ + ring_info->priv_read_index += packetlen + VMBUS_PKT_TRAILER; +} + +/* + * This call commits the read index and potentially signals the host. + * Here is the pattern for using the "in-place" consumption APIs: + * + * while (get_next_pkt_raw() { + * process the packet "in-place"; + * put_pkt_raw(); + * } + * if (packets processed in place) + * commit_rd_index(); + */ +static inline void commit_rd_index(struct vmbus_channel *channel) +{ + struct hv_ring_buffer_info *ring_info = &channel->inbound; + /* +* Make sure all reads are done before we update the read index since +* the writer may start writing to the read area once the read index +* is updated. +*/ + virt_rmb(); + ring_info->ring_buffer->read_index = ring_info->priv_read_index; + + if (hv_need_to_signal_on_read(ring_info)) + vmbus_set_event(channel); +} + + #endif /* _HYPERV_H */ -- 1.7.4.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/7] Drivers: hv: vmbus: Fix a bug in hv_need_to_signal_on_read()
We need to issue a full memory barrier prior making a signalling decision. Signed-off-by: K. Y. Srinivasan Cc: sta...@vger.kernel.org --- drivers/hv/ring_buffer.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index 2919395..67dc245 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -104,6 +104,7 @@ static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi) u32 cur_write_sz; u32 pending_sz; + mb(); pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz); /* If the other end is not blocked on write don't bother. */ if (pending_sz == 0) -- 1.7.4.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/7] Drivers: hv: vmbus: Introduce functions for estimating room in the ring buffer
Introduce separate functions for estimating how much can be read from and written to the ring buffer. Signed-off-by: K. Y. Srinivasan --- drivers/hv/ring_buffer.c | 24 include/linux/hyperv.h | 27 +++ 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index 085003a..902375b 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -38,8 +38,6 @@ void hv_begin_read(struct hv_ring_buffer_info *rbi) u32 hv_end_read(struct hv_ring_buffer_info *rbi) { - u32 read; - u32 write; rbi->ring_buffer->interrupt_mask = 0; mb(); @@ -49,9 +47,7 @@ u32 hv_end_read(struct hv_ring_buffer_info *rbi) * If it is not, we raced and we need to process new * incoming messages. */ - hv_get_ringbuffer_availbytes(rbi, &read, &write); - - return read; + return hv_get_bytes_to_read(rbi); } /* @@ -106,18 +102,13 @@ static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi) static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi) { u32 cur_write_sz; - u32 r_size; - u32 write_loc = rbi->ring_buffer->write_index; - u32 read_loc = rbi->ring_buffer->read_index; u32 pending_sz = rbi->ring_buffer->pending_send_sz; /* If the other end is not blocked on write don't bother. */ if (pending_sz == 0) return false; - r_size = rbi->ring_datasize; - cur_write_sz = write_loc >= read_loc ? r_size - (write_loc - read_loc) : - read_loc - write_loc; + cur_write_sz = hv_get_bytes_to_write(rbi); if (cur_write_sz >= pending_sz) return true; @@ -317,7 +308,6 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info, { int i = 0; u32 bytes_avail_towrite; - u32 bytes_avail_toread; u32 totalbytes_towrite = 0; u32 next_write_location; @@ -333,9 +323,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info, if (lock) spin_lock_irqsave(&outring_info->ring_lock, flags); - hv_get_ringbuffer_availbytes(outring_info, - &bytes_avail_toread, - &bytes_avail_towrite); + bytes_avail_towrite = hv_get_bytes_to_write(outring_info); /* * If there is only room for the packet, assume it is full. @@ -386,7 +374,6 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer, u32 buflen, u32 *buffer_actual_len, u64 *requestid, bool *signal, bool raw) { - u32 bytes_avail_towrite; u32 bytes_avail_toread; u32 next_read_location = 0; u64 prev_indices = 0; @@ -402,10 +389,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, *buffer_actual_len = 0; *requestid = 0; - hv_get_ringbuffer_availbytes(inring_info, - &bytes_avail_toread, - &bytes_avail_towrite); - + bytes_avail_toread = hv_get_bytes_to_read(inring_info); /* Make sure there is something to read */ if (bytes_avail_toread < sizeof(desc)) { /* diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index ecd81c3..a6b053c 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -151,6 +151,33 @@ hv_get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi, *read = dsize - *write; } +static inline u32 hv_get_bytes_to_read(struct hv_ring_buffer_info *rbi) +{ + u32 read_loc, write_loc, dsize, read; + + dsize = rbi->ring_datasize; + read_loc = rbi->ring_buffer->read_index; + write_loc = READ_ONCE(rbi->ring_buffer->write_index); + + read = write_loc >= read_loc ? (write_loc - read_loc) : + (dsize - read_loc) + write_loc; + + return read; +} + +static inline u32 hv_get_bytes_to_write(struct hv_ring_buffer_info *rbi) +{ + u32 read_loc, write_loc, dsize, write; + + dsize = rbi->ring_datasize; + read_loc = READ_ONCE(rbi->ring_buffer->read_index); + write_loc = rbi->ring_buffer->write_index; + + write = write_loc >= read_loc ? dsize - (write_loc - read_loc) : + read_loc - write_loc; + return write; +} + /* * VMBUS version is 32 bit entity broken up into * two 16 bit quantities: major_number. minor_number. -- 1.7.4.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH net-next] hv_netvsc: Fix the order of num_sc_offered decrement
From: Haiyang Zhang Date: Wed, 23 Mar 2016 14:54:48 -0700 > Reorder the code in netvsc_sc_open(), so num_sc_offered is only decremented > after vmbus_open() is called. This avoid pontential race of removing device > before all channels are setup. > > Signed-off-by: Haiyang Zhang > Reviewed-by: K. Y. Srinivasan Applied, thanks. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RESEND 2/5] staging: unisys: visorbus: replaced vague variable name in zoneguid_show
From: Alexander Curtin The variable name "s" doesn't indicate the purpose of the string, which is to store the id collected from the visorchannel_zoneid function. This just replaces the name with "zoneid". Signed-off-by: Alexander Curtin Signed-off-by: David Kershner --- drivers/staging/unisys/visorbus/visorbus_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index af5add5..41a6d3a 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -291,12 +291,12 @@ static ssize_t zoneguid_show(struct device *dev, struct device_attribute *attr, char *buf) { struct visor_device *vdev = to_visor_device(dev); - char s[99]; + char zoneid[99]; if (!vdev->visorchannel) return 0; return snprintf(buf, PAGE_SIZE, "%s\n", - visorchannel_zoneid(vdev->visorchannel, s)); + visorchannel_zoneid(vdev->visorchannel, zoneid)); } static ssize_t typename_show(struct device *dev, struct device_attribute *attr, -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RESEND 4/5] staging: unisys: visorbus: replaced use of vague 'x' variable
From: Alexander Curtin In client_bus_info_show, the variable 'x' is used to create keep track of the offset that the current 'pos' in the output buffer needs to be incremented by. Since 'off' is already taken 'shift' was used since it's used to shift the pointer. Signed-off-by: Alexander Curtin Signed-off-by: David Kershner --- drivers/staging/unisys/visorbus/visorbus_main.c | 65 + 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 33407a7..1fcb177 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -420,7 +420,7 @@ static ssize_t client_bus_info_show(struct device *dev, struct visor_device *vdev = to_visor_device(dev); struct visorchannel *channel = vdev->visorchannel; - int i, x, remain = PAGE_SIZE; + int i, shift, remain = PAGE_SIZE; unsigned long off; char *pos = buf; u8 *partition_name; @@ -430,44 +430,45 @@ static ssize_t client_bus_info_show(struct device *dev, if (channel) { if (vdev->name) partition_name = vdev->name; - x = snprintf(pos, remain, -"Client device / client driver info for %s partition (vbus #%d):\n", -partition_name, vdev->chipset_dev_no); - pos += x; - remain -= x; - x = visorchannel_read(channel, - offsetof(struct - spar_vbus_channel_protocol, - chp_info), - &dev_info, sizeof(dev_info)); - if (x >= 0) { - x = vbuschannel_devinfo_to_string(&dev_info, pos, - remain, -1); - pos += x; - remain -= x; + shift = snprintf(pos, remain, +"Client device / client driver info for %s eartition (vbus #%d):\n", +partition_name, vdev->chipset_dev_no); + pos += shift; + remain -= shift; + shift = visorchannel_read(channel, + offsetof(struct + spar_vbus_channel_protocol, + chp_info), + &dev_info, sizeof(dev_info)); + if (shift >= 0) { + shift = vbuschannel_devinfo_to_string(&dev_info, pos, + remain, -1); + pos += shift; + remain -= shift; } - x = visorchannel_read(channel, - offsetof(struct - spar_vbus_channel_protocol, - bus_info), - &dev_info, sizeof(dev_info)); - if (x >= 0) { - x = vbuschannel_devinfo_to_string(&dev_info, pos, - remain, -1); - pos += x; - remain -= x; + shift = visorchannel_read(channel, + offsetof(struct + spar_vbus_channel_protocol, + bus_info), + &dev_info, sizeof(dev_info)); + if (shift >= 0) { + shift = vbuschannel_devinfo_to_string(&dev_info, pos, + remain, -1); + pos += shift; + remain -= shift; } off = offsetof(struct spar_vbus_channel_protocol, dev_info); i = 0; while (off + sizeof(dev_info) <= visorchannel_get_nbytes(channel)) { - x = visorchannel_read(channel, - off, &dev_info, sizeof(dev_info)); - if (x >= 0) { - x = vbuschannel_devinfo_to_string + shift = visorchannel_read(channel, + off, &dev_info, + sizeof(dev_info)); + if (shift >= 0) { + shift = vbuschannel_devinfo_to_string (&dev_info, pos, remain, i); - pos += x; -
[PATCH RESEND 3/5] staging: unisys: visorbus: replaced vague 'p' variable with 'pos'
From: Alexander Curtin In the case of client_bus_info_show, the variable 'p' was used to indicate the position in the output buffer. This was changed to 'pos' to indicate that it kept track of the current position in the output buffer. Signed-off-by: Alexander Curtin Signed-off-by: David Kershner --- drivers/staging/unisys/visorbus/visorbus_main.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 41a6d3a..33407a7 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -422,7 +422,7 @@ static ssize_t client_bus_info_show(struct device *dev, int i, x, remain = PAGE_SIZE; unsigned long off; - char *p = buf; + char *pos = buf; u8 *partition_name; struct ultra_vbus_deviceinfo dev_info; @@ -430,10 +430,10 @@ static ssize_t client_bus_info_show(struct device *dev, if (channel) { if (vdev->name) partition_name = vdev->name; - x = snprintf(p, remain, + x = snprintf(pos, remain, "Client device / client driver info for %s partition (vbus #%d):\n", partition_name, vdev->chipset_dev_no); - p += x; + pos += x; remain -= x; x = visorchannel_read(channel, offsetof(struct @@ -441,9 +441,9 @@ static ssize_t client_bus_info_show(struct device *dev, chp_info), &dev_info, sizeof(dev_info)); if (x >= 0) { - x = vbuschannel_devinfo_to_string(&dev_info, p, + x = vbuschannel_devinfo_to_string(&dev_info, pos, remain, -1); - p += x; + pos += x; remain -= x; } x = visorchannel_read(channel, @@ -452,9 +452,9 @@ static ssize_t client_bus_info_show(struct device *dev, bus_info), &dev_info, sizeof(dev_info)); if (x >= 0) { - x = vbuschannel_devinfo_to_string(&dev_info, p, + x = vbuschannel_devinfo_to_string(&dev_info, pos, remain, -1); - p += x; + pos += x; remain -= x; } off = offsetof(struct spar_vbus_channel_protocol, dev_info); @@ -465,8 +465,8 @@ static ssize_t client_bus_info_show(struct device *dev, off, &dev_info, sizeof(dev_info)); if (x >= 0) { x = vbuschannel_devinfo_to_string - (&dev_info, p, remain, i); - p += x; + (&dev_info, pos, remain, i); + pos += x; remain -= x; } off += sizeof(dev_info); -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RESEND 0/5] staging: unisys: Replace vague variable names
Replaced vague variable names with more meaningful ones in several different areas. Resent due to distribution list being wrong. Alexander Curtin (5): staging: unisys: visorbus: replaced vague variable name in typeguid_show staging: unisys: visorbus: replaced vague variable name in zoneguid_show staging: unisys: visorbus: replaced vague 'p' variable with 'pos' staging: unisys: visorbus: replaced use of vague 'x' variable staging: unisys: include: changed 'v' variable to 'state' drivers/staging/unisys/include/channel.h| 4 +- drivers/staging/unisys/visorbus/visorbus_main.c | 77 + 2 files changed, 41 insertions(+), 40 deletions(-) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RESEND 1/5] staging: unisys: visorbus: replaced vague variable name in typeguid_show
From: Alexander Curtin The variable name "s" doesn't indicate the purpose of the string, which is to store the id collected from the visorchannel_id function. This just replaces the name with "typeid". Signed-off-by: Alexander Curtin Signed-off-by: David Kershner --- drivers/staging/unisys/visorbus/visorbus_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 54d77dd..af5add5 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -279,12 +279,12 @@ static ssize_t typeguid_show(struct device *dev, struct device_attribute *attr, char *buf) { struct visor_device *vdev = to_visor_device(dev); - char s[99]; + char typeid[99]; if (!vdev->visorchannel) return 0; return snprintf(buf, PAGE_SIZE, "%s\n", - visorchannel_id(vdev->visorchannel, s)); + visorchannel_id(vdev->visorchannel, typeid)); } static ssize_t zoneguid_show(struct device *dev, struct device_attribute *attr, -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RESEND 5/5] staging: unisys: include: changed 'v' variable to 'state'
From: Alexander Curtin The argument for ULTRA_CHANNELCLI_STRING is supposed to be an integer representing the channel state. 'state' is a more descriptive variable name for this. Signed-off-by: Alexander Curtin Signed-off-by: David Kershner --- drivers/staging/unisys/include/channel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/include/channel.h b/drivers/staging/unisys/include/channel.h index 5af59a5..3829d4b 100644 --- a/drivers/staging/unisys/include/channel.h +++ b/drivers/staging/unisys/include/channel.h @@ -76,9 +76,9 @@ enum channel_clientstate { }; static inline const u8 * -ULTRA_CHANNELCLI_STRING(u32 v) +ULTRA_CHANNELCLI_STRING(u32 state) { - switch (v) { + switch (state) { case CHANNELCLI_DETACHED: return (const u8 *)("DETACHED"); case CHANNELCLI_DISABLED: -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/2] staging: dgnc: fix CamelCase in dgnc_drvier.h and
fix checkpatch.pl warning about CamelCase Signed-off-by: Daeseok Youn --- drivers/staging/dgnc/dgnc_driver.h | 12 ++-- drivers/staging/dgnc/dgnc_tty.c| 32 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index f3d00df..3d8e15f 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -203,15 +203,15 @@ struct dgnc_board { */ struct tty_driver serial_driver; - charSerialName[200]; + charserial_name[200]; struct tty_driver print_driver; - charPrintName[200]; + charprint_name[200]; - booldgnc_Major_Serial_Registered; - booldgnc_Major_TransparentPrint_Registered; + booldgnc_major_serial_registered; + booldgnc_major_transparent_print_registered; - uintdgnc_Serial_Major; - uintdgnc_TransparentPrint_Major; + uintdgnc_serial_major; + uintdgnc_transparent_print_major; uintTtyRefCnt; diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index 081ac75..98b88d1 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -180,9 +180,9 @@ int dgnc_tty_register(struct dgnc_board *brd) brd->serial_driver.magic = TTY_DRIVER_MAGIC; - snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgnc_%d_", brd->boardnum); + snprintf(brd->serial_name, MAXTTYNAMELEN, "tty_dgnc_%d_", brd->boardnum); - brd->serial_driver.name = brd->SerialName; + brd->serial_driver.name = brd->serial_name; brd->serial_driver.name_base = 0; brd->serial_driver.major = 0; brd->serial_driver.minor_start = 0; @@ -218,7 +218,7 @@ int dgnc_tty_register(struct dgnc_board *brd) */ tty_set_operations(&brd->serial_driver, &dgnc_tty_ops); - if (!brd->dgnc_Major_Serial_Registered) { + if (!brd->dgnc_major_serial_registered) { /* Register tty devices */ rc = tty_register_driver(&brd->serial_driver); if (rc < 0) { @@ -226,7 +226,7 @@ int dgnc_tty_register(struct dgnc_board *brd) "Can't register tty device (%d)\n", rc); return rc; } - brd->dgnc_Major_Serial_Registered = true; + brd->dgnc_major_serial_registered = true; } /* @@ -235,9 +235,9 @@ int dgnc_tty_register(struct dgnc_board *brd) * we are when we get into the dgnc_tty_open() routine. */ brd->print_driver.magic = TTY_DRIVER_MAGIC; - snprintf(brd->PrintName, MAXTTYNAMELEN, "pr_dgnc_%d_", brd->boardnum); + snprintf(brd->print_name, MAXTTYNAMELEN, "pr_dgnc_%d_", brd->boardnum); - brd->print_driver.name = brd->PrintName; + brd->print_driver.name = brd->print_name; brd->print_driver.name_base = 0; brd->print_driver.major = brd->serial_driver.major; brd->print_driver.minor_start = 0x80; @@ -273,7 +273,7 @@ int dgnc_tty_register(struct dgnc_board *brd) */ tty_set_operations(&brd->print_driver, &dgnc_tty_ops); - if (!brd->dgnc_Major_TransparentPrint_Registered) { + if (!brd->dgnc_major_transparent_print_registered) { /* Register Transparent Print devices */ rc = tty_register_driver(&brd->print_driver); if (rc < 0) { @@ -282,12 +282,12 @@ int dgnc_tty_register(struct dgnc_board *brd) rc); return rc; } - brd->dgnc_Major_TransparentPrint_Registered = true; + brd->dgnc_major_transparent_print_registered = true; } dgnc_BoardsByMajor[brd->serial_driver.major] = brd; - brd->dgnc_Serial_Major = brd->serial_driver.major; - brd->dgnc_TransparentPrint_Major = brd->print_driver.major; + brd->dgnc_serial_major = brd->serial_driver.major; + brd->dgnc_transparent_print_major = brd->print_driver.major; return rc; } @@ -407,9 +407,9 @@ void dgnc_tty_uninit(struct dgnc_board *brd) { int i = 0; - if (brd->dgnc_Major_Serial_Registered) { + if (brd->dgnc_major_serial_registered) { dgnc_BoardsByMajor[brd->serial_driver.major] = NULL; - brd->dgnc_Serial_Major = 0; + brd->dgnc_serial_major = 0; for (i = 0; i < brd->nasync; i++) { if (brd->channels[i]) dgnc_remove_tty_sysfs(brd->channels[i]-> @@ -417,12 +417,12 @@ void dgnc_tty_uninit(struct dgnc_board *brd) tty_unregister_device(&brd->serial_driver, i);
[PATCH 2/2] staging: dgnc: remove unused variable in dgnc_board
TtyRefCnt was not used anywhere in dgnc. Signed-off-by: Daeseok Youn --- drivers/staging/dgnc/dgnc_driver.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index 3d8e15f..44216ae 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -213,8 +213,6 @@ struct dgnc_board { uintdgnc_serial_major; uintdgnc_transparent_print_major; - uintTtyRefCnt; - u16 dpatype;/* The board "type", * as defined by DPA */ -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel