]> Pileus Git - ~andy/linux/log
~andy/linux
11 years agostaging: comedi: rti800: tidy up CR_{CHAN,RANGE} usage
H Hartley Sweeten [Tue, 9 Apr 2013 01:19:41 +0000 (18:19 -0700)]
staging: comedi: rti800: tidy up CR_{CHAN,RANGE} usage

The insn->chanspec passed to the CR_{CHAN,RANGE} macros is an unsigned
int. For aesthetic reasons, put the result of the macros into an
unsigned int local var.

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>
11 years agostaging: comedi: rti800: tidy up rti800_ao_insn_read()
H Hartley Sweeten [Tue, 9 Apr 2013 01:19:23 +0000 (18:19 -0700)]
staging: comedi: rti800: tidy up rti800_ao_insn_read()

For aesthetic reasons, tidy up the parameters passed to this function.

The comedi core expects (*insn_read) functions to return the number
of data values actually read (insn->n). Change the return to make
clearer.

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>
11 years agostaging: comedi: rti800: fix rti800_ao_insn_write()
H Hartley Sweeten [Tue, 9 Apr 2013 01:19:06 +0000 (18:19 -0700)]
staging: comedi: rti800: fix rti800_ao_insn_write()

This board has two independent analog output channels. Each channel
has its own 12-bit D.A converter. Each channel can be set to output
a unipolar 10V or bipolar 10V signal. This selection is handled by
a jumper on the board and configured by the user with options[5] and
[7] passed during the attach of the board.

The two channels can also be configured with jumpers to use straight
binary or two's complement data. The user configures the data type
with options[6] and [8] when attaching.

Currently, this driver uses the dac0 selection, option[6], for both
channels. Fix the rti800_ao_insn_write() function to properly use
the configuration specified by the user.

Change the dac[01]_coding in the private data to a simple bool
array, dac_2comp.

Add some local vars to hold the registers offsets needed to write
to the DAC.

Only the last value written to the DAC needs to be cached for readback,

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>
11 years agostaging: comedi: rti800: tidy up rti800_di_insn_bits()
H Hartley Sweeten [Tue, 9 Apr 2013 01:18:44 +0000 (18:18 -0700)]
staging: comedi: rti800: tidy up rti800_di_insn_bits()

For aesthetic reasons, tidy up the parameters passed to this
function.

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>
11 years agostaging: comedi: rti800: tidy up rti800_do_insn_bits()
H Hartley Sweeten [Tue, 9 Apr 2013 01:18:26 +0000 (18:18 -0700)]
staging: comedi: rti800: tidy up rti800_do_insn_bits()

To clarify the function a bit, add local variables for the 'mask'
and 'bits', passed by the comedi core, used to update the digital
outputs.

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>
11 years agostaging: comedi: rti800: add some whitespace to the subdevice init
H Hartley Sweeten [Tue, 9 Apr 2013 01:18:07 +0000 (18:18 -0700)]
staging: comedi: rti800: add some whitespace to the subdevice init

For aesthetic reasons, add some whitespace to the subdevice init
to make it more readable.

Remove the commented out init of subdevice 4, it's not allocated.
Add a comment about 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>
11 years agostaging: comedi: rti800: use arrays to hold the ai/ao ranges
H Hartley Sweeten [Tue, 9 Apr 2013 01:17:43 +0000 (18:17 -0700)]
staging: comedi: rti800: use arrays to hold the ai/ao ranges

The analog in/analog out ranges are selected by the user using options
passed during the legacy attach. Put the valid ranges into arrays and
use those instead of the switch () statements when initializing the
subdevice range information.

If the passed user option is not valid, set the range information to
range_unknown.

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>
11 years agostaging: comedi: rti800: remove dac[01]_range from private data
H Hartley Sweeten [Tue, 9 Apr 2013 01:17:22 +0000 (18:17 -0700)]
staging: comedi: rti800: remove dac[01]_range from private data

The 'dac[01]_range' is only used in the attach of the board. Remove
it from the private data.

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>
11 years agostaging: comedi: rti800: remove adc_range from private data
H Hartley Sweeten [Tue, 9 Apr 2013 01:17:01 +0000 (18:17 -0700)]
staging: comedi: rti800: remove adc_range from private data

The 'adc_range' is only used in the attach of the board. Remove it
from the private data.

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>
11 years agostaging: comedi: rti800: remove adc_mux from private data
H Hartley Sweeten [Tue, 9 Apr 2013 01:16:42 +0000 (18:16 -0700)]
staging: comedi: rti800: remove adc_mux from private data

The 'adc_mux' is only used in the attach of the board. Remove it
from the private data.

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>
11 years agostaging: comedi: rti800: move the comedi_alloc_subdevices()
H Hartley Sweeten [Tue, 9 Apr 2013 01:16:22 +0000 (18:16 -0700)]
staging: comedi: rti800: move the comedi_alloc_subdevices()

For aesthetic reasons, move the call to comedi_alloc_subdevices()
so it occurs right before the subdevice init.

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>
11 years agostaging: comedi: rti800: remove interrupt code
H Hartley Sweeten [Tue, 9 Apr 2013 01:16:03 +0000 (18:16 -0700)]
staging: comedi: rti800: remove interrupt code

Interrupts are not enabled, or used, in this driver. Remove the
{request,free}_irq() as well as the dummy interrupt function.

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>
11 years agostaging: comedi: rti800: cleanup dev->board_name usage
H Hartley Sweeten [Tue, 9 Apr 2013 01:15:46 +0000 (18:15 -0700)]
staging: comedi: rti800: cleanup dev->board_name usage

The comedi core initializes the dev->board_name before calling the
driver (*attach) function. There is not reason to reinitialize it
in the driver.

Use the dev->board_name when doing the request_{region,irq}() instead
of the open-coded string.

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>
11 years agostaging: comedi: rti800: remove board attach kernel noise
H Hartley Sweeten [Tue, 9 Apr 2013 01:15:27 +0000 (18:15 -0700)]
staging: comedi: rti800: remove board attach kernel noise

The printk's during the bard attach are just added noise. Remove
them.

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>
11 years agostaging: comedi: rti800: remove the 'fingerprint' debug printk
H Hartley Sweeten [Tue, 9 Apr 2013 01:15:07 +0000 (18:15 -0700)]
staging: comedi: rti800: remove the 'fingerprint' debug printk

Remove the debug noise that outputs the board 'fingerprint' during
the attach.

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>
11 years agostaging: comedi: rti800: remove '0' boardinfo data
H Hartley Sweeten [Tue, 9 Apr 2013 01:14:45 +0000 (18:14 -0700)]
staging: comedi: rti800: remove '0' boardinfo data

Remove the boardinfo data that is set to '0', this is the default.

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>
11 years agostaging: comedi: rti800: cleanup boardinfo
H Hartley Sweeten [Tue, 9 Apr 2013 01:14:28 +0000 (18:14 -0700)]
staging: comedi: rti800: cleanup boardinfo

For aesthetic reasons, move the boardinfo table near the struct
definition. Reformat the boardinfo in C99 format and add some
whitespace to help readability.

Rename the boardinfotable so it has namespace associated with
the driver.

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>
11 years agostaging: comedi: rti800: remove forward declaration
H Hartley Sweeten [Tue, 9 Apr 2013 01:14:05 +0000 (18:14 -0700)]
staging: comedi: rti800: remove forward declaration

This forward declaration is not needed.

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>
11 years agostaging: comedi: rti800: cleanup comedi_lrange tables
H Hartley Sweeten [Tue, 9 Apr 2013 01:13:46 +0000 (18:13 -0700)]
staging: comedi: rti800: cleanup comedi_lrange tables

Cleanup the whitespace in the comedi_lrange tables.

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>
11 years agostaging: comedi: acl7225b: Update the MODULE_DESCRIPTION
H Hartley Sweeten [Mon, 8 Apr 2013 21:32:05 +0000 (14:32 -0700)]
staging: comedi: acl7225b: Update the MODULE_DESCRIPTION

Update the MODULE_DESCRIPTION to better describe the driver.

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>
11 years agostaging: comedi: acl7225b: cleanup acl7225b_di_insn_bits()
H Hartley Sweeten [Mon, 8 Apr 2013 21:31:41 +0000 (14:31 -0700)]
staging: comedi: acl7225b: cleanup acl7225b_di_insn_bits()

Use a local variable to hold the base register, 'reg', that is used
to read from the device.

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>
11 years agostaging: comedi: acl7225b: cleanup acl7225b_do_insn_bits()
H Hartley Sweeten [Mon, 8 Apr 2013 21:31:23 +0000 (14:31 -0700)]
staging: comedi: acl7225b: cleanup acl7225b_do_insn_bits()

Use a local variable to hold the base register, 'reg', that is used
to write to the relays.

Add local variables for the 'mask' and 'bits' values used to update
the relays.

The relays only need to be updated if the 'mask' is set. Move the outb()
calls into the if (mask) to make this clearer.

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>
11 years agostaging: comedi: acl7225b: rename the (*insn_bits) subdevice functions
H Hartley Sweeten [Mon, 8 Apr 2013 21:31:04 +0000 (14:31 -0700)]
staging: comedi: acl7225b: rename the (*insn_bits) subdevice functions

For aesthetic reasons, and to help with greps, rename the (*insn_bits)
functions in this driver.

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>
11 years agostaging: comedi: acl7225b: add some whitespace to the subdevice init
H Hartley Sweeten [Mon, 8 Apr 2013 21:30:40 +0000 (14:30 -0700)]
staging: comedi: acl7225b: add some whitespace to the subdevice init

For aesthetic reasons, add some whitespace to the subdevice init
to make it more readable.

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>
11 years agostaging: comedi: acl7225b: dev->irq is already '0'
H Hartley Sweeten [Mon, 8 Apr 2013 21:30:23 +0000 (14:30 -0700)]
staging: comedi: acl7225b: dev->irq is already '0'

This driver does not use interrupts and the dev->irq variable is
already set to '0' when then (*attach) function is called. Setting
it in the driver is unnecessary.

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>
11 years agostaging: comedi: acl7225b: remove local var in acl7225b_attach()
H Hartley Sweeten [Mon, 8 Apr 2013 21:30:06 +0000 (14:30 -0700)]
staging: comedi: acl7225b: remove local var in acl7225b_attach()

The 'iorange' local variable is only used in the request_region()
call. Remove the variable and just use the board->io_range directly.

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>
11 years agostaging: comedi: acl7225b: cleanup dev->board_name usage
H Hartley Sweeten [Mon, 8 Apr 2013 21:29:47 +0000 (14:29 -0700)]
staging: comedi: acl7225b: cleanup dev->board_name usage

The comedi core initializes the dev->board_name before calling the
driver (*attach) function. There is not reason to reinitialize it
in the driver.

Use the dev->board_name when doing the request_resource() instead
of the open-coded string.

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>
11 years agostaging: comedi: acl7225b: remove board attach kernel noise
H Hartley Sweeten [Mon, 8 Apr 2013 21:29:21 +0000 (14:29 -0700)]
staging: comedi: acl7225b: remove board attach kernel noise

The printk's during the board attach are just added noise. Remove
them.

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>
11 years agostaging: comedi: acl7225b: cleanup boardinfo
H Hartley Sweeten [Mon, 8 Apr 2013 21:29:02 +0000 (14:29 -0700)]
staging: comedi: acl7225b: cleanup boardinfo

For aesthetic reasons, move the boardinfo table near the struct
definition. Remove the unnecessary comments in the struct definition.
Reformat the boardinfo in C99 format and add some whitespace to
help readability.

Rename the boardinfo struct and the boardinfo table so they have
namespace associated with the driver.

Remove the ACL7225_SIZE and P16R16DIO_SIZE defines. They are only
used in the boardinfo table and the open-coded values provide the
information more clearly.

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>
11 years agostaging: drm/imx: Add support for Television Encoder (TVEv2)
Philipp Zabel [Mon, 8 Apr 2013 16:04:38 +0000 (18:04 +0200)]
staging: drm/imx: Add support for Television Encoder (TVEv2)

This driver adds support for the Television Encoder integrated
on i.MX53 SoCs (TVEv2).

Currently only the VGA output mode is supported, which only uses
the TVDAC to generate RGB levels. HSYNC and VSYNC signals are
routed directly from the IPU signal generator pins through IOMUXC.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 years agostaging: drm/imx: ipu-dc: force black output during blanking
Philipp Zabel [Mon, 8 Apr 2013 16:04:37 +0000 (18:04 +0200)]
staging: drm/imx: ipu-dc: force black output during blanking

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 years agostaging: drm/imx: ipu-dc: add WCLK/WRG opcodes
Philipp Zabel [Mon, 8 Apr 2013 16:04:36 +0000 (18:04 +0200)]
staging: drm/imx: ipu-dc: add WCLK/WRG opcodes

Add WRG and WCLK opcodes to the display controller microcode,
and allow multi instruction codes.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 years agostaging: drm/imx: Add support for VGA via TVE on i.MX53
Philipp Zabel [Mon, 8 Apr 2013 16:04:35 +0000 (18:04 +0200)]
staging: drm/imx: Add support for VGA via TVE on i.MX53

This adds display interface timings for the Television Encoder
connected to IPU DI1 on i.MX53 and adds some configuration
glue code to select which IPU signal generators / pins are to
be used for HSYNC/VSYNC signals.

The default configuration is pin2/pin3 for hsync/vsync. The
VGA connector on i.MX53-QSB uses pin7/pin8, and the analog
part of the DVI-I connector on MBa53 connects to pin4/pin6.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 years agostaging: drm/imx: ipu-di: add comments explaining signal generator configuration
Philipp Zabel [Mon, 8 Apr 2013 16:04:34 +0000 (18:04 +0200)]
staging: drm/imx: ipu-di: add comments explaining signal generator configuration

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 years agostaging: drm/imx: ipuv3-crtc: use external clock for TV Encoder
Philipp Zabel [Mon, 8 Apr 2013 16:04:33 +0000 (18:04 +0200)]
staging: drm/imx: ipuv3-crtc: use external clock for TV Encoder

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 years agostaging: drm/imx: ipu-dc: add 24-bit GBR support to DC
Philipp Zabel [Mon, 8 Apr 2013 16:04:32 +0000 (18:04 +0200)]
staging: drm/imx: ipu-dc: add 24-bit GBR support to DC

24-bit GBR order is needed on the display interface connected
to the Television Encoder (TVEv2) on i.MX53.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 years agostaging: speakup: fix a bug when translate octal numbers
Andy Shevchenko [Tue, 9 Apr 2013 12:22:16 +0000 (15:22 +0300)]
staging: speakup: fix a bug when translate octal numbers

There are actually overflow bug and typo. And bug was never happened due to the
typo.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 years agoMerge tag 'iio-for-3.10d' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23...
Greg Kroah-Hartman [Tue, 9 Apr 2013 19:20:43 +0000 (12:20 -0700)]
Merge tag 'iio-for-3.10d' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Fourth set of changes for iio in the 3.10 cycle.  This time just a fix an
a cleanup.

The fix is to the dummy driver for some inconsistent specification of
parameters available vs parameters supplied.

The cleanup is for some silly memcmp usage.

11 years agostaging:iio:dummy: Fix mismatch and export sysfs entry
Jin Feng [Fri, 5 Apr 2013 04:51:00 +0000 (05:51 +0100)]
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>
11 years agostaging:iio:adt7316 Fix some 'interesting' string operations
Luck, Tony [Thu, 4 Apr 2013 21:37:00 +0000 (22:37 +0100)]
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>
11 years agostaging: comedi: remove unnecessary dev->board_name initialization
H Hartley Sweeten [Mon, 8 Apr 2013 17:57:35 +0000 (10:57 -0700)]
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>
11 years agostaging: comedi: comedi_pci: dev->board_name is always valid
H Hartley Sweeten [Mon, 8 Apr 2013 17:56:20 +0000 (10:56 -0700)]
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>
11 years agostaging: comedi: drivers: dev->board_name is always valid
H Hartley Sweeten [Mon, 8 Apr 2013 17:56:02 +0000 (10:56 -0700)]
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>
11 years agostaging: comedi: drivers: set dev->board_name before attaching
H Hartley Sweeten [Mon, 8 Apr 2013 17:55:29 +0000 (10:55 -0700)]
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>
11 years agostaging: comedi: drivers: rename 'comedi_dev' in comedi_auto_config()
H Hartley Sweeten [Mon, 8 Apr 2013 17:55:05 +0000 (10:55 -0700)]
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>
11 years agostaging: ti-soc-thermal: fix device removal
Eduardo Valentin [Mon, 8 Apr 2013 12:19:14 +0000 (08:19 -0400)]
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>
11 years agostaging: ti-soc-thermal: defer probe if cpufreq is not ready
Eduardo Valentin [Mon, 8 Apr 2013 12:19:13 +0000 (08:19 -0400)]
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>
11 years agostaging: ti-soc-thermal: remove extrapolation rules from TODO
Eduardo Valentin [Mon, 8 Apr 2013 12:19:12 +0000 (08:19 -0400)]
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>
11 years agostaging: ti-soc-thermal: update OMAP5 extrapolation rules
Eduardo Valentin [Mon, 8 Apr 2013 12:19:11 +0000 (08:19 -0400)]
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>
11 years agostaging: ti-soc-thermal: introduce OMAP4430 extrapolation constants
Eduardo Valentin [Mon, 8 Apr 2013 12:19:10 +0000 (08:19 -0400)]
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>
11 years agostaging: ti-soc-thermal: Remove TC1/TC2 TODO (already done)
Eduardo Valentin [Mon, 8 Apr 2013 12:19:09 +0000 (08:19 -0400)]
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>
11 years agostaging: ti-soc-thermal: fix min/max TODO (already done)
Eduardo Valentin [Mon, 8 Apr 2013 12:19:08 +0000 (08:19 -0400)]
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>
11 years agostaging: ti-soc-thermal: update TODO list
Eduardo Valentin [Mon, 8 Apr 2013 12:19:07 +0000 (08:19 -0400)]
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>
11 years agostaging/fwserial: Replace seq_printf with seq_puts
Valentin Ilie [Mon, 8 Apr 2013 10:49:21 +0000 (13:49 +0300)]
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>
11 years agoDrivers: Staging: cxt1e1: strncpy issue, need set zero at the end.
Chen Gang [Sun, 7 Apr 2013 10:01:48 +0000 (18:01 +0800)]
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>
11 years agostaging: comedi: ni_at_a2150: remove 'thisboard' macro
H Hartley Sweeten [Sat, 6 Apr 2013 00:36:40 +0000 (17:36 -0700)]
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>
11 years agostaging: comedi: dt282x: remove 'boardtype' macro
H Hartley Sweeten [Sat, 6 Apr 2013 00:36:22 +0000 (17:36 -0700)]
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>
11 years agostaging: comedi: dt2801: remove 'boardtype' macro
H Hartley Sweeten [Sat, 6 Apr 2013 00:36:03 +0000 (17:36 -0700)]
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>
11 years agostaging: comedi: das800: remove 'thisboard' macro
H Hartley Sweeten [Sat, 6 Apr 2013 00:35:44 +0000 (17:35 -0700)]
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>
11 years agostaging: comedi: das1800: remove 'thisboard' macro
H Hartley Sweeten [Sat, 6 Apr 2013 00:35:22 +0000 (17:35 -0700)]
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>
11 years agostaging: comedi: serial2002: remove #if 0'ed out code
H Hartley Sweeten [Fri, 5 Apr 2013 23:13:23 +0000 (16:13 -0700)]
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>
11 years agostaging: comedi: serial2002: remove pr_err() noise in serial2002_read()
H Hartley Sweeten [Fri, 5 Apr 2013 23:12:52 +0000 (16:12 -0700)]
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>
11 years agostaging: comedi: serial2002: rename all the static functions
H Hartley Sweeten [Fri, 5 Apr 2013 23:12:10 +0000 (16:12 -0700)]
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>
11 years agostaging: comedi: serial2002: hookup the (*open) and (*close) last
H Hartley Sweeten [Fri, 5 Apr 2013 23:11:50 +0000 (16:11 -0700)]
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>
11 years agostaging: comedi: serial2002: return 0 after successful attach
H Hartley Sweeten [Fri, 5 Apr 2013 23:11:13 +0000 (16:11 -0700)]
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>
11 years agostaging: comedi: serial2002: remove attach dev_dbg() noise
H Hartley Sweeten [Fri, 5 Apr 2013 23:10:42 +0000 (16:10 -0700)]
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>
11 years agostaging: comedi: serial2002: add some whitespace to the subdevice init
H Hartley Sweeten [Fri, 5 Apr 2013 23:10:22 +0000 (16:10 -0700)]
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>
11 years agostaging: comedi: serial2002: don't assume the number of subdevices to detach
H Hartley Sweeten [Fri, 5 Apr 2013 23:10:01 +0000 (16:10 -0700)]
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>
11 years agostaging: comedi: serial2002: cleanup serial2002_setup_subdevs()
H Hartley Sweeten [Fri, 5 Apr 2013 23:09:40 +0000 (16:09 -0700)]
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>
11 years agostaging: comedi: serial2002: split up serial_2002_open()
H Hartley Sweeten [Fri, 5 Apr 2013 23:09:15 +0000 (16:09 -0700)]
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>
11 years agostaging: comedi: serial2002: cleanup serial_read()
H Hartley Sweeten [Fri, 5 Apr 2013 23:08:51 +0000 (16:08 -0700)]
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>
11 years agostaging: comedi: serial2002: cleanup tty_setspeed()
H Hartley Sweeten [Fri, 5 Apr 2013 23:08:32 +0000 (16:08 -0700)]
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>
11 years agostaging: comedi: serial2002: factor (*poll) busy wait out of tty_read()
H Hartley Sweeten [Fri, 5 Apr 2013 23:08:13 +0000 (16:08 -0700)]
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>
11 years agostaging: comedi: serial2002: fix different address space sparse warnings
H Hartley Sweeten [Fri, 5 Apr 2013 23:07:49 +0000 (16:07 -0700)]
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>
11 years agostaging:csr: Fix typo in staging/csr driver
Masanari Iida [Mon, 8 Apr 2013 14:16:36 +0000 (23:16 +0900)]
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>
11 years agostaging: cptm1217: Use dev_pm_ops
Lars-Peter Clausen [Mon, 8 Apr 2013 07:56:07 +0000 (09:56 +0200)]
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>
11 years agostaging: speakup: selection.c fix typo in comment
Valentin Ilie [Fri, 5 Apr 2013 12:42:26 +0000 (15:42 +0300)]
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>
11 years agostaging: comedi: add comedi_clear_board_dev()
Ian Abbott [Thu, 4 Apr 2013 13:59:18 +0000 (14:59 +0100)]
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>
11 years agostaging: comedi: remove struct comedi_file_info
Ian Abbott [Thu, 4 Apr 2013 13:59:17 +0000 (14:59 +0100)]
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>
11 years agostaging: comedi: simplify comedi_board_minor_table[]
Ian Abbott [Thu, 4 Apr 2013 13:59:16 +0000 (14:59 +0100)]
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>
11 years agostaging: comedi: simplify comedi_subdevice_minor_table[]
Ian Abbott [Thu, 4 Apr 2013 13:59:15 +0000 (14:59 +0100)]
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>
11 years agostaging: comedi: remove comedi_file_info_from_board_minor()
Ian Abbott [Thu, 4 Apr 2013 13:59:14 +0000 (14:59 +0100)]
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>
11 years agostaging: comedi: remove comedi_clear_subdevice_minor()
Ian Abbott [Thu, 4 Apr 2013 13:59:13 +0000 (14:59 +0100)]
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>
11 years agostaging: comedi: refactor comedi_dev_from_minor()
Ian Abbott [Thu, 4 Apr 2013 13:59:12 +0000 (14:59 +0100)]
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>
11 years agostaging: comedi: reduce use of struct comedi_file_info
Ian Abbott [Thu, 4 Apr 2013 13:59:11 +0000 (14:59 +0100)]
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>
11 years agostaging: comedi: change comedi_read/write_subdevice() parameters
Ian Abbott [Thu, 4 Apr 2013 13:59:10 +0000 (14:59 +0100)]
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>
11 years agostaging: comedi: use minor device number in attribute functions
Ian Abbott [Thu, 4 Apr 2013 13:59:09 +0000 (14:59 +0100)]
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>
11 years agostaging: comedi: get mutex before subdevice in attribute functions
Ian Abbott [Thu, 4 Apr 2013 13:59:08 +0000 (14:59 +0100)]
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>
11 years agostaging: comedi: rename dev parameter of device attribute functions
Ian Abbott [Thu, 4 Apr 2013 13:59:07 +0000 (14:59 +0100)]
staging: comedi: rename dev parameter of device attribute functions

Most of the comedi core uses the identifier `dev` to point to a `struct
comedi_device`.  The device sysfs attribute functions such as
`show_max_read_buffer_kb()` use the parameter id `dev` to point to a
`struct device`.  Rename the parameter to `csdev` for "class device" for
consistency with the functions that call `device_create()` to create
these class devices (`comedi_alloc_board_minor()` and
`comedi_alloc_subdevice_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>
11 years agostaging: comedi: remove hardware_device from struct comedi_device_info
Ian Abbott [Thu, 4 Apr 2013 13:59:06 +0000 (14:59 +0100)]
staging: comedi: remove hardware_device from struct comedi_device_info

The `hardware_device` member of `struct comedi_device_info` is only set
to point to a hardware device by the auto-configuration code (specifically
`comedi_alloc_board_minor() with a non-NULL `hardware_device` parameter)
so that it can be found again by the auto-unconfiguration code
(specifically `comedi_release_hardware_device()`).  However, as
`info->device->hw_dev` (where `info` is a pointer to the `struct
comedi_device_info`) is set to the same value as `info->hardware_device`
(by calling `comedi_set_hw_dev()` with the same hardware device pointer)
we can look for that instead, so there is no need for the
`hardware_device` member any more.  Get rid of 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>
11 years agostaging: comedi: remove comedi_clear_minor()
Ian Abbott [Thu, 4 Apr 2013 13:59:05 +0000 (14:59 +0100)]
staging: comedi: remove comedi_clear_minor()

`comedi_clear_minor()` calls either `comedi_clear_board_minor()` or
`comedi_clear_subdevice_minor()` depending on its minor device number
parameter.  The one it calls only depends on where it is called from, so
bypass the calls to `comedi_clear_minor()` and 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>
11 years agostaging: comedi: separate board and subdevice minor tables
Ian Abbott [Thu, 4 Apr 2013 13:59:04 +0000 (14:59 +0100)]
staging: comedi: separate board and subdevice minor tables

The comedi core reserves minor device numbers from 0 to
`COMEDI_NUM_BOARD_MINORS - 1` (0 to 0x30 - 1) for the main comedi
"board" devices and reserves minor device numbers from
`COMEDI_NUM_BOARD_MINORS` to `COMEDI_NUM_MINORS - 1` (0x30 to 0x100 - 1)
for comedi subdevices (or at least those that claim to support
asynchronous comedi commands).  There is an array
`comedi_file_info_table[COMEDI_NUM_MINORS]` used to hold pointers to
information for each board minor device number and subdevice minor
device number that has been allocated (with NULL pointers for those not
allocated), along with a protective lock `comedi_file_info_table_lock`.

Since the ranges of board minor device numbers and subdevice minor
device numbers do not overlap, we can use separate tables and separate
locks for the different types of minor device numbers.  This will allow
us to use different pointer types for the elements of each table in the
future without just using a generic `void *`.  (At the moment, the table
elements point to a `struct comedi_file_info` allocated dynamically for
each allocated board minor device or subdevice minor device, but I plan
to get rid of that data structure.)

Replace `comedi_file_info_table[COMEDI_NUM_MINORS]` with two new arrays
of the same type, `comedi_board_minor_table[COMEDI_NUM_BOARD_MINORS]`
for board minors, and
`comedi_subdevice_minor_table[COMEDI_NUM_SUBDEVICE_MINORS]` for
subdevice minors (where `COMEDI_NUM_SUBDEVICE_MINORS` is
`COMEDI_NUM_MINORS - COMEDI_NUM_BOARD_MINORS`).
`comedi_subdevice_minor_table[]` is indexed by the subdevice minor
number minus `COMEDI_NUM_BOARD_MINORS` since `COMEDI_NUM_BOARD_MINORS`
is the first valid subdevice minor number.

Replace `comedi_file_info_table_lock` with
`comedi_board_minor_table_lock` for board minors and
`comedi_subdevice_minor_table_lock` for subdevice minors.

Refactor `comedi_clear_minor()` to call one of two new functions
`comedi_clear_board_minor()` and `comedi_clear_subdevice_minor()`
depending on the minor device number passed as a parameter.  Similarly,
refactor `comedi_file_info_from_minor()` to call one of two new
functions `comedi_file_info_from_board_minor()` and
`comedi_file_info_from_subdevice_minor()` depending on the minor device
number parameter.

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>
11 years agostaging: comedi: remove COMEDI_FIRST_SUBDEVICE_MINOR
Ian Abbott [Thu, 4 Apr 2013 13:59:03 +0000 (14:59 +0100)]
staging: comedi: remove COMEDI_FIRST_SUBDEVICE_MINOR

The macro `COMEDI_FIRST_SUBDEVICE_MINOR` just expands to another macro
`COMEDI_NUM_BOARD_MINORS`.  Replace uses of
`COMEDI_FIRST_SUBDEVICE_MINOR` with `COMEDI_NUM_BOARD_MINORS` and get
rid of the former.

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>
11 years agostaging: comedi: move COMEDI_NUM_MINORS and COMEDI_FIRST_SUBDEVICE_MINOR
Ian Abbott [Thu, 4 Apr 2013 13:59:02 +0000 (14:59 +0100)]
staging: comedi: move COMEDI_NUM_MINORS and COMEDI_FIRST_SUBDEVICE_MINOR

The macro definitions `COMEDI_NUM_MINORS` and
`COMEDI_FIRST_SUBDEVICE_MINOR` are only used in "comedi_fops.c" so move
them to there from "comedidev.h".

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>
11 years agostaging: comedi: change comedi_file_info_table_lock to mutex
Ian Abbott [Thu, 4 Apr 2013 13:59:01 +0000 (14:59 +0100)]
staging: comedi: change comedi_file_info_table_lock to mutex

The spin-lock `comedi_file_info_table_lock` is used to protect against
simultaneous modification and access of `comedi_file_info_table[]`.
Change it from a spin-lock to a mutex as it is only used in contexts
where sleeping is allowed.

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>
11 years agostaging: comedi: set hw_dev in comedi_alloc_board_minor()
Ian Abbott [Thu, 4 Apr 2013 13:59:00 +0000 (14:59 +0100)]
staging: comedi: set hw_dev in comedi_alloc_board_minor()

Call `comedi_set_hw_dev()` to set the `hw_dev` member of `struct
comedi_device` in `comedi_alloc_board_minor()` instead of in
`comedi_auto_config()`.  Don't bother to check for an error returned by
`comedi_set_hw_dev()` here; it only fails when changing a non-NULL
pointer to a different non-NULL pointer and since the `struct
comedi_device` has just been allocated and initialized, its `hw_dev`
will be NULL already.  Calling `comedi_set_hw_dev()` with a non-NULL
hardware device pointer increments the kref counter for the hardware
device.

If `comedi_alloc_board_minor()` fails further down the function, we rely
on its call to `comedi_device_cleanup()` to call `comedi_clear_hw_dev()`
(via `comedi_device_detach()` and `cleanup_device()`) to clear `hw_dev`
and decrement its kref counter.  (That's the "beneficial side-effect"
mentioned in the patch that replaced `__comedi_device_detach()`.)

Remove the call to `comedi_set_hw_dev()` from `comedi_auto_config()` as
the call to `comedi_alloc_board_minor()` does it for us.

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>
11 years agostaging: comedi: move detach out of post-config
Ian Abbott [Thu, 4 Apr 2013 13:58:59 +0000 (14:58 +0100)]
staging: comedi: move detach out of post-config

`comedi_device_postconfig()` calls `comedi_device_detach()` on failure.
Remove that call and make the callers of `comedi_device_postconfig()`
call `comedi_device_detach()` themselves if it returns an error.  This
seems more logical as the callers of `comedi_device_postconfig()` called
`comedi_device_detach()` anyway if they didn't call
`comedi_device_postconfig()`.

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>
11 years agostaging: comedi: replace __comedi_device_detach()
Ian Abbott [Thu, 4 Apr 2013 13:58:58 +0000 (14:58 +0100)]
staging: comedi: replace __comedi_device_detach()

`comedi_device_detach()` does nothing if the `struct comedi_device`'s
`attached` member is false, otherwise it calls
`__comedi_device_detach()` to do the real work.
`__comedi_device_detach()` is called from various other functions in
"drivers.c" (`comedi_device_postconfig()`, `comedi_device_attach()`, and
`comedi_auto_config()`) to bypass the check for the `attached` member
being false.

If we make `__comedi_device_detach()` safe to call when the `attached`
member is already false, we can remove the check in
`comedi_device_detach()`, subsume `__comedi_device_detach()` within
`comedi_device_detach()`, and replace all the calls to
`__comedi_device_detach()` with calls to `comedi_device_detach()`.

In fact, it is already safe to call `__comedi_device_detach()` when the
`attached` member is false.  We just need to remove the warning message
it outputs when the `driver` member is NULL.  Then the function becomes
idempotent without outputting spurious warnings.  (It is idempotent
because `dev->driver->detach()` will only be called once at most and the
call to `cleanup_device()` is idempotent itself.)

Combine `comedi_device_detach()` with `__comedi_device_detach()`,
removing the check for the `attached` member being false and removing
the warning about the `driver` member being NULL, and replace all calls
to `__comedi_device_detach()` with calls to the combined
`comedi_device_detach()`.

A beneficial side-effect of the above change is that a call to
`comedi_device_detach()` will always result in a call to
`cleanup_device()` and so always result in a call to
`comedi_clear_hw_dev()`.  We will make use of this beneficial
side-effect in a later patch.

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>
11 years agostaging: comedi: put module _after_ detach
Ian Abbott [Thu, 4 Apr 2013 13:58:57 +0000 (14:58 +0100)]
staging: comedi: put module _after_ detach

On failure of the call to the low-level comedi device driver's
`->attach()` handler from `__comedi_device_attach()`, reverse the
current ordering of the calls to `module_put()` and
`comedi_device_detach()` because `__comedi_device_detach()` will call
code in the module being put.

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>
11 years agostaging: comedi: simplify driver module counting
Ian Abbott [Thu, 4 Apr 2013 13:58:56 +0000 (14:58 +0100)]
staging: comedi: simplify driver module counting

For a legacy device attachment with the `COMEDI_DEVCONFIG` ioctl,
`do_devconfig_ioctl()` calls `comedi_device_attach()` to find a matching
device driver and attach the device.  It then tries to increment the
device driver's module count and if that fails it detaches the device.
So on successful attachment of a device by the `COMEDI_DEVCONFIG` ioctl,
the device driver's module count will have been incremented.

`comedi_device_attach()` is called from nowhere else.  It already
increments the device driver's module count temporarily and decrements
it again; if it gets as far as calling `comedi_device_postconfig()` the
module count is decremented within that function.

Simplify the above by removing the decrement of the device driver module
count from `comedi_device_postconfig()`.  If the call to
`comedi_device_postconfig()` succeeds, `comedi_device_attach()` will
return with the module count still incremented, otherwise decrement the
module count before returning the error.  Don't try and increment the
module count in `do_devconfig_ioctl()` after a successful return from
`comedi_device_attach()` as the module count has now already been
incremented.

`comedi_device_postconfig()` is also called by `comedi_auto_config()`
which currently has to increment the device driver's module count
temporarily so that `comedi_device_postconfig()` can decrement it, but
always returns with no overall change to the module count.  Remove all
the module count manipulations from `comedi_device_postconfig()`.  There
is no other reason for `comedi_auto_config()` to increment the device
driver's module count temporarily, since it is only called (indirectly)
from the device driver itself (usually via one of the wrappers
`comedi_pci_auto_config()` or `comedi_usb_auto_config()`).

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>