Commit Graph

362727 Commits

Author SHA1 Message Date
Jin Feng
ff3fc8eb47 staging:iio:dummy: Fix mismatch and export sysfs entry
Correct the mismatch bewteen calibscale and calibbias, and export
the in_accel_calibscale sysfs entry

Updated to apply to current tree.

Signed-off-by: Jin Feng <jin88.feng@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-04-09 18:29:52 +01:00
Luck, Tony
9f16778c5d staging:iio:adt7316 Fix some 'interesting' string operations
Calling memcmp() to check the value of the first byte in a string is overkill.
Just use buf[0] == '1' or buf[0] != '1' as appropriate.

Signed-off-by: Tony Luck <tony.luck@intel.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-04-09 18:29:02 +01:00
H Hartley Sweeten
5993f3a269 staging: comedi: remove unnecessary dev->board_name initialization
The dev->board_name is now initialized by the comedi core before calling
the(*attach) or (*auto_attach) function in a driver. As long as the driver
does no additional probing, it's no longer necessary initialize the board_name.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 11:44:07 -07:00
H Hartley Sweeten
46c58127ad staging: comedi: comedi_pci: dev->board_name is always valid
The dev->board_name is always initialized before calling the(*attach)
or (*auto_attach) function. It's no longer necessary to validate the
pointer in comedi_pci_enable().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 11:39:19 -07:00
H Hartley Sweeten
ae5dd5fcab staging: comedi: drivers: dev->board_name is always valid
The dev->board_name is always initialized before calling the(*attach)
or (*auto_attach) function. The "BUG" check in comedi_device_postconfig()
is no longer necessary.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 11:39:19 -07:00
H Hartley Sweeten
34b68400ee staging: comedi: drivers: set dev->board_name before attaching
The comedi (*attach) and (*auto_attach) functions are used to attach
legacy and PnP type devices to the comedi subsystem. If we can set the
dev->board_name before doing the attach, the drivers will not have to
worry about doing it.

Drivers that do additional probing can still change the dev->board_name
if necessary.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 11:39:19 -07:00
H Hartley Sweeten
6013a9a57b staging: comedi: drivers: rename 'comedi_dev' in comedi_auto_config()
The struct comedi_device pointer in this file, and the rest of the
comedi subsystem, is typically called 'dev'. Rename the local variable
'comedi_dev' in comedi_auto_config() for consistency.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 11:39:19 -07:00
Eduardo Valentin
262235b13c staging: ti-soc-thermal: fix device removal
While removing, the device needs to unregister
the sensor from thermal framework. Before
calling the call back the driver needs to check
if the call back is registered. This patch
fix the check by checking the right callback.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:35:09 -07:00
Eduardo Valentin
f155333423 staging: ti-soc-thermal: defer probe if cpufreq is not ready
When builtin compiled, there is a chance for this driver
be probed before cpufreq driver is up and running. In this
case, the cpucooling device can be wrong initialized.

Thus, this patch makes sure this driver is probed only
when cpufreq driver is ready. Whenever there is no
cpufreq driver registered, the probe will return -EPROBE_DEFER.

Tested-by: J Keerthy <j-keerthy@ti.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:35:08 -07:00
Eduardo Valentin
537eb9364c staging: ti-soc-thermal: remove extrapolation rules from TODO
Extrapolation rules have been revisited.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:35:08 -07:00
Eduardo Valentin
21bf220211 staging: ti-soc-thermal: update OMAP5 extrapolation rules
Update the constants to the correct hotspot extrapolation
equation constants. OMAP4 constants are revisited and correct.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:35:08 -07:00
Eduardo Valentin
b763fdaeae staging: ti-soc-thermal: introduce OMAP4430 extrapolation constants
This patch defines and utilizes the extrapolation constants for OMAP4430.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:35:08 -07:00
Eduardo Valentin
0359090ea7 staging: ti-soc-thermal: Remove TC1/TC2 TODO (already done)
TC1/TC2 are not needed anymore, API has been upgraded.
This is a TODO left-over.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:35:08 -07:00
Eduardo Valentin
67b4c47422 staging: ti-soc-thermal: fix min/max TODO (already done)
Min/Max cooling state are defined by registration helper
function, if no specific limits are passed. No need to change
this code.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:35:08 -07:00
Eduardo Valentin
2c014c841e staging: ti-soc-thermal: update TODO list
This patch removes out of the TODO list those already completed.

Here is the status and why they are removed:
 on ti-bandgap.c:
-- Add support to hwmon: REMOVED, no need to have hwmon interfaces as
   the control is done via thermal framework.
-- Test every exposed API to userland: DONE, via thermal fw APIs
   By now, no specific API is exposed by this driver
-- Revisit data structures and simplify them: DONE, all
   unused fields are flagged for future removal.
-- Once SCM-core api settles, update this driver accordingly: DONE,
   the BG driver can exist without SCM driver by ioremapping its own
   registers and doing its own locking.

 on ti-thermal-common.c/ti-thermal.h:
-- Revisit trips and its definitions: DONE, for now there is no
   need to change current definition. Alert based policy will be add
   in future.
-- Revisit trending: DONE, OMAP5 history buffer support has been
   implemented. Devices without history buffer will use thermal fw
   trending capability.

on omap5-thermal.c
-- Add support for GPU cooling: REMOVED: this will not be part
   of this driver. Must be done in a separated cooling device.

 generally:
-- make checkpatch.pl and sparse happy: DONE, sparse remaining
   warning is not an issue.
-- update documentation: DONE, kernel-doc for ti-bandgap is now
   available.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:35:08 -07:00
Valentin Ilie
dd7cc7e418 staging/fwserial: Replace seq_printf with seq_puts
Fix checkpatch warning about seq_printf.

Signed-off-by: Valentin Ilie <valentin.ilie@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:32:53 -07:00
Chen Gang
f1159d7cc0 Drivers: Staging: cxt1e1: strncpy issue, need set zero at the end.
need set '\0' at the end. or cause issue.

    it is called by c4_ioctl in drivers/staging/cxt1e1/linux.c
    all things need be initialized, before provide them to user mode.
    so we can not use strlcpy instead of strncpy.

  code style:
    all contents of the file use 4 spaces instead of '\t',
    so this patch has to follow, now.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:32:53 -07:00
H Hartley Sweeten
e8e1560a02 staging: comedi: ni_at_a2150: remove 'thisboard' macro
The 'thisboard' macro relies on a local variable having a specific
name and yields a pointer derived from that local variable.

Replace the macro with local variables and use the comedi_board()
helper to get the pointer.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:29:59 -07:00
H Hartley Sweeten
a56ec2fe66 staging: comedi: dt282x: remove 'boardtype' macro
The 'boardtype' macro relies on a local variable having a specific
name and yields a struct derived from that local variable.

Replace the macro with local variables and use the comedi_board()
helper to get the struct as a pointer. Use pointer access when
using the variable.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:29:59 -07:00
H Hartley Sweeten
23e79f81ad staging: comedi: dt2801: remove 'boardtype' macro
The 'boardtype' macro relies on a local variable having a specific
name and yields a struct derived from that local variable.

Replace the macro with local variables and use the comedi_board()
helper to get the struct as a pointer. Use pointer access when
using the variable.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:29:59 -07:00
H Hartley Sweeten
3cb65d4d9d staging: comedi: das800: remove 'thisboard' macro
The 'thisboard' macro relies on a local variable having a specific
name and yields a pointer derived from that local variable.

Replace the macro with local variables and use the comedi_board()
helper to get the pointer.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:29:59 -07:00
H Hartley Sweeten
fef2aa646f staging: comedi: das1800: remove 'thisboard' macro
The 'thisboard' macro relies on a local variable having a specific
name and yields a pointer derived from that local variable.

Replace the macro with local variables and use the comedi_board()
helper to get the pointer.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:29:58 -07:00
H Hartley Sweeten
9876d566f2 staging: comedi: serial2002: remove #if 0'ed out code
This function is not used. Just remove it.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:27:45 -07:00
H Hartley Sweeten
7e32f5ada5 staging: comedi: serial2002: remove pr_err() noise in serial2002_read()
This pr_err() is just added noise, the user can't do anything about it.
Just remove it.

Since this is the only pr_level() message in the driver, also remove
the pr_fmt() macro.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:27:45 -07:00
H Hartley Sweeten
a058be68bd staging: comedi: serial2002: rename all the static functions
Many of the static functions in this driver have names that could
potentially clash with external symbols (tty_ioctl, tty_write, etc.).

Rename all the static functions so they have a 'serial2002_' prefix
to avoid any issues.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:27:44 -07:00
H Hartley Sweeten
e7ccc452b2 staging: comedi: serial2002: hookup the (*open) and (*close) last
For aesthetic reasons, hookup the comedi_device (*open) and (*close)
functions after everything else in the attach has succeeded.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:27:44 -07:00
H Hartley Sweeten
81c01c3fb8 staging: comedi: serial2002: return 0 after successful attach
A return value of >=0 indicates a successful attach to the comedi core.
Return 0 since that is more common in the kernel.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:27:44 -07:00
H Hartley Sweeten
8399965210 staging: comedi: serial2002: remove attach dev_dbg() noise
This is just added noise. Remove it.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:27:44 -07:00
H Hartley Sweeten
adbd1741a5 staging: comedi: serial2002: add some whitespace to the subdevice init
To improve the readability, add some whitespace to the subdevice
init.

Also, for aesthetic reasons and the help with greps, rename the
(*insn_{read,write}) functions.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:27:44 -07:00
H Hartley Sweeten
fd47579ba0 staging: comedi: serial2002: don't assume the number of subdevices to detach
Use the number of subdevices allocated (dev->n_subdevices) in the
(*detach) instead of assuming a given number.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:27:44 -07:00
H Hartley Sweeten
ee422bb687 staging: comedi: serial2002: cleanup serial2002_setup_subdevs()
Define and document the bit shifts of the serial.data read from
the device that is used to configure the subdevice channels.

Use the new defines to tidy up the configuration process.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:27:43 -07:00
H Hartley Sweeten
623a73926c staging: comedi: serial2002: split up serial_2002_open()
Split out the code that sets up the comedi subdevices that are
attached to the serial port.

There are actually two steps:

1) Read the configuration of the attached subdevices.
2) Use the configuration data to setup the comedi subdevices.

Step 1 is split out as serial2002_setup_subdevs().
Step 2 is split out as serial2002_setup_subdevice().

Cleanup the split out code to remove all the extra '{ }' and indents.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:27:43 -07:00
H Hartley Sweeten
761a38a4e7 staging: comedi: serial2002: cleanup serial_read()
Remove the unnecessary '{ }' around the code and the extra indents
in the switch().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:27:43 -07:00
H Hartley Sweeten
071e0866d2 staging: comedi: serial2002: cleanup tty_setspeed()
Rename the two local variables used to set the serial port speed
and latency so thy are unique.

Remove the unnecessary '{ }' around the code and the extra indents.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:27:43 -07:00
H Hartley Sweeten
0a245982e6 staging: comedi: serial2002: factor (*poll) busy wait out of tty_read()
Factor the (*poll) busy wait code out of tty_read() so the indent
level can be reduced and tty_read() is a bit cleaner.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:27:43 -07:00
H Hartley Sweeten
32ef0e3e30 staging: comedi: serial2002: fix different address space sparse warnings
The struct file_operations (*read) and (*write) operations expect the
buffer to be a __user space pointer.

Currently the (*write) operations in this driver cause this warning:
warning: incorrect type in argument 2 (different address spaces)
  expected char const [noderef] <asn:1>*<noident>
  got unsigned char [usertype] *buf

And the (*read) operations cause this warning:
warning: incorrect type in argument 2 (different address spaces)
  expected char [noderef] <asn:1>*<noident>
  got unsigned char *<noident>

Use __force to cast the buffer to a __user pointer to suppress the
warnings.

Consolidate the (*read) calls into a helper function, __tty_readb().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:27:43 -07:00
Masanari Iida
4445d254cd staging:csr: Fix typo in staging/csr driver
Correct spelling typo in comment within staging/csr

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:22:50 -07:00
Lars-Peter Clausen
bc73488cb7 staging: cptm1217: Use dev_pm_ops
Use dev_pm_ops instead of the deprecated legacy suspend/resume callbacks.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-08 10:20:16 -07:00
Valentin Ilie
c6ac992b8f staging: speakup: selection.c fix typo in comment
Replace disallocated with deallocated

Signed-off-by: Valentin Ilie <valentin.ilie@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-05 15:03:09 -07:00
Ian Abbott
db210da268 staging: comedi: add comedi_clear_board_dev()
Add local function `comedi_clear_board_dev()` as a safer alternative to
`comedi_clear_board_minor()` when we already have a pointer to a `struct
comedi_device`.  It uses the board minor device number stored in the
`struct comedi_device` (which must have already been initialized) and
only clears the entry in `comedi_board_minor_table[]` if it points to
the specified `struct comedi_device`.  Rather than returning the old
table entry, it returns `true` if the entry matched (and so has just
been cleared) and returns `false` otherwise.

Call `comedi_clear_board_dev()` instead of `comedi_clear_board_minor()`
in `comedi_unlocked_ioctl()` (in the code that frees a dynamically
allocated comedi device detached by the `COMEDI_DEVCONFIG` ioctl).  That
ought to return `true` but check it just in case before freeing the
device.  There is still a race condition here which needs to be dealt
with once we've implemented reference counting for `struct
comedi_device`s.

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>
2013-04-05 14:33:29 -07:00
Ian Abbott
c6f5b4d587 staging: comedi: remove struct comedi_file_info
`struct comedi_file_info` is no longer used so remove it.

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>
2013-04-05 14:33:27 -07:00
Ian Abbott
cb6b79dedb staging: comedi: simplify comedi_board_minor_table[]
`comedi_alloc_board_minor()` allocates and initializes a `struct
comedi_file_info` and a `struct comedi_device`, and assigns a board
minor device number (if there are any available), storing a pointer to
the allocated `struct comedi_file_info` in
`comedi_board_minor_table[minor]` where `minor` is the board minor
device number.

There is no longer anything useful in the `struct comedi_file_info`
apart from the pointer to the `struct comedi_device` that was allocated,
so the `struct comedi_file_info` is superfluous.

Change `comedi_board_minor_table[]` to hold pointers to the actual
`struct comedi_device`'s.  `comedi_alloc_board_minor()` no longer needs
to allocate a `struct comedi_file_info`.  Replace
`comedi_free_board_file_info()` with `comedi_free_board_dev()` with its
parameter pointing to the `struct comedi_device` to be freed (there is
no longer a `struct comedi_file_info` to be freed).

There are consequential changes to `comedi_dev_from_board_minor()`,
`comedi_clear_board_minor()` (which now returns a `struct comedi_device
*`), `comedi_free_board_minor()`, `comedi_release_hardware_device()` and
`comedi_unlocked_ioctl()` (when dealing with detachment of a dynamically
allocated comedi device by the `COMEDI_DEVCONFIG` ioctl).

`comedi_dev_from_file_info()` is no longer used as a result of the above
changes so remove it.

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>
2013-04-05 14:33:21 -07:00
Ian Abbott
bd5b4173d5 staging: comedi: simplify comedi_subdevice_minor_table[]
`comedi_alloc_subdevice_minor()` allocates and initializes a `struct
comedi_file_info` and assigns a subdevice minor device number (if there
are any available), storing a pointer to the allocated `struct
comedi_file_info` in `comedi_subdevice_minor_table[i]` where `i` is the
array index corresponding to the subdevice minor device number (indexed
by subdevice minor device number minus `COMEDI_NUM_BOARD_MINORS`).

The information stored in the `struct comedi_file_info` can be derived
from the subdevice structure (`struct comedi_subdevice`) itself, so the
`struct comedi_file_info` is superfluous.

Change `comedi_subdevice_minor_table[]` to hold pointers to the actual
`struct comedi_subdevice`'s.  `comedi_alloc_subdevice_minor()` no longer
needs to allocate a `struct comedi_file_info` and
`comedi_free_subdevice_info()` no longer has a `struct comedi_file_info`
to free.

Replace `comedi_file_info_from_minor()` with
`comedi_subdevice_from_minor()`, returning a (possibly NULL) pointer to
a `struct comedi_subdevice` from the table.  This has knock-on effects
for `comedi_dev_from_subdevice_minor()`, `comedi_read_subdevice()` and
`comedi_write_subdevice()`.  In particular, `comedi_read_subdevice()`
and `comedi_write_subdevice()` now need to check the subdevice flags to
see if the determine whether to override the comedi device's default
read/write subdevice.

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>
2013-04-05 14:33:21 -07:00
Ian Abbott
dac59de2dd staging: comedi: remove comedi_file_info_from_board_minor()
Merge the code from `comedi_file_info_from_board_minor()` into
`comedi_dev_from_board_minor()` and remove it since nothing else calls
it.

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>
2013-04-05 14:33:21 -07:00
Ian Abbott
0fcc9d48a0 staging: comedi: remove comedi_clear_subdevice_minor()
Merge the code from `comedi_clear_subdevice_minor()` into
`comedi_free_subdevice_minor()` and remove it since nothing else calls
it.

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>
2013-04-05 14:33:21 -07:00
Ian Abbott
f3abc83138 staging: comedi: refactor comedi_dev_from_minor()
Refactor `comedi_dev_from_minor()` to call one of two new functions
`comedi_dev_from_board_minor()` (for minor device numbers less than
`COMEDI_NUM_BOARD_MINORS`) or `comedi_dev_from_subdevice_minor()` (for
minor device numbers greater than or equal to `COMEDI_NUM_BOARD_MINORS`,
which are subdevice minor device numbers).

Remove `comedi_file_info_from_minor()` as it is no longer used.

This is a step towards removing `struct comedi_file_info`.

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>
2013-04-05 14:33:20 -07:00
Ian Abbott
5e04c25435 staging: comedi: reduce use of struct comedi_file_info
Since the parameters of `comedi_read_subdevice()` and
`comedi_write_subdevice()` have changed, there is no longer a need to
keep a local variable `struct comedi_file_info *info` hanging around in
the file operation functions and device attribute access functions.
Remove the variable from those function and replace the call sequence
`info = comedi_file_info_from_minor(minor)`,  `dev =
comedi_dev_from_file_info(info)` with the simpler `dev =
comedi_dev_from_minor(minor)`.

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>
2013-04-05 14:33:20 -07:00
Ian Abbott
da56fdc6cd staging: comedi: change comedi_read/write_subdevice() parameters
`comedi_read_subdevice()` and `comedi_write_subdevice()` currently take
a single parameter pointing to a `struct comedi_file_info`.  I'm trying
to get rid of `struct comedi_file_info` so as part of that plan,
`comedi_read_subdevice()` and `comedi_write_subdevice()` need to change.
Change them to take two parameters: a pointer to a `struct
comedi_device` and a minor device number.  If the minor device number is
a "board" minor device number (`minor < COMEDI_NUM_BOARD_MINORS`) we'll
always return the default read or write subdevice.  If the minor device
number if a "subdevice" minor device number a different read or write
subdevice may be returned.  In that case, use the subdevice minor device
number to look up the information about whether the default read or
write subdevice needs to be overridden.

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>
2013-04-05 14:33:20 -07:00
Ian Abbott
c88db46908 staging: comedi: use minor device number in attribute functions
The comedi device attribute functions such as
`show_max_read_buffer_kb()` call `dev_get_drvdata()` to get a pointer to
a `struct comedi_file_info` from the private driver data field of class
device.  Change them to use the minor device number to look up this
pointer value so they behave more like the file operation functions.
Check the pointer is non-NULL as the entry in the minor device table
could have been set to NULL.  Note that there is still a race condition
in the use of this pointer value after acquiring the mutex which needs
to be dealt with once reference counting has been implemented for comedi
devices.

The calls to `dev_set_drvdata()` from `comedi_alloc_board_minor()` and
`comedi_alloc_subdevice_minor()` are no longer needed so 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>
2013-04-05 14:33:20 -07:00
Ian Abbott
7f4656c5f7 staging: comedi: get mutex before subdevice in attribute functions
The comedi device attribute functions such as
`show_read_buffer_kb()` or `show_write_buffer_kb()` call
`comedi_read_subdevice()` or `comedi_write_subdevice()` without
acquiring the comedi device's mutex first, although the functions do
acquire the mutex afterwards.  Change them to acquire the mutex first.
This is consistent with most of the comedi device file operation
functions (apart from `comedi_read()` and `comedi_write()` which
probably need looking at).

Despite the use of the mutex, there are still race conditions as the
`struct comedi_file_info *info` variable value set before acquiring the
mutex could be stale after acquiring the mutex.  This problem will be
dealt with once reference counting has been implemented for the comedi
devices.

This patch also adds local variable `struct comedi_device *dev` to the
functions to reduce the use of the `info` variable a little bit.

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>
2013-04-05 14:33:20 -07:00