Commit graph

8848 commits

Author SHA1 Message Date
Spencer E. Olson
a0c5e84600 staging: comedi: ni_660x: clean up pfi routing
Cleans up the pfi routing code to make it easier to follow, read, and also
to prepare to use this cleaned up code for enabling the device-global
routing interface for ni_660x devices.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:36:05 +02:00
Spencer E. Olson
51c4ba6407 staging: comedi: ni_660x: Add NI PCI-6608 to list of supported devices
Previously, only the PXI version of the NI-6608 board was supported.  This
change adds support for the PCI version as well.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:36:05 +02:00
Spencer E. Olson
713ebc5939 staging: comedi: ni_mio_common: create device-global access to tio
Adds tio sub-devices of ni_mio_common supported hardware to the
implementation of test_route, connect_route, disconnect_route.  This change
delegates the actual functionality to the ni_tio module.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:36:05 +02:00
Spencer E. Olson
347e244884 staging: comedi: tio: implement global tio/ctr routing
Adds ability to use device-global names in command args, in particular
cmd->start_arg (for NI_CtrArmStartTrigger), and cmd->scan_begin_arg or
cmd->convert_arg (either is used to specify NI_CtrGate, with preference
given to cmd->scan_begin_arg, if it is set).

The actual arguments of cmd->start_arg are not fully checked against known
register values for the particular devices because these are not documented
or currently known.  This follows the precedence of prior versions of the
tio driver.  Should these become known, they should be annotated in the
route_values tables and the set of lines in ni_tio_cmdtest should be
uncommented to allow the tests to be made.

This patch also adds interface functions that allow routes for particular
counter route destinations to be made/queried/unmade.  This allows overseer
modules to implement test_route, connect_route, and disconnect_route.  As a
part of these changes, various functions were cleaned up and clarified.

These new interface functions allow direct writing/reading of register
values.  This is an example of exactly what the new device-global access
was intended to solve:  the old interface was not consistent with other
portions of the ni_* drivers--it did not allow full register values to be
given for various MUXes.  Instead, the old interface _did_ abstract away
some of the actual hardware from the underlying devices, but it was not
consistent with any other NI hardware.  Allowing the device-global
identifiers to be used, the new patch provides for consistency across all
ni_* drivers.  One final note:  these changes provide for backwards
compatibility by allowing the older values to still be used in through the
pre-existing kernel interfaces--though not in the new device-global
test/dis/connect/route interfaces.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:36:05 +02:00
Spencer E. Olson
02d1c6e827 staging: comedi: ni_mio_common: implement output selection of GPFO_{0, 1}
Implement the ability to route various signals to NI_CtrOut(x) pin.  This
pin is also known as GPFO_{0,1} in the DAQ STC.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:36:04 +02:00
Spencer E. Olson
d4961bb3d9 staging: comedi: ni_mio_common: implement global pfi, rtsi routing
Implement device-global config interface for ni_mio devices.  In
particular, this patch implements:
INSN_DEVICE_CONFIG_TEST_ROUTE,
INSN_DEVICE_CONFIG_CONNECT_ROUTE,
INSN_DEVICE_CONFIG_DISCONNECT_ROUTE,
INSN_DEVICE_CONFIG_GET_ROUTES
for the ni mio devices.  This means that the new abstracted signal/terminal
names can be used to define signal routing with regards to the PFI
terminals and RTSI trigger bus lines.

This also adds ability to identify PFI and RTSI channels on the PFI and
RTSI subdevices using the new device-global names.  This does not change
the values that are set for channel output selections using the subdevice
interfaces--these still require direct register values.

Annotates and updates tables of register values to reflect this new
implementation status.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:36:04 +02:00
Spencer E. Olson
56d0b826d3 staging: comedi: ni_mio_common: implement new routing for TRIG_EXT
Use new signal routing capability for all comedi command *_src == TRIG_EXT
options.  This new interface allows the user specify signals and terminals
as TRIG_EXT sources using a very consistent naming convention. Furthermore,
the interface allows backwards compatibility to prior behavior of
specifying register-level (or near register-level) values as *_arg options
when *_src == TRIG_EXT.

Annotates and updates tables of register values to reflect this new
implementation status.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:36:04 +02:00
Spencer E. Olson
4bb90c87ab staging: comedi: add interface to ni routing table information
Adds interface and associated unittests for accessing/looking-up/validating
the new ni routing table information.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:36:04 +02:00
Spencer E. Olson
ba932fcfee staging: comedi: ni_routing: Add NI signal routing info
See README for a thorough discussion of this content.

Adds tables of all register values for routing various signals to various
terminals on National Instruments hardware.  This information is directly
compared to and taken from register-level programming documentation and/or
register-level programming examples as provided by National Instruments.

Furthermore, this information was mostly compared (favorably) to the
register values already used in the comedi drivers for NI hardware.

Adds tables of valid routes for many devices.  This information is not
consistent from device to device, nor entirely consistent within device
families.  One additional major challenge is that this information does not
seem to be obtainable in any programmatic fashion, neither through the
proprietary NIDAQmx(-base) c-libraries, nor with register level
programming, _nor_ through any documentation.  In fact, the only consistent
source of this information is through the proprietary NI-MAX software,
which currently only runs on Windows platforms.  A further challenge is
that this information cannot be exported from NI-MAX, except by screenshot.

The collection and maintenance of this information is somewhat tedious and
requires frequent re-examination and comparison of NI-MAX and/or the
NI-MHDDK documentation (register programming information) and NI-MHDDK
examples.  Tools are added with this patch to facilitate generating CSV
files from the data tables.  These CSV files can be used with a spreadsheet
program to provide better visual comparision with screenshots gathered from
NI-MAX.  Tools are also added to regenerate the data tables from CSV
content--this greatly enhances updating data tables with large changes
(such as when adding devices).

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:34:51 +02:00
Spencer E. Olson
d7569ad766 staging: comedi: add new device-global config interface
Adds interface for configuring options that are global to all sub-devices.
For now, only options to configure device-globally identified signal routes
have been defined.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:32:38 +02:00
Spencer E. Olson
5912827dfe staging: comedi: add abstracted NI signal/terminal named constants
This change adds abstracted constants for National Instruments
terminal/signal names.

Some background:
  There have been significant confusions over the past many years for users
  when trying to understand how to connect to/from signals and terminals on
  NI hardware using comedi.  The major reason for this is that the actual
  register values were exposed and required to be used by users.  Several
  major reasons exist why this caused major confusion for users:

  1) The register values are _NOT_ in user documentation, but rather in
    arcane locations, such as a few register programming manuals that are
    increasingly hard to find and the NI-MHDDK (comments in in example
    code).  There is no one place to find the various valid values of the
    registers.

  2) The register values are _NOT_ completely consistent.  There is no way
    to gain any sense of intuition of which values, or even enums one
    should use for various registers.  There was some attempt in prior use
    of comedi to name enums such that a user might know which enums should
    be used for varying purposes, but the end-user had to gain a knowledge
    of register values to correctly wield this approach.

  3) The names for signals and registers found in the various register
    level programming manuals and vendor-provided documentation are _not_
    even close to the same names that are in the end-user documentation.

Similar confusion, albeit less, plagued NI's previous version of their own
proprietary drivers.  Earlier than 2003, NI greatly simplified the
situation for users by releasing a new API that abstracted the names of
signals/terminals to a common and intuitive set of names.  In addition,
this new API provided a much more common interface to use for most of NI
hardware.

The names added here mirror the names chosen and well documented by NI.
These names are exposed to the user via the comedilib user library.  By
keeping the names in this format, in spite of the use of CamelScript,
maintenance will be greatly eased and confusion for users _and_ comedi
developers will be greatly reduced.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:32:07 +02:00
Spencer E. Olson
040e9e4dfa staging: comedi: tests: add unittest framework for comedi
Adds a framework for unittests for comedi drivers.  It was certainly
possible to write some unit tests before and test various aspects of a
particular driver, but this framework makes this a bit easier and hopefully
inspires more unittest modules to be written.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:32:06 +02:00
Spencer E. Olson
e0b2ca8979 staging: comedi: comedi_test: implement INSN_CONFIG_GET_CMD_TIMING_CONSTRAINTS
Adds implementation of the new INSN_CONFIG_GET_CMD_TIMING_CONSTRAINTS
instruction.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:27:47 +02:00
Spencer E. Olson
3ad53c4090 staging: comedi: ni_pcidio: implement INSN_CONFIG_GET_CMD_TIMING_CONSTRAINTS
Adds implementation of the new INSN_CONFIG_GET_CMD_TIMING_CONSTRAINTS
instruction.  This patch also adds data for this implementation, based on
spec sheets from NI.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:27:47 +02:00
Spencer E. Olson
51fd367383 staging: comedi: ni_mio_common: implement INSN_CONFIG_GET_CMD_TIMING_CONSTRAINTS
Adds implementation of the new INSN_CONFIG_GET_CMD_TIMING_CONSTRAINTS
instruction.  This patch also adds data for digital subdevices that are
streaming capable (within the ni_mio_* family).  Mostly, only the m-series
devices are capable of digital streaming.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:27:47 +02:00
Spencer E. Olson
832f33366c staging: comedi: add facility to directly query subdevice timing constraints
Adds facility to directly query the hardware speed limits of subdevices,
in particular for scan_begin and convert signals.  This information can be
critical for integrating comedi with other hardware modules, and also
comedi modules together with software where software requires specific
timing capabilities in order to properly coordinate multiple devices.

Currently, comedi_command_test almost satisfies this need, but really only
for when *_src == TRIG_TIMER.  For *_src == TRIG_EXT, comedi_command_test
does not help at all.  For many subdevices, one might simply use
*_src==TRIG_TIMER in command_test in order to determine these limits.  For
other subdevices, this tactic does not work since *_src == TRIG_TIMER might
not be valid.  There is also the possibility that the timing limits are
different between the TRIG_TIMER and TRIG_EXT modes.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:27:47 +02:00
Spencer E. Olson
1cbca5852d staging: comedi: ni_mio_common: protect register write overflow
Fixes two problems introduced as early as
commit 03aef4b6dc  ("Staging: comedi: add ni_mio_common code"):
(1) Ensures that the last four bits of NISTC_RTSI_TRIGB_OUT_REG register is
    not unduly overwritten on e-series devices.  On e-series devices, the
    first three of the last four bits are reserved.  The last bit defines
    the output selection of the RGOUT0 pin, otherwise known as
    RTSI_Sub_Selection.  For m-series devices, these last four bits are
    indeed used as the output selection of the RTSI7 pin (and the
    RTSI_Sub_Selection bit for the RGOUT0 pin is moved to the
    RTSI_Trig_Direction register.
(2) Allows all 4 RTSI_BRD lines to be treated as valid sources for RTSI
    lines.

This patch also cleans up the ni_get_rtsi_routing command for readability.

Fixes: 03aef4b6dc  ("Staging: comedi: add ni_mio_common code")
Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09 15:23:16 +02:00
Ian Abbott
e083926b3e staging: comedi: ni_mio_common: fix subdevice flags for PFI subdevice
The PFI subdevice flags indicate that the subdevice is readable and
writeable, but that is only true for the supported "M-series" boards,
not the older "E-series" boards.  Only set the SDF_READABLE and
SDF_WRITABLE subdevice flags for the M-series boards.  These two flags
are mainly for informational purposes.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-08-08 14:11:19 +02:00
Greg Kroah-Hartman
500cc548c8 staging: comedi: drop serial2002 driver
There's not been any work on this driver since it was originally merged,
and it really needs to be rewritten to use the serdev layer instead if
people really need/want it.

Reported-by: Christoph Hellwig <hch@lst.de>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-08-01 19:56:17 +02:00
Nishad Kamdar
642e0692be staging: comedi: comedi_fops: Shift assignment operator '=' to previous line
Shift '=' assignment operator to the end of previous
line to conform to preferred kernel style line wrapping.
Issue reported by checkpatch CHECK.

Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-16 11:47:12 +02:00
Colin Ian King
c833223652 staging: comedi: remove redundant variable segpos
Variable segpos is being assigned but is never used hence it is redundant
and can be removed.

Cleans up clang warning:
warning: variable 'segpos' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-11 13:12:34 +02:00
Greg Kroah-Hartman
7f5d8f7116 Merge 4.18-rc3 into staging-next
We want the staging/iio fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-02 08:21:54 +02:00
Dan Carpenter
1376b0a216 staging: comedi: quatech_daqp_cs: fix no-op loop daqp_ao_insn_write()
There is a '>' vs '<' typo so this loop is a no-op.

Fixes: d35dcc89fc ("staging: comedi: quatech_daqp_cs: fix daqp_ao_insn_write()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-25 22:54:04 +08:00
ankit patel
6557dd4936 Staging: comedi: comedi_compat32.h: fixed missing or malformed SPDX-License-Identifier
Fixed SPDX-License-Identifier comment on first line

Signed-off-by: ankit patel <ankit.mayurbhai.patel@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-18 10:55:11 +02:00
ankit patel
aa4c8dc649 Staging: comedi: comedi_pci.h: fixed missing or malformed SPDX-License-Identifier
Fixed SPDX-License-Identifier comment on first line

Signed-off-by: ankit patel <ankit.mayurbhai.patel@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-18 10:55:11 +02:00
ankit patel
46c851a928 Staging: comedi: comedi_pcmcia.h: fixed missing or malformed SPDX-License-Identifier
Fixed SPDX-License-Identifier comment on first line

Signed-off-by: ankit patel <ankit.mayurbhai.patel@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-18 10:55:11 +02:00
ankit patel
be932c686b Staging: comedi: comedilib.h: fixed missing or malformed SPDX-License-Identifier
Fixed SPDX-License-Identifier comment on first line

Signed-off-by: ankit patel <ankit.mayurbhai.patel@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-18 10:55:11 +02:00
ankit patel
50b1cf85b1 Staging: comedi: comedi.h: fixed missing or malformed SPDX-License-Identifier
Fixed SPDX-License-Identifier comment on first line

Signed-off-by: ankit patel <ankit.mayurbhai.patel@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-18 10:55:11 +02:00
Chris Opperman
2665df5101 staging: comedi: Improved readability of function comedi_nsamples_left.
Improve readability of comedi_nsamples_left:
a) Reduce nesting by using more return statements.
b) Declare variables scans_left and samples_left at start of function.
c) Change type of scans_Left to unsigned long long to avoid cast.

Signed-off-by: Chris Opperman <eklikeroomys@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-17 09:05:11 +02:00
Giulio Benetti
fbe1be81b2 staging: comedi: drivers: ni_mio_common: add names to function pointer parameters.
Checkpatch.pl complains about packbits function pointer that lacks
parameters name.

Add parameter names to packbits function pointer.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-17 09:05:11 +02:00
Giulio Benetti
d83301c850 staging: comedi: drivers: cb_pcimdda: fix warning on quoted string split across lines.
Checkpatch.pl complains about "quoted string split across lines" for
string in MODULE_DESCRIPTION().

Put string on only one line.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-17 09:05:11 +02:00
Giulio Benetti
6aa0209393 staging: comedi: drivers: daqboard2000: make bool bit-field unsigned int bit-fields.
Checkpatch complains on bool bitfields to be an int or u8/u16/u32
bitfield.

Make bool bit-fields to be unsigned int bit-fields.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-17 09:05:11 +02:00
Giulio Benetti
904f9d4d3a staging: comedi: drivers: amplc_pci230: make bool bit-field unsigned int bit-fields.
Checkpatch complains on bool bitfields to be an int or u8/u16/u32
bitfield.

Make bool bit-fields to be unsigned int bit-fields.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-17 09:05:11 +02:00
Giulio Benetti
3164da7b9c staging: comedi: drivers: amplc_dio200_common: make bool bit-field unsigned int bit-fields.
Checkpatch complains on bool bitfields to be an int or u8/u16/u32
bitfield.

Make bool bit-fields to be unsigned int bit-fields.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-17 09:05:10 +02:00
Giulio Benetti
46fb63b3a1 staging: comedi: drivers: amplc_dio200: make bool bit-field unsigned int bit-fields.
Checkpatch complains on bool bitfields to be an int or u8/u16/u32
bitfield.

Make bool bit-fields to be unsigned int bit-fields.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-17 09:05:10 +02:00
Giulio Benetti
fd02c95fab staging: comedi: comedidev: make bool bit-field unsigned int bit-fields.
Checkpatch complains on bool bitfields to be an int or u8/u16/u32
bitfield.

Make bool bit-fields to be unsigned int bit-fields.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-17 09:05:10 +02:00
Giulio Benetti
b3c1622701 staging: comedi: comedi_fops: make bool bit-field unsigned int bit-fields.
Checkpatch complains on bool bitfields to be an int or u8/u16/u32
bitfield.

Make bool bit-fields to be unsigned int bit-fields.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-17 09:05:10 +02:00
Linus Torvalds
eafdca4d70 Staging/IIO patches for 4.18-rc1
Here is the big staging and IIO driver update for 4.18-rc1.
 
 It was delayed as I wanted to make sure the final driver deletions did
 not cause any major merge issues, and all now looks good.
 
 There are a lot of patches here, just over 1000.  The diffstat summary
 shows the major changes here:
 	1007 files changed, 16828 insertions(+), 227770 deletions(-)
 Because of this, we might be close to shrinking the overall kernel
 source code size for two releases in a row.
 
 There was loads of work in this release cycle, primarily:
 	- tons of ks7010 driver cleanups
 	- lots of mt7621 driver fixes and cleanups
 	- most driver cleanups
 	- wilc1000 fixes and cleanups
 	- lots and lots of IIO driver cleanups and new additions
 	- debugfs cleanups for all staging drivers
 	- lots of other staging driver cleanups and fixes, the shortlog
 	  has the full details.
 
 but the big user-visable things here are the removal of 3 chunks of
 code:
 	- ncpfs and ipx were removed on schedule, no one has cared about
 	  this code since it moved to staging last year, and if it needs
 	  to come back, it can be reverted.
 	- lustre file system is removed.  I've ranted at the lustre
 	  developers about once a year for the past 5 years, with no
 	  real forward progress at all to clean things up and get the
 	  code into the "real" part of the kernel.  Given that the
 	  lustre developers continue to work on an external tree and try
 	  to port those changes to the in-kernel tree every once in a
 	  while, this whole thing really really is not working out at
 	  all.  So I'm deleting it so that the developers can spend the
 	  time working in their out-of-tree location and get things
 	  cleaned up properly to get merged into the tree correctly at a
 	  later date.
 
 Because of these file removals, you will have merge issues on some of
 these files (2 in the ipx code, 1 in the ncpfs code, and 1 in the
 atomisp driver).  Just delete those files, it's a simple merge :)
 
 All of this has been in linux-next for a while with no reported
 problems.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWxvjGQ8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ymoEwCbBYnyUl3cwCszIJ3L3/zvUWpmqIgAn1DDsAim
 dM4lmKg6HX/JBSV4GAN0
 =zdta
 -----END PGP SIGNATURE-----

Merge tag 'staging-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging/IIO updates from Greg KH:
 "Here is the big staging and IIO driver update for 4.18-rc1.

  It was delayed as I wanted to make sure the final driver deletions did
  not cause any major merge issues, and all now looks good.

  There are a lot of patches here, just over 1000. The diffstat summary
  shows the major changes here:

	1007 files changed, 16828 insertions(+), 227770 deletions(-)

  Because of this, we might be close to shrinking the overall kernel
  source code size for two releases in a row.

  There was loads of work in this release cycle, primarily:

   - tons of ks7010 driver cleanups

   - lots of mt7621 driver fixes and cleanups

   - most driver cleanups

   - wilc1000 fixes and cleanups

   - lots and lots of IIO driver cleanups and new additions

   - debugfs cleanups for all staging drivers

   - lots of other staging driver cleanups and fixes, the shortlog has
     the full details.

  but the big user-visable things here are the removal of 3 chunks of
  code:

   - ncpfs and ipx were removed on schedule, no one has cared about this
     code since it moved to staging last year, and if it needs to come
     back, it can be reverted.

   - lustre file system is removed.

     I've ranted at the lustre developers about once a year for the past
     5 years, with no real forward progress at all to clean things up
     and get the code into the "real" part of the kernel.

     Given that the lustre developers continue to work on an external
     tree and try to port those changes to the in-kernel tree every once
     in a while, this whole thing really really is not working out at
     all. So I'm deleting it so that the developers can spend the time
     working in their out-of-tree location and get things cleaned up
     properly to get merged into the tree correctly at a later date.

  Because of these file removals, you will have merge issues on some of
  these files (2 in the ipx code, 1 in the ncpfs code, and 1 in the
  atomisp driver). Just delete those files, it's a simple merge :)

  All of this has been in linux-next for a while with no reported
  problems"

* tag 'staging-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (1011 commits)
  staging: ipx: delete it from the tree
  ncpfs: remove uapi .h files
  ncpfs: remove Documentation
  ncpfs: remove compat functionality
  staging: ncpfs: delete it
  staging: lustre: delete the filesystem from the tree.
  staging: vc04_services: no need to save the log debufs dentries
  staging: vc04_services: vchiq_debugfs_log_entry can be a void *
  staging: vc04_services: remove struct vchiq_debugfs_info
  staging: vc04_services: move client dbg directory into static variable
  staging: vc04_services: remove odd vchiq_debugfs_top() wrapper
  staging: vc04_services: no need to check debugfs return values
  staging: mt7621-gpio: reorder includes alphabetically
  staging: mt7621-gpio: change gc_map to don't use pointers
  staging: mt7621-gpio: use GPIOF_DIR_OUT and GPIOF_DIR_IN macros instead of custom values
  staging: mt7621-gpio: change 'to_mediatek_gpio' to make just a one line return
  staging: mt7621-gpio: dt-bindings: update documentation for #interrupt-cells property
  staging: mt7621-gpio: update #interrupt-cells for the gpio node
  staging: mt7621-gpio: dt-bindings: complete documentation for the gpio
  staging: mt7621-dts: add missing properties to gpio node
  ...
2018-06-09 10:32:39 -07:00
Linus Torvalds
408afb8d78 Merge branch 'work.aio-1' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull aio updates from Al Viro:
 "Majority of AIO stuff this cycle. aio-fsync and aio-poll, mostly.

  The only thing I'm holding back for a day or so is Adam's aio ioprio -
  his last-minute fixup is trivial (missing stub in !CONFIG_BLOCK case),
  but let it sit in -next for decency sake..."

* 'work.aio-1' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (46 commits)
  aio: sanitize the limit checking in io_submit(2)
  aio: fold do_io_submit() into callers
  aio: shift copyin of iocb into io_submit_one()
  aio_read_events_ring(): make a bit more readable
  aio: all callers of aio_{read,write,fsync,poll} treat 0 and -EIOCBQUEUED the same way
  aio: take list removal to (some) callers of aio_complete()
  aio: add missing break for the IOCB_CMD_FDSYNC case
  random: convert to ->poll_mask
  timerfd: convert to ->poll_mask
  eventfd: switch to ->poll_mask
  pipe: convert to ->poll_mask
  crypto: af_alg: convert to ->poll_mask
  net/rxrpc: convert to ->poll_mask
  net/iucv: convert to ->poll_mask
  net/phonet: convert to ->poll_mask
  net/nfc: convert to ->poll_mask
  net/caif: convert to ->poll_mask
  net/bluetooth: convert to ->poll_mask
  net/sctp: convert to ->poll_mask
  net/tipc: convert to ->poll_mask
  ...
2018-06-04 13:57:43 -07:00
Bhanusree Pola
d22e273245 staging: comedi: comedi_usb.h: SPDX License Identifier is added in the first line
SPDX License Identifier is added in form of a comment.

Signed-off-by: Bhanusree Pola <bhanusreemahesh@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-31 19:00:53 +02:00
Christoph Hellwig
9965ed174e fs: add new vfs_poll and file_can_poll helpers
These abstract out calls to the poll method in preparation for changes
in how we poll.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
2018-05-26 09:16:44 +02:00
Nishad Kamdar
03f17b5d40 staging: comedi: comedidev.h: Fix SPDX-License-Identifier tag style
Replace // SPDX-License-Identifier: GPL-2.0+ by
/* SPDX-License-Identifier: GPL-2.0+ */ as per licensing rule
for C header files. Issue found by checkpatch. Part of
Eudyptula Challenge.

Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-25 18:25:30 +02:00
Christoph Hellwig
3f3942aca6 proc: introduce proc_create_single{,_data}
Variants of proc_create{,_data} that directly take a seq_file show
callback and drastically reduces the boilerplate code in the callers.

All trivial callers converted over.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-16 07:23:35 +02:00
Pratik Jain
7ca399f1ef Staging:Comedi:comedi_compat32.c: Lindent changes
Recommended indentation by Lindent on file comedi_compat32.c

Signed-off-by: Pratik Jain <pratik.jain0509@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-15 09:31:38 +02:00
Gabriel Francisco Mandaji
eb641b920b staging: comedi: cb_pcidas64: fix alignment of function parameters
Fix most checkpatch.pl issues of type:

CHECK: Alignment should match open parenthesis

Signed-off-by: Gabriel Francisco Mandaji <gfmandaji@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-23 15:51:34 +02:00
Paul McQuade
e10b178176 staging: comedi: s626: Use Preferred kernel type
Change to kenel type u8 or u16 instead of uint8_t or uint16_t

Signed-off-by: Paul McQuade <paulmcquad@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-29 11:53:27 +02:00
Jian Zhang
0c27d1747b Staging: comedi: fix multiple line dereference coding style issue in cb_pcidas64.c
This is a patch to the cb_pcidas64.c file that fixes up a multiple line
dereference warning found by the checkpatch.pl tool.

Signed-off-by: Jian Zhang <kernel@ubicomp.com.au>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-23 15:55:21 +01:00
Ian Abbott
9eb7194690 staging: comedi: cb_pcidas64: Fix external_ai_queue_in_use()
`external_ai_queue_in_use()` is supposed to return 1 if the external
channel sequencer is in use by an AI command, else return 0.  If the
"read" subdevice (which is the AI subdevice) is not busy then no AI
command is running so the external channel sequencer is not in use, so
the function should return 0.  Unfortunately, the function's "read"
subdevice busy test is inverted, so the function always returns 0 when
the "read" subdevice is busy.  Worse, if the "read" subdevice is
not busy the subsequent call to `use_internal_queue_6xxx()` results in a
null pointer dereference if a previous AI command used a channel list
with a length greater than 1.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-23 15:55:21 +01:00
Ian Abbott
5d20e467df Revert "staging: comedi: cb_pcidas64: change params to external_ai_queue_in_use()"
This reverts commit f5f3a2c656 ("staging: comedi: cb_pcidas64: change
params to external_ai_queue_in_use()").  The
`external_ai_queue_in_use()` was being called from `ao_cmd()` with
pointers to the "write" subdevice and AO command, but is supposed to
check whether the external AI queue is currently in use by the "read"
subdevice and AI command.  In fact, the return value always indicated
that the external AI queue was not in use in this case (because the AO
command's channel list is sequential), so was fairly useless.  (However,
even before the reverted commit, the logic in
`external_ai_queue_in_use()` was wrong.  That will be corrected in a
subsequent commit.)

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-23 15:55:21 +01:00
Frank Mori Hess
e1d9fc04c4 staging: comedi: ni_mio_common: ack ai fifo error interrupts.
Ack ai fifo error interrupts in interrupt handler to clear interrupt
after fifo overflow.  It should prevent lock-ups after the ai fifo
overflows.

Cc: <stable@vger.kernel.org> # v4.2+
Signed-off-by: Frank Mori Hess <fmh6jj@gmail.com>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-19 19:43:24 +01:00
Pratik Jain
988f4a3b6a Staging: comedi: drivers: ni_atmio.c: fixed multi-line derefernce issue
Fixed coding style issue.

Signed-off-by: Pratik Jain <pratik.jain0509@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-19 19:43:24 +01:00
Greg Kroah-Hartman
73709e1af5 Merge 4.16-rc6 into staging-next
We want the staging fixes in here as well to handle merge/test issues.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-19 06:47:01 +01:00
Colin Ian King
b8461ff774 staging: comedi: adl_pci6208: remove redundant initialization of 'val'
Variable 'val' is initialized with a value that is never read, it is
updated with a new value again after intitialization. Remove the
redundant initialization and move the declaration and assignment into
the scope of the for-loop.

Cleans up clang warning:
drivers/staging/comedi/drivers/adl_pci6208.c:61:15: warning: Value
stored to 'val' during its initialization is never read

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-14 12:57:06 +01:00
Frank Mori Hess
a42ae59051 staging: comedi: fix comedi_nsamples_left.
A rounding error was causing comedi_nsamples_left to
return the wrong value when nsamples was not a multiple
of the scan length.

Cc: <stable@vger.kernel.org> # v4.4+
Signed-off-by: Frank Mori Hess <fmh6jj@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-06 07:21:10 -08:00
Arushi Singhal
471c3615e5 staging: comedi: Replace "dont" with "don't
Replace "dont" with "don't".
"Dont" is not same as "Do not" or "Don't".

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-06 04:01:10 -08:00
Eisha Chen-yen-su
38614ed802 staging: comedi: Use '"%s:", __func__' instead of function name
Replace all occurrences of functions' names in strings by a reference
to __func__, to improve robustness. Problem found with checkpatch.

Signed-off-by: Eisha Chen-yen-su <chenyensu0@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-22 14:53:05 +01:00
Eisha Chen-yen-su
4f7b006ff1 staging: comedi: Remove a "tracing" call
Remove a "tracing" call as it is not needed anymore
because there is an in-kernel function for that.

Signed-off-by: Eisha Chen-yen-su <chenyensu0@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-22 14:53:05 +01:00
Eisha Chen-yen-su
c318bb0835 staging: comedi: Use '"%s:", __func__' instead of function name
Replace an occurrence of the function name in a string by a reference
to __func__, to improve robustness. Problem found with checkpatch.

Signed-off-by: Eisha Chen-yen-su <chenyensu0@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-19 17:57:43 +01:00
Eisha Chen-yen-su
b32b2cacd9 staging: comedi: Add a missing space
Add a missing space so that the * is properly aligned with
the rest of the block comment. Problem found with checkpatch.

Signed-off-by: Eisha Chen-yen-su <chenyensu0@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-19 17:57:43 +01:00
Eisha Chen-yen-su
cc62f8164e staging: comedi: Remove a newline inside a dereference
Remove a new line inside a dereference so that it is not on
multiple lines.
And avoid making the line go over 80 columns by moving the whole
dma_alloc_coherent() call back 4 columns. Problem found with
checkpatch.

Signed-off-by: Eisha Chen-yen-su <chenyensu0@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-19 17:57:43 +01:00
Linus Torvalds
a9a08845e9 vfs: do bulk POLL* -> EPOLL* replacement
This is the mindless scripted replacement of kernel use of POLL*
variables as described by Al, done by this script:

    for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do
        L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'`
        for f in $L; do sed -i "-es/^\([^\"]*\)\(\<POLL$V\>\)/\\1E\\2/" $f; done
    done

with de-mangling cleanups yet to come.

NOTE! On almost all architectures, the EPOLL* constants have the same
values as the POLL* constants do.  But they keyword here is "almost".
For various bad reasons they aren't the same, and epoll() doesn't
actually work quite correctly in some cases due to this on Sparc et al.

The next patch from Al will sort out the final differences, and we
should be all done.

Scripted-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-02-11 14:34:03 -08:00
Linus Torvalds
5d8515bc23 Staging/IIO patches for 4.16-rc1
Here is the big Staging and IIO driver patches for 4.16-rc1.
 
 There is the normal amount of new IIO drivers added, like all releases.
 
 The networking IPX and the ncpfs filesystem are moved into the staging
 tree, as they are on their way out of the kernel due to lack of use
 anymore.
 
 The visorbus subsystem finall has started moving out of the staging tree
 to the "real" part of the kernel, and the most and fsl-mc codebases are
 almost ready to move out, that will probably happen for 4.17-rc1 if all
 goes well.
 
 Other than that, there is a bunch of license header cleanups in the
 tree, along with the normal amount of coding style churn that we all
 know and love for this codebase.  I also got frustrated at the
 Meltdown/Spectre mess and took it out on the dgnc tty driver, deleting
 huge chunks of it that were never even being used.
 
 Full details of everything is in the shortlog.
 
 All of these patches have been in linux-next for a while with no
 reported issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWnLxoA8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+yk4vgCgjeMlwhtar65DIticIRj626EFxiQAnjGmH8Kd
 d9Xz2Piq8X47uSsC/6AE
 =xxMT
 -----END PGP SIGNATURE-----

Merge tag 'staging-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging/IIO updates from Greg KH:
 "Here is the big Staging and IIO driver patches for 4.16-rc1.

  There is the normal amount of new IIO drivers added, like all
  releases.

  The networking IPX and the ncpfs filesystem are moved into the staging
  tree, as they are on their way out of the kernel due to lack of use
  anymore.

  The visorbus subsystem finall has started moving out of the staging
  tree to the "real" part of the kernel, and the most and fsl-mc
  codebases are almost ready to move out, that will probably happen for
  4.17-rc1 if all goes well.

  Other than that, there is a bunch of license header cleanups in the
  tree, along with the normal amount of coding style churn that we all
  know and love for this codebase. I also got frustrated at the
  Meltdown/Spectre mess and took it out on the dgnc tty driver, deleting
  huge chunks of it that were never even being used.

  Full details of everything is in the shortlog.

  All of these patches have been in linux-next for a while with no
  reported issues"

* tag 'staging-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (627 commits)
  staging: rtlwifi: remove redundant initialization of 'cfg_cmd'
  staging: rtl8723bs: remove a couple of redundant initializations
  staging: comedi: reformat lines to 80 chars or less
  staging: lustre: separate a connection destroy from free struct kib_conn
  Staging: rtl8723bs: Use !x instead of NULL comparison
  Staging: rtl8723bs: Remove dead code
  Staging: rtl8723bs: Change names to conform to the kernel code
  staging: ccree: Fix missing blank line after declaration
  staging: rtl8188eu: remove redundant initialization of 'pwrcfgcmd'
  staging: rtlwifi: remove unused RTLHALMAC_ST and RTLPHYDM_ST
  staging: fbtft: remove unused FB_TFT_SSD1325 kconfig
  staging: comedi: dt2811: remove redundant initialization of 'ns'
  staging: wilc1000: fix alignments to match open parenthesis
  staging: wilc1000: removed unnecessary defined enums typedef
  staging: wilc1000: remove unnecessary use of parentheses
  staging: rtl8192u: remove redundant initialization of 'timeout'
  staging: sm750fb: fix CamelCase for dispSet var
  staging: lustre: lnet/selftest: fix compile error on UP build
  staging: rtl8723bs: hal_com_phycfg: Remove unneeded semicolons
  staging: rts5208: Fix "seg_no" calculation in reset_ms_card()
  ...
2018-02-01 09:51:57 -08:00
Linus Torvalds
168fe32a07 Merge branch 'misc.poll' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull poll annotations from Al Viro:
 "This introduces a __bitwise type for POLL### bitmap, and propagates
  the annotations through the tree. Most of that stuff is as simple as
  'make ->poll() instances return __poll_t and do the same to local
  variables used to hold the future return value'.

  Some of the obvious brainos found in process are fixed (e.g. POLLIN
  misspelled as POLL_IN). At that point the amount of sparse warnings is
  low and most of them are for genuine bugs - e.g. ->poll() instance
  deciding to return -EINVAL instead of a bitmap. I hadn't touched those
  in this series - it's large enough as it is.

  Another problem it has caught was eventpoll() ABI mess; select.c and
  eventpoll.c assumed that corresponding POLL### and EPOLL### were
  equal. That's true for some, but not all of them - EPOLL### are
  arch-independent, but POLL### are not.

  The last commit in this series separates userland POLL### values from
  the (now arch-independent) kernel-side ones, converting between them
  in the few places where they are copied to/from userland. AFAICS, this
  is the least disruptive fix preserving poll(2) ABI and making epoll()
  work on all architectures.

  As it is, it's simply broken on sparc - try to give it EPOLLWRNORM and
  it will trigger only on what would've triggered EPOLLWRBAND on other
  architectures. EPOLLWRBAND and EPOLLRDHUP, OTOH, are never triggered
  at all on sparc. With this patch they should work consistently on all
  architectures"

* 'misc.poll' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (37 commits)
  make kernel-side POLL... arch-independent
  eventpoll: no need to mask the result of epi_item_poll() again
  eventpoll: constify struct epoll_event pointers
  debugging printk in sg_poll() uses %x to print POLL... bitmap
  annotate poll(2) guts
  9p: untangle ->poll() mess
  ->si_band gets POLL... bitmap stored into a user-visible long field
  ring_buffer_poll_wait() return value used as return value of ->poll()
  the rest of drivers/*: annotate ->poll() instances
  media: annotate ->poll() instances
  fs: annotate ->poll() instances
  ipc, kernel, mm: annotate ->poll() instances
  net: annotate ->poll() instances
  apparmor: annotate ->poll() instances
  tomoyo: annotate ->poll() instances
  sound: annotate ->poll() instances
  acpi: annotate ->poll() instances
  crypto: annotate ->poll() instances
  block: annotate ->poll() instances
  x86: annotate ->poll() instances
  ...
2018-01-30 17:58:07 -08:00
Eujon Sellers
26311087d1 staging: comedi: reformat lines to 80 chars or less
This is a cleanup patch to fix line length issue found
by checkpatch.pl script.

In this patch, lines 186, 192 and 199 have been wrapped.

Signed-off-by: Eujon Sellers <eujon.sellers@gmail.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-26 15:08:43 +01:00
Colin Ian King
d8bc23d3ba staging: comedi: dt2811: remove redundant initialization of 'ns'
Variable ns is being initialized with a value that is never read, ns
is being re-assigned a new value later on. Remove the redundant
initialization.

Cleans up clang warning:
drivers/staging/comedi/drivers/dt2811.c:310:21: warning: Value stored
to 'ns' during its initialization is never read

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-23 11:51:12 +01:00
Richard Sudaryono
357f862bd2 staging: comedi: adv_pci1760: fix typo in comments
Changed 'firware' to 'firmware'

Signed-off-by: Richard Sudaryono <richardsudaryono@gmail.com>
2018-01-08 16:45:45 +01:00
Michael Gebhard
2c5f7348fe staging: comedi: add identifiers to function parameters
Fix these checkpatch.pl warnings in comedidev.h:
WARNING: function definition argument '<name>' should also have an identifier name

Introduces this checkpatch.pl warning in lines 195 and 205:
WARNING: line over 80 characters
Breaking these lines would make the code less compact.

Signed-off-by: Michael Gebhard <im72ywil@cip.cs.fau.de>
Signed-off-by: David Sauerwein <la38vyti@cip.cs.fau.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-21 18:25:37 +01:00
Roman Lakeev
e9f14f1954 staging: comedi: s626.c - fix multiline dereference
staging: comedi: s626.c - fix the following checkpatch issues:
WARNING: Avoid multiple line dereference - prefer 'devpriv->rps_buf.logical_base'
#1380: FILE: drivers/s626.c:1380:
+				   (unsigned long)devpriv->
+						  rps_buf.logical_base);

WARNING: Avoid multiple line dereference - prefer 'cmd->scan_begin_arg'
#1898: FILE: drivers/s626.c:1898:
+			err |= comedi_check_trigger_arg_min(&cmd->
+							    scan_begin_arg,

Signed-off-by: Roman Lakeev <sunnyddayss@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:10:09 +01:00
Vikash Kesarwani
e0a0df6319 Staging: comedi: drivers: serial2002 fixed a blank line coding style
Fixed a blank line coding style after a declaration

Signed-off-by: Vikash Kesarwani <vikash.ckiiita30@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:43:08 +01:00
Greg Kroah-Hartman
e8cd29b774 Merge Linus's staging merge point into staging-next
This resolves the merge issue pointed out by Stephen in
drivers/iio/adc/meson_saradc.c.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-06 15:27:17 +01:00
Al Viro
afc9a42b74 the rest of drivers/*: annotate ->poll() instances
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2017-11-28 11:06:58 -05:00
Matthew Giassa
02d69c0359 staging: comedi: ni_atmio: fix license warning.
Resolving license check warning for drivers/staging/comedi. Added the
license definitions present in the rest of the module and made sure it's
aligned with the license (GPL) in the comments for the affected file
(ni_atmio.c). Original warning:

WARNING: modpost: missing MODULE_LICENSE() in drivers/staging/comedi//drivers/ni_atmio.o
see include/linux/module.h for more information.

No longer present after change.

Signed-off-by: Matthew Giassa <matthew@giassa.net>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-28 14:36:45 +01:00
Greg Kroah-Hartman
f814e74c9b staging: comedi: Remove redundant license text
Now that the SPDX tag is in all comedi files, that identifies the
license in a specific and legally-defined manner.  So the extra GPL text
wording can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text.  And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-28 13:20:46 +01:00
Greg Kroah-Hartman
b69839391d staging: comedi: drivers: Remove redundant license text
Now that the SPDX tag is in all comedi files, that identifies the
license in a specific and legally-defined manner.  So the extra GPL text
wording can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text.  And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-28 13:20:46 +01:00
Greg Kroah-Hartman
e184e2bed8 staging: comedi: add SPDX identifiers to all greybus driver files
It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the drivers/staging/comedi files files with the correct SPDX
license identifier based on the license text in the file itself.  The
SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-28 13:20:45 +01:00
Al Viro
e6c8adca20 anntotate the places where ->poll() return values go
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2017-11-27 16:19:53 -05:00
Colin Ian King
bc4eec76e6 staging: comedi: usbdux: remove redundant initialization of val
The early initialization of val is redundant as the value is never
read and is updated inside a for-loop. Remove the initialization
and move the declaration and initialization to the for-loop scope.
Cleans up clang warning:

drivers/staging/comedi/drivers/usbdux.c:812:15: warning: Value stored
to 'val' during its initialization is never read

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-27 09:20:40 +01:00
Linus Torvalds
449fcf3ab0 Staging/IIO patches for 4.15-rc1
Here is the "big" staging and IIO driver update for 4.15-rc1.
 
 Lots and lots of little changes, almost all minor code cleanups as the
 Outreachy application process happened during this development cycle.
 Also happened was a lot of IIO driver activity, and the typec USB code
 moving out of staging to drivers/usb (same commits are in the USB tree
 on a persistent branch to not cause merge issues.)
 
 Overall, it's a wash, I think we added a few hundred more lines than
 removed, but really only a few thousand were modified at all.
 
 All of these have been in linux-next for a while.  There might be a
 merge issue with Al's vfs tree in the pi433 driver (take his changes,
 they are always better), and the media tree with some of the odd atomisp
 cleanups (take the media tree's version).
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWgnFrg8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ymxbwCgtNlBkqD2JJYpLRKvI/C4w1vzZsEAnA2THRkt
 g3ioPBqmqC/2DSbldr2o
 =/ebw
 -----END PGP SIGNATURE-----

Merge tag 'staging-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging and IIO updates from Greg KH:
 "Here is the "big" staging and IIO driver update for 4.15-rc1.

  Lots and lots of little changes, almost all minor code cleanups as the
  Outreachy application process happened during this development cycle.
  Also happened was a lot of IIO driver activity, and the typec USB code
  moving out of staging to drivers/usb (same commits are in the USB tree
  on a persistent branch to not cause merge issues.)

  Overall, it's a wash, I think we added a few hundred more lines than
  removed, but really only a few thousand were modified at all.

  All of these have been in linux-next for a while. There might be a
  merge issue with Al's vfs tree in the pi433 driver (take his changes,
  they are always better), and the media tree with some of the odd
  atomisp cleanups (take the media tree's version)"

* tag 'staging-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (507 commits)
  staging: lustre: add SPDX identifiers to all lustre files
  staging: greybus: Remove redundant license text
  staging: greybus: add SPDX identifiers to all greybus driver files
  staging: ccree: simplify ioread/iowrite
  staging: ccree: simplify registers access
  staging: ccree: simplify error handling logic
  staging: ccree: remove dead code
  staging: ccree: handle limiting of DMA masks
  staging: ccree: copy IV to DMAable memory
  staging: fbtft: remove redundant initialization of buf
  staging: sm750fb: Fix parameter mistake in poke32
  staging: wilc1000: Fix bssid buffer offset in Txq
  staging: fbtft: fb_ssd1331: fix mirrored display
  staging: android: Fix checkpatch.pl error
  staging: greybus: loopback: convert loopback to use generic async operations
  staging: greybus: operation: add private data with get/set accessors
  staging: greybus: loopback: Fix iteration count on async path
  staging: greybus: loopback: Hold per-connection mutex across operations
  staging: greybus/loopback: use ktime_get() for time intervals
  staging: fsl-dpaa2/eth: Extra headroom in RX buffers
  ...
2017-11-13 20:53:28 -08:00
Greg Kroah-Hartman
b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.

By default all files without license information are under the default
license of the kernel, which is GPL version 2.

Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier.  The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.

This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.

How this work was done:

Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
 - file had no licensing information it it.
 - file was a */uapi/* one with no licensing information in it,
 - file was a */uapi/* one with existing licensing information,

Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.

The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne.  Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.

The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed.  Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.

Criteria used to select files for SPDX license identifier tagging was:
 - Files considered eligible had to be source code files.
 - Make and config files were included as candidates if they contained >5
   lines of source
 - File already had some variant of a license header in it (even if <5
   lines).

All documentation files were explicitly excluded.

The following heuristics were used to determine which SPDX license
identifiers to apply.

 - when both scanners couldn't find any license traces, file was
   considered to have no license information in it, and the top level
   COPYING file license applied.

   For non */uapi/* files that summary was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0                                              11139

   and resulted in the first patch in this series.

   If that file was a */uapi/* path one, it was "GPL-2.0 WITH
   Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0 WITH Linux-syscall-note                        930

   and resulted in the second patch in this series.

 - if a file had some form of licensing information in it, and was one
   of the */uapi/* ones, it was denoted with the Linux-syscall-note if
   any GPL family license was found in the file or had no licensing in
   it (per prior point).  Results summary:

   SPDX license identifier                            # files
   ---------------------------------------------------|------
   GPL-2.0 WITH Linux-syscall-note                       270
   GPL-2.0+ WITH Linux-syscall-note                      169
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
   LGPL-2.1+ WITH Linux-syscall-note                      15
   GPL-1.0+ WITH Linux-syscall-note                       14
   ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
   LGPL-2.0+ WITH Linux-syscall-note                       4
   LGPL-2.1 WITH Linux-syscall-note                        3
   ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
   ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1

   and that resulted in the third patch in this series.

 - when the two scanners agreed on the detected license(s), that became
   the concluded license(s).

 - when there was disagreement between the two scanners (one detected a
   license but the other didn't, or they both detected different
   licenses) a manual inspection of the file occurred.

 - In most cases a manual inspection of the information in the file
   resulted in a clear resolution of the license that should apply (and
   which scanner probably needed to revisit its heuristics).

 - When it was not immediately clear, the license identifier was
   confirmed with lawyers working with the Linux Foundation.

 - If there was any question as to the appropriate license identifier,
   the file was flagged for further research and to be revisited later
   in time.

In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.

Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights.  The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.

Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.

In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.

Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
 - a full scancode scan run, collecting the matched texts, detected
   license ids and scores
 - reviewing anything where there was a license detected (about 500+
   files) to ensure that the applied SPDX license was correct
 - reviewing anything where there was no detection but the patch license
   was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
   SPDX license was correct

This produced a worksheet with 20 files needing minor correction.  This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.

These .csv files were then reviewed by Greg.  Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected.  This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.)  Finally Greg ran the script using the .csv files to
generate the patches.

Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-02 11:10:55 +01:00
Anton Dozenko
682455befd staging: comedi: adv_pci_dio: update for PCI-1761
Advantech PCI-1761 device support to the driver adv_pci_dio has been
added. Patch has been successfully tested on a real card (8 digital
outs, 8 digital inputs).

Signed-off-by: Anton Dozenko <anton.dozenko@gmail.com>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-18 15:45:48 +02:00
Arvind Yadav
526739265e staging: comedi: dt282x: fix IRQ assignment for dev->irq.
Here, dev->irq is not assigned with irq. comedi_legacy_detach()
is using dev->irq for release irq and dt282x_attach() is using dev->irq
for initialize comedi_subdevice.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-18 15:45:48 +02:00
Gustavo A. R. Silva
0cb7e343de staging: comedi: s526: mark expected switch fall-through
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-18 15:45:48 +02:00
Kees Cook
e44d4907f8 staging/comedi: Convert timers to use timer_setup()
In preparation for unconditionally passing the struct timer_list pointer
to all timer callbacks, switch to using the new timer_setup() and
from_timer() to pass the timer pointer explicitly. Adds pointer back to
comedi device from private struct.

Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: devel@driverdev.osuosl.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-18 15:45:48 +02:00
Kees Cook
1c937c1390 staging/comedi/das16: Make timer initialization unconditional
With timer initialization made unconditional, there is no reason to
make del_timer_sync() calls conditionally, there by removing the test
of the .data field.

Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: devel@driverdev.osuosl.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-22 10:57:22 +02:00
Linus Torvalds
581bfce969 Merge branch 'work.set_fs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull more set_fs removal from Al Viro:
 "Christoph's 'use kernel_read and friends rather than open-coding
  set_fs()' series"

* 'work.set_fs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  fs: unexport vfs_readv and vfs_writev
  fs: unexport vfs_read and vfs_write
  fs: unexport __vfs_read/__vfs_write
  lustre: switch to kernel_write
  gadget/f_mass_storage: stop messing with the address limit
  mconsole: switch to kernel_read
  btrfs: switch write_buf to kernel_write
  net/9p: switch p9_fd_read to kernel_write
  mm/nommu: switch do_mmap_private to kernel_read
  serial2002: switch serial2002_tty_write to kernel_{read/write}
  fs: make the buf argument to __kernel_write a void pointer
  fs: fix kernel_write prototype
  fs: fix kernel_read prototype
  fs: move kernel_read to fs/read_write.c
  fs: move kernel_write to fs/read_write.c
  autofs4: switch autofs4_write to __kernel_write
  ashmem: switch to ->read_iter
2017-09-14 18:13:32 -07:00
Christoph Hellwig
9a779bc149 serial2002: switch serial2002_tty_write to kernel_{read/write}
Instead of playing games with the address limit.  This also gains
us proper usage of the write counter, time stamp updates and kvec
validation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2017-09-04 19:05:15 -04:00
Simo Koskinen
423a8a6eac staging: comedi: coding style fixes found by checkpatch.pl
The patch removes "WARNING: Prefer using '"%s...", __func__'
to using 'xxxxxxxx', this function's name, in a string" warnings
reported by checkpatch.pl script.

Signed-off-by: Simo Koskinen <koskisoft@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-08-29 08:25:41 +02:00
Bryan Garza
e4f857f739 Staging: comedi: comedi_fops: fix dev_err() warning style
Changed dev_err() call to use function name constant instead of hardcoded
string. Issue found by checkpatch.

Signed-off-by: Bryan Garza <bry@riseup.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-08-23 16:26:10 -07:00
Greg Kroah-Hartman
8652892ed4 Merge 4.13-rc5 into staging-next
We need it here for iio fixes.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-08-14 13:35:22 -07:00
Ian Abbott
cef988642c staging: comedi: comedi_fops: do not call blocking ops when !TASK_RUNNING
Comedi's read and write file operation handlers (`comedi_read()` and
`comedi_write()`) currently call `copy_to_user()` or `copy_from_user()`
whilst in the `TASK_INTERRUPTIBLE` state, which falls foul of the
`might_fault()` checks when enabled.  Fix it by setting the current task
state back to `TASK_RUNNING` a bit earlier before calling these
functions.

Reported-by: Piotr Gregor <piotrgregor@rsyncme.org>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: <stable@vger.kernel.org> # 4.5+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-30 08:38:43 -07:00
Christopher Mårtensson
dc5b02a908 staging: comedi: ni_mio_common.c: fix coding style issue
"checkpatch.pl -f ..." gave
ERROR: open brace '{' following function definitions go on the next line

Signed-off-by: Christopher Mårtensson <cribalik@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-30 08:00:37 -07:00
Greg Kroah-Hartman
a29e249072 Merge 4.13-rc2 into staging-next
This resolves a merge issue and gets the vmbox drm driver into this
branch to be able to start taking fixes for it...

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-23 19:53:30 -07:00
Ian Abbott
15d5193104 staging: comedi: ni_mio_common: fix AO timer off-by-one regression
As reported by Éric Piel on the Comedi mailing list (see
<https://groups.google.com/forum/#!topic/comedi_list/ueZiR7vTLOU/discussion>),
the analog output asynchronous commands are running too fast with a
period 50 ns shorter than it should be.  This affects all boards with AO
command support that are supported by the "ni_pcimio", "ni_atmio", and
"ni_mio_cs" drivers.

This is a regression bug introduced by commit 080e6795cb ("staging:
comedi: ni_mio_common: Cleans up/clarifies ni_ao_cmd"), specifically,
this line in `ni_ao_cmd_set_update()`:

		/* following line: N-1 per STC */
		ni_stc_writel(dev, trigvar - 1, NISTC_AO_UI_LOADA_REG);

The `trigvar` variable value comes from a call to `ni_ns_to_timer()`
which converts a timer period in nanoseconds to a hardware divisor
value. The function already reduces the divisor by 1 as required by the
hardware, so the above line should not reduce it further by 1.  Fix it
by replacing `trigvar` by `trigvar - 1` in the above line, and remove
the misleading comment.

Reported-by: Éric Piel <piel@delmic.com>
Fixes: 080e6795cb ("staging: comedi: ni_mio_common: Cleans up/clarifies ni_ao_cmd")
Cc: Éric Piel <piel@delmic.com>
Cc: Spencer E. Olson <olsonse@umich.edu>
Cc: <stable@vger.kernel.org> # 4.7+
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-16 09:13:53 +02:00
Amitoj Kaur Chawla
f47d8b11ee staging: comedi: Use offset_in_page macro
Use offset_in_page macro instead of (var & ~PAGE_MASK)

The Coccinelle semantic patch used to make this change is as follows:
// <smpl>
@@
unsigned long p;
@@
- p & ~PAGE_MASK
+ offset_in_page(p)
// </smpl>

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-16 08:41:01 +02:00
Ian Abbott
125178d1eb staging: comedi: use centralized error clean-up in comedi_init()
Centralize the "clean-up on error" handling in `comedi_init()` using
`goto` statements.  Also change some of the explicit `-EIO` return
values to the error return values from the failing functions as there is
no good reason to use `-EIO` explicitly.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-24 00:37:07 +08:00
Ian Abbott
a9332e9ad0 staging: comedi: fix clean-up of comedi_class in comedi_init()
There is a clean-up bug in the core comedi module initialization
functions, `comedi_init()`.  If the `comedi_num_legacy_minors` module
parameter is non-zero (and valid), it creates that many "legacy" devices
and registers them in SysFS.  A failure causes the function to clean up
and return an error.  Unfortunately, it fails to destroy the "comedi"
class that was created earlier.  Fix it by adding a call to
`class_destroy(comedi_class)` at the appropriate place in the clean-up
sequence.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: <stable@vger.kernel.org> # 3.9+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-24 00:37:07 +08:00
Amisha Singh
38d0353c6e Staging: comedi: ni_labpc_regs: fixed a block comment alignment issue
Fixed a coding style issue.

Signed-off-by: Amisha Singh <amisha.sh22@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-13 12:06:56 +02:00
Adrian Stanciu
97b30bad76 staging: comedi: ni_labpc_isadma: fixed a comment coding style issue
Fixed a BLOCK_COMMENT_STYLE warning reported by checkpatch.pl script.

Signed-off-by: Adrian Stanciu <adrian.stanciu.pub@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-06 16:16:09 +02:00
edcarter
3137139a65 Staging: comedi: s626.c: fixed trailing */ style issue
Fixed coding style issue where trailing */ in block comments
were not on separate lines.

Signed-off-by: Elias Carter <edcarter@ualberta.ca>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-04 10:17:42 +02:00
Pan Bian
a455178e59 staging: comedi: addi_apci_3xxx: check return value
Function pci_ioremap_bar() will return a NULL pointer if there is no
enough memory. However, in function apci3xxx_auto_attach(), the return
value of function pci_ioremap_bar() is not validated. This may result in
NULL dereference in following access to dev->mmio. This patch fixes the
bug.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-25 20:43:42 +02:00
Ian Abbott
255364f7b8 staging: comedi: support vm_access_process for mmap'd buffer
If a process that has mmap'd a COMEDI buffer is being run under a
debugger such as GDB, the buffer contents are inaccessible from the
debugger.  Support the `access()` VM operation to allow the buffer
contents to be accessed by another process.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-25 20:43:42 +02:00
Andrea della Porta
e45c237912 staging: comedi: drivers: s626.c - fixed checkpatch issue about data type
staging: comedi: drivers: s626.c - fixed the following checkpatch issue:
CHECK: Prefer kernel type 's16' over 'int16_t'
#1939: FILE: drivers/staging/comedi/drivers/s626.c:1939:
+               int16_t dacdata = (int16_t)data[i];

Signed-off-by: Andrea della Porta <sfaragnaus@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-08 17:05:59 +02:00
Ian Abbott
2bbd5023ee staging: comedi: amplc_pci224: convert CLK_CONFIG() macro to function
Convert the `CLK_CLKFIG(chan, src)` macro to a static function
`pci224_clk_config(chan, src)`.  This is consistent with an earlier
change to convert `GAT_CONFIG(chan, src)` to a static function.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-08 13:03:17 +02:00
Ian Abbott
a19aa38022 staging: comedi: amplc_pci224: remove 'inline' from pci224_gat_config()
Let the compiler figure out whether `pci224_gat_confip()` should be
inlined by itself.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-08 13:03:17 +02:00
Ian Abbott
c5665dfb90 staging: comedi: amplc_pci230: convert CLK_CONFIG() macro to function
Convert the `CLK_CONFIG(chan, src)` macro to a static function
`pci230_clk_config(chan, src)`.  This is consistent with an earlier
change to convert `GAT_CONFIG(chan, src)` to a static function.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-08 13:03:17 +02:00
Ian Abbott
112d55e585 staging: comedi: amplc_pci230: remove 'inline' from pci230_gat_config()
Let the compiler figure out whether `pci230_gat_config()` should be
inlined by itself.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-08 13:03:17 +02:00
Arnd Bergmann
54f74b492f staging: comedi: labpc: fix isadma dependency
When COMEDI_NI_LABPC is built-in and COMEDI_NI_LABPC_ISA is a loadable
module, thhe ISA DMA code is not reachable by the common module, causing
a link error:

drivers/staging/built-in.o: In function `labpc_interrupt':
ni_labpc_common.c:(.text+0x1d178): undefined reference to `labpc_handle_dma_status'
ni_labpc_common.c:(.text+0x1d1cb): undefined reference to `labpc_drain_dma'
drivers/staging/built-in.o: In function `labpc_ai_cmd':
ni_labpc_common.c:(.text+0x1d8ad): undefined reference to `labpc_setup_dma'

This changes the definition of COMEDI_NI_LABPC_ISADMA so that it will
also be builtin for that case. This looks like a rather old bug, but
I have never seen this in randconfig testing until today.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-08 12:54:09 +02:00
simran singhal
cb52fce160 staging: comedi: amplc_pci224: Convert macro GAT_CONFIG to static inline function
Convert macro GAT_CONFIG to static inline function as static inline
functions are preferred over macros. This change is possible since the
arguments at all call sites have the same type.

The uses were updated with Coccinelle:

@r1@
expression dev,reg,chan,src;
@@
-GAT_CONFIG(chan, src)
+pci224_gat_config(chan, src)

Also, the comment describing the macro has been removed.

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-14 06:27:31 +08:00
Varsha Rao
06cb6b5434 staging: comedi: Compress return logic into one line.
Simplify function return by merging assignment and return into a single
line. The following coccinelle script is used to fix this issue.

@@
expression e;
local idexpression ret;
@@

-ret = e;
-return ret;
+return e;

Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-14 06:27:31 +08:00
Ian Abbott
d2c94a351b staging: comedi: jr3_pci: change module description
Change the MODULE_DESCRIPTION string from the generic "Comedi low-level
driver" to the more specific "Comedi driver for JR3/PCI force sensor
board".

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-12 14:57:00 +01:00
Ian Abbott
6541964dcd staging: comedi: jr3_pci: fix initial range[8] max value
`jr3_pci_alloc_spriv()` initializes `spriv->range[8]` to use a maximum
value of 65536, but that will be overwritten with 65535 at a later time
by `jr3_pci_poll_subdevice()` once the "set full scales" command is
complete.  The initial setting looks like a mistake.  This range is only
associated with a couple of dummy channels (channels 56 and 57) to read
back the model number and serial number, so no user code should be
attempting to convert those numbers to physical units.  Just change the
initial value to 65535 to match the final value.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-12 14:57:00 +01:00
Ian Abbott
8abde9acdf staging: comedi: jr3_pci: check PCI BAR 0 size
The various supported boards have different numbers of subdevices from 1
to 4.  Each subdevice needs a block of registers in PCI BAR 0.  Check
the region is large enough for the required number of subdevices.
Return an error from `jr3_pci_auto_attach()` if it is too small.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-12 14:57:00 +01:00
Ian Abbott
7cb1c5c2cd staging: comedi: jr3_pci: check sizes at compile time
The driver currently checks the size of `struct jr3_sensor` is correct
when a device is attached, returning an error if it is wrong.  Replace
that with a compile-time check.  We don't care too much about the size
of `struct jr3_sensor` as it is embedded in the larger `struct
jr3_block` and is followed by a lot of padding.  We should care more
that the size of `struct jr3_block` is correct, as it describes the
overall register layout of a block, and there is an array of such blocks
(one per subdevice).  Check its size at compile-time using the
`BUILD_BUG_ON()` macro.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-12 14:57:00 +01:00
Ian Abbott
6fbd1330e5 staging: comedi: jr3_pci: omit pointless debug info
`jr3_pci_open()` outputs several debug log messages containing serial
numbers of the sensors (one per subdevice) along with a pointer to the
subdevice private data structure.  The latter is of no use, so reformat
the debug log to omit it.

`jr3_pci_alloc_spriv()` outputs a debug log message containing more
useless information about the remapped base address of the board
registers, the sensor registers, and the difference between them.  Get
rid of it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-12 14:57:00 +01:00
Ian Abbott
9d6a94291e staging: comedi: jr3_pci: use struct jr3_block instead of jr3_t
`struct jr3_t` contains a single array member `block` of member type
`struct jr3_block`.  Rather than using pointers to `struct jr3_t`, just
use pointers to `struct jr3_block` instead and treat it as an array.
Replace the local variables `struct jr3_t __iomem *iobase` with `struct
jr3_block __iomem *block`.  Remove the definition of `struct jr3_t` as
it is no longer needed.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-12 14:57:00 +01:00
Ian Abbott
4e861f0fd8 staging: comedi: jr3_pci: separate out block type
`struct jr3_t` contains a single array member `block` of a tag-less
`struct` type.  Rename the tag-less `struct` type to `struct jr3_block`
and move its definition outside of `struct jr3_t`.  This will allow us
to use pointers of this type.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-12 14:57:00 +01:00
Ian Abbott
6c7f58084f staging: comedi: jr3_pci: rename 'channel' to 'block'
The term "channel" is overloaded in this driver.  Rename the `channel`
member of `struct jr3_t` to `block` to reduce confusion.  `block` is an
array of an anonymous `struct` type, with each element covering the
registers for one subdevice.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-12 14:57:00 +01:00
Ian Abbott
ef3ab9f85c staging: comedi: jr3_pci: rename data to sensor
Rename the `channel[x].data` member of `struct jr3_t` to
`channel[x].sensor` to match its type `struct jr3_sensor`.  Also rename
local variable `ch0data` in `jr3_pci_show_copyright()` to `sensor0` for
consistency.  It points to the `struct jr3_sensor` embedded in the
registers for "channel" 0.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-12 14:57:00 +01:00
Ian Abbott
713eab88c6 staging: comedi: jr3_pci: rename channel to sensor
The driver overloads the term "channel" a lot.  To help reduce
confusion, rename the `channel` member of `struct
jr3_pci_subdev_private` to `sensor` as it points to a `struct
jr3_sensor`.  Also rename the various function parameters and local
variables called `channel` that point to a `struct jr3_sensor` to
`sensor`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-12 14:57:00 +01:00
Ian Abbott
c5ad0c7b51 staging: comedi: jr3_pci: rename struct jr3_channel to jr3_sensor
The driver overloads the term "channel" a lot.  To help reduce
confusion, rename `struct jr3_channel` to `struct jr3_sensor`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-12 14:57:00 +01:00
Varsha Rao
a2be06266b staging: comedi: Remove useless cast.
Variable dac_data is already declared as of type u8. Again explicit type
casting of dac_data to u8, is not required. Hence this patch removes it
by using the following coccinelle script.

@@
type T;
T *ptr;
T p;
@@
(
- (T *)(&p)
+ &p
|
- (T *)ptr
+ ptr
|
- (T *)(ptr)
+ ptr
|
- (T)(p)
+ p
)

Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09 19:07:57 +01:00
Ian Abbott
08680307eb staging: comedi: ni_atmio: make device_ids const
The `device_ids[]` passed to `MODULE_DEVICE_TABLE()` should be `const`.
When the "ni_atmio" driver is built-in, gcc warns about `device_ids`
being defined but ununsed.  Make it `const`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09 14:08:58 +01:00
Ian Abbott
144113b003 staging: comedi: allow it to be built-in
There is no particular reason why comedi has to be built as kernel
modules.  Remove the `depends on m` from the Kconfig file to allow it to
be built-in.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09 14:08:58 +01:00
Cheah Kok Cheong
d1d78d2080 Staging: comedi: comedi_fops: Change comedi_num_legacy_minors type
Change to unsigned to allow removal of negative value check in
init section. Use smaller data type since the max possible
value currently is 48.

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09 14:08:58 +01:00
simran singhal
fb1e87656e staging: comedi: Replace "is is" with "is"
This patch replace "is is " with "is". The replacement couldn't be
automated because sometimes the first "is" was meant to be another
word.

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-07 20:00:22 +01:00
Cheah Kok Cheong
607b6cd3d0 Staging: comedi: drivers: comedi_test: Avoid multiple line dereference
Fix checkpatch warning "Avoid multiple line dereference"
using a pointer variable to avoid line wrap.

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06 09:16:58 +01:00
simran singhal
7dfc697124 staging: comedi: Using macro DIV_ROUND_UP
The macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /(d)).
It clarifies the divisor calculations. This occurence was detected using
the coccinelle script:

@@
expression e1;
expression e2;
@@
(
- ((e1) + e2 - 1) / (e2)
+ DIV_ROUND_UP(e1,e2)
|
- ((e1) + (e2 - 1)) / (e2)
+ DIV_ROUND_UP(e1,e2)
)

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06 09:16:58 +01:00
Tobin C. Harding
427fda4e5c staging: comedi: s626: Kernel doc format comments
Checkpatch emits WARNING: Block comments use a trailing */ on a
separate line. Offending comments are commenting variables within
the main data structure of s626 driver. We can move these comments
to kernel doc format with the benefit of clearing the warning and
improving the documentation for the driver.

Remove comments on structure members. Add original comments to the
head of the structure definition in kernel doc format.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06 09:16:58 +01:00
Ian Abbott
138bec7629 staging: comedi: jr3_pci: replace devpriv->iobase with dev->mmio
The "jr3_pci" driver currently uses the `iobase` member of its private
device data `struct jr3_pci_dev_private` to store a pointer to its
ioremapped register region.  Use the `mmio` member of the `struct
comedi_device` to store this instead, and remove the `iobase` member.
The `iobase` member was of type `struct jr3_t __iomem *`, with the
board's complicated register layout described by `struct jr3_t`.  The
`mmio` member is a generic `void __iomem *`, so its value needs
converting to a `struct jr3_t __iomem *` for our purposes.

Change the clean-up in `jr3_pci_detach()` to call `comedi_pci_detach()`
instead of `comedi_pci_disable()`, as that will iounmap `dev->mmio` for
us.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06 09:16:58 +01:00
Ian Abbott
8c8022fcd8 staging: comedi: jr3_pci: pass transform by reference
Local function `set_transforms` has a parameter of type `struct
jr3_pci_transform`.  This has a size 32 bytes, which is quite large for
passing around in a function call.  Change it to use type `const struct
jr3_pci_transform *`.  (In practice, it is probably inlined by the
compiler anyway, but doing this seems to save a few bytes.)

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06 09:16:58 +01:00
Ian Abbott
4af8c81951 staging: comedi: jr3_pci: re-work struct jr3_pci_subdev_private range
The `range` member of `struct jr3_pci_subdev_private` is an array of a
tag-less `struct` type whose layout is similar to `struct
comedi_lrange`.  Both `struct` types end with a member also called
`range`.  In the case of tag-less `struct` type, it is a single `struct
comedi_krange`.  In the case of `struct comedi_lrange`, it is a flexible
array of `struct comedi_krange`.

Elements of the `range` array member in `struct jr3_pci_subdev_private`
are pointed to by elements of the `range_table_list` array member, which
are of type `const struct comedi_lrange *`.  This requires some dodgy
type casting.

To avoid the dodgy type casting, change the element type of the `range`
member of `struct jr3_pci_subdev_private` to be a new type `union
jr3_pci_single_range`.  This contains a member `l` of type `struct
comedi_lrange`, and an array member `_reserved` that is large enough to
encompass the `struct comedi_lrange` plus a single `struct
comedi_krange`.  It is the same size as the previous type.  Accesses to
`spriv->range[i].length` and `spriv->range[i].range` are replaced with
`spriv->range[i].l.length` and `spriv->range[i].l.range[0]` respectively
(where `spriv` is a `struct jr3_pci_subdev_private *`, and `i` is an
array index).  Type-casted pointers to `spriv->range[i]` are replaced
with pointers to `spriv->range[i].l`, which do not require the type
casts.  Since we defined a new type, we can define local variables of
the corresponding pointer type to shorten some lines of code.  This is
made use of in `jr3_pci_alloc_spriv()`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06 09:16:58 +01:00
Ian Abbott
de98befe56 staging: comedi: jr3_pci: separate out poll state enum
The type of the `state` member of `struct jr3_pci_subdev_private` is
defined in-situ as an enumerated type without a tag.  For aesthetic
reasons, define the type as `enum jr3_pci_poll_state` outside the
containing `struct`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06 09:16:58 +01:00
Ian Abbott
dc5761db87 staging: comedi: jr3_pci: remove next_time_max member
The `next_time_max` member of `struct jr3_pci_subdev_private` is
assigned to, but never read.  Remove it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06 09:16:58 +01:00
Ian Abbott
67aa069d93 staging: comedi: jr3_pci: remove unneeded 'spriv' checks
If `jr3_pci_auto_attach()` returns with no error, we can now be sure
that the COMEDI subdevice private data structures have been allocated.
Remove the tests for a valid pointer to the private data structure in
`jr3_pci_ai_insn_read()`, `jr3_pci_open()`, and
`jr3_pci_poll_subdevice()`, since they will not be called if the pointer
is invalid.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06 09:16:58 +01:00
Ian Abbott
048ad49af3 staging: comedi: jr3_pci: re-work firmware copyright display
If debug messages are enabled, the card initialization done in
`jr3_pci_auto_attach()` spits out 24 (0x18) debug messages to show the
null-terminated copyright string embedded in the firmware, one character
at a time, including the ASCII NUL characters at the end.  Factor out
the copyright display into a new function `jr3_pci_show_copyright()` and
re-work it to copy the whole copyright string into a buffer, so that it
can be shown with a single debug message.

Incidentally, this also removes a checkpatch warning "Avoid multiple
line dereference" in the original code.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06 09:16:58 +01:00
Ian Abbott
47ba9b5285 staging: comedi: jr3_pci: struct comedi_lrange should normally be const
Fix three checkpatch warnings of the form:

WARNING: struct comedi_lrange should normally be const

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06 09:16:58 +01:00
Ian Abbott
800f35d773 staging: comedi: jr3_pci: Reset all DSPs
The various JR3 PCI models have from 1 to 4 DSPs, one per subdevice.
Prior to loading the firmware to all the DSPs, the initialization code
in `jr3_pci_auto_attach()` resets the first DSP.  As far as I can tell,
it should reset all of them.  Change it to do so.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06 09:16:58 +01:00
Ian Abbott
8ec04a4918 staging: comedi: jr3_pci: cope with jiffies wraparound
The timer expiry routine `jr3_pci_poll_dev()` checks for expiry by
checking whether the absolute value of `jiffies` (stored in local
variable `now`) is greater than the expected expiry time in jiffy units.
This will fail when `jiffies` wraps around.  Also, it seems to make
sense to handle the expiry one jiffy earlier than the current test.  Use
`time_after_eq()` to check for expiry.

Cc: <stable@vger.kernel.org> # 3.15+
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06 09:16:58 +01:00
Ian Abbott
45292be0b3 staging: comedi: jr3_pci: fix possible null pointer dereference
For some reason, the driver does not consider allocation of the
subdevice private data to be a fatal error when attaching the COMEDI
device.  It tests the subdevice private data pointer for validity at
certain points, but omits some crucial tests.  In particular,
`jr3_pci_auto_attach()` calls `jr3_pci_alloc_spriv()` to allocate and
initialize the subdevice private data, but the same function
subsequently dereferences the pointer to access the `next_time_min` and
`next_time_max` members without checking it first.  The other missing
test is in the timer expiry routine `jr3_pci_poll_dev()`, but it will
crash before it gets that far.

Fix the bug by returning `-ENOMEM` from `jr3_pci_auto_attach()` as soon
as one of the calls to `jr3_pci_alloc_spriv()` returns `NULL`.  The
COMEDI core will subsequently call `jr3_pci_detach()` to clean up.

Cc: <stable@vger.kernel.org> # 3.15+
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06 09:16:58 +01:00
Ingo Molnar
174cd4b1e5 sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h>
Fix up affected files that include this signal functionality via sched.h.

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-03-02 08:42:32 +01:00
Linus Torvalds
caa5942897 staging/iio driver patches for 4.11-rc1
Here is the big staging and iio driver patchsets for 4.11-rc1.
 
 We almost broke even this time around, with only a few thousand lines
 added overall, as we removed the old and obsolete i4l code, but added
 some new drivers for the RPi platform, as well as adding some new IIO
 drivers.
 
 All of these have been in linux-next for a while with no reported
 issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWK2j/w8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ymZ1ACdFR4o6xYrWEizmao4a/u+lUZE1aIAnRmcGcIc
 J+leO1n9bE5iadQvKYUW
 =sKVA
 -----END PGP SIGNATURE-----

Merge tag 'staging-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging/iio driver updates from Greg KH:
 "Here is the big staging and iio driver patchsets for 4.11-rc1.

  We almost broke even this time around, with only a few thousand lines
  added overall, as we removed the old and obsolete i4l code, but added
  some new drivers for the RPi platform, as well as adding some new IIO
  drivers.

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'staging-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (669 commits)
  Staging: vc04_services: Fix the "space prohibited" code style errors
  Staging: vc04_services: Fix the "wrong indent" code style errors
  staging: octeon: Use net_device_stats from struct net_device
  Staging: rtl8192u: ieee80211: ieee80211.h - style fix
  Staging: rtl8192u: ieee80211: ieee80211_tx.c - style fix
  Staging: rtl8192u: ieee80211: rtl819x_BAProc.c - style fix
  Staging: rtl8192u: ieee80211: ieee80211_module.c - style fix
  Staging: rtl8192u: ieee80211: rtl819x_TSProc.c - style fix
  Staging: rtl8192u: r8192U.h - style fix
  Staging: rtl8192u: r8192U_core.c - style fix
  Staging: rtl8192u: r819xU_cmdpkt.c - style fix
  staging: rtl8192u: blank lines aren't necessary before a close brace '}'
  staging: rtl8192u: Adding space after enum and struct definition
  staging: rtl8192u: Adding space after struct definition
  Staging: ks7010: Add required and preferred spaces around operators
  Staging: ks7010: ks*: Remove redundant blank lines
  Staging: ks7010: ks*: Add missing blank lines after declarations
  staging: visorbus, replace init_timer with setup_timer
  staging: vt6656: rxtx.c Removed multiple dereferencing
  staging: vt6656: Alignment match open parenthesis
  ...
2017-02-22 12:14:01 -08:00
Cheah Kok Cheong
9ff7400bd3 Staging: comedi: drivers: comedi_test: Add auto-configuration capability
Currently this module needs to be manually configured by COMEDI
userspace tool before the test waveform can be read by a COMEDI
compatible application.

This patch adds auto-configuration capability and makes it the default
loading option. This is achieved by creating a device during init
to stand in for a real hardware device. This allows comedi_auto_config()
to perform auto-configuration. With this patch, the test waveform can
be read by a COMEDI compatible application without needing manual
configuration.

Previous behaviour is still selectable via module loading parameter.
Module loading without passing any parameter will default to
auto-configuration with the same default waveform amplitude and
period values. For auto-configuration, different amplitude and
period values can be set via module loading parameters.

Tested on Xubuntu 16.04 using Xoscope ver: 2.0 which is available
in the Ubuntu repository. Xoscope is a COMEDI compatible digital
oscilloscope application. For manual configuration, only module
loading/unloading is tested.

Here are the truncated dmesg output.
[sudo modprobe comedi_test]

comedi_test: 1000000 microvolt, 100000 microsecond waveform attached
driver 'comedi_test' has successfully auto-configured 'comedi_test'.

[sudo modprobe comedi_test amplitude=2500000 period=150000]

comedi_test: 2500000 microvolt, 150000 microsecond waveform attached
driver 'comedi_test' has successfully auto-configured 'comedi_test'.

[sudo modprobe comedi_test noauto=1]

comedi_test: module is from the staging directory, the quality is unknown,
you have been warned.

For those without an actual hardware, the comedi_test module
is as close as one can get to test the COMEDI system.
Having both auto and manual configuration capability will broaden
the test function of this module.
Hopefully this will make it easier for people to check out the
COMEDI system and contribute to its development.

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-16 10:14:45 -08:00
Artur Lorincz
e3f75db14d staging: comedi: fixed multiple line dereference
Fixed multiple line dereference for &cmd->scan_begin_arg.

Signed-off-by: Artur Lorincz <larturus@yahoo.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-14 10:17:06 -08:00
Artur Lorincz
fa4508ddc3 staging: comedi: made comedi_lrange struct constant
Added the const type qualifier to the comedi_lrange structure.

Signed-off-by: Artur Lorincz <larturus@yahoo.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-14 10:17:06 -08:00
Karthik Nayak
2c9c5f5a73 staging: comedi: ni_pcimio: remove unused variable 'serial_number'
The struct 'ni_private' holds the variable 'serial_number' which post
assignment is never used. Remove the variable and code pertaining to
obtaining its value.

As a side note, this also fixes the following sparse error:
drivers/staging/comedi/drivers//ni_pcimio.c:1229:32: warning: incorrect type in assignment (different base types)
drivers/staging/comedi/drivers//ni_pcimio.c:1229:32:    expected restricted __be32 [usertype] serial_number
drivers/staging/comedi/drivers//ni_pcimio.c:1229:32:    got unsigned int

Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-14 09:08:30 -08:00
Saber Rezvani
e1ea433d6e staging: comedi: dyna_pci10xx: usleep_range is preferred over udelay
Fix the checkpatch.pl issue:
CHECK: usleep_range is preferred over udelay

Signed-off-by: Saber Rezvani <irsaber@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-14 09:08:30 -08:00
Saber Rezvani
df6ff8a1ee staging: comedi: s626: usleep_range is preferred over udelay
Fix the checkpatch.pl issue:
CHECK: usleep_range is preferred over udelay

Signed-off-by: Saber Rezvani <irsaber@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-14 09:08:30 -08:00
Saber Rezvani
020883e5e5 staging: comedi: ni_pcidio.c: Spaces preferred around operators
Fix the checkpatch.pl issue:
CHECK: spaces preferred around that '|' (ctx:VxV)

Signed-off-by: Saber Rezvani <irsaber@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-14 09:08:30 -08:00
Saber Rezvani
16cc73893f staging: comedi: ni_pcidio: blank line issues
Fix the checkpatch.pl issue:
CHECK: Please use a blank line after function/struct/union/enum
declarations

Signed-off-by: Saber Rezvani <irsaber@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-14 09:08:30 -08:00
Saber Rezvani
bc9e43ad50 staging: comedi: dmm32at: usleep_range is preferred over udelay
Fix the checkpatch.pl issue:
CHECK: usleep_range is preferred over udelay

Signed-off-by: Saber Rezvani <irsaber@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-12 13:22:08 +01:00
Saber Rezvani
4f280a69e9 staging: comedi: dt2801: usleep_range is preferred over udelay
Fix the checkpatch.pl issue:
CHECK: usleep_range is preferred over udelay

Signed-off-by: Saber Rezvani <irsaber@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-12 13:22:08 +01:00
Saber Rezvani
9fbe9b06e7 staging: comedi: dt2814: usleep_range is preferred over udelay
Fix the checkpatch.pl issue:
CHECK: usleep_range is preferred over udelay

Signed-off-by: Saber Rezvani <irsaber@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-12 13:22:08 +01:00
Saber Rezvani
1b2d7f1981 staging: comedi: dt2815: usleep_range is preferred over udelay
Fix the checkpatch.pl issue:
CHECK: usleep_range is preferred over udelay

Signed-off-by: Saber Rezvani <irsaber@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-12 13:22:08 +01:00
Saber Rezvani
8bd05c98b2 staging: comedi: ni_at_a2150: usleep_range is preferred over udelay
Fix the checkpatch.pl issue:
CHECK: usleep_range is preferred over udelay

Signed-off-by: Saber Rezvani <irsaber@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-12 13:22:08 +01:00
Ian Abbott
910f404afc staging: comedi: ni_pcimio: Support more PXI cards
Add support for NI PXI-6220, PXI-6221, PXI-6229, PXI-6250, PXI-6254,
PXI-6259, PXIe-6259, PXI-6280, PXI-6284, and PXI-6289 boards, treating
them the same as the correspondingly numbered PCI and PCIe boards (apart
from having different Comedi board name strings).  The same has
previously been done for other PXI boards supported by the driver.

The PCI device IDs for the newly supported boards come from the
"nixswv.inf" file in National Instrument's Windows drivers.

Also, sort `ni_pcimio_pci_table[]` by PCI device ID.  It is mostly
sorted already, so only the entries for PXI-6251 and PXIe-6251 need
moving.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-19 10:49:50 +01:00
Ian Abbott
0d0ad8298d staging: comedi: ni_660x: Support PCI-6224
Add support for the NI PCI-6224 board, assuming it behaves like the NI
PXI-6224 board at the register level.

The PCI device ID comes from the "nitiowv.inf" file in National
Instrument's Windows drivers.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-19 10:49:50 +01:00
Peter Zijlstra
2c935bc572 locking/atomic, kref: Add kref_read()
Since we need to change the implementation, stop exposing internals.

Provide kref_read() to read the current reference count; typically
used for debug messages.

Kills two anti-patterns:

	atomic_read(&kref->refcount)
	kref->refcount.counter

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-01-14 11:37:18 +01:00
Cheah Kok Cheong
5dc6f89da1 Staging: comedi: comedi_fops: Remove unused stat.h header
Unused after commit 6e30293976 ("staging: comedi: comedi_fops:
coding style fixes") - Fixed coding style in comedi_fops.c
Symbolic to octal permission.

Anyway it's included in module.h

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Cheah Kok Cheong
38d14bdbe7 Staging: comedi: comedi_fops: Remove unused vmalloc.h header
Unused after commit d18431325b ("staging: comedi:
deprecate loading firmware with comedi_config").

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Cheah Kok Cheong
7bfe956c78 Staging: comedi: comedi_fops: Remove redundant init.h header
After commit 0fd972a7d9 ("module: relocate module_init
from init.h to module.h"), including module.h will do and
init.h is also thrown in.

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Cheah Kok Cheong
79adc3577e Staging: comedi: comedi_fops: Remove unused kmod.h header
Unused after commit f30f2c2d41 ("staging: comedi:
remove check for CONFIG_KMOD").

Anyway it's included in module.h

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Ian Abbott
aa72f35ea6 staging: comedi: daqboard2000: use pci_id_table 'driver_data'
The driver's COMEDI "auto-attach" handler `db2k_auto_attach()` calls
`db2k_find_boardinfo()` to find an element of our board information
array `db2k_boardtypes[]` that matches the probed PCI device.  The
driver's PCI device table matches several boards in the DaqBoard/2000
series that match a single PCI vendor and device ID combination.
`db2k_find_boardinfo()` uses the probed PCI device's subvendor and
subdevice IDs to find the matching board information, returning `NULL`
for no match.

Change the driver's PCI device table `db2k_pci_table[]` to match
supported PCI vendor, device, subvendor and subdevice IDs, and set the
`.driver_data` member of each element to the index of the matching
element of `db2k_boardtypes[]`.  That index gets passed through to the
COMEDI auto-attach handler `db2k_auto_attach()`.  Use it to index
directly into `db2k_boardtypes[]` instead of calling
`db2k_find_boardinfo()` to find the match.
Use array index designators in the initializer of `db2k_boardtypes[]`.
Use enumerated constants defined by new type `enum db2k_boardids` to
name the board type indices.

The `id` member of `struct db2k_boardtype` is no longer used, so remove
it.  Also remove the subdevice ID macros `DB2K_SUBSYSTEM_IDS2` and
`DB2K_SUBSYSTEM_IDS4` as the subdevice IDs are now specified as numbers
in the PCI device table.  Remove `db2k_find_boardinfo()` as it is no
longer used.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Ian Abbott
41ab27de8f staging: comedi: daqboard2000: change COMEDI device names
The COMEDI device name strings are currently set to "ids2" for the
DaqBoard/2000, and to "ids4" for the DaqBoard/2001.  Change them to
"daqboard2000" and "daqboard2001" respectively.  (The COMEDI driver name
string is also "daqboard2000".)

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Ian Abbott
ca685dc914 staging: comedi: daqboard2000: support 4 AO channels
The driver supports DaqBoard/2000 and DaqBoard/2001. DaqBoard/2000 has 2
AO channels, but DaqBoard/2001 has 4 AO channels.  The driver currently
only supports 2 AO channels, but supporting 4 channels is just a case of
setting the `n_chan` member of the COMEDI subdevice to 4 instead of 2.

Add a new boolean flag member `has_2_ao` to `struct db2k_boardtype` to
be set to `true` if the board only has 2 AO channels.  Set this to
`true` in the element of `db2k_boardtypes[]` that corresponds to the
DaqBoard/2000.  Use it in `db2k_auto_attach()` to initialize the number
of AO channels to 2 or 4, as appropriate.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Ian Abbott
54e22bbf11 staging: comedi: daqboard2000: use designated initializers
Replace the undesignated initializers for each element of
`db2k_boardtypes[]` with an equivalent designated initializer for ease
of future maintenance.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Ian Abbott
852d3f917a staging: comedi: daqboard2000: use shorter, consistent prefix
Use a consistent prefix of `db2k_` or `DB2K_` for identifiers.  The
existing prefixes `DAQBOARD2000_` and `daqboard2000_` are a bit on the
lengthy side.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Ian Abbott
1c5a6eab8b staging: comedi: daqboard2000: remove unused 'card' member
The `card` member of `struct daqboard2000_private` and the enumerated
constant `card_daqboard_2000` are not used.  Remove them.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Ian Abbott
fba4e898b9 staging: comedi: daqboard2000: check CPLD status before writing firmware data
According to an old GPL'ed driver at
<ftp://ftp.mccdaq.com/downloads/iotech_software/DaqBoard_1000_2000_Series/Linux_driver_kernelv2.4.x/>,
The CPLD status register can be checked to make sure that it is ready to
accept the next 16-bit word of FPGA firmware data, but that doesn't work
on older versions of the CPLD, where a simple delay should be used
between successive writes.  The current version of the Comedi driver
just uses a delay between successive writes.  Change it to check for the
newer CPLD in the `daqboard2000_load_firmware()`, and change the
firmware word writing function `daqboard2000_write_cpld()` to wait for
the status bit (`DB2K_CPLD_STATUS_TXREADY`, previously called
`DB2K_CPLD_TXDONE`) to be set for newer CPLD, or just delay for older CPLD.
Return an error if it times out waiting for the status bit.

The wait for the `DB2K_CPLD_STATUS_TXREADY` status bit to be set is
performed by new function `daqboard2000_wait_cpld_txready()`, which
returns 0 if the status bit is set within 100 microseconds, or
`-ETIMEDOUT` if not.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Ian Abbott
f8d7b3b2f9 staging: comedi: daqboard2000: check result of FPGA programming
According to an old, GPL'ed Linux driver at
<ftp://ftp.mccdaq.com/downloads/iotech_software/DaqBoard_1000_2000_Series/Linux_driver_kernelv2.4.x/>,
after programming the FPGA, the General Purpose Input (USERI) of the PLX
PCI-9080 should go high shortly after a valid FPGA bitstream has been
loaded.  Add a new function `daqboard2000_wait_fpga_programmed()` to
wait for that, performing up to 200 checks over a 20 ms period (this is
loosely based on `pollFPGADone()` in the above-mentioned old driver).
Return 0 if the FPGA appears to have loaded successfully, or
`-ETIMEDOUT` if it runs out of checks.  Call it from the firmware
loading callback `daqboard2000_load_firmware()` after writing the
firmware to the FPGA to check it is programmed successfully.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Ian Abbott
7680a22729 staging: comedi: daqboard2000: change daqboard2000_write_cpld() return value
`daqboard2000_write_cpld()` currently returns 1 on success, or 0 on
failure.  Change it to return 0 on success, or `-EIO` on failure.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Ian Abbott
90bc9cb34b staging: comedi: daqboard2000: replace daqboard2000_poll_cpld()
`daqboard2000_poll_cpld()` waits for a specified status bit in the CPLD
status register to be set, giving up after 50 tries over a period of
about 5 milliseconds.  It returns 1 if the status bit is set, otherwise
0.  It is only ever called to check the "INIT" status bit.  Replace it
with new function `daqboard2000_wait_cpld_init()`, which returns 0 if
the "INIT" status bit becomes set within 50 tries, or `-ETIMEDOUT` if
not set within 50 tries.  The firmware loading callback
`daqboard2000_load_firmware()` may return the error result from
`daqboard2000_wait_cpld_init()` if it has used up all its firmware
loading attempts and that was the last error.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Ian Abbott
7cff0b776a staging: comedi: daqboard2000: check firmware length
Firmware files for DAQBoard/2000 have a header, which is skipped,
followed by a sequence of FPGA configuration bytes to be programmed in
pairs.  The FPGA configuration bytes start with the sequence 0xff, 0x20.

Make the firmware loading callback function
`daqboard2000_load_firmware()` return an error `-EINVAL` if the FPGA
start sequence is not found, or the remaining length is not a multiple
of 2.

The firmware loading callback tries to program the FPGA up to 3 times
until it succeeds or it has tried too many times.  Currently, it
searches for the FPGA start sequence in the firmware data each time
through the retry loop.  Change it to adjust the start position and
length before entering the loop.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Ian Abbott
3bc3a82390 staging: comedi: daqboard2000: use type 'u16' for CPLD data and status
The CPLD status and data registers used to load firmware are 16 bits
wide.  Use the type `u16` to represent data and status values instead of
`int`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Ian Abbott
1736bcf3c5 staging: comedi: daqboard2000: define macros for CPLD registers
The Daqboard/2000 uses a write-only data register and a read-only status
register in a pre-programmed CPLD device to program the main firmware on
the board.  Both registers are at offset 0x1000 from PCI BAR 2.  Define
macros for the register offsets.  Rename the existing macros for the
status register values for consistency.  (Two status bits are defined,
but the driver code only seems to use one of them.)

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Ian Abbott
1d7f14dd92 staging: comedi: daqboard2000: use macros from "plx9080.h"
The Daqboard/2000 uses a PLX PCI-9080 chip to interface with the PCI
bus.  The "daqboard2000" driver uses the PCI-9080 "CNTRL" register to
perform various tasks, but defines its own macros for the register
values.  Use the macros from "plx9080.h" instead.  The various functions
that change the CNTRL register just wiggle individual bits up and down,
but they ignore the current register value - the old macros defined the
full value to be written to the register.  Change them to read and
modify the register value.

Also remove a read of the CNTRL register in `daqboard2000_auto_attach()`
where the value is just thrown away, as it seems to serve no purpose
there (such as flushing PCI writes).

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-10 17:38:32 +01:00
Cheah Kok Cheong
2e4b5cd641 Staging: comedi: proc: Warn if unable to create proc entry
The proc entry is not essential for the comedi system as
evident by the support for !CONFIG_PROC_FS. So for failure
to create, just warn and continue loading.

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:30:21 +01:00
Cheah Kok Cheong
6bd68e29b6 Staging: comedi: proc: Add module owner
Since this is a loadable kernel module, add module ownership
to follow LKM semantics.

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:30:21 +01:00
Cheah Kok Cheong
ec0bff06bb Staging: comedi: proc: Add __init prefix
Add __init prefix so that symbol will be discarded after
module loading.

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:30:21 +01:00
Cheah Kok Cheong
5f52f319cd Staging: comedi: proc: Change file permission to read only
As there's no write operation, change to read only.
Was inadvertantly switched to 0644 in commit 1f817b86d5
("comedi: Don't use create_proc_read_entry()").

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:30:21 +01:00
Cheah Kok Cheong
bf279ece37 Staging: comedi: comedi_fops: Avoid orphaned proc entry
Move comedi_proc_init to the end to avoid orphaned proc entry
if module loading failed.

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:30:21 +01:00
Cheah Kok Cheong
3358a0ca21 Staging: comedi: comedidev.h: Drop old style zero-length array
According to Documentation/Changes, the minimum gcc version required
to compile the kernel is 3.2 (this is probably outdated too).

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:29:06 +01:00
Saber Rezvani
3c4a2d9e25 staging: comedi: ni_670x: using the BIT(x) macro
Fix the checkpatch.pl issue:
CHECK: Prefer using the BIT macro
replacing bit shifting on 1 with the BIT(x) macro.

Signed-off-by: Saber Rezvani <irsaber@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:29:06 +01:00
Saber Rezvani
8f2ee91256 staging: comedi: ni_at_ao: using the BIT(x) macro
Fix the checkpatch.pl issue:
CHECK: Prefer using the BIT macro
replacing bit shifting on 1 with the BIT(x) macro.

Signed-off-by: Saber Rezvani <irsaber@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:29:06 +01:00
Saber Rezvani
db30e33f4a staging: comedi: cb_pcidas64: use preferred kernel type u32
Fix the checkpatch.pl issue:
CHECK: Prefer kernel type 'u32' over 'uint32_t'

Signed-off-by: Saber Rezvani <irsaber@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:29:06 +01:00
Saber Rezvani
9e23afed35 staging: comedi: cb_pcidas64: use preferred kernel type u16
Fix the checkpatch.pl issue:
CHECK: Prefer kernel type 'u16' over 'uint16_t'

Signed-off-by: Saber Rezvani <irsaber@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:29:06 +01:00
Saber Rezvani
7afd6d2179 staging: comedi: cb_pcidas64: use preferred kernel type u8
Fix the checkpatch.pl issue:
CHECK: Prefer kernel type 'u8' over 'uint8_t'

Signed-off-by: Saber Rezvani <irsaber@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:29:06 +01:00
Ian Abbott
9fe3b628e6 staging: comedi: comedidev.h: add identifiers to function parameters
Fix checkpatch.pl warnings of the form "function definition argument
'foo' should also have an identifier name".

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:27:55 +01:00
Ian Abbott
1016d5a6c2 staging: comedi: comedi_usb.h: add identifiers to function parameters
Fix checkpatch.pl warnings of the form "function definition argument
'foo' should also have an identifier name".

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:27:55 +01:00
Ian Abbott
514871ef43 staging: comedi: comedi_pcmcia.[ch]: add identifiers to function parameters
Fix checkpatch.pl warnings of the form "function definition argument
'foo' should also have an identifier name".

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:27:55 +01:00
Ian Abbott
751922da90 staging: comedi: comedi_internal.h: add identifiers to function parameters
Fix checkpatch.pl warnings of the form "function definition argument
'foo' should also have an identifier name".

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:27:55 +01:00
Ian Abbott
7885bc8389 staging: comedi: comedi_compat32.h: add identifiers to function parameters
Fix checkpatch.pl warnings of the form "function definition argument
'foo' should also have an identifier name".

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:27:55 +01:00
Ian Abbott
bef966264b staging: comedi: ni_tio_internal.h: add identifiers to function parameters
Fix checkpatch.pl warnings of the form "function definition argument
'foo' should also have an identifier name".

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:27:55 +01:00
Ian Abbott
d83889a87b staging: comedi: ni_tio.h: add identifiers to function parameters
Fix checkpatch.pl warnings of the form "function definition argument
'foo' should also have an identifier name".

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:27:55 +01:00
Ian Abbott
13938181e2 staging: comedi: ni_labpc.h: add identifiers to function parameters
Fix checkpatch.pl warnings of the form "function definition argument
'foo' should also have an identifier name".

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:27:55 +01:00
Ian Abbott
22d3c2ca82 staging: comedi: mite.h: add identifiers to function parameters
Fix checkpatch.pl warnings of the form "function definition argument
'foo' should also have an identifier name".

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:27:55 +01:00
Ian Abbott
81735efcc9 staging: comedi: comedi_isadma.h: add identifiers to function parameters
Fix checkpatch.pl warnings of the form "function definition argument
'foo' should also have an identifier name".

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:27:55 +01:00
Ian Abbott
00b298544c staging: comedi: comedi_8254.h: add identifiers to function parameters
Fix checkpatch.pl warnings of the form "function definition argument
'foo' should also have an identifier name".

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:27:55 +01:00
Ian Abbott
cf9781131b staging: comedi: addi_watchdog.h: add identifiers to function parameters
Fix checkpatch.pl warnings of the form "function definition argument
'foo' should also have an identifier name".

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:27:54 +01:00
Piotr Gregor
e9f363c014 drivers: staging: comedi: fix function prototypes
Add names of parameters to function prototypes in comedi PCI.
Checkpatch reports now no errors.

Signed-off-by: Piotr Gregor <piotrgregor@rsyncme.org>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 15:27:12 +01:00
Ian Abbott
3e0f9b2ca8 staging: comedi: comedidev.h: Document usage of 'detach' handler
Document when the "detach" handler function pointed to by the `detach`
member of a `struct comedi_driver` is called by the comedi core, and how
the "attach" and "auto_attach" handlers can defer clean-up to it when
they return an error to the comedi core.  This is already mentioned as
part of the documentation for `comedi_auto_config()`, but is useful to
document it for `struct comedi_driver` as well, since
`comedi_auto_config()` is not usually called directly by low-level
comedi drivers, and it is not called at all for "legacy" comedi devices
that are configured manually.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-12-08 21:01:23 +01:00