Ian Abbott [Mon, 24 Sep 2012 15:27:59 +0000 (16:27 +0100)]
staging: comedi: ni_mio_common: always lock in ni_ai_poll()
`ni_ai_poll()` currently acquires (and later releases) the comedi
device's spin-lock iff `in_interrupt()` returns 0. However, it is only
called during processing of a `COMEDI_POLL` ioctl so `in_interrupt()`
will always return 0 in this case. Remove this test and acquire/release
the spin-lock unconditionally. This eliminates a sparse warning about
different lock contexts for basic block.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Mon, 24 Sep 2012 16:20:53 +0000 (17:20 +0100)]
staging: comedi: s626: add FIXME comment
`s626_enc_insn_config()` is the `insn_config()` handler for a counter
subdevice. The `data[0]` value is supposed to be one of the
`INSN_CONFIG_...` constants defined in "comedi.h" indicating the type of
configuration instruction, but this function seems to be using it as a
variable value to preload the counter with. Various values of `data[0]`
are going to cause `check_insn_config_length()` in the comedi core
("comedi_fops.c") to return an error, and this function won't be called
in those cases. Most other values will log a warning to the kernel log.
It's not entirely clear what constant should be checked for in
`data[0]`, so add a "FIXME" comment for now.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
`s626_enc_insn_config()` is incorrectly dereferencing `insn->data` which
is a pointer to user memory. It should be dereferencing the separate
`data` parameter that points to a copy of the data in kernel memory.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: s626: remove 'allocatedBuf' from private data
This variable is only used to count the number of dma buffers
allocated during the attach. If an allocation fails, the attach
function exits with -ENOMEM. When this variable is checked later
it will always be == 2. Just remove the variable and the check.
This allows bringing the code back an indent level in
s626_initialize(). Note, coding style issues in this function
are not addressed yet.
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>
The local variable 'resourceStart' is only used in the ioremap()
to hold the PCI bar 0 base address. Just use the pci_resource_start()
directly in the ioremap().
Also, instead of assuming the resource size for the ioremap, use
pci_resource_len() to get the actual size.
Remove the kernel noise when the ioremap fails and change the error
code from -ENODEV to -ENOMEM.
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>
staging: comedi: s626: remove 'got_regions' from private data
This variable is only used as a flag to indicate that the pci device
has been enabled and needs to be disabled in the detach. Use the
comedi_device 'iobase' for this and remove the private data 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>
Convert this PCI driver to use the comedi PCI auto config attach
mechanism by adding an 'attach_pci' callback function. Since the
driver does not require any external configuration options, and
the legacy 'attach' callback is not optional, 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>
Ian Abbott [Fri, 21 Sep 2012 11:05:47 +0000 (12:05 +0100)]
staging: comedi: ni_daq_700: add AI subdevice
Add subdevice 1 as an analog input (AI) subdevice. It currently only
supports basic, software-triggered acquisitions.
This is mostly the work of Fred Brooks (MODULE_AUTHOR), but he based his
update on an older version of the driver. I applied the relevant
changes with a few tweaks: adding an explicit `udelay(1)` in a timeout
loop, replacing binary constants with hex, renaming functions, replacing
`printk()` calls, removing exported symbols, removing (very) incomplete
comedi "command" support, and making some coding-style changes.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Kevin McKinney [Mon, 24 Sep 2012 03:07:17 +0000 (23:07 -0400)]
Staging: bcm: Remove typedef for _stCPacketClassificationRuleSI and call directly.
This patch removes typedef for
_stCPacketClassificationRuleSI, changes the
name of the struct to bcm_packet_class_rules,
and updates the comments appropriately . In
addition, any calls to typedefs
"CCPacketClassificationRuleSI,
stCPacketClassificationRuleSI,
or *pstCPacketClassificationRuleSI" are changed
to call the struct directly.
Signed-off-by: Kevin McKinney <klmckinney1@gmail.com> Acked-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Kevin McKinney [Mon, 24 Sep 2012 03:07:16 +0000 (23:07 -0400)]
Staging: bcm: Remove typedef for _stPhsRuleSI and call directly.
This patch removes typedef for _stPhsRuleSI,
changes the name of the struct to
bcm_phs_rules, and updates the comments
appropriately. In addition, any
calls to typedefs "stPhsRuleSI,
*pstPhsRuleSI, or CPhsRuleSI" are
changed to call the struct directly.
Signed-off-by: Kevin McKinney <klmckinney1@gmail.com> Acked-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Kevin McKinney [Mon, 24 Sep 2012 03:07:15 +0000 (23:07 -0400)]
Staging: bcm: Remove typedef for _stConvergenceSLTypes and call directly.
This patch removes typedef for _stConvergenceSLTypes,
changes the name of the struct to
bcm_convergence_types, and updates the
comments appropriately. In addition, any
calls to typedefs "stConvergenceSLTypes,
CConvergenceSLTypes, and *pstConvergenceSLTypes"
are changed to call the struct directly.
Signed-off-by: Kevin McKinney <klmckinney1@gmail.com> Acked-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Kevin McKinney [Mon, 24 Sep 2012 03:07:14 +0000 (23:07 -0400)]
Staging: bcm: Remove typedef for _stServiceFlowParamSI and call directly.
This patch removes typedef for _stServiceFlowParamSI,
changes the name of the struct to
bcm_connect_mgr_params, and updates the
comments appropriately. In addition, any
calls to typedefs "stServiceFlowParamSI,
*pstServiceFlowParamSI, and CServiceFlowParamSI"
are changed to call the struct directly.
Signed-off-by: Kevin McKinney <klmckinney1@gmail.com> Acked-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Kevin McKinney [Mon, 24 Sep 2012 03:07:13 +0000 (23:07 -0400)]
Staging: bcm: Remove typedef for _stLocalSFAddRequest and call directly.
This patch removes typedef for _stLocalSFAddRequest,
and changes the name of the struct to
bcm_add_request. In addition, any
calls to typedefs "stLocalSFAddRequest or
*pstLocalSFAddRequest" are changed to
call the struct directly.
Signed-off-by: Kevin McKinney <klmckinney1@gmail.com> Acked-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Kevin McKinney [Mon, 24 Sep 2012 03:07:12 +0000 (23:07 -0400)]
Staging: bcm: Remove typedef for _stLocalSFAddIndication and call directly.
This patch removes typedef for _stLocalSFAddIndication,
and changes the name of the struct to
bcm_add_indication. In addition, any
calls to typedefs "stLocalSFAddIndication,
*pstLocalSFAddIndication, stLocalSFChangeRequest,
*pstLocalSFChangeRequest, stLocalSFChangeIndication,
or *pstLocalSFChangeIndication " are changed to
call the struct directly.
Signed-off-by: Kevin McKinney <klmckinney1@gmail.com> Acked-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Kevin McKinney [Mon, 24 Sep 2012 03:07:11 +0000 (23:07 -0400)]
Staging: bcm: Remove typedef for _stLocalSFDeleteRequest and call directly.
This patch removes typedef for _stLocalSFDeleteRequest,
and changes the name of the struct to
bcm_del_request. In addition, any
calls to typedefs "stLocalSFDeleteRequest or
*pstLocalSFDeleteRequest" are
changed to call the struct directly.
Signed-off-by: Kevin McKinney <klmckinney1@gmail.com> Acked-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Kevin McKinney [Mon, 24 Sep 2012 03:07:10 +0000 (23:07 -0400)]
Staging: bcm: Remove typedef for stLocalSFDeleteIndication and call directly.
This patch removes typedef for
stLocalSFDeleteIndication, and
changes the name of the struct to
bcm_del_indication. In addition, any
calls to the following typedef
"stLocalSFDeleteIndication" are changed to call
the struct directly.
Signed-off-by: Kevin McKinney <klmckinney1@gmail.com> Acked-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: rtl8712: fix foo* bar (foo*) errors reported by checkpatch
fixes the following errors:
drivers/staging/rtl8712/rtl871x_security.c:61: ERROR: "foo * bar" should
be "foo *bar"
drivers/staging/rtl8712/rtl871x_security.c:291: ERROR: "foo * bar"
should be "foo *bar"
drivers/staging/rtl8712/rtl871x_security.c:323: ERROR: "foo * bar"
should be "foo *bar"
drivers/staging/rtl8712/rtl871x_security.c:1371: ERROR: "(foo*)" should
be "(foo *)"
Merge tag 'iio-for-v3.7e' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Fifth round of new drivers and device support for the IIO
subsystem in the 3.7 cycle.
Here we have a mixed bag of new stuff, minor fixes and
more major fixes for drivers added earlier in this cycle.
1) A number of fixes for the HID sensors code added in previous
pull request. Typical stuff that has become apparent as more eyes
have looked at the code post merging. Similar case for the ad5755 dac.
2) Cleanups of error handing in inkern.c - again typical stuff to see
as code comes into heavier use and people notice the naughty short
cuts that snuck in originally and kindly fix them.
3) A series from Lars that removes some incorrect error handling
from the remove functions of a number of drivers. These have been
there for a very long time hence I'm not pushing these out for the
3.6 cycle.
4) Support for more parts in the ad7780 driver.
5) A driver for the adcs on the lp8788 power management unit
6) A client driver for IIO to allow it's ADCs to be used for
battery status measurement. Note this driver has some dependencies
on some utility functions added to IIO in this series, hence it is
coming via this tree rather than Anton's.
7) A null pointer dereference bug in the 'fake' driver. I'm not
doing this as a fix for the 3.6 cycle because it only effects
'fake' hardware and that code is typically only used by people
investigating how IIO works as part of writing new drivers. Hence
it's hardly a critical fix.
staging: winbond: Coding Style correction and removal of unused macro
Removed an unused macro. Plus, couple of grammatical and coding style fixes.
1) The macro _INLINE is not used anywhere. Anyways __inline is not portable.
2) Changed comment from "Not use" to "Unused" make it grammatically correct and
to fit in 80 word limit.
3.) Removed space after *
staging: sbe-2t3e3: fix error handling in t3e3_init_channel()
t3e3_init_channel() incorrectly handles errors in several places:
it returns zero and does not deallocate all required resources.
The patch fixes that places.
Found by Linux Driver Verification project (linuxtesting.org).
If the config contains CONFIG_IIO_BUFFER=y and CONFIG_IIO_SIMPLE_DUMMY_BUFFER=n
iio_simple_dummy_configure_buffer() is stubbed out and iio_buffer_register() is
not. As a result we try to register a buffer which has not been configured.
This will causes a NULL pointer deref in iio_buffer_register. To solve this
issue move the iio_buffer_register() call to iio_simple_dummy_configure_buffer(),
so it will only be called if iio_simple_dummy_configure_buffer() has been called.
Driver to allow use of the ADC drivers supported by the IIO
subsystem for battery status monitoring. Connecting this
driver to the relevant IIO device requires registration of
the appropriate iio_map structure array by the IIO device
driver (usually from platform data). If specified the driver
will also make use of a gpio to provide interrupt driven
notification that the battery is fully charged.
In last version:
Addressed concerns raised by lars:
a. made the adc_bat per device.
b. get the IIO channel using hardcoded channel names.
c. Minor issues related to gpio_is_valid and some code
refactoring.
In V1:
Addressed concerns raised by Anton:
a. changed the struct name to gab(generic adc battery).
b. Added some functions to neaten the code.
c. Some minor coding guidelines changes.
d. Used the latest function introduce by lars:
iio_read_channel_processed to streamline the code.
In V2:
Addressed concerns by lars:
a. No need of allocating memory for channels.Make it array.
b. Code restructring, coding style and following kernel guidelines changes
suggested by him.
In V3:
Addressed conerns by Anton:
a. Added the copyright.
b. Coding guidelines changes suggested by him.
c. Added Makefile and Kconfig
Signed-off-by: anish kumar <anish198519851985@gmail.com> Acked-by: Anton Vorontsov <cbouatmailru@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Fix below issues:
1. In the case of goto err_close, hid_hw_stop(hdev) is called twice. Fix it.
2. If fails to allocate MFD device name, we also need to free all
successfully allocated names in previous iterations.
3. In sensor_hub_remove(), Call hid_hw_close() before hid_hw_stop().
4. Adjust unnecessary change lines for hid_err.
Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Jiri Kosina <jkosina@suse.cz> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Axel Lin [Wed, 19 Sep 2012 15:30:00 +0000 (16:30 +0100)]
HID: hid-sensor-hub: Remove hdev->claimed setting
Current implementation of hid_hw_start() allows connect_mask to be 0.
Setting hdev->claimed = HID_CLAIMED_INPUT before calling hid_hw_start()
is not necessary. Remove it.
Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Jiri Kosina <jkosina@suse.cz> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Kim, Milo [Mon, 17 Sep 2012 09:35:00 +0000 (10:35 +0100)]
iio: adc: add new lp8788 adc driver
TI LP8788 PMU provides regulators, battery charger, ADC,
RTC, backlight driver and current sinks.
This patch enables the LP8788 ADC functions.
The LP8788 ADC has several ADC input selection and supports 12bit resolution.
Internal operation of getting ADC is access to registers of LP8788.
The LP8788 ADC uses exported functions for accessing these registers.
(exported by LP8788 MFD device driver)
This driver supports IIO_CHAN_INFO_RAW and SCALE.
So the IIO consumer can calculate the value with raw and scale.
The unit of scale is micro.
(ADC Input Selection)
Voltage: battery voltage (MAX 5.0, 5.5 and 6.0V)
charger input voltage
four general ADC inputs
coin cell voltage
Current: battery charging current
Temperature: IC temperature
(The IIO map for the IIO consumer)
The ADC input is configurable in the platform side.
Even though this platform data is not defined,
the default IIO map is created for supporting the power supply driver.
The battery voltage and temperature are used inside this driver.
(History)
Patch v6.
(a) Fix scale value for each ADC input selection
Voltage and current type are mili unit and temperature is degree.
To calculate the IC temperature,
temp = raw * scaleint + (raw * scalepart)/ 1000000, scaleint is always 0.
= raw * 0.061050, raw: 0 ~ 4095
Then range of IC temperature(ADC result) is 0 ~ 250'C
(b) Reorganization of the IIO channel Spec
Remove address, scan_type and scan_index and rollback the datasheet name.
The reason why 'address' field is unnecessary is no relation with each channel.
Moreover, to get the raw ADC value, the address info is not only one register
but also several registers.
Therefore specific function(lp8788_get_adc_result) is called rather than
using one 'address' field.
(c) Fix coding style
Remove duplicated checking routine while unregistering the IIO map.
Fix code for space and parenthesis.
Patch v5.
Fix default consumer name as 'lp8788-charger'.
Add mutex for ADC read operation.
Reorganization on lp8788_adc_read_raw().
Patch v4.
Fix adc_raw function: support RAW and SCALE channel info.
Change LP8788 ADC platform data - iio map.
Enables the default IIO map.
staging:iio:ad7780: Add support for the ad7170/ad7171
The ad7170/ad7171 have a software interface similar to the ad7780. They do not
have an external pin which allows to change the internal gain and the what is
used for the gain bit in the ad7780/ad7781 becomes part of the check pattern.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Some designs hardwire the PDRST pin to always on. In this case there is no GPIO
to control the mode of the device, so make the GPIO optional. Since now all of
the the platform data fields are optional now, make the platform data as a whole
optional as well.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:sca3000: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.
The errors which the driver tries to handle in the remove function are
non-critical, so we can just ignore them and continue to free all resources and
remove the IIO device.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:lis3l02dq: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.
The errors which the driver tries to handle in the remove function are
non-critical, so we can just ignore them and continue to free all resources and
remove the IIO device.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:ade7759: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.
The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:ade7758: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.
The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:ade7754: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.
The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:ade7753: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.
The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:adis16400: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.
The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:adis16200: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.
The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Kim, Milo [Tue, 18 Sep 2012 04:56:00 +0000 (05:56 +0100)]
iio: inkern: clean up error return code
When the IIO consumer tries to get specific IIO channel,
few error cases can be happened.
(a) Memory allocation failure
(b) No matched ADC channel error
(c) Invalid input arguments
This patch enables cleaning up error handling in case of (a) and (b).
In error handling code,
(a): the reference count of the IIO device should be decreased.
(b): the allocated memory should be freed with restoring the reference count.
Therefore iio_deivce_put() is called in both cases.
This can be handled in the last error statement.
Additionally, integer variable is used for stating each error case explicitly.
Then, the error returns as ERR_PTR() with this value.
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Kim, Milo [Tue, 18 Sep 2012 04:55:00 +0000 (05:55 +0100)]
iio: inkern: put the IIO device when it fails to allocate memory
The reference count of the IIO device is increased if the IIO map has
matched consumer name.
After then, it tries to allocate the iio_channel which is used by the consumer.
If it fails to allocate memory, the reference count should be decreased.
This patch enables restoring the reference count of the IIO device.
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
When hid sensor hub is unplugged, there is a crash in
iio_device_unregister_trigger_consumer.
In a typical IIO driver when remove is called, it will unregister and free
trigger and then it will call iio_device_free.
The function iio_trigger_free() will free the allocated memory for trigger.
If this trigger was assigned to iio_dev->trig, then it should be set to NULL.
Othewise when iio_device_free() is called later, it finally calls
iio_device_unregsister_trigger(), which checks for
if (indio_dev->trig)
iio_trigger_put(indio_dev->trig);
If indio_dev->trig is not set to NULL, it calls iio_trigger_put on a bad
pointer causing crash.
This scenerio can happen in any driver, which is storing trigger pointer in
iio_dev structure and following current procedure during remove.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Ian Abbott [Wed, 19 Sep 2012 18:37:39 +0000 (19:37 +0100)]
staging: comedi: fix memory leak for saved channel list
When `do_cmd_ioctl()` allocates memory for the kernel copy of a channel
list, it frees any previously allocated channel list in
`async->cmd.chanlist` and replaces it with the new one. However, if the
device is ever removed (or "detached") the cleanup code in
`cleanup_device()` in "drivers.c" does not free this memory so it is
lost.
A sensible place to free the kernel copy of the channel list is in
`do_become_nonbusy()` as at that point the comedi asynchronous command
associated with the channel list is no longer valid. Free the channel
list in `do_become_nonbusy()` instead of `do_cmd_ioctl()` and clear the
pointer to prevent it being freed more than once.
Note that `cleanup_device()` could be called at an inappropriate time
while the comedi device is open, but that's a separate bug not related
to this this patch.
Cc: stable@vger.kernel.org Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Wed, 19 Sep 2012 18:37:37 +0000 (19:37 +0100)]
staging: comedi: ni_labpc: pass ai scan mode through various functions
Pass the `enum scan_mode` value calculated by `labpc_ai_scan_mode()` as
a parameter to various other functions so they don't have to call it
themselves. Amongst others, the affected functions include
`labpc_adc_timing()`, `labpc_ai_convert_period()` and
`labpc_ai_scan_period()`.
`labpc_adc_timing()` calls `labpc_ai_convert_period()` and
`labpc_ai_scan_period()` in several places, but the returned values are
the same each time, so change it to just call those functions once and
re-use the return values.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: 8253: mmio address is a void __iomem *
The inline functions for accessing a memory mapped 8254 device
are using a void * for the 'base_address' of the device. Memory
mapped io using the read/write functions should be using a
void __iomem * for the address.
Fixing these exposed a couple other void * / void __iomem *
issues in the ni_labpc driver.
This fixes a number of sparse warnings like:
warning: incorrect type in argument 2 (different address spaces)
expected void volatile [noderef] <asn:2>*addr
got void *
warning: incorrect type in argument 1 (different address spaces)
expected void const volatile [noderef] <asn:2>*addr
got void *<noident>
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>
staging: comedi: kcomedilib: fix a __user space access issue
The 'data' field in struct comedi_insn is an unsigned int __user *.
The comedi core copies this data to kernel space before passing it
on to a drivers insn_bits/insn_config method.
kcomedilib provides an interface for external kernel modules to
use the comedi drivers. This interface creates a comedi_insn
that is then passed to the comedi drivers insn_bits/insn_config
method. Unfortunately, kcomedilib is using the comedi_insn 'data'
field directly which results in some sparse warnings:
warning: incorrect type in argument 4 (different address spaces)
expected unsigned int *<noident>
got unsigned int [noderef] <asn:1>*data
warning: incorrect type in assignment (different address spaces)
expected unsigned int [noderef] <asn:1>*[addressable] [assigned] data
got unsigned int *<noident>
Fix this by passing the kernel data directly, as a separate parameter,
instead of trying to put in into the comedi_insn 'data' field. This is
how the comedi core handles the data from user space.
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>
Convert this PCI driver to use the comedi PCI auto config attach
mechanism by adding an 'attach_pci' callback function. Since the
driver does not require any external configuration options. and
the legacy 'attach' callback is now optional, remove it.
Also, make the boardinfo 'name' unique for the different board types.
Use this name when requesting the PCI resources. Change the printk
at the end of the attach into a dev_info.
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>
This driver requires loading a firmware file for the fpga. This
is currently being done by passing the firmware data using the
COMEDI_DEVCONFIG ioctl through the attach() hook in the driver.
This does not work for auto-configured PCI devices due to the
firmware loading options not being set in the comedi_devconfig
parameter passed to the driver.
Change the driver so it gets the firmware using request_firmware()
and ignore any firmware options passed in the comedi_devconfig.
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>
This driver originally used the 'attach' method in order to get
the firmware for the device from the comedi_config utility. It
now uses request_firmware_nowait() in the usb_driver probe to
get this firmware.
Since this driver has an 'attach_usb' method in the comedi_driver,
the 'attach' method can be removed because it is now optional.
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>
This driver originally used the 'attach' method in order to get
the firmware for the device from the comedi_config utility. It
now uses request_firmware_nowait() in the usb_driver probe to
get this firmware.
Since this driver has an 'attach_usb' method in the comedi_driver,
the 'attach' method can be removed because it is now optional.
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>
This driver originally used the 'attach' method in order to get
the firmware for the device from the comedi_config utility. It
now uses request_firmware_nowait() in the usb_driver probe to
get this firmware.
Since this driver has an 'attach_usb' method in the comedi_driver,
the 'attach' method can be removed because it is now optional.
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>
For aesthetic reasons, rename the private data variable
's526_ai_config' to simply 'ai_config'. Its private data
and does not need the 's526_' namespace.
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>
The enum in this struct is used by the driver to know how the
gpct channels have been configured. Instead of using the private
enum S526_GPCT_APP_CLASS, we can just use the INSN_CONFIG_* value
that was passed in data[0] to the s526_gpct_insn_config().
The data array in this struct in never used. It actually could
cause a BUG since it assumes that the data pointer passed to
s526_gpct_insn_config() always has 6 values but the comments
indicate that there are really only 4 or 5.
Remove the s526GPCTConfig struct and associated S526_GPCT_APP_CLASS
enum and just use and unsigned int array in the private data to
hold the gpct configuration.
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>
Use a local variable for the iobase of the channel being read.
This makes the inw() calls a bit cleaner.
Move the masking of the read data to make the value stored in
the data array a bit clearer.
The comedi core expects insn_read functions to return the number
of insn data values read. For this function, the final value of
'i' is correct but change the return to 'insn->n' just to make
it clear.
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>
The comedi_insn 'data' pointer is a __user pointer that is
passed into the kernel using an ioctl. The comedi core copies
this data to kernel space in do_insnlist_ioctl() and then
passes that kernel data to the drivers as a separate parameter.
The drivers never need to access the data through the insn->data
pointer.
This fixes a number of sparse warnings about:
warning: dereference of noderef expression
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>
This adds a i.MX51/53/6 IPU (Image Processing Unit) KMS driver. The
driver has been tested on the i.MX51 babbage board, the i.MX53 LOCO
board and the i.MX6q sabrelite board in different clone mode and dual
head setups.
The IPU is the Image Processing Unit found on i.MX51/53/6 SoCs. It
features several units for image processing, this patch adds support
for the units needed for Framebuffer support, namely:
This patch is based on the Freescale driver, but follows a different
approach. The Freescale code implements logical idmac channels and
the handling of the subunits is hidden in common idmac code pathes
in big switch/case statements. This patch instead just provides code
and resource management for the different subunits. The user, in this
case the framebuffer driver, decides how the different units play
together.
This adds support for parallel displays for i.MX. It consists
of a drm encoder/connector pair which eventually passes EDID
data from the devicetree to the drm core.
Kevin McKinney [Fri, 21 Sep 2012 02:43:44 +0000 (22:43 -0400)]
Staging: bcm: Remove typedef for _stIM_sfHostNotify and call directly.
This patch removes typedef for _stIM_sfHostNotify,
changes the name of the struct from
_stIM_sfHostNotify to bcm_stim_sfhostnotify.
In addition, any calls to the following typedef
"stIM_sfHostNotify" are changed to call the
struct directly.
Signed-off-by: Kevin McKinney <klmckinney1@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>