Skip to content

Commit 634c5fa

Browse files
committed
Merge tag 'iio-fixes-for-6.1c' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next
Jonathan writes: "3rd set of IIO fixes for the 6.1 cycle. Usual mixed bunch of driver fixes. * sw-triggers - Fix failure to cleanup up list registration in an error path. * aspeed,adc - Drop the trim valid dts property as it doesn't account for unprogrammed OTP and that can be easily detected without it. * avago,apds9960: - Fix register address for gesture gain. * bosch,bma400 - Fix a memory leak in an error path. * rohm,rpr0521 - Fix missing dependency on IIO_BUFFER/IIO_TRIGGERED_BUFFER. * ti,afe4403/4404 - Fix out of band read by moving reads down to where they are used." * tag 'iio-fixes-for-6.1c' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: dt-bindings: iio: adc: Remove the property "aspeed,trim-data-valid" iio: adc: aspeed: Remove the trim valid dts property. iio: core: Fix entry not deleted when iio_register_sw_trigger_type() fails iio: accel: bma400: Fix memory leak in bma400_get_steps_reg() iio: light: rpr0521: add missing Kconfig dependencies iio: health: afe4404: Fix oob read in afe4404_[read|write]_raw iio: health: afe4403: Fix oob read in afe4403_read_raw iio: light: apds9960: fix wrong register for gesture gain
2 parents 552d6ba + 398e347 commit 634c5fa

File tree

8 files changed

+31
-28
lines changed

8 files changed

+31
-28
lines changed

Documentation/devicetree/bindings/iio/adc/aspeed,ast2600-adc.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,6 @@ properties:
6262
description:
6363
Inform the driver that last channel will be used to sensor battery.
6464

65-
aspeed,trim-data-valid:
66-
type: boolean
67-
description: |
68-
The ADC reference voltage can be calibrated to obtain the trimming
69-
data which will be stored in otp. This property informs the driver that
70-
the data store in the otp is valid.
71-
7265
required:
7366
- compatible
7467
- reg

drivers/iio/accel/bma400_core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,10 @@ static int bma400_get_steps_reg(struct bma400_data *data, int *val)
805805

806806
ret = regmap_bulk_read(data->regmap, BMA400_STEP_CNT0_REG,
807807
steps_raw, BMA400_STEP_RAW_LEN);
808-
if (ret)
808+
if (ret) {
809+
kfree(steps_raw);
809810
return ret;
811+
}
810812
*val = get_unaligned_le24(steps_raw);
811813
kfree(steps_raw);
812814
return IIO_VAL_INT;

drivers/iio/adc/aspeed_adc.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ static int aspeed_adc_set_trim_data(struct iio_dev *indio_dev)
202202
((scu_otp) &
203203
(data->model_data->trim_locate->field)) >>
204204
__ffs(data->model_data->trim_locate->field);
205+
if (!trimming_val)
206+
trimming_val = 0x8;
205207
}
206208
dev_dbg(data->dev,
207209
"trimming val = %d, offset = %08x, fields = %08x\n",
@@ -563,12 +565,9 @@ static int aspeed_adc_probe(struct platform_device *pdev)
563565
if (ret)
564566
return ret;
565567

566-
if (of_find_property(data->dev->of_node, "aspeed,trim-data-valid",
567-
NULL)) {
568-
ret = aspeed_adc_set_trim_data(indio_dev);
569-
if (ret)
570-
return ret;
571-
}
568+
ret = aspeed_adc_set_trim_data(indio_dev);
569+
if (ret)
570+
return ret;
572571

573572
if (of_find_property(data->dev->of_node, "aspeed,battery-sensing",
574573
NULL)) {

drivers/iio/health/afe4403.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,14 @@ static int afe4403_read_raw(struct iio_dev *indio_dev,
245245
int *val, int *val2, long mask)
246246
{
247247
struct afe4403_data *afe = iio_priv(indio_dev);
248-
unsigned int reg = afe4403_channel_values[chan->address];
249-
unsigned int field = afe4403_channel_leds[chan->address];
248+
unsigned int reg, field;
250249
int ret;
251250

252251
switch (chan->type) {
253252
case IIO_INTENSITY:
254253
switch (mask) {
255254
case IIO_CHAN_INFO_RAW:
255+
reg = afe4403_channel_values[chan->address];
256256
ret = afe4403_read(afe, reg, val);
257257
if (ret)
258258
return ret;
@@ -262,6 +262,7 @@ static int afe4403_read_raw(struct iio_dev *indio_dev,
262262
case IIO_CURRENT:
263263
switch (mask) {
264264
case IIO_CHAN_INFO_RAW:
265+
field = afe4403_channel_leds[chan->address];
265266
ret = regmap_field_read(afe->fields[field], val);
266267
if (ret)
267268
return ret;

drivers/iio/health/afe4404.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,20 +250,20 @@ static int afe4404_read_raw(struct iio_dev *indio_dev,
250250
int *val, int *val2, long mask)
251251
{
252252
struct afe4404_data *afe = iio_priv(indio_dev);
253-
unsigned int value_reg = afe4404_channel_values[chan->address];
254-
unsigned int led_field = afe4404_channel_leds[chan->address];
255-
unsigned int offdac_field = afe4404_channel_offdacs[chan->address];
253+
unsigned int value_reg, led_field, offdac_field;
256254
int ret;
257255

258256
switch (chan->type) {
259257
case IIO_INTENSITY:
260258
switch (mask) {
261259
case IIO_CHAN_INFO_RAW:
260+
value_reg = afe4404_channel_values[chan->address];
262261
ret = regmap_read(afe->regmap, value_reg, val);
263262
if (ret)
264263
return ret;
265264
return IIO_VAL_INT;
266265
case IIO_CHAN_INFO_OFFSET:
266+
offdac_field = afe4404_channel_offdacs[chan->address];
267267
ret = regmap_field_read(afe->fields[offdac_field], val);
268268
if (ret)
269269
return ret;
@@ -273,6 +273,7 @@ static int afe4404_read_raw(struct iio_dev *indio_dev,
273273
case IIO_CURRENT:
274274
switch (mask) {
275275
case IIO_CHAN_INFO_RAW:
276+
led_field = afe4404_channel_leds[chan->address];
276277
ret = regmap_field_read(afe->fields[led_field], val);
277278
if (ret)
278279
return ret;
@@ -295,19 +296,20 @@ static int afe4404_write_raw(struct iio_dev *indio_dev,
295296
int val, int val2, long mask)
296297
{
297298
struct afe4404_data *afe = iio_priv(indio_dev);
298-
unsigned int led_field = afe4404_channel_leds[chan->address];
299-
unsigned int offdac_field = afe4404_channel_offdacs[chan->address];
299+
unsigned int led_field, offdac_field;
300300

301301
switch (chan->type) {
302302
case IIO_INTENSITY:
303303
switch (mask) {
304304
case IIO_CHAN_INFO_OFFSET:
305+
offdac_field = afe4404_channel_offdacs[chan->address];
305306
return regmap_field_write(afe->fields[offdac_field], val);
306307
}
307308
break;
308309
case IIO_CURRENT:
309310
switch (mask) {
310311
case IIO_CHAN_INFO_RAW:
312+
led_field = afe4404_channel_leds[chan->address];
311313
return regmap_field_write(afe->fields[led_field], val);
312314
}
313315
break;

drivers/iio/industrialio-sw-trigger.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ int iio_register_sw_trigger_type(struct iio_sw_trigger_type *t)
5858

5959
t->group = configfs_register_default_group(iio_triggers_group, t->name,
6060
&iio_trigger_type_group_type);
61-
if (IS_ERR(t->group))
61+
if (IS_ERR(t->group)) {
62+
mutex_lock(&iio_trigger_types_lock);
63+
list_del(&t->list);
64+
mutex_unlock(&iio_trigger_types_lock);
6265
ret = PTR_ERR(t->group);
66+
}
6367

6468
return ret;
6569
}

drivers/iio/light/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ config RPR0521
293293
tristate "ROHM RPR0521 ALS and proximity sensor driver"
294294
depends on I2C
295295
select REGMAP_I2C
296+
select IIO_BUFFER
297+
select IIO_TRIGGERED_BUFFER
296298
help
297299
Say Y here if you want to build support for ROHM's RPR0521
298300
ambient light and proximity sensor device.

drivers/iio/light/apds9960.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@
5454
#define APDS9960_REG_CONTROL_PGAIN_MASK_SHIFT 2
5555

5656
#define APDS9960_REG_CONFIG_2 0x90
57-
#define APDS9960_REG_CONFIG_2_GGAIN_MASK 0x60
58-
#define APDS9960_REG_CONFIG_2_GGAIN_MASK_SHIFT 5
59-
6057
#define APDS9960_REG_ID 0x92
6158

6259
#define APDS9960_REG_STATUS 0x93
@@ -77,6 +74,9 @@
7774
#define APDS9960_REG_GCONF_1_GFIFO_THRES_MASK_SHIFT 6
7875

7976
#define APDS9960_REG_GCONF_2 0xa3
77+
#define APDS9960_REG_GCONF_2_GGAIN_MASK 0x60
78+
#define APDS9960_REG_GCONF_2_GGAIN_MASK_SHIFT 5
79+
8080
#define APDS9960_REG_GOFFSET_U 0xa4
8181
#define APDS9960_REG_GOFFSET_D 0xa5
8282
#define APDS9960_REG_GPULSE 0xa6
@@ -396,9 +396,9 @@ static int apds9960_set_pxs_gain(struct apds9960_data *data, int val)
396396
}
397397

398398
ret = regmap_update_bits(data->regmap,
399-
APDS9960_REG_CONFIG_2,
400-
APDS9960_REG_CONFIG_2_GGAIN_MASK,
401-
idx << APDS9960_REG_CONFIG_2_GGAIN_MASK_SHIFT);
399+
APDS9960_REG_GCONF_2,
400+
APDS9960_REG_GCONF_2_GGAIN_MASK,
401+
idx << APDS9960_REG_GCONF_2_GGAIN_MASK_SHIFT);
402402
if (!ret)
403403
data->pxs_gain = idx;
404404
mutex_unlock(&data->lock);

0 commit comments

Comments
 (0)