summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-11-11 09:04:02 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-11-11 09:04:02 -0500
commit4dbe5ea929ac5a5b8dc21787d0e79fc55a0ea9ac (patch)
treec932d92219afa1262ecca059fc0eff4181aaf3bc
parentfa0858523f07f8dd71d89b221f4422c3b8096d90 (diff)
parent79c8dffd84e9784ec05bea68dbe5e71f7ec9941a (diff)
Merge tag 'iio-fixes-for-7.4a' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-linus
Johathan writes: IIO: 1st set of fixes for the 7.4 cycle. A bumper set at least partly because I was traveling for a few weeks at the end of last cycle so things that would otherwise have hit for the merge window are in here. Usual mixed bag of recent stuff and older bugs. More trivial recent fixes are separately queued for next merge window. Rebase just now to drop a patch that should go via drivers/hid, rest have been in linux-next for a few days at least. core - Return an error rather than eating attempt to have more consumers of a trigger than supported. - Fix an ordering issue which could lead to a trigger ID reuse before sysfs is torn down resulting in a failure to create file. acpi - Allow for commas in ROTM strings (unofficial but common windows ACPI extension). Fixes a bunch of machines. hid-sensors - Fix handling of fraction part of value for unit exponents -7 and -8. - Avoiding reading past end of short data fields for ALS. - Fix scaling for magnetic north heading. - Use per instance callbacks to ensure multiple instances don't clash. afe-rescale - Don't hide the offset attribute if the source has one (just pass that through). - Avoid a division by zero. adi,ad_sigma_delta library - Ensure ad_sd_init() return value always checked as gpio request may result in a -EPROBE_DEFER. adi,ad5758 - Fix miss specified current range matched against dt binding. Given it is obviously wrong we assume no one was using that value. adi,ad74413r - Fix values passed to gpio set multiple. adi,ad7923 - Add missing AD7927 entry to the SPI ID table to ensure autoprobe works when fallback compatible in use. adi,adxl313 - Missing Kconfig dependencies. adi,adxl345 - Missing Kconfig dependencies. adi,adxl380 - Don't get stuck in standby on invalid value write attempt. aosong,am2315 - Fix handling of negative temperatures. aspeed,adc - Use sycon phandle for trimming data rather than just finding first syscon which is the wrong one on some devices. arm,scmi-sensors - Fix truncation in a 64 bit division. atlas,ezo - Don't reject attempts to read the humdity channel. bosch,bmg160 - Fix underflow on repeated event disable. google,cros_ec - Use correct union member for calibscale invensense,mpu6050 - Fix scaling of magnetometer Y and Z axis due to missing address values. - Startup times for gyroscope and accelerometer were swapped. kionix,kmx61 - Fix underflow on repeated event disable. kionix,kxsd9 - Fix a use after free due to wrong remove() ordering. infineon,tlv493d - Fix scaling of magnetic field which was out by a factor of 100. invensense,sensors - Corner case fixes for timestamp estimation and handling of data rate changes.. melexis,mlx90614 - Fix probe check on dual channels which was inverted. memsic,mmc5633 - Ensure we aren't in regmap cache only mode when syncing the cache. memsic,mmc35240 - Ensure we aren't in regmap cache only mode when syncing the cache. microchip,mcp3564 - Reject probe if no match data found, avoiding NULL dereference. microchip,mcp4725 - Ensure cached value is only update on write success. microchip,mcp47feb02 - Reject out of range raw values being written to this DAC. qcom,spmi-adc5-gen3 - Ensure unique IDs used for ADC_TM aux devices by reusing the IIO device ID. semtech,sx9301 - Use i2c_get_match_data() to allow new_device based matching. semtech,sx9324 - Fix an out of bounds read of the scan period table as table was too short. semtech,sx9360 - Fix writing of the sampling frequency and what values are in the presented available range. semtech,sx9500 - Ignore event config writes that don't change current state to avoid reference tracking overflow/underflow. taos,tsl2591 - Avoid a divide by zero. tyhx,hx9023s - Ensure trigger is allocated before interrupt that uses it is registered. vishay,vcnl4035 - Fixed inverted ALS mode bit. * tag 'iio-fixes-for-7.4a' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (47 commits) iio: hid-sensors: fix fractional part for unit exponents -7 and -8 iio: trigger: free the trigger ID after device_del() iio: hid-sensors: fix a division by zero iio: humidity: hid-sensor-humidity: Use per-instance callbacks iio: temperature: hid-sensor-temperature: Use per-instance callbacks iio: hid-sensor: Fix scale for magnetic north heading iio: afe: rescale: expose offset if rescaler or source has one iio: accel: kxsd9: Fix potential use-after-free on removal iio: adc: qcom-spmi-adc5-gen3: Reuse IIO device ID for ADC_TM aux device iio: light: hid-sensor-als: Don't read past the end of short fields iio: accel: adxl380: don't stay in standby on -EINVAL iio: adc: check the result of ad_sd_init() iio: adc: ad7923: add the AD7927 to the SPI ID table iio: addac: ad74413r: fix the values of set_multiple iio: sx9310: use the data of the I2C table iio: proximity: sx9500: ignore event config writes that don't change state iio: dac: mcp4725: Update the cached DAC value only on success iio: proximity: sx9360: fix sampling frequency write and available range iio: dac: mcp47feb02: reject out-of-range raw values iio: adc: mcp3564: reject devices without match data ...
-rw-r--r--Documentation/devicetree/bindings/iio/adc/aspeed,ast2600-adc.yaml17
-rw-r--r--Documentation/devicetree/bindings/iio/dac/adi,ad5758.yaml4
-rw-r--r--drivers/iio/accel/Kconfig4
-rw-r--r--drivers/iio/accel/adxl380.c11
-rw-r--r--drivers/iio/accel/kxsd9.c2
-rw-r--r--drivers/iio/adc/ad7780.c4
-rw-r--r--drivers/iio/adc/ad7791.c4
-rw-r--r--drivers/iio/adc/ad7793.c4
-rw-r--r--drivers/iio/adc/ad7923.c1
-rw-r--r--drivers/iio/adc/aspeed_adc.c25
-rw-r--r--drivers/iio/adc/max11205.c4
-rw-r--r--drivers/iio/adc/mcp3564.c3
-rw-r--r--drivers/iio/adc/qcom-spmi-adc5-gen3.c5
-rw-r--r--drivers/iio/addac/ad74413r.c2
-rw-r--r--drivers/iio/afe/iio-rescale.c3
-rw-r--r--drivers/iio/chemical/atlas-ezo-sensor.c3
-rw-r--r--drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c5
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-attributes.c14
-rw-r--r--drivers/iio/common/inv_sensors/inv_sensors_timestamp.c24
-rw-r--r--drivers/iio/common/scmi_sensors/scmi_iio.c27
-rw-r--r--drivers/iio/dac/ad5758.c4
-rw-r--r--drivers/iio/dac/mcp4725.c2
-rw-r--r--drivers/iio/dac/mcp47feb02-core.c3
-rw-r--r--drivers/iio/gyro/bmg160_core.c2
-rw-r--r--drivers/iio/humidity/am2315.c12
-rw-r--r--drivers/iio/humidity/hid-sensor-humidity.c14
-rw-r--r--drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c24
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_core.c97
-rw-r--r--drivers/iio/imu/kmx61.c2
-rw-r--r--drivers/iio/industrialio-acpi.c9
-rw-r--r--drivers/iio/industrialio-trigger.c4
-rw-r--r--drivers/iio/light/hid-sensor-als.c16
-rw-r--r--drivers/iio/light/tsl2591.c32
-rw-r--r--drivers/iio/light/vcnl4035.c4
-rw-r--r--drivers/iio/magnetometer/mmc35240.c3
-rw-r--r--drivers/iio/magnetometer/mmc5633.c3
-rw-r--r--drivers/iio/magnetometer/tlv493d.c6
-rw-r--r--drivers/iio/proximity/hx9023s.c16
-rw-r--r--drivers/iio/proximity/sx9310.c2
-rw-r--r--drivers/iio/proximity/sx9324.c13
-rw-r--r--drivers/iio/proximity/sx9360.c29
-rw-r--r--drivers/iio/proximity/sx9500.c6
-rw-r--r--drivers/iio/temperature/hid-sensor-temperature.c14
-rw-r--r--drivers/iio/temperature/mlx90614.c2
-rw-r--r--include/linux/iio/common/inv_sensors_timestamp.h3
45 files changed, 348 insertions, 140 deletions
diff --git a/Documentation/devicetree/bindings/iio/adc/aspeed,ast2600-adc.yaml b/Documentation/devicetree/bindings/iio/adc/aspeed,ast2600-adc.yaml
index 249101b55cf4..140d7034e219 100644
--- a/Documentation/devicetree/bindings/iio/adc/aspeed,ast2600-adc.yaml
+++ b/Documentation/devicetree/bindings/iio/adc/aspeed,ast2600-adc.yaml
@@ -67,6 +67,11 @@ properties:
description:
Inform the driver that last channel will be used to sensor battery.
+ aspeed,trim-syscon:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description:
+ Phandle to the SCU holding the ADC's reference-voltage trimming data.
+
required:
- compatible
- reg
@@ -74,6 +79,18 @@ required:
- resets
- "#io-channel-cells"
+allOf:
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - aspeed,ast2700-adc0
+ - aspeed,ast2700-adc1
+ then:
+ required:
+ - aspeed,trim-syscon
+
additionalProperties: false
examples:
diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5758.yaml b/Documentation/devicetree/bindings/iio/dac/adi,ad5758.yaml
index 5121685337b5..a0f2649129e0 100644
--- a/Documentation/devicetree/bindings/iio/dac/adi,ad5758.yaml
+++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5758.yaml
@@ -66,8 +66,8 @@ properties:
- const: 0
- enum: [20000, 24000]
- items:
- - const: 4
- - const: 24000
+ - const: 4000
+ - const: 20000
- items:
- const: -20000
- const: 20000
diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
index 141ac984247c..c6fce69ac470 100644
--- a/drivers/iio/accel/Kconfig
+++ b/drivers/iio/accel/Kconfig
@@ -33,6 +33,8 @@ config ADIS16209
config ADXL313
tristate
+ select IIO_BUFFER
+ select IIO_KFIFO_BUF
config ADXL313_I2C
tristate "Analog Devices ADXL313 3-Axis Digital Accelerometer I2C Driver"
@@ -62,6 +64,8 @@ config ADXL313_SPI
config ADXL345
tristate
+ select IIO_BUFFER
+ select IIO_KFIFO_BUF
config ADXL345_I2C
tristate "Analog Devices ADXL345 3-Axis Digital Accelerometer I2C Driver"
diff --git a/drivers/iio/accel/adxl380.c b/drivers/iio/accel/adxl380.c
index 8518ee23e114..03b140303520 100644
--- a/drivers/iio/accel/adxl380.c
+++ b/drivers/iio/accel/adxl380.c
@@ -334,8 +334,11 @@ static int adxl380_set_act_inact_threshold(struct iio_dev *indio_dev,
return ret;
ret = adxl380_write_act_inact_threshold(st, act, th);
- if (ret)
+ if (ret) {
+ /* Leave standby also if the value was refused */
+ adxl380_set_measure_en(st, true);
return ret;
+ }
return adxl380_set_measure_en(st, true);
}
@@ -698,6 +701,12 @@ static int adxl380_set_range(struct adxl380_state *st, u8 range)
guard(mutex)(&st->lock);
+ /* The thresholds are rescaled: see that they fit before any change */
+ if (mult_frac(max(st->act_threshold, st->inact_threshold),
+ adxl380_range_scale_factor_tbl[st->range],
+ adxl380_range_scale_factor_tbl[range]) > ADXL380_THRESH_MAX)
+ return -EINVAL;
+
ret = adxl380_set_measure_en(st, false);
if (ret)
return ret;
diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
index 7ac885d94d7f..27adcdd31201 100644
--- a/drivers/iio/accel/kxsd9.c
+++ b/drivers/iio/accel/kxsd9.c
@@ -478,8 +478,8 @@ void kxsd9_common_remove(struct device *dev)
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct kxsd9_state *st = iio_priv(indio_dev);
- iio_triggered_buffer_cleanup(indio_dev);
iio_device_unregister(indio_dev);
+ iio_triggered_buffer_cleanup(indio_dev);
pm_runtime_get_sync(dev);
pm_runtime_put_noidle(dev);
pm_runtime_disable(dev);
diff --git a/drivers/iio/adc/ad7780.c b/drivers/iio/adc/ad7780.c
index 1cfad70320fe..c1428f30241c 100644
--- a/drivers/iio/adc/ad7780.c
+++ b/drivers/iio/adc/ad7780.c
@@ -311,7 +311,9 @@ static int ad7780_probe(struct spi_device *spi)
st = iio_priv(indio_dev);
st->gain = 1;
- ad_sd_init(&st->sd, indio_dev, spi, &ad7780_sigma_delta_info);
+ ret = ad_sd_init(&st->sd, indio_dev, spi, &ad7780_sigma_delta_info);
+ if (ret)
+ return ret;
st->chip_info =
&ad7780_chip_info_tbl[spi_get_device_id(spi)->driver_data];
diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c
index c2688307bbba..10aa40ca35e7 100644
--- a/drivers/iio/adc/ad7791.c
+++ b/drivers/iio/adc/ad7791.c
@@ -435,7 +435,9 @@ static int ad7791_probe(struct spi_device *spi)
return ret;
st->info = &ad7791_chip_infos[spi_get_device_id(spi)->driver_data];
- ad_sd_init(&st->sd, indio_dev, spi, &ad7791_sigma_delta_info);
+ ret = ad_sd_init(&st->sd, indio_dev, spi, &ad7791_sigma_delta_info);
+ if (ret)
+ return ret;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->modes = INDIO_DIRECT_MODE;
diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
index b0f44c144f20..937c8b09ad45 100644
--- a/drivers/iio/adc/ad7793.c
+++ b/drivers/iio/adc/ad7793.c
@@ -796,7 +796,9 @@ static int ad7793_probe(struct spi_device *spi)
st = iio_priv(indio_dev);
- ad_sd_init(&st->sd, indio_dev, spi, &ad7793_sigma_delta_info);
+ ret = ad_sd_init(&st->sd, indio_dev, spi, &ad7793_sigma_delta_info);
+ if (ret)
+ return ret;
if (pdata->refsel != AD7793_REFSEL_INTERNAL) {
ret = devm_regulator_get_enable_read_voltage(dev, "refin");
diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
index 44e014da9722..69fafb4aa4ea 100644
--- a/drivers/iio/adc/ad7923.c
+++ b/drivers/iio/adc/ad7923.c
@@ -366,6 +366,7 @@ static const struct spi_device_id ad7923_id[] = {
{ .name = "ad7924", .driver_data = AD7924 },
{ .name = "ad7908", .driver_data = AD7908 },
{ .name = "ad7918", .driver_data = AD7918 },
+ { .name = "ad7927", .driver_data = AD7928 },
{ .name = "ad7928", .driver_data = AD7928 },
{ }
};
diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c
index 452c30cf04f2..085fdaffb9cd 100644
--- a/drivers/iio/adc/aspeed_adc.c
+++ b/drivers/iio/adc/aspeed_adc.c
@@ -201,18 +201,29 @@ static const struct iio_chan_spec aspeed_adc_iio_bat_channels[] = {
static int aspeed_adc_set_trim_data(struct iio_dev *indio_dev)
{
- struct device_node *syscon;
+ struct device_node *np, *syscon;
struct regmap *scu;
u32 scu_otp, trimming_val;
struct aspeed_adc_data *data = iio_priv(indio_dev);
+ const char *propname = "aspeed,trim-syscon";
- syscon = of_find_node_by_name(NULL, "syscon");
- if (syscon == NULL) {
- dev_warn(data->dev, "Couldn't find syscon node\n");
- return -EOPNOTSUPP;
+ np = dev_of_node(data->dev);
+ if (of_property_present(np, propname)) {
+ scu = syscon_regmap_lookup_by_phandle(np, propname);
+ } else {
+ /*
+ * No "aspeed,trim-syscon" phandle: either a single-SCU SoC,
+ * or a DTB predating the property. Fall back to the old
+ * global by-name lookup for backward compatibility.
+ */
+ syscon = of_find_node_by_name(NULL, "syscon");
+ if (!syscon) {
+ dev_warn(data->dev, "Couldn't find syscon node\n");
+ return -EOPNOTSUPP;
+ }
+ scu = syscon_node_to_regmap(syscon);
+ of_node_put(syscon);
}
- scu = syscon_node_to_regmap(syscon);
- of_node_put(syscon);
if (IS_ERR(scu)) {
dev_warn(data->dev, "Failed to get syscon regmap\n");
return -EOPNOTSUPP;
diff --git a/drivers/iio/adc/max11205.c b/drivers/iio/adc/max11205.c
index 53ac2f4f383e..e46e90400bdc 100644
--- a/drivers/iio/adc/max11205.c
+++ b/drivers/iio/adc/max11205.c
@@ -114,7 +114,9 @@ static int max11205_probe(struct spi_device *spi)
st = iio_priv(indio_dev);
- ad_sd_init(&st->sd, indio_dev, spi, &max11205_sigma_delta_info);
+ ret = ad_sd_init(&st->sd, indio_dev, spi, &max11205_sigma_delta_info);
+ if (ret)
+ return ret;
st->chip_info = spi_get_device_match_data(spi);
if (!st->chip_info)
diff --git a/drivers/iio/adc/mcp3564.c b/drivers/iio/adc/mcp3564.c
index 259ac4ebdedf..91796a47e412 100644
--- a/drivers/iio/adc/mcp3564.c
+++ b/drivers/iio/adc/mcp3564.c
@@ -1204,6 +1204,9 @@ static int mcp3564_config(struct iio_dev *indio_dev, bool *use_internal_vref_att
* try using fallback compatible in device tree to deal with some newer part number.
*/
adc->chip_info = spi_get_device_match_data(adc->spi);
+ if (!adc->chip_info)
+ return -ENODATA;
+
adc->have_vref = adc->chip_info->have_vref;
} else {
adc->chip_info = &mcp3564_chip_infos_tbl[ids];
diff --git a/drivers/iio/adc/qcom-spmi-adc5-gen3.c b/drivers/iio/adc/qcom-spmi-adc5-gen3.c
index c68c6c5f6aca..a23eb5c9096d 100644
--- a/drivers/iio/adc/qcom-spmi-adc5-gen3.c
+++ b/drivers/iio/adc/qcom-spmi-adc5-gen3.c
@@ -610,7 +610,7 @@ static void adc5_gen3_delete_aux(void *data)
static void adc5_gen3_aux_device_release(struct device *dev) {}
-static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc)
+static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc, int id)
{
struct tm5_aux_dev_wrapper *aux_device;
int i, ret, i_tm = 0;
@@ -620,6 +620,7 @@ static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc)
return -ENOMEM;
aux_device->aux_dev.name = "adc5_tm_gen3";
+ aux_device->aux_dev.id = id;
aux_device->aux_dev.dev.parent = adc->dev;
aux_device->aux_dev.dev.release = adc5_gen3_aux_device_release;
@@ -799,7 +800,7 @@ static int adc5_gen3_probe(struct platform_device *pdev)
return ret;
if (adc->n_tm_channels > 0) {
- ret = adc5_gen3_add_aux_tm_device(adc);
+ ret = adc5_gen3_add_aux_tm_device(adc, iio_device_id(indio_dev));
if (ret)
dev_err_probe(dev, ret,
"Failed to add auxiliary TM device\n");
diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c
index 2e5a58e48a89..20db890d958b 100644
--- a/drivers/iio/addac/ad74413r.c
+++ b/drivers/iio/addac/ad74413r.c
@@ -312,7 +312,7 @@ static int ad74413r_gpio_set_multiple(struct gpio_chip *chip,
return ret;
real_mask |= BIT(real_offset);
- if (*bits & offset)
+ if (test_bit(offset, bits))
real_bits |= BIT(real_offset);
}
diff --git a/drivers/iio/afe/iio-rescale.c b/drivers/iio/afe/iio-rescale.c
index 3a6a09ffa526..c01292a15a29 100644
--- a/drivers/iio/afe/iio-rescale.c
+++ b/drivers/iio/afe/iio-rescale.c
@@ -303,7 +303,8 @@ static int rescale_configure_channel(struct device *dev,
chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_SCALE);
- if (rescale->offset)
+ if (rescale->offset ||
+ iio_channel_has_info(schan, IIO_CHAN_INFO_OFFSET))
chan->info_mask_separate |= BIT(IIO_CHAN_INFO_OFFSET);
/*
diff --git a/drivers/iio/chemical/atlas-ezo-sensor.c b/drivers/iio/chemical/atlas-ezo-sensor.c
index 298b2fe48a19..abe26ba212f5 100644
--- a/drivers/iio/chemical/atlas-ezo-sensor.c
+++ b/drivers/iio/chemical/atlas-ezo-sensor.c
@@ -116,9 +116,6 @@ static int atlas_ezo_read_raw(struct iio_dev *indio_dev,
struct atlas_ezo_data *data = iio_priv(indio_dev);
struct i2c_client *client = data->client;
- if (chan->type != IIO_CONCENTRATION)
- return -EINVAL;
-
switch (mask) {
case IIO_CHAN_INFO_RAW: {
int ret;
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
index 551b86236abc..2839714f5bc8 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
@@ -70,7 +70,7 @@ static int cros_ec_sensors_read(struct iio_dev *indio_dev,
break;
case IIO_CHAN_INFO_CALIBSCALE:
st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_SCALE;
- st->core.param.sensor_offset.flags = 0;
+ st->core.param.sensor_scale.flags = 0;
ret = cros_ec_motion_send_host_cmd(&st->core, 0);
if (ret == -EPROTO || ret == -EOPNOTSUPP) {
@@ -178,8 +178,7 @@ static int cros_ec_sensors_write(struct iio_dev *indio_dev,
/* Send to EC for each axis, even if not complete */
st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_SCALE;
- st->core.param.sensor_offset.flags =
- MOTION_SENSE_SET_OFFSET;
+ st->core.param.sensor_scale.flags = MOTION_SENSE_SET_OFFSET;
for (i = CROS_EC_SENSOR_X; i < CROS_EC_SENSOR_MAX_AXIS; i++)
st->core.param.sensor_scale.scale[i] =
st->core.calib[i].scale;
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
index 9e7c26e37880..cb7713646e21 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
@@ -38,6 +38,8 @@ static const struct {
{HID_USAGE_SENSOR_COMPASS_3D, 0, 0, 1000000},
{HID_USAGE_SENSOR_COMPASS_3D, HID_USAGE_SENSOR_UNITS_GAUSS, 1, 0},
+ {HID_USAGE_SENSOR_ORIENT_COMP_MAGN_NORTH, 0, 1, 0},
+
{HID_USAGE_SENSOR_INCLINOMETER_3D, 0, 0, 17453293},
{HID_USAGE_SENSOR_INCLINOMETER_3D,
HID_USAGE_SENSOR_UNITS_DEGREES, 0, 17453293},
@@ -96,9 +98,14 @@ static void simple_div(int dividend, int divisor, int *whole, int *micro_frac)
static void split_micro_fraction(unsigned int no, int exp, int *val1, int *val2)
{
int divisor = int_pow(10, exp);
+ unsigned int rem;
*val1 = no / divisor;
- *val2 = no % divisor * int_pow(10, 6 - exp);
+ rem = no % divisor;
+ if (exp > 6)
+ *val2 = rem / (unsigned int)int_pow(10, exp - 6);
+ else
+ *val2 = rem * int_pow(10, 6 - exp);
}
/*
@@ -140,7 +147,10 @@ static u32 convert_to_vtf_format(int size, int exp, int val1, int val2)
if (val1 < 0 || val2 < 0)
sign = -1;
exp = hid_sensor_convert_exponent(exp);
- if (exp < 0) {
+ if (exp < -6) {
+ value = abs(val1) * int_pow(10, -exp);
+ value += abs(val2) * int_pow(10, -exp - 6);
+ } else if (exp < 0) {
divisor = int_pow(10, 6 + exp);
value = abs(val1) * int_pow(10, -exp);
value += abs(val2) / divisor;
diff --git a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
index 8c9e81a77e68..b3a784d3e67d 100644
--- a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
+++ b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
@@ -133,15 +133,26 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
return;
/* no previous data, compute theoretical value from interrupt */
- if (ts->timestamp == 0) {
+ if (!ts->init) {
/* elapsed time: sensor period * sensor samples number */
interval = (s64)ts->period * (s64)sample_nb;
- ts->timestamp = timestamp - interval;
+ delta = timestamp - interval;
+ /* prevent next timestamp to be lower than the last one */
+ if ((delta + ts->period) > ts->timestamp)
+ ts->timestamp = delta;
+ ts->init = true;
+
}
/* update delta timestamps and estimated period */
it = &ts->delta;
ts->delta_counter += sample_nb;
+ /* reset in case of odr change */
+ if (ts->new_mult) {
+ it->lo = 0;
+ it->up = 0;
+ ts->delta_counter = 0;
+ }
delta = timestamp - it->up;
delta_threshold = INV_SENSORS_TIMESTAMP_MIN(INV_SENSORS_MIN_IT_DELTA, ts->chip.jitter);
if (delta >= delta_threshold) {
@@ -161,7 +172,7 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
it->lo = it->up;
it->up = timestamp;
delta = it->up - it->lo;
- if (it->lo != 0) {
+ if (it->lo != 0 && !ts->new_mult) {
/* compute period and check validity */
period = div_s64(delta, sample_nb);
valid = inv_validate_period(ts, period);
@@ -184,7 +195,7 @@ void inv_sensors_timestamp_apply_odr(struct inv_sensors_timestamp *ts,
u32 fifo_period, size_t fifo_nb,
unsigned int fifo_no)
{
- s64 interval;
+ s64 interval, timestamp;
u32 fifo_mult;
if (ts->new_mult == 0)
@@ -207,7 +218,10 @@ void inv_sensors_timestamp_apply_odr(struct inv_sensors_timestamp *ts,
fifo_period = fifo_mult * ts->chip_period.val;
/* computes time interval between interrupt and this sample */
interval = (s64)(fifo_nb - fifo_no) * (s64)fifo_period;
- ts->timestamp = ts->it.up - interval;
+ timestamp = ts->it.up - interval;
+ /* prevent next timestamp to be lower than current one */
+ if ((timestamp + ts->period) > ts->timestamp)
+ ts->timestamp = timestamp;
}
}
EXPORT_SYMBOL_NS_GPL(inv_sensors_timestamp_apply_odr, "IIO_INV_SENSORS_TIMESTAMP");
diff --git a/drivers/iio/common/scmi_sensors/scmi_iio.c b/drivers/iio/common/scmi_sensors/scmi_iio.c
index 442b40ef27cf..659a2f888ac9 100644
--- a/drivers/iio/common/scmi_sensors/scmi_iio.c
+++ b/drivers/iio/common/scmi_sensors/scmi_iio.c
@@ -14,6 +14,7 @@
#include <linux/iio/sysfs.h>
#include <linux/kernel.h>
#include <linux/kthread.h>
+#include <linux/math64.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/scmi_protocol.h>
@@ -70,8 +71,7 @@ static int scmi_iio_sensor_update_cb(struct notifier_block *nb,
*/
tstamp_scale = sensor->sensor_info->tstamp_scale + 9;
if (tstamp_scale < 0) {
- do_div(time, int_pow(10, abs(tstamp_scale)));
- time_ns = time;
+ time_ns = div64_u64(time, int_pow(10, abs(tstamp_scale)));
} else {
time_ns = time * int_pow(10, tstamp_scale);
}
@@ -162,7 +162,7 @@ static int scmi_iio_set_odr_val(struct iio_dev *iio_dev, int val, int val2)
mult = scnprintf(buf, sizeof(buf), "%llu", sf) - 1;
sec = int_pow(10, mult) * MICROHZ_PER_HZ;
- do_div(sec, uHz);
+ sec = div64_u64(sec, uHz);
if (sec == 0) {
dev_err(&iio_dev->dev,
"Trying to set invalid sensor update value for sensor %s",
@@ -237,13 +237,10 @@ static int scmi_iio_read_avail(struct iio_dev *iio_dev,
static void convert_ns_to_freq(u64 interval_ns, u64 *hz, u64 *uhz)
{
- u64 rem, freq;
+ u64 rem;
- freq = NSEC_PER_SEC;
- rem = do_div(freq, interval_ns);
- *hz = freq;
- *uhz = rem * 1000000UL;
- do_div(*uhz, interval_ns);
+ *hz = div64_u64_rem(HZ_PER_GHZ, interval_ns, &rem);
+ *uhz = div64_u64(rem * MICROHZ_PER_HZ, interval_ns);
}
static int scmi_iio_get_odr_val(struct iio_dev *iio_dev, int *val, int *val2)
@@ -269,7 +266,8 @@ static int scmi_iio_get_odr_val(struct iio_dev *iio_dev, int *val, int *val2)
mult = SCMI_SENS_CFG_GET_UPDATE_EXP(sensor_config);
if (mult < 0) {
sensor_interval_mult = int_pow(10, abs(mult));
- do_div(sensor_update_interval, sensor_interval_mult);
+ sensor_update_interval = div64_u64(sensor_update_interval,
+ sensor_interval_mult);
} else {
sensor_interval_mult = int_pow(10, mult);
sensor_update_interval =
@@ -395,9 +393,9 @@ static ssize_t scmi_iio_get_raw_available(struct iio_dev *iio_dev,
*/
exponent = exponent - scale;
if (exponent < 0) {
- rem = do_div(resolution,
- int_pow(10, abs(exponent))
- );
+ resolution = div64_u64_rem(resolution,
+ int_pow(10, abs(exponent)),
+ &rem);
len = sysfs_emit(buf,
"[%lld %llu.%llu %lld]\n", min_range,
resolution, rem, max_range);
@@ -491,7 +489,8 @@ static u64 scmi_iio_convert_interval_to_ns(u32 val)
mult = SCMI_SENS_INTVL_GET_EXP(val);
if (mult < 0) {
sensor_interval_mult = int_pow(10, abs(mult));
- do_div(sensor_update_interval, sensor_interval_mult);
+ sensor_update_interval = div64_u64(sensor_update_interval,
+ sensor_interval_mult);
} else {
sensor_interval_mult = int_pow(10, mult);
sensor_update_interval =
diff --git a/drivers/iio/dac/ad5758.c b/drivers/iio/dac/ad5758.c
index 1e21ad2a050d..4c15447ccb6b 100644
--- a/drivers/iio/dac/ad5758.c
+++ b/drivers/iio/dac/ad5758.c
@@ -141,7 +141,7 @@ enum ad5758_output_range {
AD5758_RANGE_PLUSMINUS_10V,
AD5758_RANGE_0mA_20mA = 8,
AD5758_RANGE_0mA_24mA,
- AD5758_RANGE_4mA_24mA,
+ AD5758_RANGE_4mA_20mA,
AD5758_RANGE_PLUSMINUS_20mA,
AD5758_RANGE_PLUSMINUS_24mA,
AD5758_RANGE_MINUS_1mA_PLUS_22mA,
@@ -164,7 +164,7 @@ static const struct ad5758_range ad5758_voltage_range[] = {
static const struct ad5758_range ad5758_current_range[] = {
{ AD5758_RANGE_0mA_20mA, 0, 20000},
{ AD5758_RANGE_0mA_24mA, 0, 24000 },
- { AD5758_RANGE_4mA_24mA, 4, 24000 },
+ { AD5758_RANGE_4mA_20mA, 4000, 20000 },
{ AD5758_RANGE_PLUSMINUS_20mA, -20000, 20000 },
{ AD5758_RANGE_PLUSMINUS_24mA, -24000, 24000 },
{ AD5758_RANGE_MINUS_1mA_PLUS_22mA, -1000, 22000 },
diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c
index 3fa7acc69aeb..94d51af83042 100644
--- a/drivers/iio/dac/mcp4725.c
+++ b/drivers/iio/dac/mcp4725.c
@@ -356,6 +356,8 @@ static int mcp4725_write_raw(struct iio_dev *indio_dev,
switch (mask) {
case IIO_CHAN_INFO_RAW:
ret = mcp4725_set_value(indio_dev, val);
+ if (ret)
+ return ret;
data->dac_value = val;
break;
default:
diff --git a/drivers/iio/dac/mcp47feb02-core.c b/drivers/iio/dac/mcp47feb02-core.c
index 88bffbab0854..b5a2ac4a2e67 100644
--- a/drivers/iio/dac/mcp47feb02-core.c
+++ b/drivers/iio/dac/mcp47feb02-core.c
@@ -696,6 +696,9 @@ static int mcp47feb02_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec
switch (mask) {
case IIO_CHAN_INFO_RAW:
+ if (val < 0 || val > GENMASK(data->chip_features->resolution - 1, 0))
+ return -EINVAL;
+
ret = regmap_write(data->regmap, REG_ADDR(ch->address), val);
if (ret)
return ret;
diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
index b007f46d3fd6..0958b7d31a92 100644
--- a/drivers/iio/gyro/bmg160_core.c
+++ b/drivers/iio/gyro/bmg160_core.c
@@ -761,7 +761,7 @@ static int bmg160_write_event_config(struct iio_dev *indio_dev,
struct bmg160_data *data = iio_priv(indio_dev);
int ret;
- if (state && data->ev_enable_state)
+ if (state == data->ev_enable_state)
return 0;
mutex_lock(&data->mutex);
diff --git a/drivers/iio/humidity/am2315.c b/drivers/iio/humidity/am2315.c
index 5c7582f3a4f9..8cf7e4e176a9 100644
--- a/drivers/iio/humidity/am2315.c
+++ b/drivers/iio/humidity/am2315.c
@@ -123,6 +123,7 @@ static int am2315_read_data(struct am2315_data *data,
*/
u8 rx_buf[8];
u16 crc;
+ u16 temp_raw;
/* First wake up the device. */
am2315_ping(data->client);
@@ -154,8 +155,15 @@ static int am2315_read_data(struct am2315_data *data,
sensor_data->hum_data = (rx_buf[AM2315_HUM_OFFSET] << 8) |
rx_buf[AM2315_HUM_OFFSET + 1];
- sensor_data->temp_data = (rx_buf[AM2315_TEMP_OFFSET] << 8) |
- rx_buf[AM2315_TEMP_OFFSET + 1];
+
+ /*
+ * Temperature is sign-magnitude, not two's complement:
+ * bit 15 is the sign, bits 14-0 are the magnitude (x0.1 degC).
+ */
+ temp_raw = (rx_buf[AM2315_TEMP_OFFSET] << 8) |
+ rx_buf[AM2315_TEMP_OFFSET + 1];
+ sensor_data->temp_data = (temp_raw & 0x8000) ?
+ -(temp_raw & 0x7fff) : temp_raw;
return ret;
diff --git a/drivers/iio/humidity/hid-sensor-humidity.c b/drivers/iio/humidity/hid-sensor-humidity.c
index 7cec81ff5685..aa7d4f25c393 100644
--- a/drivers/iio/humidity/hid-sensor-humidity.c
+++ b/drivers/iio/humidity/hid-sensor-humidity.c
@@ -15,6 +15,7 @@
struct hid_humidity_state {
struct hid_sensor_common common_attributes;
struct hid_sensor_hub_attribute_info humidity_attr;
+ struct hid_sensor_hub_callbacks callbacks;
struct {
s32 humidity_data;
aligned_s64 timestamp;
@@ -184,11 +185,6 @@ static int humidity_parse_report(struct platform_device *pdev,
return ret;
}
-static struct hid_sensor_hub_callbacks humidity_callbacks = {
- .send_event = &humidity_proc_event,
- .capture_sample = &humidity_capture_sample,
-};
-
/* Function to initialize the processing for usage id */
static int hid_humidity_probe(struct platform_device *pdev)
{
@@ -240,9 +236,13 @@ static int hid_humidity_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, indio_dev);
- humidity_callbacks.pdev = pdev;
+ humid_st->callbacks = (struct hid_sensor_hub_callbacks) {
+ .send_event = humidity_proc_event,
+ .capture_sample = humidity_capture_sample,
+ .pdev = pdev,
+ };
ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_HUMIDITY,
- &humidity_callbacks);
+ &humid_st->callbacks);
if (ret)
goto error_remove_trigger;
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
index 2bf9fc29d7d2..5bff2a3a44bc 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
@@ -532,22 +532,20 @@ int inv_icm42600_buffer_fifo_parse(struct inv_icm42600_state *st)
ts = &gyro_st->ts;
inv_sensors_timestamp_interrupt(ts, st->fifo.watermark.eff_gyro,
st->timestamp.gyro);
- ret = inv_icm42600_gyro_parse_fifo(st->indio_gyro);
- if (ret)
- return ret;
}
+ ret = inv_icm42600_gyro_parse_fifo(st->indio_gyro);
+ if (ret)
+ return ret;
+
/* handle accelerometer timestamp and FIFO data parsing */
if (st->fifo.nb.accel > 0) {
ts = &accel_st->ts;
inv_sensors_timestamp_interrupt(ts, st->fifo.watermark.eff_accel,
st->timestamp.accel);
- ret = inv_icm42600_accel_parse_fifo(st->indio_accel);
- if (ret)
- return ret;
}
- return 0;
+ return inv_icm42600_accel_parse_fifo(st->indio_accel);
}
int inv_icm42600_buffer_hwfifo_flush(struct inv_icm42600_state *st,
@@ -572,20 +570,18 @@ int inv_icm42600_buffer_hwfifo_flush(struct inv_icm42600_state *st,
if (st->fifo.nb.gyro > 0) {
ts = &gyro_st->ts;
inv_sensors_timestamp_interrupt(ts, st->fifo.nb.gyro, gyro_ts);
- ret = inv_icm42600_gyro_parse_fifo(st->indio_gyro);
- if (ret)
- return ret;
}
+ ret = inv_icm42600_gyro_parse_fifo(st->indio_gyro);
+ if (ret)
+ return ret;
+
if (st->fifo.nb.accel > 0) {
ts = &accel_st->ts;
inv_sensors_timestamp_interrupt(ts, st->fifo.nb.accel, accel_ts);
- ret = inv_icm42600_accel_parse_fifo(st->indio_accel);
- if (ret)
- return ret;
}
- return 0;
+ return inv_icm42600_accel_parse_fifo(st->indio_accel);
}
int inv_icm42600_buffer_init(struct inv_icm42600_state *st)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 38c3f3b398d4..7265a3c3de05 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -150,7 +150,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6050,
.fifo_size = 1024,
.temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
- .startup_time = {INV_MPU6050_GYRO_STARTUP_TIME, INV_MPU6050_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_MPU6050_ACCEL_STARTUP_TIME,
+ .gyro = INV_MPU6050_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_MPU6500_WHOAMI_VALUE,
@@ -159,7 +162,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6500,
.fifo_size = 512,
.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
- .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+ .gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_MPU6515_WHOAMI_VALUE,
@@ -168,7 +174,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6500,
.fifo_size = 512,
.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
- .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+ .gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_MPU6880_WHOAMI_VALUE,
@@ -177,7 +186,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6500,
.fifo_size = 4096,
.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
- .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+ .gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_MPU6000_WHOAMI_VALUE,
@@ -186,7 +198,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6050,
.fifo_size = 1024,
.temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
- .startup_time = {INV_MPU6050_GYRO_STARTUP_TIME, INV_MPU6050_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_MPU6050_ACCEL_STARTUP_TIME,
+ .gyro = INV_MPU6050_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_MPU9150_WHOAMI_VALUE,
@@ -195,7 +210,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6050,
.fifo_size = 1024,
.temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
- .startup_time = {INV_MPU6050_GYRO_STARTUP_TIME, INV_MPU6050_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_MPU6050_ACCEL_STARTUP_TIME,
+ .gyro = INV_MPU6050_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_MPU9250_WHOAMI_VALUE,
@@ -204,7 +222,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6500,
.fifo_size = 512,
.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
- .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+ .gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_MPU9255_WHOAMI_VALUE,
@@ -213,7 +234,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6500,
.fifo_size = 512,
.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
- .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+ .gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_ICM20608_WHOAMI_VALUE,
@@ -222,7 +246,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6500,
.fifo_size = 512,
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
- .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+ .gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_ICM20608D_WHOAMI_VALUE,
@@ -231,7 +258,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6500,
.fifo_size = 512,
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
- .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+ .gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_ICM20609_WHOAMI_VALUE,
@@ -240,7 +270,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6500,
.fifo_size = 4 * 1024,
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
- .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+ .gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_ICM20689_WHOAMI_VALUE,
@@ -249,7 +282,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6500,
.fifo_size = 4 * 1024,
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
- .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+ .gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_ICM20600_WHOAMI_VALUE,
@@ -258,7 +294,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6500,
.fifo_size = 1008,
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
- .startup_time = {INV_ICM20602_GYRO_STARTUP_TIME, INV_ICM20602_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_ICM20602_ACCEL_STARTUP_TIME,
+ .gyro = INV_ICM20602_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_ICM20602_WHOAMI_VALUE,
@@ -267,7 +306,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6500,
.fifo_size = 1008,
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
- .startup_time = {INV_ICM20602_GYRO_STARTUP_TIME, INV_ICM20602_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_ICM20602_ACCEL_STARTUP_TIME,
+ .gyro = INV_ICM20602_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_ICM20690_WHOAMI_VALUE,
@@ -276,7 +318,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6500,
.fifo_size = 1024,
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
- .startup_time = {INV_ICM20690_GYRO_STARTUP_TIME, INV_ICM20690_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_ICM20690_ACCEL_STARTUP_TIME,
+ .gyro = INV_ICM20690_GYRO_STARTUP_TIME,
+ },
},
{ .whoami = INV_IAM20380_WHOAMI_VALUE,
.name = "IAM20380",
@@ -284,7 +329,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6500,
.fifo_size = 512,
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
- .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+ .gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_IAM20680_WHOAMI_VALUE,
@@ -293,7 +341,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6500,
.fifo_size = 512,
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
- .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+ .gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_IAM20680HP_WHOAMI_VALUE,
@@ -302,7 +353,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6500,
.fifo_size = 4 * 1024,
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
- .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+ .gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+ },
},
{
.whoami = INV_IAM20680HT_WHOAMI_VALUE,
@@ -311,7 +365,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
.config = &chip_config_6500,
.fifo_size = 4 * 1024,
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
- .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+ .startup_time = {
+ .accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+ .gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+ },
},
};
@@ -1576,6 +1633,8 @@ static const unsigned long inv_mpu_scan_masks[] = {
.type = IIO_MAGN, \
.modified = 1, \
.channel2 = _chan2, \
+ /* index of the axis in magn_raw_to_gauss[] */ \
+ .address = (_chan2) - IIO_MOD_X, \
.info_mask_separate = BIT(IIO_CHAN_INFO_SCALE) | \
BIT(IIO_CHAN_INFO_RAW), \
.scan_index = _index, \
diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c
index c288437d53ea..a4962b88ef58 100644
--- a/drivers/iio/imu/kmx61.c
+++ b/drivers/iio/imu/kmx61.c
@@ -939,7 +939,7 @@ static int kmx61_write_event_config(struct iio_dev *indio_dev,
struct kmx61_data *data = kmx61_get_data(indio_dev);
int ret = 0;
- if (state && data->ev_enable_state)
+ if (state == data->ev_enable_state)
return 0;
guard(mutex)(&data->lock);
diff --git a/drivers/iio/industrialio-acpi.c b/drivers/iio/industrialio-acpi.c
index d67a43843799..c77926f6db62 100644
--- a/drivers/iio/industrialio-acpi.c
+++ b/drivers/iio/industrialio-acpi.c
@@ -6,6 +6,7 @@
#include <linux/export.h>
#include <linux/iio/iio.h>
#include <linux/sprintf.h>
+#include <linux/string.h>
/**
* iio_read_acpi_mount_matrix() - Read accelerometer mount matrix info from ACPI
@@ -63,6 +64,14 @@ bool iio_read_acpi_mount_matrix(struct device *dev,
}
str = elements[i].string.pointer;
+ /*
+ * Microsoft's example separates the values with spaces, "0 1 0".
+ * Some BIOSes use commas instead, with or without spaces around
+ * them: "0, 1, 0", "0, -1 , 0", "1, 0,0". The string lives in
+ * the buffer allocated for us above, so turn the commas into
+ * spaces in place before parsing.
+ */
+ strreplace(str, ',', ' ');
if (sscanf(str, "%d %d %d", &val[0], &val[1], &val[2]) != 3) {
dev_err(dev, "Incorrect ACPI mount matrix string format\n");
goto out_free_buffer;
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index 76926fee0f84..1078ffa8e06a 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -105,9 +105,8 @@ void iio_trigger_unregister(struct iio_trigger *trig_info)
scoped_guard(mutex, &iio_trigger_list_lock)
list_del(&trig_info->list);
- ida_free(&iio_trigger_ida, trig_info->id);
- /* Possible issue in here */
device_del(&trig_info->dev);
+ ida_free(&iio_trigger_ida, trig_info->id);
}
EXPORT_SYMBOL(iio_trigger_unregister);
@@ -293,6 +292,7 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig,
if (pf->irq < 0) {
pr_err("Could not find an available irq for trigger %s, CONFIG_IIO_CONSUMERS_PER_TRIGGER=%d limit might be exceeded\n",
trig->name, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
+ ret = pf->irq;
goto out_put_module;
}
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 929343e42d83..00dfc2037c19 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -267,7 +267,21 @@ static int als_capture_sample(struct hid_sensor_hub_device *hsdev,
struct iio_dev *indio_dev = platform_get_drvdata(priv);
struct als_state *als_state = iio_priv(indio_dev);
int ret = -EINVAL;
- u32 sample_data = *(u32 *)raw_data;
+ u32 sample_data;
+
+ switch (raw_len) {
+ case 1:
+ sample_data = *(u8 *)raw_data;
+ break;
+ case 2:
+ sample_data = *(u16 *)raw_data;
+ break;
+ default:
+ if (raw_len < sizeof(u32))
+ return -EINVAL;
+ sample_data = *(u32 *)raw_data;
+ break;
+ }
switch (usage_id) {
case HID_USAGE_SENSOR_LIGHT_ILLUM:
diff --git a/drivers/iio/light/tsl2591.c b/drivers/iio/light/tsl2591.c
index ef3ed9635a1e..f56d31404c25 100644
--- a/drivers/iio/light/tsl2591.c
+++ b/drivers/iio/light/tsl2591.c
@@ -16,6 +16,7 @@
#include <linux/interrupt.h>
#include <linux/iopoll.h>
#include <linux/kernel.h>
+#include <linux/math64.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/pm_runtime.h>
@@ -362,6 +363,10 @@ static int tsl2591_wait_adc_complete(struct tsl2591_chip *chip)
* Scale values to get more representative value of lux i.e.
* lux = ((C0DATA - C1DATA) * (1000 - ((C1DATA * 1000) / C0DATA))) / CPL
*
+ * CPL is not computed on its own: at 1x gain it is below 1 for integration
+ * times under 500 ms, so the division by LUX DF is folded into the final
+ * division instead.
+ *
* Channel 0 = IR + Visible
* Channel 1 = IR only
*/
@@ -373,8 +378,10 @@ static int tsl2591_read_channel_data(struct iio_dev *indio_dev,
struct tsl2591_als_settings *settings = &chip->als_settings;
struct i2c_client *client = chip->client;
u8 als_data[TSL2591_NUM_DATA_REGISTERS];
- int counts_per_lux, int_time_fval, gain_multi, lux;
+ int int_time_fval, gain_multi;
u16 als_ch0, als_ch1;
+ u64 lux;
+ u32 rem;
int ret;
ret = tsl2591_wait_adc_complete(chip);
@@ -410,23 +417,28 @@ static int tsl2591_read_channel_data(struct iio_dev *indio_dev,
return gain_multi;
}
- int_time_fval = TSL2591_FVAL_TO_MSEC(settings->als_int_time);
- /* Calculate counts per lux value */
- counts_per_lux = (int_time_fval * gain_multi) / TSL2591_LUX_COEFFICIENT;
+ /* No visible light, this also catches C0DATA == 0 */
+ if (als_ch0 <= als_ch1) {
+ *val = 0;
+ *val2 = 0;
+ break;
+ }
- dev_dbg(&client->dev, "Counts Per Lux: %d\n", counts_per_lux);
+ int_time_fval = TSL2591_FVAL_TO_MSEC(settings->als_int_time);
/* Calculate lux value */
- lux = ((als_ch0 - als_ch1) *
- (1000 - ((als_ch1 * 1000) / als_ch0))) / counts_per_lux;
+ lux = (u64)(als_ch0 - als_ch1) *
+ (1000 - ((als_ch1 * 1000) / als_ch0)) *
+ TSL2591_LUX_COEFFICIENT;
+ lux = div_u64(lux, int_time_fval * gain_multi);
- dev_dbg(&client->dev, "Raw lux calculation: %d\n", lux);
+ dev_dbg(&client->dev, "Raw lux calculation: %llu\n", lux);
/* Divide by 1000 to get real lux value before scaling */
- *val = lux / 1000;
+ *val = div_u64_rem(lux, 1000, &rem);
/* Get the decimal part of lux reading */
- *val2 = (lux - (*val * 1000)) * 1000;
+ *val2 = rem * 1000;
break;
default:
diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c
index ce1bd42b0c7c..f1cc75245001 100644
--- a/drivers/iio/light/vcnl4035.c
+++ b/drivers/iio/light/vcnl4035.c
@@ -44,8 +44,8 @@
#define VCNL4035_DEV_ID_MASK GENMASK(7, 0)
/* Default values */
-#define VCNL4035_MODE_ALS_ENABLE BIT(0)
-#define VCNL4035_MODE_ALS_DISABLE 0x00
+#define VCNL4035_MODE_ALS_ENABLE 0x00
+#define VCNL4035_MODE_ALS_DISABLE BIT(0)
#define VCNL4035_MODE_ALS_INT_ENABLE BIT(1)
#define VCNL4035_MODE_ALS_INT_DISABLE 0
#define VCNL4035_DEV_ID_VAL 0x80
diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c
index 6f40cba4b1ba..7f028d7f1f1e 100644
--- a/drivers/iio/magnetometer/mmc35240.c
+++ b/drivers/iio/magnetometer/mmc35240.c
@@ -532,14 +532,13 @@ static int mmc35240_resume(struct device *dev)
struct mmc35240_data *data = iio_priv(indio_dev);
int ret;
+ regcache_cache_only(data->regmap, false);
regcache_mark_dirty(data->regmap);
ret = regcache_sync_region(data->regmap, MMC35240_REG_CTRL0,
MMC35240_REG_CTRL1);
if (ret < 0)
dev_err(dev, "Failed to restore control registers\n");
- regcache_cache_only(data->regmap, false);
-
return 0;
}
diff --git a/drivers/iio/magnetometer/mmc5633.c b/drivers/iio/magnetometer/mmc5633.c
index f4dae7ba1335..b651f01e1b5d 100644
--- a/drivers/iio/magnetometer/mmc5633.c
+++ b/drivers/iio/magnetometer/mmc5633.c
@@ -499,13 +499,12 @@ static int mmc5633_resume(struct device *dev)
struct regmap *regmap = dev_get_regmap(dev, NULL);
int ret;
+ regcache_cache_only(regmap, false);
regcache_mark_dirty(regmap);
ret = regcache_sync_region(regmap, MMC5633_REG_CTRL0, MMC5633_REG_CTRL1);
if (ret)
dev_err(dev, "Failed to restore control registers\n");
- regcache_cache_only(regmap, false);
-
return 0;
}
diff --git a/drivers/iio/magnetometer/tlv493d.c b/drivers/iio/magnetometer/tlv493d.c
index 03415cc2c9b3..234e3ce63ff7 100644
--- a/drivers/iio/magnetometer/tlv493d.c
+++ b/drivers/iio/magnetometer/tlv493d.c
@@ -299,11 +299,11 @@ static int tlv493d_read_raw(struct iio_dev *indio_dev,
switch (chan->type) {
case IIO_MAGN:
/*
- * Magnetic field scale: 0.0098 mTesla (i.e. 9.8 µT)
- * Magnetic field in Gauss: mT * 10 = 0.098.
+ * Magnetic field scale: 0.098 mTesla (i.e. 98 µT) per LSB.
+ * In Gauss (1 mT = 10 G): 0.98 G per LSB.
*/
*val = 98;
- *val2 = 1000;
+ *val2 = 100;
return IIO_VAL_FRACTIONAL;
case IIO_TEMP:
/*
diff --git a/drivers/iio/proximity/hx9023s.c b/drivers/iio/proximity/hx9023s.c
index 0199a6351a46..2a6da557f22e 100644
--- a/drivers/iio/proximity/hx9023s.c
+++ b/drivers/iio/proximity/hx9023s.c
@@ -1133,14 +1133,6 @@ static int hx9023s_probe(struct i2c_client *client)
return dev_err_probe(dev, ret, "reg config failed\n");
if (client->irq) {
- ret = devm_request_threaded_irq(dev, client->irq,
- hx9023s_irq_handler,
- hx9023s_irq_thread_handler,
- IRQF_ONESHOT,
- "hx9023s_event", indio_dev);
- if (ret)
- return ret;
-
data->trig = devm_iio_trigger_alloc(dev, "%s-dev%d",
indio_dev->name,
iio_device_id(indio_dev));
@@ -1150,6 +1142,14 @@ static int hx9023s_probe(struct i2c_client *client)
data->trig->ops = &hx9023s_trigger_ops;
iio_trigger_set_drvdata(data->trig, indio_dev);
+ ret = devm_request_threaded_irq(dev, client->irq,
+ hx9023s_irq_handler,
+ hx9023s_irq_thread_handler,
+ IRQF_ONESHOT,
+ "hx9023s_event", indio_dev);
+ if (ret)
+ return ret;
+
ret = devm_iio_trigger_register(dev, data->trig);
if (ret)
return dev_err_probe(dev, ret,
diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c
index 79ba46d8a0aa..2585b9c6fb69 100644
--- a/drivers/iio/proximity/sx9310.c
+++ b/drivers/iio/proximity/sx9310.c
@@ -891,7 +891,7 @@ static int sx9310_check_whoami(struct device *dev,
if (ret)
return ret;
- ddata = device_get_match_data(dev);
+ ddata = i2c_get_match_data(data->client);
if (ddata->whoami != whoami)
return -ENODEV;
diff --git a/drivers/iio/proximity/sx9324.c b/drivers/iio/proximity/sx9324.c
index 255a36976ac4..1c8ba28c030a 100644
--- a/drivers/iio/proximity/sx9324.c
+++ b/drivers/iio/proximity/sx9324.c
@@ -279,11 +279,20 @@ static const struct {
{ 0, 250000 }, /* 11111: 4 s */
};
+/*
+ * The scan period of the SX9324 is selected by the 5-bit wide
+ * SX9324_REG_GNRL_CTRL0_SCANPERIOD field. The values below are the scan
+ * periods in ms of the corresponding sx9324_samp_freq_table[] entries.
+ */
static const unsigned int sx9324_scan_period_table[] = {
- 2, 15, 30, 45, 60, 90, 120, 200,
- 400, 600, 800, 1000, 2000, 3000, 4000, 5000,
+ 1, 2, 4, 6, 8, 10, 14, 18, /* 0x00 - 0x07 */
+ 22, 26, 30, 34, 38, 42, 46, 50, /* 0x08 - 0x0f */
+ 56, 62, 68, 74, 80, 90, 100, 200, /* 0x10 - 0x17 */
+ 300, 400, 600, 800, 1000, 2000, 3000, 4000, /* 0x18 - 0x1f */
};
+static_assert(ARRAY_SIZE(sx9324_scan_period_table) == ARRAY_SIZE(sx9324_samp_freq_table));
+
static const struct regmap_range sx9324_writable_reg_ranges[] = {
/*
* To set COMPSTAT for compensation, even if datasheet says register is
diff --git a/drivers/iio/proximity/sx9360.c b/drivers/iio/proximity/sx9360.c
index ed83d809ecf5..2a9b37df8f62 100644
--- a/drivers/iio/proximity/sx9360.c
+++ b/drivers/iio/proximity/sx9360.c
@@ -14,10 +14,12 @@
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/log2.h>
+#include <linux/math64.h>
#include <linux/module.h>
#include <linux/pm.h>
#include <linux/property.h>
#include <linux/regmap.h>
+#include <linux/units.h>
#include <linux/iio/iio.h>
@@ -43,6 +45,7 @@
#define SX9360_REG_GNRL_CTRL1_SCANPERIOD_MASK GENMASK(2, 0)
#define SX9360_REG_GNRL_CTRL2 0x12
#define SX9360_REG_GNRL_CTRL2_PERIOD_102MS 0x32
+#define SX9360_REG_GNRL_SCANPERIOD_MAX GENMASK(10, 0)
#define SX9360_REG_GNRL_REG_2_PERIOD_MS(_r) \
(((_r) * 8192) / (SX9360_FOSC_HZ / 1000))
#define SX9360_REG_GNRL_FREQ_2_REG(_f) (((_f) * 8192) / SX9360_FOSC_HZ)
@@ -182,9 +185,9 @@ static const struct {
int val;
int val2;
} sx9360_samp_freq_interval[] = {
- { 0, 281250 }, /* 4MHz / (8192 * 2047) */
- { 0, 281250 },
- { 448, 281250 }, /* 4MHz / 8192 */
+ { 0, 238535 }, /* 4MHz / (8192 * 2047) */
+ { 0, 238419 },
+ { 488, 281250 }, /* 4MHz / 8192 */
};
static const struct regmap_range sx9360_writable_reg_ranges[] = {
@@ -383,11 +386,25 @@ static int sx9360_read_avail(struct iio_dev *indio_dev,
static int sx9360_set_samp_freq(struct sx_common_data *data,
int val, int val2)
{
- int reg;
+ unsigned int period_ticks;
+ u64 freq_uHz;
__be16 buf;
- reg = val * 8192 / SX9360_FOSC_HZ + val2 * 8192 / (SX9360_FOSC_MHZ);
- buf = cpu_to_be16(reg);
+ if (val < 0 || val2 < 0)
+ return -EINVAL;
+
+ freq_uHz = (u64)val * MICROHZ_PER_HZ + val2;
+ if (!freq_uHz)
+ return -EINVAL;
+
+ /* The register holds the scan period in ticks of 8192 FOSC cycles. */
+ period_ticks = DIV64_U64_ROUND_CLOSEST((u64)SX9360_FOSC_HZ * MICROHZ_PER_HZ,
+ freq_uHz * 8192);
+ if (!period_ticks || period_ticks > SX9360_REG_GNRL_SCANPERIOD_MAX)
+ return -EINVAL;
+
+ buf = cpu_to_be16(period_ticks);
+
guard(mutex)(&data->mutex);
return regmap_bulk_write(data->regmap, SX9360_REG_GNRL_CTRL1, &buf,
diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index dadce9b44227..26522b6c5a2d 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -548,6 +548,12 @@ static int sx9500_write_event_config(struct iio_dev *indio_dev,
mutex_lock(&data->mutex);
+ /* The user counts must only change when the state does. */
+ if (data->event_enabled[chan->channel] == state) {
+ ret = 0;
+ goto out_unlock;
+ }
+
if (state) {
ret = sx9500_inc_chan_users(data, chan->channel);
if (ret < 0)
diff --git a/drivers/iio/temperature/hid-sensor-temperature.c b/drivers/iio/temperature/hid-sensor-temperature.c
index 5e3262e461f4..ae67daff6df5 100644
--- a/drivers/iio/temperature/hid-sensor-temperature.c
+++ b/drivers/iio/temperature/hid-sensor-temperature.c
@@ -15,6 +15,7 @@
struct temperature_state {
struct hid_sensor_common common_attributes;
struct hid_sensor_hub_attribute_info temperature_attr;
+ struct hid_sensor_hub_callbacks callbacks;
struct {
s32 temperature_data;
aligned_s64 timestamp;
@@ -181,11 +182,6 @@ static int temperature_parse_report(struct platform_device *pdev,
return ret;
}
-static struct hid_sensor_hub_callbacks temperature_callbacks = {
- .send_event = &temperature_proc_event,
- .capture_sample = &temperature_capture_sample,
-};
-
/* Function to initialize the processing for usage id */
static int hid_temperature_probe(struct platform_device *pdev)
{
@@ -237,9 +233,13 @@ static int hid_temperature_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, indio_dev);
- temperature_callbacks.pdev = pdev;
+ temp_st->callbacks = (struct hid_sensor_hub_callbacks) {
+ .send_event = temperature_proc_event,
+ .capture_sample = temperature_capture_sample,
+ .pdev = pdev,
+ };
ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_TEMPERATURE,
- &temperature_callbacks);
+ &temp_st->callbacks);
if (ret)
goto error_remove_trigger;
diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c
index 27d6ab5f5d7a..4f79da1f905e 100644
--- a/drivers/iio/temperature/mlx90614.c
+++ b/drivers/iio/temperature/mlx90614.c
@@ -565,7 +565,7 @@ static int mlx90614_probe_num_ir_sensors(struct i2c_client *client)
const struct mlx_chip_info *chip_info = data->chip_info;
s32 ret;
- if (chip_info->dual_channel)
+ if (!chip_info->dual_channel)
return 0;
ret = i2c_smbus_read_word_data(client, chip_info->op_eeprom_config1);
diff --git a/include/linux/iio/common/inv_sensors_timestamp.h b/include/linux/iio/common/inv_sensors_timestamp.h
index 4f08204ede3b..91690778ae88 100644
--- a/include/linux/iio/common/inv_sensors_timestamp.h
+++ b/include/linux/iio/common/inv_sensors_timestamp.h
@@ -66,6 +66,7 @@ struct inv_sensors_timestamp {
u32 new_mult;
u32 period;
struct inv_sensors_timestamp_acc chip_period;
+ bool init;
};
void inv_sensors_timestamp_init(struct inv_sensors_timestamp *ts,
@@ -94,7 +95,7 @@ static inline void inv_sensors_timestamp_reset(struct inv_sensors_timestamp *ts)
ts->it = interval_init;
ts->delta = interval_init;
ts->delta_counter = 0;
- ts->timestamp = 0;
+ ts->init = false;
}
#endif