iio: hid-sensors: Move get sensitivity attribute to hid-sensor-common
authorYe Xiang <xiang.ye@intel.com>
Mon, 1 Feb 2021 05:49:20 +0000 (13:49 +0800)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 11 Mar 2021 20:47:09 +0000 (20:47 +0000)
No functional change has been made with this patch. The main intent here
is to reduce code repetition of getting sensitivity attribute.

In the current implementation, sensor_hub_input_get_attribute_info() is
called from multiple drivers to get attribute info for sensitivity
field. Moving this to common place will avoid code repetition.

Signed-off-by: Ye Xiang <xiang.ye@intel.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210201054921.18214-2-xiang.ye@intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
14 files changed:
drivers/iio/accel/hid-sensor-accel-3d.c
drivers/iio/common/hid-sensors/hid-sensor-attributes.c
drivers/iio/gyro/hid-sensor-gyro-3d.c
drivers/iio/humidity/hid-sensor-humidity.c
drivers/iio/light/hid-sensor-als.c
drivers/iio/light/hid-sensor-prox.c
drivers/iio/magnetometer/hid-sensor-magn-3d.c
drivers/iio/orientation/hid-sensor-incl-3d.c
drivers/iio/orientation/hid-sensor-rotation.c
drivers/iio/position/hid-sensor-custom-intel-hinge.c
drivers/iio/pressure/hid-sensor-press.c
drivers/iio/temperature/hid-sensor-temperature.c
drivers/rtc/rtc-hid-sensor-time.c
include/linux/hid-sensor-hub.h

index 5d63ed19e6e2578896acf01b27f82113bf308978..2f9465cb382ffd0d6e6445b6b20973d7a839079e 100644 (file)
@@ -43,6 +43,10 @@ static const u32 accel_3d_addresses[ACCEL_3D_CHANNEL_MAX] = {
        HID_USAGE_SENSOR_ACCEL_Z_AXIS
 };
 
+static const u32 accel_3d_sensitivity_addresses[] = {
+       HID_USAGE_SENSOR_DATA_ACCELERATION,
+};
+
 /* Channel definitions */
 static const struct iio_chan_spec accel_3d_channels[] = {
        {
@@ -317,18 +321,6 @@ static int accel_3d_parse_report(struct platform_device *pdev,
                                &st->accel[CHANNEL_SCAN_INDEX_X],
                                &st->scale_pre_decml, &st->scale_post_decml);
 
-       /* Set Sensitivity field ids, when there is no individual modifier */
-       if (st->common_attributes.sensitivity.index < 0) {
-               sensor_hub_input_get_attribute_info(hsdev,
-                       HID_FEATURE_REPORT, usage_id,
-                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
-                       HID_USAGE_SENSOR_DATA_ACCELERATION,
-                       &st->common_attributes.sensitivity);
-               dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
-                       st->common_attributes.sensitivity.index,
-                       st->common_attributes.sensitivity.report_id);
-       }
-
        return ret;
 }
 
@@ -366,8 +358,11 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
                channel_size = sizeof(gravity_channels);
                indio_dev->num_channels = ARRAY_SIZE(gravity_channels);
        }
-       ret = hid_sensor_parse_common_attributes(hsdev, hsdev->usage,
-                                       &accel_state->common_attributes);
+       ret = hid_sensor_parse_common_attributes(hsdev,
+                                                hsdev->usage,
+                                                &accel_state->common_attributes,
+                                                accel_3d_sensitivity_addresses,
+                                                ARRAY_SIZE(accel_3d_sensitivity_addresses));
        if (ret) {
                dev_err(&pdev->dev, "failed to setup common attributes\n");
                return ret;
index 5b822a4298a0917b2dd2c061c652bcb88865de7c..d349ace2e33f6242553628af5b7a16727b6b6fd6 100644 (file)
@@ -448,12 +448,15 @@ EXPORT_SYMBOL(hid_sensor_batch_mode_supported);
 
 int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
                                        u32 usage_id,
-                                       struct hid_sensor_common *st)
+                                       struct hid_sensor_common *st,
+                                       const u32 *sensitivity_addresses,
+                                       u32 sensitivity_addresses_len)
 {
 
        struct hid_sensor_hub_attribute_info timestamp;
        s32 value;
        int ret;
+       int i;
 
        hid_sensor_get_reporting_interval(hsdev, usage_id, st);
 
@@ -475,6 +478,18 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
                        HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS,
                         &st->sensitivity);
 
+       /*
+        * Set Sensitivity field ids, when there is no individual modifier, will
+        * check absolute sensitivity of data field
+        */
+       for (i = 0; i < sensitivity_addresses_len && st->sensitivity.index < 0; i++) {
+               sensor_hub_input_get_attribute_info(hsdev,
+                               HID_FEATURE_REPORT, usage_id,
+                               HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
+                                       sensitivity_addresses[i],
+                               &st->sensitivity);
+       }
+
        st->raw_hystersis = -1;
 
        sensor_hub_input_get_attribute_info(hsdev,
index fb0d678ece1a9e896f541691fb02c1c872bd2c64..dad26ee4fd1f432a79146832c021783bd63bcb3c 100644 (file)
@@ -45,6 +45,10 @@ static const u32 gyro_3d_addresses[GYRO_3D_CHANNEL_MAX] = {
        HID_USAGE_SENSOR_ANGL_VELOCITY_Z_AXIS
 };
 
+static const u32 gryo_3d_sensitivity_addresses[] = {
+       HID_USAGE_SENSOR_DATA_ANGL_VELOCITY,
+};
+
 /* Channel definitions */
 static const struct iio_chan_spec gyro_3d_channels[] = {
        {
@@ -271,17 +275,6 @@ static int gyro_3d_parse_report(struct platform_device *pdev,
                                &st->gyro[CHANNEL_SCAN_INDEX_X],
                                &st->scale_pre_decml, &st->scale_post_decml);
 
-       /* Set Sensitivity field ids, when there is no individual modifier */
-       if (st->common_attributes.sensitivity.index < 0) {
-               sensor_hub_input_get_attribute_info(hsdev,
-                       HID_FEATURE_REPORT, usage_id,
-                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
-                       HID_USAGE_SENSOR_DATA_ANGL_VELOCITY,
-                       &st->common_attributes.sensitivity);
-               dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
-                       st->common_attributes.sensitivity.index,
-                       st->common_attributes.sensitivity.report_id);
-       }
        return ret;
 }
 
@@ -305,7 +298,9 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
 
        ret = hid_sensor_parse_common_attributes(hsdev,
                                                HID_USAGE_SENSOR_GYRO_3D,
-                                               &gyro_state->common_attributes);
+                                               &gyro_state->common_attributes,
+                                               gryo_3d_sensitivity_addresses,
+                                               ARRAY_SIZE(gryo_3d_sensitivity_addresses));
        if (ret) {
                dev_err(&pdev->dev, "failed to setup common attributes\n");
                return ret;
index 52f605114ef77e52473eb3d13793aa1c66937ff8..ec88ae3f233dea2fe6173f54af20229876c5ad4d 100644 (file)
@@ -22,6 +22,10 @@ struct hid_humidity_state {
        int value_offset;
 };
 
+static const u32 humidity_sensitivity_addresses[] = {
+       HID_USAGE_SENSOR_ATMOSPHERIC_HUMIDITY,
+};
+
 /* Channel definitions */
 static const struct iio_chan_spec humidity_channels[] = {
        {
@@ -174,14 +178,6 @@ static int humidity_parse_report(struct platform_device *pdev,
                                                &st->scale_pre_decml,
                                                &st->scale_post_decml);
 
-       /* Set Sensitivity field ids, when there is no individual modifier */
-       if (st->common_attributes.sensitivity.index < 0)
-               sensor_hub_input_get_attribute_info(hsdev,
-                       HID_FEATURE_REPORT, usage_id,
-                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
-                       HID_USAGE_SENSOR_ATMOSPHERIC_HUMIDITY,
-                       &st->common_attributes.sensitivity);
-
        return ret;
 }
 
@@ -210,7 +206,9 @@ static int hid_humidity_probe(struct platform_device *pdev)
 
        ret = hid_sensor_parse_common_attributes(hsdev,
                                        HID_USAGE_SENSOR_HUMIDITY,
-                                       &humid_st->common_attributes);
+                                       &humid_st->common_attributes,
+                                       humidity_sensitivity_addresses,
+                                       ARRAY_SIZE(humidity_sensitivity_addresses));
        if (ret)
                return ret;
 
index 4093f2353d9590d22cb98fd68db273fef4fe10d8..8bf6e9e0a0e038cd9c7e58ebbfa91c51318e408a 100644 (file)
@@ -39,6 +39,10 @@ struct als_state {
        s64 timestamp;
 };
 
+static const u32 als_sensitivity_addresses[] = {
+       HID_USAGE_SENSOR_DATA_LIGHT,
+};
+
 /* Channel definitions */
 static const struct iio_chan_spec als_channels[] = {
        {
@@ -252,17 +256,6 @@ static int als_parse_report(struct platform_device *pdev,
                                &st->als_illum,
                                &st->scale_pre_decml, &st->scale_post_decml);
 
-       /* Set Sensitivity field ids, when there is no individual modifier */
-       if (st->common_attributes.sensitivity.index < 0) {
-               sensor_hub_input_get_attribute_info(hsdev,
-                       HID_FEATURE_REPORT, usage_id,
-                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
-                       HID_USAGE_SENSOR_DATA_LIGHT,
-                       &st->common_attributes.sensitivity);
-               dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
-                       st->common_attributes.sensitivity.index,
-                       st->common_attributes.sensitivity.report_id);
-       }
        return ret;
 }
 
@@ -285,7 +278,9 @@ static int hid_als_probe(struct platform_device *pdev)
        als_state->common_attributes.pdev = pdev;
 
        ret = hid_sensor_parse_common_attributes(hsdev, HID_USAGE_SENSOR_ALS,
-                                       &als_state->common_attributes);
+                                       &als_state->common_attributes,
+                                       als_sensitivity_addresses,
+                                       ARRAY_SIZE(als_sensitivity_addresses));
        if (ret) {
                dev_err(&pdev->dev, "failed to setup common attributes\n");
                return ret;
index 330cf359e0b81c27802662713239665ca4ebb8bb..4ab285a418d5e7c00d02a6f953885bb4f9729325 100644 (file)
@@ -25,6 +25,11 @@ struct prox_state {
        u32 human_presence;
 };
 
+static const u32 prox_sensitivity_addresses[] = {
+       HID_USAGE_SENSOR_HUMAN_PRESENCE,
+       HID_USAGE_SENSOR_DATA_PRESENCE,
+};
+
 /* Channel definitions */
 static const struct iio_chan_spec prox_channels[] = {
        {
@@ -216,24 +221,6 @@ static int prox_parse_report(struct platform_device *pdev,
        dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr.index,
                        st->prox_attr.report_id);
 
-       /* Set Sensitivity field ids, when there is no individual modifier */
-       if (st->common_attributes.sensitivity.index < 0) {
-               sensor_hub_input_get_attribute_info(hsdev,
-                       HID_FEATURE_REPORT, usage_id,
-                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
-                       HID_USAGE_SENSOR_DATA_PRESENCE,
-                       &st->common_attributes.sensitivity);
-               dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
-                       st->common_attributes.sensitivity.index,
-                       st->common_attributes.sensitivity.report_id);
-       }
-       if (st->common_attributes.sensitivity.index < 0)
-               sensor_hub_input_get_attribute_info(hsdev,
-                       HID_FEATURE_REPORT, usage_id,
-                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
-                       HID_USAGE_SENSOR_HUMAN_PRESENCE,
-                       &st->common_attributes.sensitivity);
-
        return ret;
 }
 
@@ -257,7 +244,9 @@ static int hid_prox_probe(struct platform_device *pdev)
        prox_state->common_attributes.pdev = pdev;
 
        ret = hid_sensor_parse_common_attributes(hsdev, HID_USAGE_SENSOR_PROX,
-                                       &prox_state->common_attributes);
+                                       &prox_state->common_attributes,
+                                       prox_sensitivity_addresses,
+                                       ARRAY_SIZE(prox_sensitivity_addresses));
        if (ret) {
                dev_err(&pdev->dev, "failed to setup common attributes\n");
                return ret;
index fa48044b7f5b574513e9abdefd8a462d652618da..b78691523dd4ce01e17e0a8dc8c09ca6571e8f2d 100644 (file)
@@ -62,6 +62,11 @@ static const u32 magn_3d_addresses[MAGN_3D_CHANNEL_MAX] = {
        HID_USAGE_SENSOR_TIME_TIMESTAMP,
 };
 
+static const u32 magn_3d_sensitivity_addresses[] = {
+       HID_USAGE_SENSOR_DATA_ORIENTATION,
+       HID_USAGE_SENSOR_ORIENT_MAGN_FLUX,
+};
+
 /* Channel definitions */
 static const struct iio_chan_spec magn_3d_channels[] = {
        {
@@ -448,27 +453,6 @@ static int magn_3d_parse_report(struct platform_device *pdev,
                        &st->rot_attr.scale_pre_decml,
                        &st->rot_attr.scale_post_decml);
 
-       /* Set Sensitivity field ids, when there is no individual modifier */
-       if (st->magn_flux_attributes.sensitivity.index < 0) {
-               sensor_hub_input_get_attribute_info(hsdev,
-                       HID_FEATURE_REPORT, usage_id,
-                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
-                       HID_USAGE_SENSOR_DATA_ORIENTATION,
-                       &st->magn_flux_attributes.sensitivity);
-               dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
-                       st->magn_flux_attributes.sensitivity.index,
-                       st->magn_flux_attributes.sensitivity.report_id);
-       }
-       if (st->magn_flux_attributes.sensitivity.index < 0) {
-               sensor_hub_input_get_attribute_info(hsdev,
-                       HID_FEATURE_REPORT, usage_id,
-                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
-                       HID_USAGE_SENSOR_ORIENT_MAGN_FLUX,
-                       &st->magn_flux_attributes.sensitivity);
-               dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
-                       st->magn_flux_attributes.sensitivity.index,
-                       st->magn_flux_attributes.sensitivity.report_id);
-       }
        if (st->rot_attributes.sensitivity.index < 0) {
                sensor_hub_input_get_attribute_info(hsdev,
                        HID_FEATURE_REPORT, usage_id,
@@ -507,12 +491,16 @@ static int hid_magn_3d_probe(struct platform_device *pdev)
 
        ret = hid_sensor_parse_common_attributes(hsdev,
                                HID_USAGE_SENSOR_COMPASS_3D,
-                               &magn_state->magn_flux_attributes);
+                               &magn_state->magn_flux_attributes,
+                               magn_3d_sensitivity_addresses,
+                               ARRAY_SIZE(magn_3d_sensitivity_addresses));
        if (ret) {
                dev_err(&pdev->dev, "failed to setup common attributes\n");
                return ret;
        }
        magn_state->rot_attributes = magn_state->magn_flux_attributes;
+       /* sensitivity of rot_attribute is not the same as magn_flux_attributes */
+       magn_state->rot_attributes.sensitivity.index = -1;
 
        ret = magn_3d_parse_report(pdev, hsdev,
                                &channels, &chan_count,
index 52ebef30f9be062231a5079d5ebbd1f0307f9f3a..6e69f6e673cc83c4ea6e138a03a1f13230280c84 100644 (file)
@@ -47,6 +47,10 @@ static const u32 incl_3d_addresses[INCLI_3D_CHANNEL_MAX] = {
        HID_USAGE_SENSOR_ORIENT_TILT_Z
 };
 
+static const u32 incl_3d_sensitivity_addresses[] = {
+       HID_USAGE_SENSOR_DATA_ORIENTATION,
+};
+
 /* Channel definitions */
 static const struct iio_chan_spec incl_3d_channels[] = {
        {
@@ -291,17 +295,6 @@ static int incl_3d_parse_report(struct platform_device *pdev,
                                &st->incl[CHANNEL_SCAN_INDEX_X],
                                &st->scale_pre_decml, &st->scale_post_decml);
 
-       /* Set Sensitivity field ids, when there is no individual modifier */
-       if (st->common_attributes.sensitivity.index < 0) {
-               sensor_hub_input_get_attribute_info(hsdev,
-                       HID_FEATURE_REPORT, usage_id,
-                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
-                       HID_USAGE_SENSOR_DATA_ORIENTATION,
-                       &st->common_attributes.sensitivity);
-               dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
-                       st->common_attributes.sensitivity.index,
-                       st->common_attributes.sensitivity.report_id);
-       }
        return ret;
 }
 
@@ -327,7 +320,9 @@ static int hid_incl_3d_probe(struct platform_device *pdev)
 
        ret = hid_sensor_parse_common_attributes(hsdev,
                                HID_USAGE_SENSOR_INCLINOMETER_3D,
-                               &incl_state->common_attributes);
+                               &incl_state->common_attributes,
+                               incl_3d_sensitivity_addresses,
+                               ARRAY_SIZE(incl_3d_sensitivity_addresses));
        if (ret) {
                dev_err(&pdev->dev, "failed to setup common attributes\n");
                return ret;
index c087d8f72a5464835c659540a60cb3e717bb5933..baa2ee353ba4ace3980e6e9aca78460119e4db40 100644 (file)
@@ -31,6 +31,10 @@ struct dev_rot_state {
        s64 timestamp;
 };
 
+static const u32 rotation_sensitivity_addresses[] = {
+       HID_USAGE_SENSOR_DATA_ORIENTATION,
+};
+
 /* Channel definitions */
 static const struct iio_chan_spec dev_rot_channels[] = {
        {
@@ -221,18 +225,6 @@ static int dev_rot_parse_report(struct platform_device *pdev,
                                &st->quaternion,
                                &st->scale_pre_decml, &st->scale_post_decml);
 
-       /* Set Sensitivity field ids, when there is no individual modifier */
-       if (st->common_attributes.sensitivity.index < 0) {
-               sensor_hub_input_get_attribute_info(hsdev,
-                       HID_FEATURE_REPORT, usage_id,
-                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
-                       HID_USAGE_SENSOR_DATA_ORIENTATION,
-                       &st->common_attributes.sensitivity);
-               dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
-                       st->common_attributes.sensitivity.index,
-                       st->common_attributes.sensitivity.report_id);
-       }
-
        return 0;
 }
 
@@ -270,8 +262,11 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       ret = hid_sensor_parse_common_attributes(hsdev, hsdev->usage,
-                               &rot_state->common_attributes);
+       ret = hid_sensor_parse_common_attributes(hsdev,
+                                                hsdev->usage,
+                                                &rot_state->common_attributes,
+                                                rotation_sensitivity_addresses,
+                                                ARRAY_SIZE(rotation_sensitivity_addresses));
        if (ret) {
                dev_err(&pdev->dev, "failed to setup common attributes\n");
                return ret;
index 64a7fa7db6af96cbc517907d566b8423657c926a..fd77e7ee87f3581f026192a2d54e7d41b403be9a 100644 (file)
@@ -47,6 +47,10 @@ struct hinge_state {
        u64 timestamp;
 };
 
+static const u32 hinge_sensitivity_addresses[] = {
+       HID_USAGE_SENSOR_DATA_FIELD_CUSTOM_VALUE(1),
+};
+
 /* Channel definitions */
 static const struct iio_chan_spec hinge_channels[] = {
        {
@@ -251,18 +255,6 @@ static int hinge_parse_report(struct platform_device *pdev,
                        &st->hinge[CHANNEL_SCAN_INDEX_HINGE_ANGLE],
                        &st->scale_pre_decml, &st->scale_post_decml);
 
-       /* Set Sensitivity field ids, when there is no individual modifier */
-       if (st->common_attributes.sensitivity.index < 0) {
-               sensor_hub_input_get_attribute_info(hsdev,
-                               HID_FEATURE_REPORT, usage_id,
-                               HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
-                                       HID_USAGE_SENSOR_DATA_FIELD_CUSTOM_VALUE(1),
-                               &st->common_attributes.sensitivity);
-               dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
-                       st->common_attributes.sensitivity.index,
-                       st->common_attributes.sensitivity.report_id);
-       }
-
        return ret;
 }
 
@@ -289,7 +281,9 @@ static int hid_hinge_probe(struct platform_device *pdev)
                st->labels[i] = hinge_labels[i];
 
        ret = hid_sensor_parse_common_attributes(hsdev, hsdev->usage,
-                                                &st->common_attributes);
+                                                &st->common_attributes,
+                                                hinge_sensitivity_addresses,
+                                                ARRAY_SIZE(hinge_sensitivity_addresses));
        if (ret) {
                dev_err(&pdev->dev, "failed to setup common attributes\n");
                return ret;
index 5c458788f346e72a47d56df9439b39b39ec7e161..8cac2c94e75a253ff7492728188539d55845349d 100644 (file)
@@ -29,6 +29,10 @@ struct press_state {
        int value_offset;
 };
 
+static const u32 press_sensitivity_addresses[] = {
+       HID_USAGE_SENSOR_DATA_ATMOSPHERIC_PRESSURE,
+};
+
 /* Channel definitions */
 static const struct iio_chan_spec press_channels[] = {
        {
@@ -225,17 +229,6 @@ static int press_parse_report(struct platform_device *pdev,
                                &st->press_attr,
                                &st->scale_pre_decml, &st->scale_post_decml);
 
-       /* Set Sensitivity field ids, when there is no individual modifier */
-       if (st->common_attributes.sensitivity.index < 0) {
-               sensor_hub_input_get_attribute_info(hsdev,
-                       HID_FEATURE_REPORT, usage_id,
-                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
-                       HID_USAGE_SENSOR_DATA_ATMOSPHERIC_PRESSURE,
-                       &st->common_attributes.sensitivity);
-               dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
-                       st->common_attributes.sensitivity.index,
-                       st->common_attributes.sensitivity.report_id);
-       }
        return ret;
 }
 
@@ -260,7 +253,9 @@ static int hid_press_probe(struct platform_device *pdev)
 
        ret = hid_sensor_parse_common_attributes(hsdev,
                                        HID_USAGE_SENSOR_PRESSURE,
-                                       &press_state->common_attributes);
+                                       &press_state->common_attributes,
+                                       press_sensitivity_addresses,
+                                       ARRAY_SIZE(press_sensitivity_addresses));
        if (ret) {
                dev_err(&pdev->dev, "failed to setup common attributes\n");
                return ret;
index 81688f1b932f1085c5540dca9f5800e13b7aebc2..e3d38cbcf354b9c09614ff6d97753a30d3a0b346 100644 (file)
@@ -22,6 +22,10 @@ struct temperature_state {
        int value_offset;
 };
 
+static const u32 temperature_sensitivity_addresses[] = {
+       HID_USAGE_SENSOR_DATA_ENVIRONMENTAL_TEMPERATURE,
+};
+
 /* Channel definitions */
 static const struct iio_chan_spec temperature_channels[] = {
        {
@@ -171,14 +175,6 @@ static int temperature_parse_report(struct platform_device *pdev,
                                &st->temperature_attr,
                                &st->scale_pre_decml, &st->scale_post_decml);
 
-       /* Set Sensitivity field ids, when there is no individual modifier */
-       if (st->common_attributes.sensitivity.index < 0)
-               sensor_hub_input_get_attribute_info(hsdev,
-                       HID_FEATURE_REPORT, usage_id,
-                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
-                       HID_USAGE_SENSOR_DATA_ENVIRONMENTAL_TEMPERATURE,
-                       &st->common_attributes.sensitivity);
-
        return ret;
 }
 
@@ -207,7 +203,9 @@ static int hid_temperature_probe(struct platform_device *pdev)
 
        ret = hid_sensor_parse_common_attributes(hsdev,
                                        HID_USAGE_SENSOR_TEMPERATURE,
-                                       &temp_st->common_attributes);
+                                       &temp_st->common_attributes,
+                                       temperature_sensitivity_addresses,
+                                       ARRAY_SIZE(temperature_sensitivity_addresses));
        if (ret)
                return ret;
 
index 1b42ee0758d298af79e67f20c9b2a9d27a37f502..47cd12db23568d641d4795f6ad850a8f7fbc4b92 100644 (file)
@@ -238,7 +238,9 @@ static int hid_time_probe(struct platform_device *pdev)
 
        ret = hid_sensor_parse_common_attributes(hsdev,
                                HID_USAGE_SENSOR_TIME,
-                               &time_state->common_attributes);
+                               &time_state->common_attributes,
+                               NULL,
+                               0);
        if (ret) {
                dev_err(&pdev->dev, "failed to setup common attributes!\n");
                return ret;
index 763802b2b8f99c4ad26427746fe9e63d9cf979cd..637ec53a98a172bf61be99d48333ab15a7a3c219 100644 (file)
@@ -248,7 +248,9 @@ static inline int hid_sensor_convert_exponent(int unit_expo)
 
 int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
                                        u32 usage_id,
-                                       struct hid_sensor_common *st);
+                                       struct hid_sensor_common *st,
+                                       const u32 *sensitivity_addresses,
+                                       u32 sensitivity_addresses_len);
 int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
                                        int val1, int val2);
 int hid_sensor_read_raw_hyst_value(struct hid_sensor_common *st,