mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
e28642c04a
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. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABAgAGBQJTnLYyAAoJEFSFNJnE9BaI6r4QAK22hjl1J3xoWwOPUJhfJ5Hh VTjwO1OxwQ1XtUN5WneeJM73eu6moXD/avG2NbX4orAkNjSXKL6+/3WAds/rYMj2 0vPiJsKsGBBlhu2w2RU80xVOPT2/XXIH3bYWDiUlr/i6DLEh8mU3kKX/yZzF+cIn hheYnOHZzLqGH8JircScEJv+B06svZtlfoDeLYaKY03HupTvEH95mvCSZk71PxZb A+7Qb3nDlZrpLBFKj4L5x15MIoEgopID2pX0kHLNY2DE1sopr2Z+FgSa3u/wtSEx k/ViyHPRk1mjTrQ92RMmTF5lMts6JFCmMgpPCNmcSyRKt6Fe6KcCMiWIlSs9I69i 6KAIes5XpP7Qti5Yd4gi70uiq7fL1hR18Yhzv6IdmNdS8iJhk53YiWDYiYBgXwWS rcOva4NsaoeLYUdNJZRtap3RLsQRKAxg7HNhL+G88rr3wCsA0P7rb6BMdFK+3MiS BDcYe8mHIzX9tJZa4EU8kOdr+aphQeDt1nH4aZDWT3J7fo6RWrWcPMWFAcx+1jp3 VVDL6Jn8WIuxYIDFznSQ6T6tvsvuqPgCqOA0ygfzvruo3m/oWvTT/+i2YFotGH3Y 7Mlw7TACAmcuZStBLg6R0R1fD39zpfp4/+GNRxFaaB8otMPyrbizb0HBcaksQCp0 0MTbFSjuAlXZ3NhVIm2O =RuB2 -----END PGP SIGNATURE----- Merge tag 'iio-fixes-for-3.16a' of 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.
139 lines
3.9 KiB
C
139 lines
3.9 KiB
C
/*
|
|
* HID Sensors Driver
|
|
* Copyright (c) 2012, Intel Corporation.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along with
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*
|
|
*/
|
|
#include <linux/device.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/module.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/irq.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/hid-sensor-hub.h>
|
|
#include <linux/iio/iio.h>
|
|
#include <linux/iio/trigger.h>
|
|
#include <linux/iio/sysfs.h>
|
|
#include "hid-sensor-trigger.h"
|
|
|
|
int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
|
|
{
|
|
int state_val;
|
|
int report_val;
|
|
|
|
if (state) {
|
|
if (sensor_hub_device_open(st->hsdev))
|
|
return -EIO;
|
|
|
|
atomic_inc(&st->data_ready);
|
|
|
|
state_val = hid_sensor_get_usage_index(st->hsdev,
|
|
st->power_state.report_id,
|
|
st->power_state.index,
|
|
HID_USAGE_SENSOR_PROP_POWER_STATE_D0_FULL_POWER_ENUM);
|
|
report_val = hid_sensor_get_usage_index(st->hsdev,
|
|
st->report_state.report_id,
|
|
st->report_state.index,
|
|
HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM);
|
|
} else {
|
|
if (!atomic_dec_and_test(&st->data_ready))
|
|
return 0;
|
|
sensor_hub_device_close(st->hsdev);
|
|
state_val = hid_sensor_get_usage_index(st->hsdev,
|
|
st->power_state.report_id,
|
|
st->power_state.index,
|
|
HID_USAGE_SENSOR_PROP_POWER_STATE_D4_POWER_OFF_ENUM);
|
|
report_val = hid_sensor_get_usage_index(st->hsdev,
|
|
st->report_state.report_id,
|
|
st->report_state.index,
|
|
HID_USAGE_SENSOR_PROP_REPORTING_STATE_NO_EVENTS_ENUM);
|
|
}
|
|
|
|
if (state_val >= 0) {
|
|
state_val += st->power_state.logical_minimum;
|
|
sensor_hub_set_feature(st->hsdev, st->power_state.report_id,
|
|
st->power_state.index,
|
|
(s32)state_val);
|
|
}
|
|
|
|
if (report_val >= 0) {
|
|
report_val += st->report_state.logical_minimum;
|
|
sensor_hub_set_feature(st->hsdev, st->report_state.report_id,
|
|
st->report_state.index,
|
|
(s32)report_val);
|
|
}
|
|
|
|
sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
|
|
st->power_state.index,
|
|
&state_val);
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(hid_sensor_power_state);
|
|
|
|
static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
|
|
bool state)
|
|
{
|
|
return hid_sensor_power_state(iio_trigger_get_drvdata(trig), state);
|
|
}
|
|
|
|
void hid_sensor_remove_trigger(struct hid_sensor_common *attrb)
|
|
{
|
|
iio_trigger_unregister(attrb->trigger);
|
|
iio_trigger_free(attrb->trigger);
|
|
}
|
|
EXPORT_SYMBOL(hid_sensor_remove_trigger);
|
|
|
|
static const struct iio_trigger_ops hid_sensor_trigger_ops = {
|
|
.owner = THIS_MODULE,
|
|
.set_trigger_state = &hid_sensor_data_rdy_trigger_set_state,
|
|
};
|
|
|
|
int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
|
|
struct hid_sensor_common *attrb)
|
|
{
|
|
int ret;
|
|
struct iio_trigger *trig;
|
|
|
|
trig = iio_trigger_alloc("%s-dev%d", name, indio_dev->id);
|
|
if (trig == NULL) {
|
|
dev_err(&indio_dev->dev, "Trigger Allocate Failed\n");
|
|
ret = -ENOMEM;
|
|
goto error_ret;
|
|
}
|
|
|
|
trig->dev.parent = indio_dev->dev.parent;
|
|
iio_trigger_set_drvdata(trig, attrb);
|
|
trig->ops = &hid_sensor_trigger_ops;
|
|
ret = iio_trigger_register(trig);
|
|
|
|
if (ret) {
|
|
dev_err(&indio_dev->dev, "Trigger Register Failed\n");
|
|
goto error_free_trig;
|
|
}
|
|
indio_dev->trig = attrb->trigger = trig;
|
|
|
|
return ret;
|
|
|
|
error_free_trig:
|
|
iio_trigger_free(trig);
|
|
error_ret:
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(hid_sensor_setup_trigger);
|
|
|
|
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@intel.com>");
|
|
MODULE_DESCRIPTION("HID Sensor trigger processing");
|
|
MODULE_LICENSE("GPL");
|