Commit 63b93e70 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

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

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

Jonathan writes:

1st set of IIO fixes for 6.5

Usual mixed bag of fixes for recently introduced issues and ones from way
back that have recently been noticed.

* core
  - Avoid a device with no parent issues seen on the dummy example device.
* adi,ad71145
  - Drop ref now that dt-schema supports -nanoamp.
* adi,ad7192
  - Fix wrong bit set for enabling AC excitation and exposure of control
    on devices without the feature.
* adi,admv1013
  - Don't ignore errors from regulator_get_voltage().
* amlogic,meson-adc
  - Make sure clocks enabled early enough.
* google,cros_ec
  - Fix undersized cros_ec_command allocation that resulted in a buffer
    overrun.
* rohm,bu27008
  - Fix truncation issue with scale format that prevents smallest value
    being set
  - Report intensity as unsigned. Previously large values would be
    interpretted as negative intensities (and odd concept).
* rohm,bu27034
  - Fix truncation issue with scale format that prevents smallest value
    being set.
* st,lsm6dsx
  - Return an error code, not false (which is 0 and hence success)
    to indicate ACPI mount matrix retrieval failed due to no ACPI
    support.
* ti,ina2xx
  - Avoid a NULL pointer dereference if fall back compatible is used.

* tag 'iio-fixes-for-6.5a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  iio: cros_ec: Fix the allocation size for cros_ec_command
  iio: imu: lsm6dsx: Fix mount matrix retrieval
  iio: adc: meson: fix core clock enable/disable moment
  iio: core: Prevent invalid memory access when there is no parent
  iio: frequency: admv1013: propagate errors from regulator_get_voltage()
  dt-bindings: iio: adi,ad74115: remove ref from -nanoamp
  iio: adc: ina2xx: avoid NULL pointer dereference on OF device match
  iio: light: bu27008: Fix intensity data type
  iio: light: bu27008: Fix scale format
  iio: light: bu27034: Fix scale format
  iio: adc: ad7192: Fix ac excitation feature
parents bb6578ba 8a462905
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -216,7 +216,6 @@ properties:
    description: Whether to enable burnout current for EXT1.

  adi,ext1-burnout-current-nanoamp:
    $ref: /schemas/types.yaml#/definitions/uint32
    description:
      Burnout current in nanoamps to be applied to EXT1.
    enum: [0, 50, 500, 1000, 10000]
@@ -233,7 +232,6 @@ properties:
    description: Whether to enable burnout current for EXT2.

  adi,ext2-burnout-current-nanoamp:
    $ref: /schemas/types.yaml#/definitions/uint32
    description: Burnout current in nanoamps to be applied to EXT2.
    enum: [0, 50, 500, 1000, 10000]
    default: 0
@@ -249,7 +247,6 @@ properties:
    description: Whether to enable burnout current for VIOUT.

  adi,viout-burnout-current-nanoamp:
    $ref: /schemas/types.yaml#/definitions/uint32
    description: Burnout current in nanoamps to be applied to VIOUT.
    enum: [0, 1000, 10000]
    default: 0
+8 −8
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@
#define AD7192_MODE_STA_MASK	BIT(20) /* Status Register transmission Mask */
#define AD7192_MODE_CLKSRC(x)	(((x) & 0x3) << 18) /* Clock Source Select */
#define AD7192_MODE_SINC3	BIT(15) /* SINC3 Filter Select */
#define AD7192_MODE_ACX		BIT(14) /* AC excitation enable(AD7195 only)*/
#define AD7192_MODE_ENPAR	BIT(13) /* Parity Enable */
#define AD7192_MODE_CLKDIV	BIT(12) /* Clock divide by 2 (AD7190/2 only)*/
#define AD7192_MODE_SCYCLE	BIT(11) /* Single cycle conversion */
@@ -91,6 +90,7 @@
/* Configuration Register Bit Designations (AD7192_REG_CONF) */

#define AD7192_CONF_CHOP	BIT(23) /* CHOP enable */
#define AD7192_CONF_ACX		BIT(22) /* AC excitation enable(AD7195 only) */
#define AD7192_CONF_REFSEL	BIT(20) /* REFIN1/REFIN2 Reference Select */
#define AD7192_CONF_CHAN(x)	((x) << 8) /* Channel select */
#define AD7192_CONF_CHAN_MASK	(0x7FF << 8) /* Channel select mask */
@@ -472,7 +472,7 @@ static ssize_t ad7192_show_ac_excitation(struct device *dev,
	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
	struct ad7192_state *st = iio_priv(indio_dev);

	return sysfs_emit(buf, "%d\n", !!(st->mode & AD7192_MODE_ACX));
	return sysfs_emit(buf, "%d\n", !!(st->conf & AD7192_CONF_ACX));
}

static ssize_t ad7192_show_bridge_switch(struct device *dev,
@@ -513,13 +513,13 @@ static ssize_t ad7192_set(struct device *dev,

		ad_sd_write_reg(&st->sd, AD7192_REG_GPOCON, 1, st->gpocon);
		break;
	case AD7192_REG_MODE:
	case AD7192_REG_CONF:
		if (val)
			st->mode |= AD7192_MODE_ACX;
			st->conf |= AD7192_CONF_ACX;
		else
			st->mode &= ~AD7192_MODE_ACX;
			st->conf &= ~AD7192_CONF_ACX;

		ad_sd_write_reg(&st->sd, AD7192_REG_MODE, 3, st->mode);
		ad_sd_write_reg(&st->sd, AD7192_REG_CONF, 3, st->conf);
		break;
	default:
		ret = -EINVAL;
@@ -579,12 +579,11 @@ static IIO_DEVICE_ATTR(bridge_switch_en, 0644,

static IIO_DEVICE_ATTR(ac_excitation_en, 0644,
		       ad7192_show_ac_excitation, ad7192_set,
		       AD7192_REG_MODE);
		       AD7192_REG_CONF);

static struct attribute *ad7192_attributes[] = {
	&iio_dev_attr_filter_low_pass_3db_frequency_available.dev_attr.attr,
	&iio_dev_attr_bridge_switch_en.dev_attr.attr,
	&iio_dev_attr_ac_excitation_en.dev_attr.attr,
	NULL
};

@@ -595,6 +594,7 @@ static const struct attribute_group ad7192_attribute_group = {
static struct attribute *ad7195_attributes[] = {
	&iio_dev_attr_filter_low_pass_3db_frequency_available.dev_attr.attr,
	&iio_dev_attr_bridge_switch_en.dev_attr.attr,
	&iio_dev_attr_ac_excitation_en.dev_attr.attr,
	NULL
};

+6 −3
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ static const struct regmap_config ina2xx_regmap_config = {
enum ina2xx_ids { ina219, ina226 };

struct ina2xx_config {
	const char *name;
	u16 config_default;
	int calibration_value;
	int shunt_voltage_lsb;	/* nV */
@@ -155,6 +156,7 @@ struct ina2xx_chip_info {

static const struct ina2xx_config ina2xx_config[] = {
	[ina219] = {
		.name = "ina219",
		.config_default = INA219_CONFIG_DEFAULT,
		.calibration_value = 4096,
		.shunt_voltage_lsb = 10000,
@@ -164,6 +166,7 @@ static const struct ina2xx_config ina2xx_config[] = {
		.chip_id = ina219,
	},
	[ina226] = {
		.name = "ina226",
		.config_default = INA226_CONFIG_DEFAULT,
		.calibration_value = 2048,
		.shunt_voltage_lsb = 2500,
@@ -996,7 +999,7 @@ static int ina2xx_probe(struct i2c_client *client)
	/* Patch the current config register with default. */
	val = chip->config->config_default;

	if (id->driver_data == ina226) {
	if (type == ina226) {
		ina226_set_average(chip, INA226_DEFAULT_AVG, &val);
		ina226_set_int_time_vbus(chip, INA226_DEFAULT_IT, &val);
		ina226_set_int_time_vshunt(chip, INA226_DEFAULT_IT, &val);
@@ -1015,7 +1018,7 @@ static int ina2xx_probe(struct i2c_client *client)
	}

	indio_dev->modes = INDIO_DIRECT_MODE;
	if (id->driver_data == ina226) {
	if (type == ina226) {
		indio_dev->channels = ina226_channels;
		indio_dev->num_channels = ARRAY_SIZE(ina226_channels);
		indio_dev->info = &ina226_info;
@@ -1024,7 +1027,7 @@ static int ina2xx_probe(struct i2c_client *client)
		indio_dev->num_channels = ARRAY_SIZE(ina219_channels);
		indio_dev->info = &ina219_info;
	}
	indio_dev->name = id->name;
	indio_dev->name = id ? id->name : chip->config->name;

	ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
					  &ina2xx_setup_ops);
+12 −11
Original line number Diff line number Diff line
@@ -916,12 +916,6 @@ static int meson_sar_adc_hw_enable(struct iio_dev *indio_dev)
		goto err_vref;
	}

	ret = clk_prepare_enable(priv->core_clk);
	if (ret) {
		dev_err(dev, "failed to enable core clk\n");
		goto err_core_clk;
	}

	regval = FIELD_PREP(MESON_SAR_ADC_REG0_FIFO_CNT_IRQ_MASK, 1);
	regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG0,
			   MESON_SAR_ADC_REG0_FIFO_CNT_IRQ_MASK, regval);
@@ -948,8 +942,6 @@ static int meson_sar_adc_hw_enable(struct iio_dev *indio_dev)
	regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3,
			   MESON_SAR_ADC_REG3_ADC_EN, 0);
	meson_sar_adc_set_bandgap(indio_dev, false);
	clk_disable_unprepare(priv->core_clk);
err_core_clk:
	regulator_disable(priv->vref);
err_vref:
	meson_sar_adc_unlock(indio_dev);
@@ -977,8 +969,6 @@ static void meson_sar_adc_hw_disable(struct iio_dev *indio_dev)

	meson_sar_adc_set_bandgap(indio_dev, false);

	clk_disable_unprepare(priv->core_clk);

	regulator_disable(priv->vref);

	if (!ret)
@@ -1211,7 +1201,7 @@ static int meson_sar_adc_probe(struct platform_device *pdev)
	if (IS_ERR(priv->clkin))
		return dev_err_probe(dev, PTR_ERR(priv->clkin), "failed to get clkin\n");

	priv->core_clk = devm_clk_get(dev, "core");
	priv->core_clk = devm_clk_get_enabled(dev, "core");
	if (IS_ERR(priv->core_clk))
		return dev_err_probe(dev, PTR_ERR(priv->core_clk), "failed to get core clk\n");

@@ -1294,15 +1284,26 @@ static int meson_sar_adc_remove(struct platform_device *pdev)
static int meson_sar_adc_suspend(struct device *dev)
{
	struct iio_dev *indio_dev = dev_get_drvdata(dev);
	struct meson_sar_adc_priv *priv = iio_priv(indio_dev);

	meson_sar_adc_hw_disable(indio_dev);

	clk_disable_unprepare(priv->core_clk);

	return 0;
}

static int meson_sar_adc_resume(struct device *dev)
{
	struct iio_dev *indio_dev = dev_get_drvdata(dev);
	struct meson_sar_adc_priv *priv = iio_priv(indio_dev);
	int ret;

	ret = clk_prepare_enable(priv->core_clk);
	if (ret) {
		dev_err(dev, "failed to enable core clk\n");
		return ret;
	}

	return meson_sar_adc_hw_enable(indio_dev);
}
+1 −1
Original line number Diff line number Diff line
@@ -253,7 +253,7 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
	platform_set_drvdata(pdev, indio_dev);

	state->ec = ec->ec_dev;
	state->msg = devm_kzalloc(&pdev->dev,
	state->msg = devm_kzalloc(&pdev->dev, sizeof(*state->msg) +
				max((u16)sizeof(struct ec_params_motion_sense),
				state->ec->max_response), GFP_KERNEL);
	if (!state->msg)
Loading