Skip to content

Commit 494b99f

Browse files
committed
Merge tag 'staging-5.13-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging and IIO driver fixes from Greg KH: "Here are some small IIO and staging driver fixes for reported issues for 5.13-rc4. Nothing major here, tiny changes for reported problems, full details are in the shortlog if people are curious. All have been in linux-next for a while with no reported problems" * tag 'staging-5.13-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: iio: adc: ad7793: Add missing error code in ad7793_setup() iio: adc: ad7923: Fix undersized rx buffer. iio: adc: ad7768-1: Fix too small buffer passed to iio_push_to_buffers_with_timestamp() iio: dac: ad5770r: Put fwnode in error case during ->probe() iio: gyro: fxas21002c: balance runtime power in error path staging: emxx_udc: fix loop in _nbu2ss_nuke() staging: iio: cdc: ad7746: avoid overwrite of num_channels iio: adc: ad7192: handle regulator voltage error first iio: adc: ad7192: Avoid disabling a clock that was never enabled. iio: adc: ad7124: Fix potential overflow due to non sequential channel numbers iio: adc: ad7124: Fix missbalanced regulator enable / disable on error.
2 parents 3837f9a + 54732a5 commit 494b99f

File tree

9 files changed

+55
-36
lines changed

9 files changed

+55
-36
lines changed

drivers/iio/adc/ad7124.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,13 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
771771
if (ret)
772772
goto err;
773773

774+
if (channel >= indio_dev->num_channels) {
775+
dev_err(indio_dev->dev.parent,
776+
"Channel index >= number of channels\n");
777+
ret = -EINVAL;
778+
goto err;
779+
}
780+
774781
ret = of_property_read_u32_array(child, "diff-channels",
775782
ain, 2);
776783
if (ret)
@@ -850,6 +857,11 @@ static int ad7124_setup(struct ad7124_state *st)
850857
return ret;
851858
}
852859

860+
static void ad7124_reg_disable(void *r)
861+
{
862+
regulator_disable(r);
863+
}
864+
853865
static int ad7124_probe(struct spi_device *spi)
854866
{
855867
const struct ad7124_chip_info *info;
@@ -895,17 +907,20 @@ static int ad7124_probe(struct spi_device *spi)
895907
ret = regulator_enable(st->vref[i]);
896908
if (ret)
897909
return ret;
910+
911+
ret = devm_add_action_or_reset(&spi->dev, ad7124_reg_disable,
912+
st->vref[i]);
913+
if (ret)
914+
return ret;
898915
}
899916

900917
st->mclk = devm_clk_get(&spi->dev, "mclk");
901-
if (IS_ERR(st->mclk)) {
902-
ret = PTR_ERR(st->mclk);
903-
goto error_regulator_disable;
904-
}
918+
if (IS_ERR(st->mclk))
919+
return PTR_ERR(st->mclk);
905920

906921
ret = clk_prepare_enable(st->mclk);
907922
if (ret < 0)
908-
goto error_regulator_disable;
923+
return ret;
909924

910925
ret = ad7124_soft_reset(st);
911926
if (ret < 0)
@@ -935,11 +950,6 @@ static int ad7124_probe(struct spi_device *spi)
935950
ad_sd_cleanup_buffer_and_trigger(indio_dev);
936951
error_clk_disable_unprepare:
937952
clk_disable_unprepare(st->mclk);
938-
error_regulator_disable:
939-
for (i = ARRAY_SIZE(st->vref) - 1; i >= 0; i--) {
940-
if (!IS_ERR_OR_NULL(st->vref[i]))
941-
regulator_disable(st->vref[i]);
942-
}
943953

944954
return ret;
945955
}
@@ -948,17 +958,11 @@ static int ad7124_remove(struct spi_device *spi)
948958
{
949959
struct iio_dev *indio_dev = spi_get_drvdata(spi);
950960
struct ad7124_state *st = iio_priv(indio_dev);
951-
int i;
952961

953962
iio_device_unregister(indio_dev);
954963
ad_sd_cleanup_buffer_and_trigger(indio_dev);
955964
clk_disable_unprepare(st->mclk);
956965

957-
for (i = ARRAY_SIZE(st->vref) - 1; i >= 0; i--) {
958-
if (!IS_ERR_OR_NULL(st->vref[i]))
959-
regulator_disable(st->vref[i]);
960-
}
961-
962966
return 0;
963967
}
964968

drivers/iio/adc/ad7192.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ static int ad7192_probe(struct spi_device *spi)
912912
{
913913
struct ad7192_state *st;
914914
struct iio_dev *indio_dev;
915-
int ret, voltage_uv = 0;
915+
int ret;
916916

917917
if (!spi->irq) {
918918
dev_err(&spi->dev, "no IRQ?\n");
@@ -949,15 +949,12 @@ static int ad7192_probe(struct spi_device *spi)
949949
goto error_disable_avdd;
950950
}
951951

952-
voltage_uv = regulator_get_voltage(st->avdd);
953-
954-
if (voltage_uv > 0) {
955-
st->int_vref_mv = voltage_uv / 1000;
956-
} else {
957-
ret = voltage_uv;
952+
ret = regulator_get_voltage(st->avdd);
953+
if (ret < 0) {
958954
dev_err(&spi->dev, "Device tree error, reference voltage undefined\n");
959955
goto error_disable_avdd;
960956
}
957+
st->int_vref_mv = ret / 1000;
961958

962959
spi_set_drvdata(spi, indio_dev);
963960
st->chip_info = of_device_get_match_data(&spi->dev);
@@ -1014,7 +1011,9 @@ static int ad7192_probe(struct spi_device *spi)
10141011
return 0;
10151012

10161013
error_disable_clk:
1017-
clk_disable_unprepare(st->mclk);
1014+
if (st->clock_sel == AD7192_CLK_EXT_MCLK1_2 ||
1015+
st->clock_sel == AD7192_CLK_EXT_MCLK2)
1016+
clk_disable_unprepare(st->mclk);
10181017
error_remove_trigger:
10191018
ad_sd_cleanup_buffer_and_trigger(indio_dev);
10201019
error_disable_dvdd:
@@ -1031,7 +1030,9 @@ static int ad7192_remove(struct spi_device *spi)
10311030
struct ad7192_state *st = iio_priv(indio_dev);
10321031

10331032
iio_device_unregister(indio_dev);
1034-
clk_disable_unprepare(st->mclk);
1033+
if (st->clock_sel == AD7192_CLK_EXT_MCLK1_2 ||
1034+
st->clock_sel == AD7192_CLK_EXT_MCLK2)
1035+
clk_disable_unprepare(st->mclk);
10351036
ad_sd_cleanup_buffer_and_trigger(indio_dev);
10361037

10371038
regulator_disable(st->dvdd);

drivers/iio/adc/ad7768-1.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ struct ad7768_state {
167167
* transfer buffers to live in their own cache lines.
168168
*/
169169
union {
170+
struct {
171+
__be32 chan;
172+
s64 timestamp;
173+
} scan;
170174
__be32 d32;
171175
u8 d8[2];
172176
} data ____cacheline_aligned;
@@ -469,11 +473,11 @@ static irqreturn_t ad7768_trigger_handler(int irq, void *p)
469473

470474
mutex_lock(&st->lock);
471475

472-
ret = spi_read(st->spi, &st->data.d32, 3);
476+
ret = spi_read(st->spi, &st->data.scan.chan, 3);
473477
if (ret < 0)
474478
goto err_unlock;
475479

476-
iio_push_to_buffers_with_timestamp(indio_dev, &st->data.d32,
480+
iio_push_to_buffers_with_timestamp(indio_dev, &st->data.scan,
477481
iio_get_time_ns(indio_dev));
478482

479483
iio_trigger_notify_done(indio_dev->trig);

drivers/iio/adc/ad7793.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ static int ad7793_setup(struct iio_dev *indio_dev,
279279
id &= AD7793_ID_MASK;
280280

281281
if (id != st->chip_info->id) {
282+
ret = -ENODEV;
282283
dev_err(&st->sd.spi->dev, "device ID query failed\n");
283284
goto out;
284285
}

drivers/iio/adc/ad7923.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ struct ad7923_state {
5959
/*
6060
* DMA (thus cache coherency maintenance) requires the
6161
* transfer buffers to live in their own cache lines.
62+
* Ensure rx_buf can be directly used in iio_push_to_buffers_with_timetamp
63+
* Length = 8 channels + 4 extra for 8 byte timestamp
6264
*/
63-
__be16 rx_buf[4] ____cacheline_aligned;
65+
__be16 rx_buf[12] ____cacheline_aligned;
6466
__be16 tx_buf[4];
6567
};
6668

drivers/iio/dac/ad5770r.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,23 +524,29 @@ static int ad5770r_channel_config(struct ad5770r_state *st)
524524
device_for_each_child_node(&st->spi->dev, child) {
525525
ret = fwnode_property_read_u32(child, "num", &num);
526526
if (ret)
527-
return ret;
528-
if (num >= AD5770R_MAX_CHANNELS)
529-
return -EINVAL;
527+
goto err_child_out;
528+
if (num >= AD5770R_MAX_CHANNELS) {
529+
ret = -EINVAL;
530+
goto err_child_out;
531+
}
530532

531533
ret = fwnode_property_read_u32_array(child,
532534
"adi,range-microamp",
533535
tmp, 2);
534536
if (ret)
535-
return ret;
537+
goto err_child_out;
536538

537539
min = tmp[0] / 1000;
538540
max = tmp[1] / 1000;
539541
ret = ad5770r_store_output_range(st, min, max, num);
540542
if (ret)
541-
return ret;
543+
goto err_child_out;
542544
}
543545

546+
return 0;
547+
548+
err_child_out:
549+
fwnode_handle_put(child);
544550
return ret;
545551
}
546552

drivers/iio/gyro/fxas21002c_core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ static int fxas21002c_temp_get(struct fxas21002c_data *data, int *val)
399399
ret = regmap_field_read(data->regmap_fields[F_TEMP], &temp);
400400
if (ret < 0) {
401401
dev_err(dev, "failed to read temp: %d\n", ret);
402+
fxas21002c_pm_put(data);
402403
goto data_unlock;
403404
}
404405

@@ -432,6 +433,7 @@ static int fxas21002c_axis_get(struct fxas21002c_data *data,
432433
&axis_be, sizeof(axis_be));
433434
if (ret < 0) {
434435
dev_err(dev, "failed to read axis: %d: %d\n", index, ret);
436+
fxas21002c_pm_put(data);
435437
goto data_unlock;
436438
}
437439

drivers/staging/emxx_udc/emxx_udc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,7 @@ static int _nbu2ss_nuke(struct nbu2ss_udc *udc,
20642064
struct nbu2ss_ep *ep,
20652065
int status)
20662066
{
2067-
struct nbu2ss_req *req;
2067+
struct nbu2ss_req *req, *n;
20682068

20692069
/* Endpoint Disable */
20702070
_nbu2ss_epn_exit(udc, ep);
@@ -2076,7 +2076,7 @@ static int _nbu2ss_nuke(struct nbu2ss_udc *udc,
20762076
return 0;
20772077

20782078
/* called with irqs blocked */
2079-
list_for_each_entry(req, &ep->queue, queue) {
2079+
list_for_each_entry_safe(req, n, &ep->queue, queue) {
20802080
_nbu2ss_ep_done(ep, req, status);
20812081
}
20822082

drivers/staging/iio/cdc/ad7746.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,6 @@ static int ad7746_probe(struct i2c_client *client,
700700
indio_dev->num_channels = ARRAY_SIZE(ad7746_channels);
701701
else
702702
indio_dev->num_channels = ARRAY_SIZE(ad7746_channels) - 2;
703-
indio_dev->num_channels = ARRAY_SIZE(ad7746_channels);
704703
indio_dev->modes = INDIO_DIRECT_MODE;
705704

706705
if (pdata) {

0 commit comments

Comments
 (0)