aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/accel/hid-sensor-accel-3d.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-11-16iio/hid-sensors: Fix IIO_CHAN_INFO_RAW returning wrong values for signed numbersHans de Goede1-1/+4
Before this commit sensor_hub_input_attr_get_raw_value() failed to take the signedness of 16 and 8 bit values into account, returning e.g. 65436 instead of -100 for the z-axis reading of an accelerometer. This commit adds a new is_signed parameter to the function and makes all callers pass the appropriate value for this. While at it, this commit also fixes up some neighboring lines where statements were needlessly split over 2 lines to improve readability. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-07iio: Replace occurrences of magic number 0 by IIO_CHAN_INFO_RAWRodrigo Siqueira1-1/+1
Usually, functions responsible for reading raw data typically relies on values from iio_chan_info_enum to correctly identify the type of data to be read. There is a set of a device driver that uses the magic number 0 instead of IIO_CHAN_INFO_RAW. This patch improves the readability by replaces the magic number 0 for the appropriate IIO_CHAN_INFO_RAW in six devices driver in the IIO subsystem. Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-08-22iio:accel: drop assign iio_info.driver_module and iio_trigger_ops.ownerJonathan Cameron1-1/+0
The equivalent of both of these are now done via macro magic when the relevant register calls are made. The actual structure elements will shortly go away. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-05-07iio: hid-sensor-accel-3d: Drop unnecessary staticJulia Lawall1-1/+1
Drop static on a local variable, when the variable is initialized before use, on every possible execution path through the function. The static has no benefit, and dropping it reduces the code size. The semantic patch that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @bad exists@ position p; identifier x; type T; @@ static T x@p; ... x = <+...x...+> @@ identifier x; expression e; type T; position p != bad.p; @@ -static T x@p; ... when != x when strict ?x = e; // </smpl> The change in code size is indicates by the following output from the size command. before: text data bss dec hex filename 3879 512 8 4399 112f drivers/iio/accel/hid-sensor-accel-3d.o after: text data bss dec hex filename 3863 512 0 4375 1117 drivers/iio/accel/hid-sensor-accel-3d.o Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-04-02iio: accel: hid-sensor-accel-3d: Fix duplicate scan index errorSrinivas Pandruvada1-1/+2
When both accel_3d and gravity sensor are present, iio_device_register() fails with "Duplicate scan index" error. The reason for this is setting of indio_dev->num_channels based on accel_3d channel for both gravity and accel-3d sensor. But number of channels are not same, so for gravity it is pointing to some invalid memory and getting scan_index to compare which may match. To fix this issue, set the indio_dev->num_channels correctly based on the sensor type. Fixes: 0e377f3b9ae9 ('iio: Add gravity sensor support') Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-05iio: Add gravity sensor supportSong Hongyan1-13/+61
Gravity sensor is a soft sensor, which derives value from standard accelerometer device by filtering out the acceleration which is not caused by gravity. Gravity sensor provides a three dimensional vector indicating the direction and magnitude of gravity. Typically, this sensor is used to determine the device's relative orientation in space. The units and the coordinate system is the same as the one used by the acceleration sensor. When a device is at rest, the output of the gravity sensor should be identical to that of the accelerometer. More information can be found in: http://www.usb.org/developers/hidpage/HUTRR59_-_Usages_for_Wearables.pdf Gravity sensor and accelerometer have similar channels and share channel usage ids. So the most of the code for accel_3d can be reused. Signed-off-by: Song Hongyan <hongyan.song@intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-03iio: accel: hid-sensor-accel-3d: Add timestampSrinivas Pandruvada1-8/+24
Added timestamp channel. With this change, each sample has a timestamp. This timestamp can be from the sensor hub when present or local kernel timestamp. HID sensors can send timestamp with input data using usage id HID_USAGE_SENSOR_TIME_TIMESTAMP. This timestamp value is converted to nano seconds before pushing this sample to the iio core. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: accel: hid-sensor-accel-3d: Fix memory leak in probe()Fabio Estevam1-7/+6
'channels' is allocated via kmemdup and it is never freed in the subsequent error paths. Use 'indio_dev->channels' directly instead, so that we avoid such memory leak problem. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-10iio: hid-sensor-accel-3d: Constify platform_device_idKrzysztof Kozlowski1-1/+1
The platform_device_id is not modified by the driver and core uses it as const. Signed-off-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-04-13Merge branch 'for-4.1/sensor-hub' into for-linusJiri Kosina1-1/+2
Conflicts: drivers/iio/common/hid-sensors/hid-sensor-trigger.c include/linux/hid-sensor-hub.h
2015-02-23HID: hid-sensor-hub: Extend API for async readsSrinivas Pandruvada1-1/+2
Add additional flag to read in async mode. In this mode the caller will get reply via registered callback for capture_sample. Callbacks can be registered using sensor_hub_register_callback function. The usage id parameter of the capture_sample can be matched with the usage id of the requested attribute. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-01-25iio: hid-sensor-accel-3d: Introduce PMSrinivas Pandruvada1-7/+1
Use common hid sensor iio pm functions. Also the poll time read and wait is part of power up function of hid sensor iio pm function, so remove from the client drivers. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-08-26iio: remove .owner field for driver using module_platform_driverSanjeev Sharma1-1/+0
This patch removes the .owner field for drivers which use the platform_driver_register api because this is overriden in _platform_driver_register. Signed-off-by: Sanjeev Sharma <Sanjeev_Sharma@mentor.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-07-05iio: hid-sensor-accel-3d: Fix return valuesSachin Kamat1-5/+2
IIO_CHAN_INFO_SAMP_FREQ and IIO_CHAN_INFO_HYSTERESIS cases ignored the actual return values (which could be -EINVAL) and instead returned IIO_VAL_INT_PLUS_MICRO always. Return the actual value obtained from the functions. Both functions return IIO_VAL_INT_PLUS_MICRO upon success. Signed-off-by: Sachin Kamat <sachin.kamat@samsung.com> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-05-05iio: hid-sensors: Accelerometer 3D: Raw read supportSrinivas Pandruvada1-3/+18
Added support for raw reading of channel. If the sensor is powered off, it will turn on for reading value. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-05-05iio: hid-sensors: Add API to power on/offSrinivas Pandruvada1-4/+3
Added an API to allow client drivers to turn ON and OFF sensors for quick read. Added data_read as counting varaible instead of boolean, so that sensor is powered off only when last user released it. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-05-05iio: hid-sensors: Accelerometer 3D: adjust scale and offsetSrinivas Pandruvada1-4/+13
Using units and unit exponent to calculate scale which is compliant to IIO ABI. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-12-02Merge v3.13-rc2 into staging-nextGreg Kroah-Hartman1-2/+3
we want these fixes in here. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-11-05iio: hid-sensors: accelerometer: Add sensitivitySrinivas Pandruvada1-0/+12
A number of Properties that can be applied to Data Fields are per data field basis or for all data fields. Adding sensitivity field for all accelerometer fields, which is most commonly used in currently available sensor hubs. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-11-02iio: hid_Sensors: fix crash during trigger unregisterSrinivas Pandruvada1-2/+3
We can't store the trigger instance created by iio_trigger_alloc, in trig field of iio_device structure. This needs to be stored in the driver private data. Othewise it can result in crash during module unload. Hence created a trig_ptr in the common data structure for each HID sensor IIO driver and storing here. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-15iio: Remove unnecessary casts for iio_push_to_buffers()Lars-Peter Clausen1-3/+4
Now that iio_push_to_buffers() takes a void pointer for the data parameter we can remove those casts to u8*. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-19iio: Remove unnecessary _write_raw_get_fmt() in several hid-sensor driversPeter Meerwald1-8/+0
IIO_VAL_INT_PLUS_MICRO is the default, no need to return it explicitly Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Acked-by: srinivas pandruvada <srinivas.pandruvada@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-03iio: hid-sensor-accel-3d: Use devm_iio_device_allocSachin Kamat1-12/+7
Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Cc: Srinivas Pandruvada <srinivas.pandruvada@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-03iio: hid-sensor-accel-3d: add module alias for autoloadAlexander Holler1-5/+11
Add a MODULE_DEVICE_TABLE in order to let hotplug mechanisms automatically load the driver. This makes it also possible to use the usual driver name instead of HID-SENSOR-2000xx which isn't very descriptive in kernel messages. Signed-off-by: Alexander Holler <holler@ahsoftware.de> Acked-by:Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-03-17iio:hid_sensors move to info_mask_(shared_by_type/separate)Jonathan Cameron1-12/+12
The original info_mask is going away in favour of the broken out versions. Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-01-25Merge 3.8-rc5 into staging-nextGreg Kroah-Hartman1-2/+2
This resolves a merge issue with a iio driver, and the zram code. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-06hid: iio: rename struct hid_sensor_iio_common to hid_sensor_commonAlexander Holler1-1/+1
The structure with common attributes for hid-sensors isn't specific to the iio-subsystem, so rename it to hid_sensor_common. Signed-off-by: Alexander Holler <holler@ahsoftware.de> Acked-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-01-06iio: merge hid-sensor-attributes.h into hid-sensor-hub.hAlexander Holler1-1/+0
The stuff in hid-sensor-attributes.h is needed by every piece which uses hid-sensor-hub and merging it into hid-sensor-hub.h makes it accessible from outside the iio subdirectory. Signed-off-by: Alexander Holler <holler@ahsoftware.de> Acked-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-01-03Drivers: iio: remove __dev* attributes.Greg Kroah-Hartman1-2/+2
CONFIG_HOTPLUG is going away as an option. As a result, the __dev* markings need to be removed. This change removes the use of __devinit, __devexit_p, and __devexit from these drivers. Based on patches originally written by Bill Pemberton, but redone by me in order to handle some of the coding style issues better, by hand. Cc: Bill Pemberton <wfp5p@virginia.edu> Cc: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-17iio: hid-sensor: Return proper error if kmemdup failsAxel Lin1-3/+3
Return -ENOMEM instead of 0 if kmemdup fails. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-11-10staging:iio: Add support for multiple buffersJonathan Cameron1-14/+1
Route all buffer writes through the demux. Addition or removal of a buffer results in tear down and setup of all the buffers for a given device. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Tested-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
2012-09-08iio: Drop timestamp parameter from buffer store_to callbackLars-Peter Clausen1-2/+1
Drop timestamp parameter from buffer store_to callback and subsequently from iio_push_to_buffer. The timestamp parameter is unused and it seems likely that it will stay unused in the future, so it should be safe to remove it. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-07staging:iio: hid-sensors Use iio_push_to_bufferJonathan Cameron1-1/+1
Consistently use iio_push_to_buffer instead of manually calling the buffers store_to callback. These crossed with Lars-Peter's patch set doing every other case. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Acked-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
2012-09-06iio: hid-sensors: Added accelerometer 3Dsrinivas pandruvada1-0/+419
Added usage id processing for Accelerometer 3D.This uses IIO interfaces for triggered buffer to present data to user mode.This uses HID sensor framework for registering callback events from the sensor hub. Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>