Skip to content

Commit a50094a

Browse files
committed
Merge tag 'staging-4.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull IIO and staging fixes from Greg KH: "Here are a number of IIO and staging bugfixes for 4.7-rc4. Nothing huge, the normal amount of iio driver fixes, and some small staging driver bugfixes for some reported problems (2 are reverts of patches that went into 4.7-rc1). All have been in linux-next with no reported issues" * tag 'staging-4.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (24 commits) Revert "Staging: rtl8188eu: rtw_efuse: Use sizeof type *pointer instead of sizeof type." Revert "Staging: drivers: rtl8188eu: use sizeof(*ptr) instead of sizeof(struct)" staging: lustre: lnet: Don't access NULL NI on failure path iio: hudmidity: hdc100x: fix incorrect shifting and scaling iio: light apds9960: Add the missing dev.parent iio: Fix error handling in iio_trigger_attach_poll_func iio: st_sensors: Disable DRDY at init time iio: st_sensors: Init trigger before irq request iio: st_sensors: switch to a threaded interrupt iio: light: bh1780: assign a static name iio: bh1780: dereference the client properly iio: humidity: hdc100x: fix IIO_TEMP channel reporting iio:st_pressure: fix sampling gains (bring inline with ABI) iio: proximity: as3935: fix buffer stack trashing iio: proximity: as3935: remove triggered buffer processing iio: proximity: as3935: correct IIO_CHAN_INFO_RAW output max44000: Remove scale from proximity iio: humidity: am2315: Remove a stray unlock iio: humidity: hdc100x: correct humidity integration time mask iio: pressure: bmp280: fix error message for wrong chip id ...
2 parents 607117a + bc8201e commit a50094a

File tree

26 files changed

+237
-105
lines changed

26 files changed

+237
-105
lines changed

Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
What /sys/bus/iio/devices/iio:deviceX/in_proximity_raw
1+
What /sys/bus/iio/devices/iio:deviceX/in_proximity_input
22
Date: March 2014
33
KernelVersion: 3.15
44
Contact: Matt Ranostay <[email protected]>

drivers/iio/accel/st_accel_buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static const struct iio_buffer_setup_ops st_accel_buffer_setup_ops = {
9191

9292
int st_accel_allocate_ring(struct iio_dev *indio_dev)
9393
{
94-
return iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
94+
return iio_triggered_buffer_setup(indio_dev, NULL,
9595
&st_sensors_trigger_handler, &st_accel_buffer_setup_ops);
9696
}
9797

drivers/iio/accel/st_accel_core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,7 @@ static const struct iio_info accel_info = {
741741
static const struct iio_trigger_ops st_accel_trigger_ops = {
742742
.owner = THIS_MODULE,
743743
.set_trigger_state = ST_ACCEL_TRIGGER_SET_STATE,
744+
.validate_device = st_sensors_validate_device,
744745
};
745746
#define ST_ACCEL_TRIGGER_OPS (&st_accel_trigger_ops)
746747
#else

drivers/iio/common/st_sensors/st_sensors_buffer.c

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,31 +57,20 @@ irqreturn_t st_sensors_trigger_handler(int irq, void *p)
5757
struct iio_poll_func *pf = p;
5858
struct iio_dev *indio_dev = pf->indio_dev;
5959
struct st_sensor_data *sdata = iio_priv(indio_dev);
60+
s64 timestamp;
6061

61-
/* If we have a status register, check if this IRQ came from us */
62-
if (sdata->sensor_settings->drdy_irq.addr_stat_drdy) {
63-
u8 status;
64-
65-
len = sdata->tf->read_byte(&sdata->tb, sdata->dev,
66-
sdata->sensor_settings->drdy_irq.addr_stat_drdy,
67-
&status);
68-
if (len < 0)
69-
dev_err(sdata->dev, "could not read channel status\n");
70-
71-
/*
72-
* If this was not caused by any channels on this sensor,
73-
* return IRQ_NONE
74-
*/
75-
if (!(status & (u8)indio_dev->active_scan_mask[0]))
76-
return IRQ_NONE;
77-
}
62+
/* If we do timetamping here, do it before reading the values */
63+
if (sdata->hw_irq_trigger)
64+
timestamp = sdata->hw_timestamp;
65+
else
66+
timestamp = iio_get_time_ns();
7867

7968
len = st_sensors_get_buffer_element(indio_dev, sdata->buffer_data);
8069
if (len < 0)
8170
goto st_sensors_get_buffer_element_error;
8271

8372
iio_push_to_buffers_with_timestamp(indio_dev, sdata->buffer_data,
84-
pf->timestamp);
73+
timestamp);
8574

8675
st_sensors_get_buffer_element_error:
8776
iio_trigger_notify_done(indio_dev->trig);

drivers/iio/common/st_sensors/st_sensors_core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,11 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
363363
if (err < 0)
364364
return err;
365365

366+
/* Disable DRDY, this might be still be enabled after reboot. */
367+
err = st_sensors_set_dataready_irq(indio_dev, false);
368+
if (err < 0)
369+
return err;
370+
366371
if (sdata->current_fullscale) {
367372
err = st_sensors_set_fullscale(indio_dev,
368373
sdata->current_fullscale->num);
@@ -424,6 +429,9 @@ int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable)
424429
else
425430
drdy_mask = sdata->sensor_settings->drdy_irq.mask_int2;
426431

432+
/* Flag to the poll function that the hardware trigger is in use */
433+
sdata->hw_irq_trigger = enable;
434+
427435
/* Enable/Disable the interrupt generator for data ready. */
428436
err = st_sensors_write_data_with_mask(indio_dev,
429437
sdata->sensor_settings->drdy_irq.addr,

drivers/iio/common/st_sensors/st_sensors_trigger.c

Lines changed: 89 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,73 @@
1717
#include <linux/iio/common/st_sensors.h>
1818
#include "st_sensors_core.h"
1919

20+
/**
21+
* st_sensors_irq_handler() - top half of the IRQ-based triggers
22+
* @irq: irq number
23+
* @p: private handler data
24+
*/
25+
irqreturn_t st_sensors_irq_handler(int irq, void *p)
26+
{
27+
struct iio_trigger *trig = p;
28+
struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
29+
struct st_sensor_data *sdata = iio_priv(indio_dev);
30+
31+
/* Get the time stamp as close in time as possible */
32+
sdata->hw_timestamp = iio_get_time_ns();
33+
return IRQ_WAKE_THREAD;
34+
}
35+
36+
/**
37+
* st_sensors_irq_thread() - bottom half of the IRQ-based triggers
38+
* @irq: irq number
39+
* @p: private handler data
40+
*/
41+
irqreturn_t st_sensors_irq_thread(int irq, void *p)
42+
{
43+
struct iio_trigger *trig = p;
44+
struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
45+
struct st_sensor_data *sdata = iio_priv(indio_dev);
46+
int ret;
47+
48+
/*
49+
* If this trigger is backed by a hardware interrupt and we have a
50+
* status register, check if this IRQ came from us
51+
*/
52+
if (sdata->sensor_settings->drdy_irq.addr_stat_drdy) {
53+
u8 status;
54+
55+
ret = sdata->tf->read_byte(&sdata->tb, sdata->dev,
56+
sdata->sensor_settings->drdy_irq.addr_stat_drdy,
57+
&status);
58+
if (ret < 0) {
59+
dev_err(sdata->dev, "could not read channel status\n");
60+
goto out_poll;
61+
}
62+
/*
63+
* the lower bits of .active_scan_mask[0] is directly mapped
64+
* to the channels on the sensor: either bit 0 for
65+
* one-dimensional sensors, or e.g. x,y,z for accelerometers,
66+
* gyroscopes or magnetometers. No sensor use more than 3
67+
* channels, so cut the other status bits here.
68+
*/
69+
status &= 0x07;
70+
71+
/*
72+
* If this was not caused by any channels on this sensor,
73+
* return IRQ_NONE
74+
*/
75+
if (!indio_dev->active_scan_mask)
76+
return IRQ_NONE;
77+
if (!(status & (u8)indio_dev->active_scan_mask[0]))
78+
return IRQ_NONE;
79+
}
80+
81+
out_poll:
82+
/* It's our IRQ: proceed to handle the register polling */
83+
iio_trigger_poll_chained(p);
84+
return IRQ_HANDLED;
85+
}
86+
2087
int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
2188
const struct iio_trigger_ops *trigger_ops)
2289
{
@@ -30,6 +97,10 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
3097
return -ENOMEM;
3198
}
3299

100+
iio_trigger_set_drvdata(sdata->trig, indio_dev);
101+
sdata->trig->ops = trigger_ops;
102+
sdata->trig->dev.parent = sdata->dev;
103+
33104
irq = sdata->get_irq_data_ready(indio_dev);
34105
irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq));
35106
/*
@@ -77,9 +148,12 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
77148
sdata->sensor_settings->drdy_irq.addr_stat_drdy)
78149
irq_trig |= IRQF_SHARED;
79150

80-
err = request_threaded_irq(irq,
81-
iio_trigger_generic_data_rdy_poll,
82-
NULL,
151+
/* Let's create an interrupt thread masking the hard IRQ here */
152+
irq_trig |= IRQF_ONESHOT;
153+
154+
err = request_threaded_irq(sdata->get_irq_data_ready(indio_dev),
155+
st_sensors_irq_handler,
156+
st_sensors_irq_thread,
83157
irq_trig,
84158
sdata->trig->name,
85159
sdata->trig);
@@ -88,10 +162,6 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
88162
goto iio_trigger_free;
89163
}
90164

91-
iio_trigger_set_drvdata(sdata->trig, indio_dev);
92-
sdata->trig->ops = trigger_ops;
93-
sdata->trig->dev.parent = sdata->dev;
94-
95165
err = iio_trigger_register(sdata->trig);
96166
if (err < 0) {
97167
dev_err(&indio_dev->dev, "failed to register iio trigger.\n");
@@ -119,6 +189,18 @@ void st_sensors_deallocate_trigger(struct iio_dev *indio_dev)
119189
}
120190
EXPORT_SYMBOL(st_sensors_deallocate_trigger);
121191

192+
int st_sensors_validate_device(struct iio_trigger *trig,
193+
struct iio_dev *indio_dev)
194+
{
195+
struct iio_dev *indio = iio_trigger_get_drvdata(trig);
196+
197+
if (indio != indio_dev)
198+
return -EINVAL;
199+
200+
return 0;
201+
}
202+
EXPORT_SYMBOL(st_sensors_validate_device);
203+
122204
MODULE_AUTHOR("Denis Ciocca <[email protected]>");
123205
MODULE_DESCRIPTION("STMicroelectronics ST-sensors trigger");
124206
MODULE_LICENSE("GPL v2");

drivers/iio/dac/ad5592r-base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ static int ad5592r_alloc_channels(struct ad5592r_state *st)
525525

526526
device_for_each_child_node(st->dev, child) {
527527
ret = fwnode_property_read_u32(child, "reg", &reg);
528-
if (ret || reg > ARRAY_SIZE(st->channel_modes))
528+
if (ret || reg >= ARRAY_SIZE(st->channel_modes))
529529
continue;
530530

531531
ret = fwnode_property_read_u32(child, "adi,mode", &tmp);

drivers/iio/gyro/st_gyro_buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static const struct iio_buffer_setup_ops st_gyro_buffer_setup_ops = {
9191

9292
int st_gyro_allocate_ring(struct iio_dev *indio_dev)
9393
{
94-
return iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
94+
return iio_triggered_buffer_setup(indio_dev, NULL,
9595
&st_sensors_trigger_handler, &st_gyro_buffer_setup_ops);
9696
}
9797

drivers/iio/gyro/st_gyro_core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ static const struct iio_info gyro_info = {
409409
static const struct iio_trigger_ops st_gyro_trigger_ops = {
410410
.owner = THIS_MODULE,
411411
.set_trigger_state = ST_GYRO_TRIGGER_SET_STATE,
412+
.validate_device = st_sensors_validate_device,
412413
};
413414
#define ST_GYRO_TRIGGER_OPS (&st_gyro_trigger_ops)
414415
#else

drivers/iio/humidity/am2315.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,8 @@ static irqreturn_t am2315_trigger_handler(int irq, void *p)
165165
struct am2315_sensor_data sensor_data;
166166

167167
ret = am2315_read_data(data, &sensor_data);
168-
if (ret < 0) {
169-
mutex_unlock(&data->lock);
168+
if (ret < 0)
170169
goto err;
171-
}
172170

173171
mutex_lock(&data->lock);
174172
if (*(indio_dev->active_scan_mask) == AM2315_ALL_CHANNEL_MASK) {

drivers/iio/humidity/hdc100x.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static const struct {
5555
},
5656
{ /* IIO_HUMIDITYRELATIVE channel */
5757
.shift = 8,
58-
.mask = 2,
58+
.mask = 3,
5959
},
6060
};
6161

@@ -164,14 +164,14 @@ static int hdc100x_get_measurement(struct hdc100x_data *data,
164164
dev_err(&client->dev, "cannot read high byte measurement");
165165
return ret;
166166
}
167-
val = ret << 6;
167+
val = ret << 8;
168168

169169
ret = i2c_smbus_read_byte(client);
170170
if (ret < 0) {
171171
dev_err(&client->dev, "cannot read low byte measurement");
172172
return ret;
173173
}
174-
val |= ret >> 2;
174+
val |= ret;
175175

176176
return val;
177177
}
@@ -211,18 +211,18 @@ static int hdc100x_read_raw(struct iio_dev *indio_dev,
211211
return IIO_VAL_INT_PLUS_MICRO;
212212
case IIO_CHAN_INFO_SCALE:
213213
if (chan->type == IIO_TEMP) {
214-
*val = 165;
215-
*val2 = 65536 >> 2;
214+
*val = 165000;
215+
*val2 = 65536;
216216
return IIO_VAL_FRACTIONAL;
217217
} else {
218-
*val = 0;
219-
*val2 = 10000;
220-
return IIO_VAL_INT_PLUS_MICRO;
218+
*val = 100;
219+
*val2 = 65536;
220+
return IIO_VAL_FRACTIONAL;
221221
}
222222
break;
223223
case IIO_CHAN_INFO_OFFSET:
224-
*val = -3971;
225-
*val2 = 879096;
224+
*val = -15887;
225+
*val2 = 515151;
226226
return IIO_VAL_INT_PLUS_MICRO;
227227
default:
228228
return -EINVAL;

drivers/iio/imu/bmi160/bmi160_core.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,11 @@ static const struct bmi160_scale_item bmi160_scale_table[] = {
209209
};
210210

211211
static const struct bmi160_odr bmi160_accel_odr[] = {
212-
{0x01, 0, 78125},
213-
{0x02, 1, 5625},
214-
{0x03, 3, 125},
215-
{0x04, 6, 25},
216-
{0x05, 12, 5},
212+
{0x01, 0, 781250},
213+
{0x02, 1, 562500},
214+
{0x03, 3, 125000},
215+
{0x04, 6, 250000},
216+
{0x05, 12, 500000},
217217
{0x06, 25, 0},
218218
{0x07, 50, 0},
219219
{0x08, 100, 0},
@@ -229,7 +229,7 @@ static const struct bmi160_odr bmi160_gyro_odr[] = {
229229
{0x08, 100, 0},
230230
{0x09, 200, 0},
231231
{0x0A, 400, 0},
232-
{0x0B, 8000, 0},
232+
{0x0B, 800, 0},
233233
{0x0C, 1600, 0},
234234
{0x0D, 3200, 0},
235235
};
@@ -364,8 +364,8 @@ int bmi160_set_odr(struct bmi160_data *data, enum bmi160_sensor_type t,
364364

365365
return regmap_update_bits(data->regmap,
366366
bmi160_regs[t].config,
367-
bmi160_odr_table[t].tbl[i].bits,
368-
bmi160_regs[t].config_odr_mask);
367+
bmi160_regs[t].config_odr_mask,
368+
bmi160_odr_table[t].tbl[i].bits);
369369
}
370370

371371
static int bmi160_get_odr(struct bmi160_data *data, enum bmi160_sensor_type t,

drivers/iio/industrialio-trigger.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,22 +210,35 @@ static int iio_trigger_attach_poll_func(struct iio_trigger *trig,
210210

211211
/* Prevent the module from being removed whilst attached to a trigger */
212212
__module_get(pf->indio_dev->info->driver_module);
213+
214+
/* Get irq number */
213215
pf->irq = iio_trigger_get_irq(trig);
216+
if (pf->irq < 0)
217+
goto out_put_module;
218+
219+
/* Request irq */
214220
ret = request_threaded_irq(pf->irq, pf->h, pf->thread,
215221
pf->type, pf->name,
216222
pf);
217-
if (ret < 0) {
218-
module_put(pf->indio_dev->info->driver_module);
219-
return ret;
220-
}
223+
if (ret < 0)
224+
goto out_put_irq;
221225

226+
/* Enable trigger in driver */
222227
if (trig->ops && trig->ops->set_trigger_state && notinuse) {
223228
ret = trig->ops->set_trigger_state(trig, true);
224229
if (ret < 0)
225-
module_put(pf->indio_dev->info->driver_module);
230+
goto out_free_irq;
226231
}
227232

228233
return ret;
234+
235+
out_free_irq:
236+
free_irq(pf->irq, pf);
237+
out_put_irq:
238+
iio_trigger_put_irq(trig, pf->irq);
239+
out_put_module:
240+
module_put(pf->indio_dev->info->driver_module);
241+
return ret;
229242
}
230243

231244
static int iio_trigger_detach_poll_func(struct iio_trigger *trig,

drivers/iio/light/apds9960.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@ static int apds9960_probe(struct i2c_client *client,
10111011

10121012
iio_device_attach_buffer(indio_dev, buffer);
10131013

1014+
indio_dev->dev.parent = &client->dev;
10141015
indio_dev->info = &apds9960_info;
10151016
indio_dev->name = APDS9960_DRV_NAME;
10161017
indio_dev->channels = apds9960_channels;

0 commit comments

Comments
 (0)