Skip to content

Commit 47df986

Browse files
committed
Merge tag 'staging-4.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging driver fixes from Greg KH: "Here are some IIO and staging driver fixes for 4.0-rc3. Details are in the shortlog, nothing major, mostly IIO fixes for reported issues. All have been in linux-next successfully" * tag 'staging-4.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (23 commits) staging: comedi: adv_pci1710: fix AI INSN_READ for non-zero channel staging: comedi: vmk80xx: remove "firmware version" kernel messages staging: comedi: comedi_isadma: fix "stalled" detect in comedi_isadma_disable_on_sample() iio: ak8975: fix AK09911 dependencies iio: common: ssp_sensors: Protect PM-only functions to kill warning IIO: si7020: Allocate correct amount of memory in devm_iio_device_alloc Revert "iio:humidity:si7020: fix pointer to i2c client" iio: light: gp2ap020a00f: Select REGMAP_I2C iio: light: jsa1212: Select REGMAP_I2C iio: ad5686: fix optional reference voltage declaration iio:adc:mcp3422 Fix incorrect scales table iio: mxs-lradc: fix iio channel map regression iio: imu: adis16400: Fix sign extension staging: iio: ad2s1200: Fix sign extension iio: mxs-lradc: only update the buffer when its conversions have finished iio: mxs-lradc: make ADC reads not unschedule touchscreen conversions iio: mxs-lradc: make ADC reads not disable touchscreen interrupts iio: mxs-lradc: separate touchscreen and buffer virtual channels iio: imu: inv_mpu6050: Prevent dereferencing NULL iio: iadc: wait_for_completion_timeout time in jiffies ...
2 parents 29191c7 + abe46b8 commit 47df986

File tree

15 files changed

+175
-226
lines changed

15 files changed

+175
-226
lines changed

drivers/iio/adc/mcp3422.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,11 @@
5858
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
5959
}
6060

61-
/* LSB is in nV to eliminate floating point */
62-
static const u32 rates_to_lsb[] = {1000000, 250000, 62500, 15625};
63-
64-
/*
65-
* scales calculated as:
66-
* rates_to_lsb[sample_rate] / (1 << pga);
67-
* pga is 1 for 0, 2
68-
*/
69-
7061
static const int mcp3422_scales[4][4] = {
71-
{ 1000000, 250000, 62500, 15625 },
72-
{ 500000 , 125000, 31250, 7812 },
73-
{ 250000 , 62500 , 15625, 3906 },
74-
{ 125000 , 31250 , 7812 , 1953 } };
62+
{ 1000000, 500000, 250000, 125000 },
63+
{ 250000 , 125000, 62500 , 31250 },
64+
{ 62500 , 31250 , 15625 , 7812 },
65+
{ 15625 , 7812 , 3906 , 1953 } };
7566

7667
/* Constant msleep times for data acquisitions */
7768
static const int mcp3422_read_times[4] = {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ static int iadc_do_conversion(struct iadc_chip *iadc, int chan, u16 *data)
296296
if (iadc->poll_eoc) {
297297
ret = iadc_poll_wait_eoc(iadc, wait);
298298
} else {
299-
ret = wait_for_completion_timeout(&iadc->complete, wait);
299+
ret = wait_for_completion_timeout(&iadc->complete,
300+
usecs_to_jiffies(wait));
300301
if (!ret)
301302
ret = -ETIMEDOUT;
302303
else

drivers/iio/common/ssp_sensors/ssp_dev.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ static int ssp_remove(struct spi_device *spi)
640640
return 0;
641641
}
642642

643+
#ifdef CONFIG_PM_SLEEP
643644
static int ssp_suspend(struct device *dev)
644645
{
645646
int ret;
@@ -688,6 +689,7 @@ static int ssp_resume(struct device *dev)
688689

689690
return 0;
690691
}
692+
#endif /* CONFIG_PM_SLEEP */
691693

692694
static const struct dev_pm_ops ssp_pm_ops = {
693695
SET_SYSTEM_SLEEP_PM_OPS(ssp_suspend, ssp_resume)

drivers/iio/dac/ad5686.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static int ad5686_probe(struct spi_device *spi)
322322
st = iio_priv(indio_dev);
323323
spi_set_drvdata(spi, indio_dev);
324324

325-
st->reg = devm_regulator_get(&spi->dev, "vcc");
325+
st->reg = devm_regulator_get_optional(&spi->dev, "vcc");
326326
if (!IS_ERR(st->reg)) {
327327
ret = regulator_enable(st->reg);
328328
if (ret)

drivers/iio/humidity/dht11.c

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/wait.h>
3030
#include <linux/bitops.h>
3131
#include <linux/completion.h>
32+
#include <linux/mutex.h>
3233
#include <linux/delay.h>
3334
#include <linux/gpio.h>
3435
#include <linux/of_gpio.h>
@@ -39,8 +40,12 @@
3940

4041
#define DHT11_DATA_VALID_TIME 2000000000 /* 2s in ns */
4142

42-
#define DHT11_EDGES_PREAMBLE 4
43+
#define DHT11_EDGES_PREAMBLE 2
4344
#define DHT11_BITS_PER_READ 40
45+
/*
46+
* Note that when reading the sensor actually 84 edges are detected, but
47+
* since the last edge is not significant, we only store 83:
48+
*/
4449
#define DHT11_EDGES_PER_READ (2*DHT11_BITS_PER_READ + DHT11_EDGES_PREAMBLE + 1)
4550

4651
/* Data transmission timing (nano seconds) */
@@ -57,6 +62,7 @@ struct dht11 {
5762
int irq;
5863

5964
struct completion completion;
65+
struct mutex lock;
6066

6167
s64 timestamp;
6268
int temperature;
@@ -88,7 +94,7 @@ static int dht11_decode(struct dht11 *dht11, int offset)
8894
unsigned char temp_int, temp_dec, hum_int, hum_dec, checksum;
8995

9096
/* Calculate timestamp resolution */
91-
for (i = 0; i < dht11->num_edges; ++i) {
97+
for (i = 1; i < dht11->num_edges; ++i) {
9298
t = dht11->edges[i].ts - dht11->edges[i-1].ts;
9399
if (t > 0 && t < timeres)
94100
timeres = t;
@@ -138,13 +144,35 @@ static int dht11_decode(struct dht11 *dht11, int offset)
138144
return 0;
139145
}
140146

147+
/*
148+
* IRQ handler called on GPIO edges
149+
*/
150+
static irqreturn_t dht11_handle_irq(int irq, void *data)
151+
{
152+
struct iio_dev *iio = data;
153+
struct dht11 *dht11 = iio_priv(iio);
154+
155+
/* TODO: Consider making the handler safe for IRQ sharing */
156+
if (dht11->num_edges < DHT11_EDGES_PER_READ && dht11->num_edges >= 0) {
157+
dht11->edges[dht11->num_edges].ts = iio_get_time_ns();
158+
dht11->edges[dht11->num_edges++].value =
159+
gpio_get_value(dht11->gpio);
160+
161+
if (dht11->num_edges >= DHT11_EDGES_PER_READ)
162+
complete(&dht11->completion);
163+
}
164+
165+
return IRQ_HANDLED;
166+
}
167+
141168
static int dht11_read_raw(struct iio_dev *iio_dev,
142169
const struct iio_chan_spec *chan,
143170
int *val, int *val2, long m)
144171
{
145172
struct dht11 *dht11 = iio_priv(iio_dev);
146173
int ret;
147174

175+
mutex_lock(&dht11->lock);
148176
if (dht11->timestamp + DHT11_DATA_VALID_TIME < iio_get_time_ns()) {
149177
reinit_completion(&dht11->completion);
150178

@@ -157,8 +185,17 @@ static int dht11_read_raw(struct iio_dev *iio_dev,
157185
if (ret)
158186
goto err;
159187

188+
ret = request_irq(dht11->irq, dht11_handle_irq,
189+
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
190+
iio_dev->name, iio_dev);
191+
if (ret)
192+
goto err;
193+
160194
ret = wait_for_completion_killable_timeout(&dht11->completion,
161195
HZ);
196+
197+
free_irq(dht11->irq, iio_dev);
198+
162199
if (ret == 0 && dht11->num_edges < DHT11_EDGES_PER_READ - 1) {
163200
dev_err(&iio_dev->dev,
164201
"Only %d signal edges detected\n",
@@ -185,6 +222,7 @@ static int dht11_read_raw(struct iio_dev *iio_dev,
185222
ret = -EINVAL;
186223
err:
187224
dht11->num_edges = -1;
225+
mutex_unlock(&dht11->lock);
188226
return ret;
189227
}
190228

@@ -193,27 +231,6 @@ static const struct iio_info dht11_iio_info = {
193231
.read_raw = dht11_read_raw,
194232
};
195233

196-
/*
197-
* IRQ handler called on GPIO edges
198-
*/
199-
static irqreturn_t dht11_handle_irq(int irq, void *data)
200-
{
201-
struct iio_dev *iio = data;
202-
struct dht11 *dht11 = iio_priv(iio);
203-
204-
/* TODO: Consider making the handler safe for IRQ sharing */
205-
if (dht11->num_edges < DHT11_EDGES_PER_READ && dht11->num_edges >= 0) {
206-
dht11->edges[dht11->num_edges].ts = iio_get_time_ns();
207-
dht11->edges[dht11->num_edges++].value =
208-
gpio_get_value(dht11->gpio);
209-
210-
if (dht11->num_edges >= DHT11_EDGES_PER_READ)
211-
complete(&dht11->completion);
212-
}
213-
214-
return IRQ_HANDLED;
215-
}
216-
217234
static const struct iio_chan_spec dht11_chan_spec[] = {
218235
{ .type = IIO_TEMP,
219236
.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), },
@@ -256,18 +273,14 @@ static int dht11_probe(struct platform_device *pdev)
256273
dev_err(dev, "GPIO %d has no interrupt\n", dht11->gpio);
257274
return -EINVAL;
258275
}
259-
ret = devm_request_irq(dev, dht11->irq, dht11_handle_irq,
260-
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
261-
pdev->name, iio);
262-
if (ret)
263-
return ret;
264276

265277
dht11->timestamp = iio_get_time_ns() - DHT11_DATA_VALID_TIME - 1;
266278
dht11->num_edges = -1;
267279

268280
platform_set_drvdata(pdev, iio);
269281

270282
init_completion(&dht11->completion);
283+
mutex_init(&dht11->lock);
271284
iio->name = pdev->name;
272285
iio->dev.parent = &pdev->dev;
273286
iio->info = &dht11_iio_info;

drivers/iio/humidity/si7020.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ static int si7020_read_raw(struct iio_dev *indio_dev,
4545
struct iio_chan_spec const *chan, int *val,
4646
int *val2, long mask)
4747
{
48-
struct i2c_client *client = iio_priv(indio_dev);
48+
struct i2c_client **client = iio_priv(indio_dev);
4949
int ret;
5050

5151
switch (mask) {
5252
case IIO_CHAN_INFO_RAW:
53-
ret = i2c_smbus_read_word_data(client,
53+
ret = i2c_smbus_read_word_data(*client,
5454
chan->type == IIO_TEMP ?
5555
SI7020CMD_TEMP_HOLD :
5656
SI7020CMD_RH_HOLD);
@@ -126,7 +126,7 @@ static int si7020_probe(struct i2c_client *client,
126126
/* Wait the maximum power-up time after software reset. */
127127
msleep(15);
128128

129-
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*client));
129+
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
130130
if (!indio_dev)
131131
return -ENOMEM;
132132

drivers/iio/imu/adis16400_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/list.h>
2727
#include <linux/module.h>
2828
#include <linux/debugfs.h>
29+
#include <linux/bitops.h>
2930

3031
#include <linux/iio/iio.h>
3132
#include <linux/iio/sysfs.h>
@@ -414,7 +415,7 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
414415
mutex_unlock(&indio_dev->mlock);
415416
if (ret)
416417
return ret;
417-
val16 = ((val16 & 0xFFF) << 4) >> 4;
418+
val16 = sign_extend32(val16, 11);
418419
*val = val16;
419420
return IIO_VAL_INT;
420421
case IIO_CHAN_INFO_OFFSET:

drivers/iio/imu/inv_mpu6050/inv_mpu_core.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,11 @@ static int inv_mpu_probe(struct i2c_client *client,
780780

781781
i2c_set_clientdata(client, indio_dev);
782782
indio_dev->dev.parent = &client->dev;
783-
indio_dev->name = id->name;
783+
/* id will be NULL when enumerated via ACPI */
784+
if (id)
785+
indio_dev->name = (char *)id->name;
786+
else
787+
indio_dev->name = (char *)dev_name(&client->dev);
784788
indio_dev->channels = inv_mpu_channels;
785789
indio_dev->num_channels = ARRAY_SIZE(inv_mpu_channels);
786790

drivers/iio/light/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ config CM36651
7373
config GP2AP020A00F
7474
tristate "Sharp GP2AP020A00F Proximity/ALS sensor"
7575
depends on I2C
76+
select REGMAP_I2C
7677
select IIO_BUFFER
7778
select IIO_TRIGGERED_BUFFER
7879
select IRQ_WORK
@@ -126,6 +127,7 @@ config HID_SENSOR_PROX
126127
config JSA1212
127128
tristate "JSA1212 ALS and proximity sensor driver"
128129
depends on I2C
130+
select REGMAP_I2C
129131
help
130132
Say Y here if you want to build a IIO driver for JSA1212
131133
proximity & ALS sensor device.

drivers/iio/magnetometer/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ config AK8975
1818

1919
config AK09911
2020
tristate "Asahi Kasei AK09911 3-axis Compass"
21+
depends on I2C
22+
depends on GPIOLIB
2123
select AK8975
2224
help
2325
Deprecated: AK09911 is now supported by AK8975 driver.

drivers/staging/comedi/drivers/adv_pci1710.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ static int pci171x_ai_insn_read(struct comedi_device *dev,
426426
unsigned int *data)
427427
{
428428
struct pci1710_private *devpriv = dev->private;
429-
unsigned int chan = CR_CHAN(insn->chanspec);
430429
int ret = 0;
431430
int i;
432431

@@ -447,7 +446,7 @@ static int pci171x_ai_insn_read(struct comedi_device *dev,
447446
if (ret)
448447
break;
449448

450-
ret = pci171x_ai_read_sample(dev, s, chan, &val);
449+
ret = pci171x_ai_read_sample(dev, s, 0, &val);
451450
if (ret)
452451
break;
453452

drivers/staging/comedi/drivers/comedi_isadma.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ unsigned int comedi_isadma_disable_on_sample(unsigned int dma_chan,
9191
stalled++;
9292
if (stalled > 10)
9393
break;
94+
} else {
95+
residue = new_residue;
96+
stalled = 0;
9497
}
95-
residue = new_residue;
96-
stalled = 0;
9798
}
9899
return residue;
99100
}

0 commit comments

Comments
 (0)