iio: buffer: Allocate standard attributes in the core
All buffers want at least the length and the enable attribute. Move the
creation of those attributes to the core instead of having to do this in
each individual buffer implementation. This allows us to get rid of some
boiler-plate code.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: buffer: Move iio_buffer_alloc_sysfs and iio_buffer_free_sysfs
The next patch will introduce new dependencies in iio_buffer_alloc_sysfs()
to functions which are currently defined after iio_buffer_alloc_sysfs(). To
avoid forward declarations move both iio_buffer_alloc_sysfs() and
iio_buffer_free_sysfs() after those function.
This is split into two patches one moving the functions and one adding the
dependencies to make review of the actual changes easier.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: Remove get_bytes_per_datum() from iio_buffer_access_funcs
There haven't been any users of the get_bytes_per_datum() callback for a
while. The core assumes that the number of bytes per datum can be calculated
based on the enabled channels and the storage size of the channel and
iio_compute_scan_bytes() is used to compute this number. So remove the
callback.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Originally device and buffer registration were kept as separate operations
in IIO to allow to register two distinct sets of channels for buffered and
non-buffered operations. This has since already been further restricted and
the channel set registered for the buffer needs to be a subset of the
channel set registered for the device. Additionally the possibility to not
have a raw (or processed) attribute for a channel which was registered for
the device was added a while ago. This means it is possible to not register
any device level attributes for a channel even if it is registered for the
device. Also if a channel's scan_index is set to -1 and the channel is
registered for the buffer it is ignored.
So in summary it means it is possible to register the same channel array for
both the device and the buffer yet still end up with distinctive sets of
channels for both of them. This makes the argument for having to have to
manually register the channels for both the device and the buffer invalid.
Considering that the vast majority of all drivers want to register the same
set of channels for both the buffer and the device it makes sense to move
the buffer registration into the core to avoid some boiler-plate code in the
device driver setup path.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:dummy: Register same channels for device and buffer
In preparation for moving the buffer registration to the core make sure to
register the same channel array for the device and the buffer. Currently the
output voltage and the activity channels are not registered for the buffer,
setting its scan index to -1 will make sure that it is skipped for the
buffer.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:sca3000: Register same channels for device and buffer
In preparation for moving the buffer registration to the core make sure to
register the same channel array for the device and the buffer. Currently
the temperature channel is not registered for the buffer, setting its scan
index to -1 will make sure that it is skipped for the buffer.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Individual drivers should not be messing with the scan mask that contains
the list of enabled channels. This is something that is supposed to be
managed by the core.
Now that the last few drivers that used it to configure a default scan mask
have been updated to not do this anymore we can unexport the function.
Note, this patch also requires moving a few functions around so they are all
declared before the first internal user.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Reviewed-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Irina Tirdea [Fri, 5 Dec 2014 22:18:08 +0000 (00:18 +0200)]
iio: accel: kxcjk-1013: only set power state if CONFIG_PM is defined
When CONFIG_PM is not defined and the driver tries to power off the device,
kxcjk1013_set_power_state will call pm_runtime_put_autosuspend, which is
not implemented (wil return -ENOSYS).
Only call pm_runtime calls to change power state when CONFIG_PM is defined.
Irina Tirdea [Fri, 5 Dec 2014 22:18:07 +0000 (00:18 +0200)]
iio: accel: kxcjk-1013: always power on device in resume
When the system resumes, it will first call system resume and
then runtime suspend (if CONFIG_RUNTIME_PM is enabled).
There is no need to conditionally power on the device in
system resume, so always power it on and leave runtime
suspend to power it off if needed.
This chip allows some limited number of sensors connected to it as
slaves, which can be directly accessed by register interface of this
driver.But the current upstream driver doesn't support such mode.
To attach such slaves to main processor i2c bus, chip has to be set
up in bypass mode. This change adds i2c mux, which will enable/disable
this mode for transaction to/from such slave devices.
This was discussed for a while in mailing list, this was the outcome:
Reference:
http://www.spinics.net/lists/linux-iio/msg12126.html
http://comments.gmane.org/gmane.linux.kernel.iio/11470
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Reviewed-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Gwendal Grignou [Fri, 21 Nov 2014 18:45:49 +0000 (10:45 -0800)]
iio: ak8975: add ak09911 and ak09912 support
Add 2 new definition entries to support ak0991x compass.
Add a more advanced function to check we are dealing with the
expected device.
Remove standalone driver for ak09911.
Gwendal Grignou [Fri, 21 Nov 2014 18:45:48 +0000 (10:45 -0800)]
iio: ak8975: add definition structure per compass type
For each type of compass supported (AK8975 and AK8963),
add a definition structure for register masks, important registers,
raw data interpretation.
This change will make integrating new type of devices easier.
Remove i2c register cache. It is only used for one single register.
Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Zachary Warren [Sat, 22 Nov 2014 11:19:31 +0000 (22:19 +1100)]
drivers:staging:iio: fix checkpatch complaint about space before comma
Fixes:
drivers/staging/iio/adc/ad7192.c:615: ERROR: space prohibited before that ','
drivers/staging/iio/meter/ade7759.c:119: ERROR: space prohibited before that ','
Signed-off-by: Zachary Warren <conflatulence@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Daniel Baluta [Mon, 10 Nov 2014 12:45:34 +0000 (14:45 +0200)]
iio: dummy: Demonstrate the usage of new channel types
Adds support for the new channel types in the dummy driver:
* a new channel IIO_ACTIVITY
* two state transition events (running and walking)
* a new channel IIO_STEPS and support for reading and writing
pedometer step counter
* step detect event
* a new IIO_CHAN_INFO_CALIBHEIGHT mask bit for reading and writing
user's height.
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Irina Tirdea [Mon, 10 Nov 2014 12:45:33 +0000 (14:45 +0200)]
iio: core: Introduce IIO_CHAN_INFO_CALIBHEIGHT
Some devices need the height of the user to compute various
parameters. One of this devices is Freescale's MMA9553L
(http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf)
that needs the height of the user to compute the stride length which
is used further to determine distance, speed and activity type.
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Irina Tirdea [Mon, 10 Nov 2014 12:45:32 +0000 (14:45 +0200)]
iio: core: Introduce STEPS channel, ENABLE mask and INSTANCE event
These changes are needed to support the functionality of a pedometer.
A pedometer has two basic functionalities: step counter and step detector.
The step counter needs to be enabled and then it will count the steps
in its hardware register. Whenever the application needs to check
the step count, it will read the step counter register. To support the
step counter a new channel type STEPS is added. Since the pedometer needs
to be enabled first so that the hardware can count and store the steps,
we need a specific ENABLE channel info mask.
The step detector will generate an interrupt each time a step is detected.
To support this functionality we add a new event type INSTANCE.
For more information on the Android requirements for step counter and step
detector see:
http://source.android.com/devices/sensors/composite_sensors.html#counter
and http://source.android.com/devices/sensors/composite_sensors.html#detector.
A device that has the pedometer functionality this interface needs to
support is Freescale's MMA9553L:
http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Daniel Baluta [Mon, 10 Nov 2014 12:45:30 +0000 (14:45 +0200)]
iio: core: Introduce IIO_ACTIVITY channel
This channel will be used for exposing information about
activity composite sensors. Activities supported so far:
* running
* jogging
* walking
* still
THRESHOLD event is used to signal a change in the activity
state.
We associate a confidence interval for each activity expressed
as a percentage from 0 to 100.
* 0, means the sensor IS NOT reporting that activity.
* 100, means the sensor IS reporting that activity.
Users of this interface have two possible means to gather
information about the ongoing activities.
1. Event based, via event file descriptor
* sensor may report an event when ENTERING an activity or LEAVING
an activity based on a threshold value.
* drivers will wake up applications waiting data on the event fd
2. Polling, by reading the sysfs associated attribute files:
* /sys/bus/iio/devices/iio:device0/in_activity_running_input
expressed as percentage confidence value from 0 to 100.
This will offer an interface for Android significant motion
composite sensor defined here:
http://source.android.com/devices/sensors/composite_sensors.html
Activities listed above are supported by Freescale's MMA9553 sensor:
http://freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Bastien Nocera [Sun, 11 May 2014 21:09:00 +0000 (22:09 +0100)]
iio:kxcjk-1013: Add support for SMO8500 device
The Onda v975w tablet contains an accelerometer that's advertised over
ACPI as SMO8500. This device is however a KXCJ9 accelerometer as
can be seen in the Windows driver's INF file, and from the etching on
the chipset ("KXCJ9 41566 0414").
This patch also removes the attempt to get the IRQ for the "data ready"
signal, as it does not seem to be supported by this device on this
platform.
Signed-off-by: Bastien Nocera <hadess@hadess.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging: comedi: usbduxsigma: use comedi_async 'scans_done' to detect AI EOA
Remove the private data member 'ai_sample_count' and use the comedi_async
'scans_done' member to detect the analog input end-of-acquisition.
Move the EOA check so it happens after adding the samples from the current
urb to the async buffer. This prevents the unnecessary resubmit of the urb
when the EOA occurs.
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>
staging: comedi: usbdux: use comedi_async 'scans_done' to detect AI EOA
Remove the private data member 'ai_sample_count' and use the comedi_async
'scans_done' member to detect the analog input end-of-acquisition.
Move the EOA check so it happens after adding the samples from the current
urb to the async buffer. This prevents the unnecessary resubmit of the urb
when the EOA occurs.
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>
staging: comedi: comedidev.h: add 'scans_done' member to comedi_async
Introduce a new member to comedi_async to count the number of scans completed.
This member is cleared by comedi_buf_reset() along with the other comedi_async
members. It is incremented in comedi_inc_scan_progress() when the end of scan
is detected.
This member will be used to clean up the scan counting in the comedi drivers.
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>
Ian Abbott [Tue, 4 Nov 2014 18:09:01 +0000 (18:09 +0000)]
staging: comedi: add ioctls to set per-file read and write subdevice
Now that Comedi has the structures in place to support setting the
current "read" and/or "write" subdevice on a per-file object basis, add
new ioctls to set them. The newly chosen "read" ("write") subdevice
needs to support "read" ("write") commands, and the file cannot be busy
handling a "read" ("write") command on the previous subdevice (if any).
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>
Ian Abbott [Tue, 4 Nov 2014 18:09:00 +0000 (18:09 +0000)]
staging: comedi: prepare support for per-file read and write subdevices
Comedi devices may have several subdevices that support "read" and/or
"write" asynchronous commands that use the "read" or "write" file
operations for data transfer. The low-level Comedi drivers may nominate
a default "read" subdevice and/or a default "write" subdevice, but it
may have other subdevices that support asynchronous commands.
The Comedi core provides a somewhat clunky mechanism to provide access
to the asynchronous command support of the non-default subdevices. When
a low-level device is "attached" to a core Comedi device, it dynamically
allocates a minor device number for each of the subdevices that support
asynchrounous commands and associates them with files created in SysFS
named "comediX_subdY", where "X" is the minor device number of the main
comedi device, and "Y" is the subdevice number. An application can open
these subdevice-specific files and they behave like the regular
"comediX" files except that the "read" and/or "write" subdevice may be
different to the default chosen by the low-level driver.
This patch adds a layer of indirection between the file object and the
comedi device object to allow the current "read" and/or "write"
subdevice to be altered after opening the Comedi device, on a per-file
object basis. The advantage is that an application only needs to open
the main Comedi device file and can then choose which subdevice it wants
to "read" or "write". The main Comedi device file can be opened more
than once, and each file object can choose the "read" and "write"
subdevices independently.
The new `struct comedi_file` is created on "open" and freed on
"release". It includes pointers to the main Comedi device structure,
and to the current "read" and "write" subdevice structures (which may be
NULL). It also has information to keep track of when a low-level device
has been attached or detached since the previous time the file object
was used. In that case, the current "read" and "write" subdevices in
the `struct comedi_file` will be changed to the new defaults (or set to
NULL). (The change to new defaults is done by `comedi_file_reset()`.
The checking for attach/detach is done by `comedi_file_check()` which
will call `comedi_file_reset()` if there have been any attach/detach
operations since the previous call.)
A subsequent patch will add the ioctls to change the current "read" and
"write" subdevices.
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>
Daeseok Youn [Wed, 5 Nov 2014 08:58:11 +0000 (17:58 +0900)]
staging: dgap: remove unnecessary function
The dgap_init_global() initialize the dgap_board
that is a global variable as static and dgap_poll_timer.
But init_timer() is called twice in dgap_start() and dgap_board
doesn't need to be initialized to NULL.
Ken Depro [Wed, 5 Nov 2014 15:57:57 +0000 (10:57 -0500)]
staging: unisys: Remove extra blank lines from virthba files
This patch removes extra blank lines from the virthba header and source
files. This is the first of a set of patches that will clean up the
virthba source file. The only checkpatch issue in the header file was
the blank line warnings.
Signed-off-by: Ken Depro <kenneth.depro@unisys.com> Signed-off-by: Ben Romer <benjamin.romer@unisys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Benjamin Romer [Tue, 4 Nov 2014 16:25:19 +0000 (11:25 -0500)]
staging: unisys: fix line over 80 characters in mapit()
The error output in mapit() in memregion_direct.c has variables past the 80
character limit. Move them to the next line, but the string constant will still
go past the limit, and that's okay.
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Merge tag 'iio-for-3.19a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes:
First round of new drivers, features and cleanups for IIO in the 3.19 cycle.
New drivers / supported parts
* rockchip - rk3066-tsadc variant
* si7020 humidity and temperature sensor
* mcp320x - add mcp3001, mcp3002, mcp3004, mcp3008, mcp3201, mcp3202
* bmp280 pressure and temperature sensor
* Qualcomm SPMI PMIC current ADC driver
* Exynos_adc - support exynos7
New features
* vf610-adc - add temperature sensor support
* Documentation of current attributes, scaled pressure, offset and
scaled humidity, RGBC intensity gain factor and scale applied to
differential voltage channels.
* Bring iio_event_monitor up to date with newer modifiers.
* Add of_xlate function to allow for complex channel mappings from the
device tree.
* Add -g parameter to generic_buffer example to allow for devices with
directly fed (no trigger) buffers.
* Move exynos driver over to syscon for PMU register access.
Cleanups, fixes for new drivers
* lis3l02dq drop an unneeded else.
* st sensors - renam st_sensors to st_sensor_settings (for clarity)
* st sensors - drop an unused parameter from all the probe utility
functions.
* vf610 better error handling and tidy up.
* si7020 - cleanups following merge
* as3935 - drop some unnecessary semicolons.
* bmp280 - fix the pressure calculation.
Hartmut Knaack [Fri, 31 Oct 2014 01:22:00 +0000 (01:22 +0000)]
iio:pressure:bmp280: fix pressure calculation
According to the datasheet and as defined in struct bmp280_comp_press, dig_p1 is
of type u16, while dig_p2 to dig_p9 are of type s16. In
bmp280_read_compensation_press(), values read from the device were treated as
the wrong type.
In bmp280_read_press() the fractional part of the measured pressure is
calculated wrong. A better way is to use *val for the raw pressure and *val2 for
the quotient and let the core do the proper conversion using IIO_VAL_FRACTIONAL.
The ADC on exynos7 is quite similar to ADCv2. The differences are as
follows:
- exynos7-adc has 8 input channels (as against 10 in ADCv2).
- exynos7 does not include an ADC PHY control register.
- Some ADC_CON2 register bits being used in ADCv2 are listed as
reserved in exynos7-adc. This results in a different init_hw
function for exynos7.
Instead of using the ADC_PHY register base address, use sysreg phandle
in ADC node to control ADC_PHY configuration register.
This patch adds syscon node for Exynos3250, Exynos4x12, Exynos5250,
and Exynos5420, Exynos5800.
Signed-off-by: Naveen Krishna Chatradhi <ch.naveen@samsung.com>
To: linux-samsung-soc@vger.kernel.org Acked-by: Kukjin Kim <kgene.kim@samsung.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Documentation: dt-bindings: update exynos-adc.txt with syscon handle
This patch updates the DT bindings for ADC in exynos-adc.txt with the
syscon phandle to the ADC nodes.
Signed-off-by: Naveen Krishna Chatradhi <ch.naveen@samsung.com>
To: devicetree@vger.kernel.org Acked-by: Kukjin Kim <kgene.kim@samsung.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: exyno-adc: use syscon for PMU register access
This patch updates the IIO based ADC driver to use syscon and regmap
APIs to access and use PMU registers instead of remapping the PMU
registers in the driver.
Signed-off-by: Naveen Krishna Chatradhi <ch.naveen@samsung.com>
To: linux-iio@vger.kernel.org Acked-by: Kukjin Kim <kgene.kim@samsung.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Jia He [Tue, 4 Nov 2014 01:39:58 +0000 (09:39 +0800)]
staging: rtl8188eu: Fix coding style space related ERROR problems
This fixes space related ERROR reports by checkpatch.pl
Generated by $ git ls-files "drivers/staging/rtl8188eu/*.[ch]" | \
xargs ./scripts/checkpatch.pl -f --fix-inplace --strict --types=SPACING
Already checked by text comparasion
$git diff -w
and binary comparasion of r8188eu.ko
$objdiff diff <old_commit> <new_commit>
Signed-off-by: Jia He <hejianet@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Joe Perches [Tue, 4 Nov 2014 00:25:44 +0000 (16:25 -0800)]
staging: ft1000: Logging message neatening
Use a more common logging style.
o Convert DEBUG macros to pr_debug
o Add pr_fmt
o Remove embedded function names from pr_debug
o Convert printks to pr_<level>
o Coalesce formats and align arguments
o Add missing terminating newlines
Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>