Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f3d3162 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Merge tag 'iio-fixes-for-5.4a' of...

Merge tag 'iio-fixes-for-5.4a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus

Jonathan writes:

First set of IIO fixes for the 5.4 cycle.

* adis16400
  - Make sure to free memory on a few failure paths.
* adxl372
  - Fix wrong fifo depth
  - Fix wrong indexing of data from the fifo.
  - Perform a reset at startup to avoid a problem with inconsistent state.
* axp288
  - This is a fix for a fix.  The original fix made sure we kept the
    configuration from some firmwares to preserve a bias current.
    Unfortunately it appears the previous behaviour was working around
    a buggy firmware by overwriting the wrong value it had.  Hence
    a regression was seen.
* bmc150
  - Fix the centre temperature.  This was due to an error in one of the
    datasheets.
* hx711
  - Fix an issue where a badly timed interrupt could lead to a control
    line being high long enough to put the device into a low power state.
* meson_sar_adc
  - Fix a case where the irq was enabled before everything it uses was
    allocated.
* st_lsm6dsx
  - Ensure we don't set the sensor sensitivity to 0 as it will force
    all readings to 0.
  - Fix a wait time for the slave i2c controller when the accelerometer
    is not enabled.
* stm32-adc
  - Precursor for fix. Move a set of register definitions to a header.
  - Fix a race when several ADCs are in use with some using interrupts
    to control the dataflow and some using DMA.
* vcnl4000
  - Fix a garbage of_match_table in which a string was passed instead
    of the intended enum.

* tag 'iio-fixes-for-5.4a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  iio: Fix an undefied reference error in noa1305_probe
  iio: light: opt3001: fix mutex unlock race
  iio: adc: ad799x: fix probe error handling
  iio: light: add missing vcnl4040 of_compatible
  iio: light: fix vcnl4000 devicetree hooks
  iio: imu: st_lsm6dsx: fix waitime for st_lsm6dsx i2c controller
  iio: adc: axp288: Override TS pin bias current for some models
  iio: imu: adis16400: fix memory leak
  iio: imu: adis16400: release allocated memory on failure
  iio: adc: stm32-adc: fix a race when using several adcs with dma and irq
  iio: adc: stm32-adc: move registers definitions
  iio: accel: adxl372: Perform a reset at start up
  iio: accel: adxl372: Fix push to buffers lost samples
  iio: accel: adxl372: Fix/remove limitation for FIFO samples
  iio: adc: hx711: fix bug in sampling of data
  iio: fix center temperature of bmc150-accel-core
  iio: imu: st_lsm6dsx: forbid 0 sensor sensitivity
  iio: adc: meson_saradc: Fix memory allocation order
parents 80b15db5 a26e0fbe
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -474,12 +474,17 @@ static int adxl372_configure_fifo(struct adxl372_state *st)
	if (ret < 0)
		return ret;

	fifo_samples = st->watermark & 0xFF;
	/*
	 * watermark stores the number of sets; we need to write the FIFO
	 * registers with the number of samples
	 */
	fifo_samples = (st->watermark * st->fifo_set_size);
	fifo_ctl = ADXL372_FIFO_CTL_FORMAT_MODE(st->fifo_format) |
		   ADXL372_FIFO_CTL_MODE_MODE(st->fifo_mode) |
		   ADXL372_FIFO_CTL_SAMPLES_MODE(st->watermark);
		   ADXL372_FIFO_CTL_SAMPLES_MODE(fifo_samples);

	ret = regmap_write(st->regmap, ADXL372_FIFO_SAMPLES, fifo_samples);
	ret = regmap_write(st->regmap,
			   ADXL372_FIFO_SAMPLES, fifo_samples & 0xFF);
	if (ret < 0)
		return ret;

@@ -548,8 +553,7 @@ static irqreturn_t adxl372_trigger_handler(int irq, void *p)
			goto err;

		/* Each sample is 2 bytes */
		for (i = 0; i < fifo_entries * sizeof(u16);
		     i += st->fifo_set_size * sizeof(u16))
		for (i = 0; i < fifo_entries; i += st->fifo_set_size)
			iio_push_to_buffers(indio_dev, &st->fifo_buf[i]);
	}
err:
@@ -571,6 +575,14 @@ static int adxl372_setup(struct adxl372_state *st)
		return -ENODEV;
	}

	/*
	 * Perform a software reset to make sure the device is in a consistent
	 * state after start up.
	 */
	ret = regmap_write(st->regmap, ADXL372_RESET, ADXL372_RESET_CODE);
	if (ret < 0)
		return ret;

	ret = adxl372_set_op_mode(st, ADXL372_STANDBY);
	if (ret < 0)
		return ret;
+1 −1
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@
#define BMC150_ACCEL_SLEEP_1_SEC		0x0F

#define BMC150_ACCEL_REG_TEMP			0x08
#define BMC150_ACCEL_TEMP_CENTER_VAL		24
#define BMC150_ACCEL_TEMP_CENTER_VAL		23

#define BMC150_ACCEL_AXIS_TO_REG(axis)	(BMC150_ACCEL_REG_XOUT_L + (axis * 2))
#define BMC150_AUTO_SUSPEND_DELAY_MS		2000
+2 −2
Original line number Diff line number Diff line
@@ -810,10 +810,10 @@ static int ad799x_probe(struct i2c_client *client,

	ret = ad799x_write_config(st, st->chip_config->default_config);
	if (ret < 0)
		goto error_disable_reg;
		goto error_disable_vref;
	ret = ad799x_read_config(st);
	if (ret < 0)
		goto error_disable_reg;
		goto error_disable_vref;
	st->config = ret;

	ret = iio_triggered_buffer_setup(indio_dev, NULL,
+32 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */

#include <linux/dmi.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/device.h>
@@ -25,6 +26,11 @@
#define AXP288_ADC_EN_MASK				0xF0
#define AXP288_ADC_TS_ENABLE				0x01

#define AXP288_ADC_TS_BIAS_MASK				GENMASK(5, 4)
#define AXP288_ADC_TS_BIAS_20UA				(0 << 4)
#define AXP288_ADC_TS_BIAS_40UA				(1 << 4)
#define AXP288_ADC_TS_BIAS_60UA				(2 << 4)
#define AXP288_ADC_TS_BIAS_80UA				(3 << 4)
#define AXP288_ADC_TS_CURRENT_ON_OFF_MASK		GENMASK(1, 0)
#define AXP288_ADC_TS_CURRENT_OFF			(0 << 0)
#define AXP288_ADC_TS_CURRENT_ON_WHEN_CHARGING		(1 << 0)
@@ -177,10 +183,36 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev,
	return ret;
}

/*
 * We rely on the machine's firmware to correctly setup the TS pin bias current
 * at boot. This lists systems with broken fw where we need to set it ourselves.
 */
static const struct dmi_system_id axp288_adc_ts_bias_override[] = {
	{
		/* Lenovo Ideapad 100S (11 inch) */
		.matches = {
		  DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
		  DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo ideapad 100S-11IBY"),
		},
		.driver_data = (void *)(uintptr_t)AXP288_ADC_TS_BIAS_80UA,
	},
	{}
};

static int axp288_adc_initialize(struct axp288_adc_info *info)
{
	const struct dmi_system_id *bias_override;
	int ret, adc_enable_val;

	bias_override = dmi_first_match(axp288_adc_ts_bias_override);
	if (bias_override) {
		ret = regmap_update_bits(info->regmap, AXP288_ADC_TS_PIN_CTRL,
					 AXP288_ADC_TS_BIAS_MASK,
					 (uintptr_t)bias_override->driver_data);
		if (ret)
			return ret;
	}

	/*
	 * Determine if the TS pin is enabled and set the TS current-source
	 * accordingly.
+5 −5
Original line number Diff line number Diff line
@@ -100,14 +100,14 @@ struct hx711_data {

static int hx711_cycle(struct hx711_data *hx711_data)
{
	int val;
	unsigned long flags;

	/*
	 * if preempted for more then 60us while PD_SCK is high:
	 * hx711 is going in reset
	 * ==> measuring is false
	 */
	preempt_disable();
	local_irq_save(flags);
	gpiod_set_value(hx711_data->gpiod_pd_sck, 1);

	/*
@@ -117,7 +117,6 @@ static int hx711_cycle(struct hx711_data *hx711_data)
	 */
	ndelay(hx711_data->data_ready_delay_ns);

	val = gpiod_get_value(hx711_data->gpiod_dout);
	/*
	 * here we are not waiting for 0.2 us as suggested by the datasheet,
	 * because the oscilloscope showed in a test scenario
@@ -125,7 +124,7 @@ static int hx711_cycle(struct hx711_data *hx711_data)
	 * and 0.56 us for PD_SCK low on TI Sitara with 800 MHz
	 */
	gpiod_set_value(hx711_data->gpiod_pd_sck, 0);
	preempt_enable();
	local_irq_restore(flags);

	/*
	 * make it a square wave for addressing cases with capacitance on
@@ -133,7 +132,8 @@ static int hx711_cycle(struct hx711_data *hx711_data)
	 */
	ndelay(hx711_data->data_ready_delay_ns);

	return val;
	/* sample as late as possible */
	return gpiod_get_value(hx711_data->gpiod_dout);
}

static int hx711_read(struct hx711_data *hx711_data)
Loading