summaryrefslogtreecommitdiff
path: root/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
AgeCommit message (Collapse)Author
2017-03-05iio: hid-sensor-trigger: Change get poll value function order to avoid ↵Song Hongyan
sensor properties losing after resume from S3 In function _hid_sensor_power_state(), when hid_sensor_read_poll_value() is called, sensor's all properties will be updated by the value from sensor hardware/firmware. In some implementation, sensor hardware/firmware will do a power cycle during S3. In this case, after resume, once hid_sensor_read_poll_value() is called, sensor's all properties which are kept by driver during S3 will be changed to default value. But instead, if a set feature function is called first, sensor hardware/firmware will be recovered to the last status. So change the sensor_hub_set_feature() calling order to behind of set feature function to avoid sensor properties lose. Signed-off-by: Song Hongyan <hongyan.song@intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-08-29iio: hid-sensors: avoid unused function warningArnd Bergmann
A small rework of the PM code in this driver introduced a harmless warning when CONFIG_PM_SLEEP is not set: drivers/iio/common/hid-sensors/hid-sensor-trigger.c:212:12: error: 'hid_sensor_resume' defined but not used [-Werror=unused-function] This removes the #ifdef and instead marks all three PM functions as __maybe_unused, which covers all possible cases and is harder to get wrong. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Fixes: 7f6cf7414538 ("iio: hid-sensors: use asynchronous resume") Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-08-21iio: hid-sensors: use asynchronous resumeSrinivas Pandruvada
Some platforms power off sensor hubs during S3 suspend, which will require longer time to resume. This hurts system resume time, so resume asynchronously. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-04-16iio: common: hid-sensors: use tab for indentionSlawomir Stepien
This fixes the error reported by checkpatch.pl: ERROR: code indent should use tabs where possible Signed-off-by: Slawomir Stepien <sst@poczta.fm> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-02hid-sensor: Fix suspend/resume delaySrinivas Pandruvada
By default all the sensors are runtime suspended state (lowest power state). During Linux suspend process, all the run time suspended devices are resumed and then suspended. This caused all sensors to power up and introduced delay in suspend time, when we introduced runtime PM for HID sensors. The opposite process happens during resume process. To fix this, we do powerup process of the sensors only when the request is issued from user (raw or tiggerred). In this way when runtime, resume calls for powerup it will simply return as this will not match user requested state. Note this is a regression fix as the increase in suspend / resume times can be substantial (report of 8 seconds on Len's laptop!) Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Tested-by: Len Brown <len.brown@intel.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-04-13Merge branch 'for-4.1/sensor-hub' into for-linusJiri Kosina
Conflicts: drivers/iio/common/hid-sensors/hid-sensor-trigger.c include/linux/hid-sensor-hub.h
2015-02-23HID: hid-sensor-hub: Enhance feature report set APISrinivas Pandruvada
Current API only allows setting one offset in the field. This API is extended to set multiple offsets in the field report. Also update parameters in the users of this API. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-02-23HID: hid-sensor-hub: Enhance get feature report APISrinivas Pandruvada
Some hid sensor feature report can contain more than one reports. This API can now support receiving multiple values from the feature report. Also update the parameters in the users of this API. 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_hub: Common PM functionsSrinivas Pandruvada
To improvement power and performance, both regular and run time callbacks are introduced. Because of auto suspend delay, two consecutive read don't have to go through full power on/off procedure. The auto suspend time can be adjusted using regular power attributes of PM sysfs. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-08-25iio: hid_sensor_hub: Fix indio_dev->trig assignmentSrinivas Pandruvada
This can result in wrong reference count for trigger device, call iio_trigger_get to increment reference. Refer to http://www.spinics.net/lists/linux-iio/msg13669.html for discussion with Jonathan. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org> Cc: Stable@vger.kernel.org
2014-06-18Merge tag 'iio-fixes-for-3.16a' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus Jonathan writes: First set of IIO fixes for the 3.16 cycle. A mixed bag of fixes, many of which feel just to late for 3.15. * hid sensors - some devices need a feature report request in order to change power state. This isn't part of the spec, but has been observed on several devices and does no harm to others. * mpl3115 has had two errors in the buffer description fixed. The presure is signed, not unsigned and the temperature has 12 bits rather than 16. These could lead to incorrect interpretation of the data in userspace. * tsl2x7x - the high byte of the proximity thresholds should be written along with the low byte (which was). This could lead to interesting results with large thresholds. * twl4030 - a flag to specify processed values were required was not set when initializing a reading. As such values returned were in an unknown state. Fixed by simply initializing it appropriately. * IIO_SIMPLE_DUMMY_BUFFER did not select IIO_BUFFER leading to randconfig build errors. * ak8975 was applying an unwanted le16_to_cpu conversion as the i2c framework already performs one. As such for big endian systems, the bytes would be in the wrong order in the magnetic field measurements reported. * mxs-lradc - the controllable voltage dividers were not enabled / disabled for later channels than the first one during conversion. * at91_adc error handling returned -ENOMEM in a u8. Return value of at91_adc_get_trigger_value_by_name changed to int thus allowing -ENOMEM and also original values to be returned. * mcb - mcb_request_mem returns and ERR_PTR but the caller was checking for NULL to detect an error.
2014-05-29iio: hid-sensors: Get feature report from sensor hub after changing power stateArchana Patni
Some sensor hubs require a get feature report call to be issued soon after changing the power state of the sensor. Without this, the sensor remains in the current state. This patch adds a call soon after the power state. This is retained as a generic call across all sensor hubs since the behavior has been noticed on more than one implementation. Signed-off-by: Archana Patni <archana.patni@intel.com> Signed-off-by: Subramony Sesha <subramony.sesha@intel.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-05-05iio: hid-sensors: Add API to power on/offSrinivas Pandruvada
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-02-17iio: hid-sensor-hub: Remove hard coded indexesSrinivas Pandruvada
Remove the hard coded indexes, instead search for usage id and use the index to set the power and report state. This will fix issue, where the report descriptor doesn't contain the full list of possible selector for power and report state. 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>
2013-12-02iio: hid-sensors: Fix power and report stateSrinivas Pandruvada
In the original HID sensor hub firmwares all Named array enums were to 0-based. But the most recent hub implemented as 1-based, because of the implementation by one of the major OS vendor. Using logical minimum for the field as the base of enum. So we add logical minimum to the selector values before setting those fields. Some sensor hub FWs already changed logical minimum from 0 to 1 to reflect this and hope every other vendor will follow. There is no easy way to add a common HID quirk for NAry elements, even if the standard specifies these field as NAry, the collection used to describe selectors is still just "logical". 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 Pandruvada
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-10-01IIO: call sensor hub open close functionSrinivas Pandruvada
Call hid_sensor_hub_device_open when user space opens device and call hid_sensor_hub_device_close when device is closed. This helps in saving power. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-03-25iio:trigger: Introduce iio_tigger_{set,get}_drvdataLars-Peter Clausen
Introduce iio_tigger_{set,get}_drvdata which allows to attach driver specific data to a trigger. The functions wrap access to the triggers private_data field and all current users are updated to use iio_tigger_{set,get}_drvdata instead of directly accessing the private_data field. This is the first step towards removing the private_data field from the iio_trigger struct. The following coccinelle script has been used to update the drivers: <smpl> @@ struct iio_trigger *trigger; expression priv; @@ -trigger->private_data = priv +iio_trigger_set_drv_data(trigger, priv) @@ struct iio_trigger *trigger; @@ -trigger->private_data +iio_trigger_get_drv_data(trigger) </smpl> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-01-06hid: iio: rename struct hid_sensor_iio_common to hid_sensor_commonAlexander Holler
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 Holler
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>
2012-11-17iio: hid-sensors: convert HID_SENSOR_ENUM_BASE_QUIRKS to boolKirill A. Shutemov
It's non-sense to use tristate for the option, it's bool. Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22iio: hid-sensors: Prevent crash during hot-unplugSrinivas Pandruvada
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>
2012-09-06iio: hid-sensors: Common attribute and triggersrinivas pandruvada
This patch contains the common code, which is used by all HID sensors. There are some common set of attributes, which every hid sensor needs it. This patch contains all such attributes processing. Also the trigger interface is common among all HID sensors. This patch contains common trigger functions utilized by all HID sensors. Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>