Merge tag 'iio-for-3.12b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes:
Second round of new drivers, features and cleanups for IIO in the 3.12 cycle.
New driver:
1) tmp006 IR thermopile driver. This is an unusual temperature sensor
and was taken in to IIO with the knowledge and agreement of a hwmon
maintainer.
It measures remote temperature using infrared emissions.
I guess taking this may mean we have to fight off submissions of
devices much more suited to hwmon but such is life and we end up
doing this from time to time already.
2) twl6030 adc driver.
Cleanups:
1) More devm_* cleanups following on from the introduction of
devm_iio_device_alloc. Mostly an heroic effort from
Sachin Kamat!
2) Introduce devm_iio_trigger_alloc etc to handle trigger
allocation and deallocation in a managed fashion. There
aren't as many instances of triggers as devices, but this
will allow futher reduction in error patch complexity in
some of our most complex drivers making it a very good thing.
3) Trivial removal of unused defines in adjd_s311
4) Drop some write_raw_get_fmt callbacks where they were only
returning the default value.
5) Change mxs-lradc realbits to 12. Whilst an 18bit register
is used on the device, in its current mode only 12 bits of
useful data are returned. For now the packing is unchanged
in the buffer and this change mainly effects the input support
in the driver.
Add a resource managed devm_iio_trigger_alloc()/devm_iio_triger_free()
to automatically clean up triggers allocated by IIO drivers, thus
leading to simplified IIO drivers code.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com> Signed-off-by: Kyunmin Park <kyungmin.park@samsung.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
The GPADC is general purpose ADC found on TWL6030, and TWL6032 PMIC,
known also as Phoenix and PhoenixLite.
The TWL6030 and TWL6032 have GPADC with 17 and 19 channels
respectively. Some channels have current source and are used for
measuring voltage drop on resistive load for detecting battery ID
resistance, or measuring voltage drop on NTC resistors for external
temperature measurements. Some channels measure voltage, (i.e. battery
voltage), and have voltage dividers, thus, capable to scale voltage.
Some channels are dedicated for measuring die temperature.
Some channels are calibrated in 2 points, having offsets from ideal
values kept in trim registers. This is used to correct measurements.
The differences between GPADC in TWL6030 and TWL6032:
- 10 bit vs 12 bit ADC;
- 17 vs 19 channels;
- channels have different purpose(i.e. battery voltage
channel 8 vs channel 18);
- trim values are interpreted differently.
Based on the driver patched from Balaji TK, Graeme Gregory, Ambresh K,
Girish S Ghongdemath.
Signed-off-by: Balaji T K <balajitk@ti.com> Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk> Signed-off-by: Oleksandr Kozaruk <oleksandr.kozaruk@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
The LRADC virtual channels have an 18 bit field to store the sum of up
to 2^5 accumulated samples. The read_raw function however only operates
over a single sample (12 bit resolution).
In order to use this field for scaling operations, we need it to be the
exact resolution value of the LRADC.
Besides, the driver was using an 18 bit mask (LRADC_CH_VALUE_MASK) to
report touch coordinates to userland. A 12 bit mask should be used instead
or else the touch libraries will expect a coordinates range between 0
and 0x3ffff (18 bits), instead of between 0 and 0xfff (12 bits).
Signed-off-by: Hector Palacios <hector.palacios@digi.com> Acked-by: Marek Vasut <marex@denx.de> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Peter Meerwald [Thu, 8 Aug 2013 16:39:00 +0000 (17:39 +0100)]
iio: Add tmp006 IR temperature sensor
the TI TMP006 is a non-contact temperature sensor with I2C interface;
it measures the surface temperature of a distance object using a
thermopile to absorb IR energy emitted from the object
the sensor has two channels: IR sensor voltage (16-bit) and reference
temperature of the chip (14-bit); datasheet is here:
http://www.ti.com/lit/ds/symlink/tmp006.pdf
v2 (thanks to Grygorii Strashko, Lars-Peter Clausen, Jonathan Cameron
for review comments):
* power down device on driver remove
* use sign_extend32()
* style cleanup
* add comments what channel raw LSBs mean
* spelling of thermopile
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Cc: Grygorii Strashko <grygorii.strashko@ti.com> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Jonathan Cameron <jic23@kernel.org> Cc: LM Sensors <lm-sensors@lm-sensors.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Yann Droneaud [Thu, 15 Aug 2013 13:10:54 +0000 (15:10 +0200)]
android/sync: use get_unused_fd_flags(O_CLOEXEC) instead of get_unused_fd()
Macro get_unused_fd() is used to allocate a file descriptor with
default flags. Those default flags (0) can be "unsafe":
O_CLOEXEC must be used by default to not leak file descriptor
across exec().
Instead of macro get_unused_fd(), functions anon_inode_getfd()
or get_unused_fd_flags() should be used with flags given by userspace.
If not possible, flags should be set to O_CLOEXEC to provide userspace
with a default safe behavor.
In a further patch, get_unused_fd() will be removed so that
new code start using anon_inode_getfd() or get_unused_fd_flags()
with correct flags.
This patch replaces calls to get_unused_fd() with call to
get_unused_fd_flags(O_CLOEXEC) following advice from Erik Gilling.
Yann Droneaud [Thu, 15 Aug 2013 13:10:53 +0000 (15:10 +0200)]
android/sw_sync: use get_unused_fd_flags(O_CLOEXEC) instead of get_unused_fd()
Macro get_unused_fd() is used to allocate a file descriptor with
default flags. Those default flags (0) can be "unsafe":
O_CLOEXEC must be used by default to not leak file descriptor
across exec().
Instead of macro get_unused_fd(), functions anon_inode_getfd()
or get_unused_fd_flags() should be used with flags given by userspace.
If not possible, flags should be set to O_CLOEXEC to provide userspace
with a default safe behavor.
In a further patch, get_unused_fd() will be removed so that
new code start using anon_inode_getfd() or get_unused_fd_flags()
with correct flags.
This patch replaces calls to get_unused_fd() with call to
get_unused_fd_flags(O_CLOEXEC) following advice from Erik Gilling.
Jens Frederich [Thu, 15 Aug 2013 19:34:55 +0000 (21:34 +0200)]
Staging: olpc_dcon: replace some magic numbers
This patch replace some magic numbers. I believe it makes
the driver more readable.
The magic number 0x26 is the XO system embedded controller
(EC) command 'DCON power enable/disable'.
Number 0x41, and 0x42 are special memory controller settings
register. The 0x41 initialize bit sequence 0x101 means:
enable memory power down function and special SDRAM clock
delay for synchronize SDRAM output and clock signal.
The 0x42 initialize squence 0x101 is wrong. According to
the specification Bit 8 is reserved, thus not in use.
I removed it.
Lidza Louina [Thu, 15 Aug 2013 14:28:22 +0000 (10:28 -0400)]
staging: dgnc: removes proc code
This patch removes the dgnc_proc.c and dgnc_proc.h files and all
references to proc functions in dgnc_driver.c. This also removes proc.h
from the include headers in driver.c, mgmt.c and sysfs.c and proc.o
from the Makefile.
drivers/staging/comedi/drivers/das16.c: In function 'das16_detach':
drivers/staging/comedi/drivers/das16.c:1234: error: implicit declaration of function 'kfree'
Cc: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Dan Carpenter [Tue, 13 Aug 2013 17:29:26 +0000 (18:29 +0100)]
staging: ozwpan: Separate success & failure case for oz_hcd_pd_arrived()
This patch separates success & failure block along with fixing
following issues:-
1. The way oz_hcd_pd_arrived() looks now it's easy to think we free "ep" but
actually we do this spaghetti thing of setting it to NULL on success.
2. It is hard to read it because there are unlocks scattered throughout.
3. Currently we set "ep" to NULL on the success path and then test it and or
free it. In current code you have to scroll to the start of the function
to read code.
Original patch was submitted by Dan here :-
http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2013-August/040113.html
Lidza Louina [Tue, 13 Aug 2013 19:49:58 +0000 (15:49 -0400)]
staging: dgnc: removes read_cnt, real_raw, rawreadok and buf
This patch removes the use of read_cnt, real_raw, buf and rawreadok. The
variable buf is never used in the code. The variables rawreadok read_cnt
and real_raw don't exist in the new API. Reading the data raw is no
longer supported by the tty layer.
Lidza Louina [Tue, 13 Aug 2013 19:49:57 +0000 (15:49 -0400)]
staging: dgnc: fixes ioctl param list
The declaration for the ioctl function has changed. The previous version
of this declaration took struct file *file as a parameter and the new
one does not. This patch removes that parameter.
Lidza Louina [Tue, 13 Aug 2013 19:49:54 +0000 (15:49 -0400)]
staging: dgnc: fixes tty_port and tty_struct params
The functions tty_flip_buffer_push, tty_insert_flip_string,
tty_insert_flip_char and tty_buffer_request_room now require a struct of
type tty_port instead of struct tty_struct. This patch makes those
changes.
staging: vt6656: rxtx.c s_uFillDataHead remove dead variables.
As result of patches
staging: vt6656: rxtx.c: s_uGetDataDuration remove First Frag or Mid Frag dead code
staging: vt6656: rxtx.c: s_uGetDataDuration remove dead variables.
variables uFragIdx, cbLastFragmentSize, uMACfragNum are dead.
Minchan Kim [Mon, 12 Aug 2013 06:13:56 +0000 (15:13 +0900)]
zram: don't grab mutex in zram_slot_free_noity
[1] introduced down_write in zram_slot_free_notify to prevent race
between zram_slot_free_notify and zram_bvec_[read|write]. The race
could happen if somebody who has right permission to open swap device
is reading swap device while it is used by swap in parallel.
However, zram_slot_free_notify is called with holding spin_lock of
swap layer so we shouldn't avoid holing mutex. Otherwise, lockdep
warns it.
This patch adds new list to handle free slot and workqueue
so zram_slot_free_notify just registers slot index to be freed and
registers the request to workqueue. If workqueue is expired,
it holds mutex_lock so there is no problem any more.
If any I/O is issued, zram handles pending slot-free request
caused by zram_slot_free_notify right before handling issued
request because workqueue wouldn't be expired yet so zram I/O
request handling function can miss it.
Lastly, when zram is reset, flush_work could handle all of pending
free request so we shouldn't have memory leak.
NOTE: If zram_slot_free_notify's kmalloc with GFP_ATOMIC would be
failed, the slot will be freed when next write I/O write the slot.
[1] [57ab0485, zram: use zram->lock to protect zram_free_page()
in swap free notify path]
* from v2
* refactoring
* from v1
* totally redesign
Cc: Nitin Gupta <ngupta@vflare.org> Cc: Jiang Liu <jiang.liu@huawei.com> Cc: stable@vger.kernel.org Signed-off-by: Minchan Kim <minchan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Minchan Kim [Mon, 12 Aug 2013 06:13:55 +0000 (15:13 +0900)]
zram: fix invalid memory access
[1] tried to fix invalid memory access on zram->disk but it didn't
fix properly because get_disk failed during module exit path.
Actually, we don't need to reset zram->disk's capacity to zero
in module exit path so that this patch introduces new argument
"reset_capacity" on zram_reset_divice and it only reset it when
reset_store is called.
[1] 6030ea9b, zram: avoid invalid memory access in zram_exit()
Cc: Nitin Gupta <ngupta@vflare.org> Cc: Jiang Liu <jiang.liu@huawei.com> Cc: stable@vger.kernel.org Signed-off-by: Minchan Kim <minchan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Paul Zimmerman [Sun, 11 Aug 2013 19:50:17 +0000 (12:50 -0700)]
staging: dwc2: reorder some kernel doc comments and struct members
Reorder the kernel doc comments for 'struct dwc2_core_params' to
match the ordering in the struct itself. Reorder the members of
'struct dwc2_qh' (and its kerneldoc comments) to minimize the
amount of structure padding.
Signed-off-by: Paul Zimmerman <paulz@synopsys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Removed the unneeded SBE_INCLUDE_SYMBOLS #define, and the associated STATIC
#define, and replaced all occurances of STATIC with 'static'. This was in
response to sparse warnings of the form "symbol 'XYZ' was not declared. Should
it be static?".
Removed a function prototype (musycc_init_port) as adding the 'static'
declaration produced a new gcc warning. (musycc_init_port is only declared if
SBE_WAN256T3_ENABLE is set)
DIO subdevices always handle the INSN_CONFIG_DIO_{INPUT,OUTPUT} instructions
to configure the DIO channels. They also always handle the INSN_CONFIG_DIO_QUERY
instruction to query the configuration of a DIO channel.
Introduce a helper function to handle the (*insn_config) boilerplate for
comedi DIO subdevices. This function has the same paramters as (*insn_config)
functions with an additional parameter to allow the caller to pass a 'mask'
value for grouped DIO channels.
This function returns:
0 if the instruction was successful but requires additional handling by
the caller (INSN_CONFIG_DIO_{INPUT,OUTPUT}
insn->n if the instruction was handled (INSN_CONFIG_DIO_QUERY)
-EINVAL for all unhandled instructions
The caller is responsible for actually configuring the hardware based on
the configuration (s->io_bits).
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: drivers: use comedi_dio_insn_config() for complex cases
Convert the drivers with complex, port programmable i/o, to use the
comedi_dio_insn_config() helper function.
All of these drivers have some sort of 'port' programmable i/o where multiple
i/o channels are configured as a group. The 'mask' associated with the group
is passed to comedi_dio_insn_config() so that all the channels are configured.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
zcache is obsolete and not used anymore, Bob Liu has rewritten it and is
submitting it for inclusion through the main -mm tree, as it should have
been done in the first place...
Cc: Bob Liu <lliubbo@gmail.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Kyungmin Park <kmpark@infradead.org> Cc: Wanpeng Li <liwanp@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: drivers: use comedi_dio_insn_config() for complex cases
Convert the drivers with complex, port programmable i/o, to use the
comedi_dio_insn_config() helper function.
All of these drivers have some sort of 'port' programmable i/o where multiple
i/o channels are configured as a group. The 'mask' associated with the group
is passed to comedi_dio_insn_config() so that all the channels are configured.
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>
DIO subdevices always handle the INSN_CONFIG_DIO_{INPUT,OUTPUT} instructions
to configure the dio channels. They also always handle the INSN_CONFIG_DIO_QUERY
instruction to query the configuration of a dio channel.
Introduce a helper function to handle the (*insn_config) boilerplate for
comedi DIO subdevices. This function has the same parameters as (*insn_config)
functions with an additional parameter to allow the caller to pass a 'mask'
value for grouped dio channels.
This function returns:
0 if the instruction was successful but requires additional handling by
the caller (INSN_CONFIG_DIO_{INPUT,OUTPUT}
insn->n if the instruction was handled (INSN_CONFIG_DIO_QUERY)
-EINVAL for all unhandled instructions
The caller is responsible for actually configuring the hardware based on
the configuration (s->io_bits).
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>