Skip to content

Commit 4bffd2c

Browse files
committed
Merge tag 'iio-fixes-for-6.3a' 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.3 Usual mixed bag: - core - output buffers Fix return of bytes written when only some succeed. Fix O_NONBLOCK handling to not block. - adi,ad7791 Fix IRQ type. Not confirmed to have any impact but good to correct it anyway - adi,adis16400 Missing CONFIG_CRC32 - capella,cm32181 Unregister 2nd I2C client if one is used. - cio-dac Fix bitdepth for range check on write. - linear,ltc2497 Fix a wrong shift of the LSB introduced when switching to be24 handling. - maxim,max11410 Fix handling of return code in read_poll_timeout() - qcom,spmi-adc Fix an accidental change of channel name to include the reg value from OF. - ti,palmas Fix a null dereference on remove due to wrong function used to get the drvdata. - ti,ads7950 Mark GPIO as can sleep. * tag 'iio-fixes-for-6.3a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: adc: ti-ads7950: Set `can_sleep` flag for GPIO chip iio: adc: palmas_gpadc: fix NULL dereference on rmmod iio: adc: max11410: fix read_poll_timeout() usage iio: dac: cio-dac: Fix max DAC write value check for 12-bit iio: light: cm32181: Unregister second I2C client if present iio: accel: kionix-kx022a: Get the timestamp from the driver's private data in the trigger_handler iio: adc: ad7791: fix IRQ flags iio: buffer: make sure O_NONBLOCK is respected iio: buffer: correctly return bytes written in output buffers iio: light: vcnl4000: Fix WARN_ON on uninitialized lock iio: adis16480: select CONFIG_CRC32 drivers: iio: adc: ltc2497: fix LSB shift iio: adc: qcom-spmi-adc5: Fix the channel name
2 parents 4dd5239 + 363c7dc commit 4bffd2c

File tree

12 files changed

+59
-27
lines changed

12 files changed

+59
-27
lines changed

drivers/iio/accel/kionix-kx022a.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ static irqreturn_t kx022a_trigger_handler(int irq, void *p)
864864
if (ret < 0)
865865
goto err_read;
866866

867-
iio_push_to_buffers_with_timestamp(idev, data->buffer, pf->timestamp);
867+
iio_push_to_buffers_with_timestamp(idev, data->buffer, data->timestamp);
868868
err_read:
869869
iio_trigger_notify_done(idev->trig);
870870

drivers/iio/adc/ad7791.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static const struct ad_sigma_delta_info ad7791_sigma_delta_info = {
253253
.has_registers = true,
254254
.addr_shift = 4,
255255
.read_mask = BIT(3),
256-
.irq_flags = IRQF_TRIGGER_LOW,
256+
.irq_flags = IRQF_TRIGGER_FALLING,
257257
};
258258

259259
static int ad7791_read_raw(struct iio_dev *indio_dev,

drivers/iio/adc/ltc2497.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ struct ltc2497_driverdata {
2828
struct ltc2497core_driverdata common_ddata;
2929
struct i2c_client *client;
3030
u32 recv_size;
31-
u32 sub_lsb;
3231
/*
3332
* DMA (thus cache coherency maintenance) may require the
3433
* transfer buffers to live in their own cache lines.
@@ -65,10 +64,10 @@ static int ltc2497_result_and_measure(struct ltc2497core_driverdata *ddata,
6564
* equivalent to a sign extension.
6665
*/
6766
if (st->recv_size == 3) {
68-
*val = (get_unaligned_be24(st->data.d8) >> st->sub_lsb)
67+
*val = (get_unaligned_be24(st->data.d8) >> 6)
6968
- BIT(ddata->chip_info->resolution + 1);
7069
} else {
71-
*val = (be32_to_cpu(st->data.d32) >> st->sub_lsb)
70+
*val = (be32_to_cpu(st->data.d32) >> 6)
7271
- BIT(ddata->chip_info->resolution + 1);
7372
}
7473

@@ -122,7 +121,6 @@ static int ltc2497_probe(struct i2c_client *client)
122121
st->common_ddata.chip_info = chip_info;
123122

124123
resolution = chip_info->resolution;
125-
st->sub_lsb = 31 - (resolution + 1);
126124
st->recv_size = BITS_TO_BYTES(resolution) + 1;
127125

128126
return ltc2497core_probe(dev, indio_dev);

drivers/iio/adc/max11410.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,17 @@ static int max11410_sample(struct max11410_state *st, int *sample_raw,
414414
if (!ret)
415415
return -ETIMEDOUT;
416416
} else {
417+
int ret2;
418+
417419
/* Wait for status register Conversion Ready flag */
418-
ret = read_poll_timeout(max11410_read_reg, ret,
419-
ret || (val & MAX11410_STATUS_CONV_READY_BIT),
420+
ret = read_poll_timeout(max11410_read_reg, ret2,
421+
ret2 || (val & MAX11410_STATUS_CONV_READY_BIT),
420422
5000, MAX11410_CONVERSION_TIMEOUT_MS * 1000,
421423
true, st, MAX11410_REG_STATUS, &val);
422424
if (ret)
423425
return ret;
426+
if (ret2)
427+
return ret2;
424428
}
425429

426430
/* Read ADC Data */
@@ -851,17 +855,21 @@ static int max11410_init_vref(struct device *dev,
851855

852856
static int max11410_calibrate(struct max11410_state *st, u32 cal_type)
853857
{
854-
int ret, val;
858+
int ret, ret2, val;
855859

856860
ret = max11410_write_reg(st, MAX11410_REG_CAL_START, cal_type);
857861
if (ret)
858862
return ret;
859863

860864
/* Wait for status register Calibration Ready flag */
861-
return read_poll_timeout(max11410_read_reg, ret,
862-
ret || (val & MAX11410_STATUS_CAL_READY_BIT),
863-
50000, MAX11410_CALIB_TIMEOUT_MS * 1000, true,
864-
st, MAX11410_REG_STATUS, &val);
865+
ret = read_poll_timeout(max11410_read_reg, ret2,
866+
ret2 || (val & MAX11410_STATUS_CAL_READY_BIT),
867+
50000, MAX11410_CALIB_TIMEOUT_MS * 1000, true,
868+
st, MAX11410_REG_STATUS, &val);
869+
if (ret)
870+
return ret;
871+
872+
return ret2;
865873
}
866874

867875
static int max11410_self_calibrate(struct max11410_state *st)

drivers/iio/adc/palmas_gpadc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ static int palmas_gpadc_probe(struct platform_device *pdev)
639639

640640
static int palmas_gpadc_remove(struct platform_device *pdev)
641641
{
642-
struct iio_dev *indio_dev = dev_to_iio_dev(&pdev->dev);
642+
struct iio_dev *indio_dev = dev_get_drvdata(&pdev->dev);
643643
struct palmas_gpadc *adc = iio_priv(indio_dev);
644644

645645
if (adc->wakeup1_enable || adc->wakeup2_enable)

drivers/iio/adc/qcom-spmi-adc5.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,12 +628,20 @@ static int adc5_get_fw_channel_data(struct adc5_chip *adc,
628628
struct fwnode_handle *fwnode,
629629
const struct adc5_data *data)
630630
{
631-
const char *name = fwnode_get_name(fwnode), *channel_name;
631+
const char *channel_name;
632+
char *name;
632633
u32 chan, value, varr[2];
633634
u32 sid = 0;
634635
int ret;
635636
struct device *dev = adc->dev;
636637

638+
name = devm_kasprintf(dev, GFP_KERNEL, "%pfwP", fwnode);
639+
if (!name)
640+
return -ENOMEM;
641+
642+
/* Cut the address part */
643+
name[strchrnul(name, '@') - name] = '\0';
644+
637645
ret = fwnode_property_read_u32(fwnode, "reg", &chan);
638646
if (ret) {
639647
dev_err(dev, "invalid channel number %s\n", name);

drivers/iio/adc/ti-ads7950.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ static int ti_ads7950_probe(struct spi_device *spi)
634634
st->chip.label = dev_name(&st->spi->dev);
635635
st->chip.parent = &st->spi->dev;
636636
st->chip.owner = THIS_MODULE;
637+
st->chip.can_sleep = true;
637638
st->chip.base = -1;
638639
st->chip.ngpio = TI_ADS7950_NUM_GPIOS;
639640
st->chip.get_direction = ti_ads7950_get_direction;

drivers/iio/dac/cio-dac.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ static int cio_dac_write_raw(struct iio_dev *indio_dev,
6666
if (mask != IIO_CHAN_INFO_RAW)
6767
return -EINVAL;
6868

69-
/* DAC can only accept up to a 16-bit value */
70-
if ((unsigned int)val > 65535)
69+
/* DAC can only accept up to a 12-bit value */
70+
if ((unsigned int)val > 4095)
7171
return -EINVAL;
7272

7373
priv->chan_out_states[chan->channel] = val;

drivers/iio/imu/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ config ADIS16480
4747
depends on SPI
4848
select IIO_ADIS_LIB
4949
select IIO_ADIS_LIB_BUFFER if IIO_BUFFER
50+
select CRC32
5051
help
5152
Say yes here to build support for Analog Devices ADIS16375, ADIS16480,
5253
ADIS16485, ADIS16488 inertial sensors.

drivers/iio/industrialio-buffer.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,24 +203,27 @@ static ssize_t iio_buffer_write(struct file *filp, const char __user *buf,
203203
break;
204204
}
205205

206+
if (filp->f_flags & O_NONBLOCK) {
207+
if (!written)
208+
ret = -EAGAIN;
209+
break;
210+
}
211+
206212
wait_woken(&wait, TASK_INTERRUPTIBLE,
207213
MAX_SCHEDULE_TIMEOUT);
208214
continue;
209215
}
210216

211217
ret = rb->access->write(rb, n - written, buf + written);
212-
if (ret == 0 && (filp->f_flags & O_NONBLOCK))
213-
ret = -EAGAIN;
218+
if (ret < 0)
219+
break;
214220

215-
if (ret > 0) {
216-
written += ret;
217-
if (written != n && !(filp->f_flags & O_NONBLOCK))
218-
continue;
219-
}
220-
} while (ret == 0);
221+
written += ret;
222+
223+
} while (written != n);
221224
remove_wait_queue(&rb->pollq, &wait);
222225

223-
return ret < 0 ? ret : n;
226+
return ret < 0 ? ret : written;
224227
}
225228

226229
/**

0 commit comments

Comments
 (0)