Skip to content

Commit 3ffdea3

Browse files
committed
Merge tag 'iio-for-3.13a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes: First round of new drivers, functionality and cleanups for IIO in the 3.13 cycle A number of new drivers and some new functionality + a lot of cleanups all over IIO. New Core Elements 1) New INT_TIME info_mask element for integration time, which may have different effects on measurement noise and similar, than an amplifier and hence is different from existing SCALE. Already existed in some drivers as a custom attribute. 2) Introduce a iio_push_buffers_with_timestamp helper to cover the common case of filling the last 64 bits of data to be passed to the buffer with a timestamp. Applied to lots of drivers. Cuts down on repeated code and moves a slightly fiddly bit of logic into a single location. 3) Introduce info_mask_[shared_by_dir/shared_by_all] elements to allow support of elements such as sampling_frequency which is typically shared by all input channels on a device. This reduces code and makes these controls available from in kernel consumers of IIO devices. New drivers 1) MCP3422/3/4 ADC 2) TSL4531 ambient light sensor 3) TCS3472/5 color light sensor 4) GP2AP020A00F ambient light / proximity sensor 5) LPS001WP support added to ST pressure sensor driver. New driver functionality 1) ti_am335x_adc Add buffered sampling support. This device has a hardware fifo that is fed directly into an IIO kfifo buffer based on a watershed interrupt. Note this will act as an example of how to handle this increasingly common type of device. The only previous example - sca3000 - take a less than optimal approach which is largely why it is still in staging. A couple of little cleanups for that new functionality followed later. Core cleanups: 1) MAINTAINERS - Sachin actually brought my email address up to date because I said I'd do it and never got around to it :) 2) Assign buffer list elements as single element lists to simplify the iio_buffer_is_active logic. 3) wake_up_interruptible_poll instead of wake_up_interruptible to only wake up threads waiting for poll notifications. 4) Add O_CLOEXEC flag to anon_inode_get_fd call for IIO event interface. 5) Change iio_push_to_buffers to take a void * pointer so as to avoid some annoying and unnecessary type casts. 6) iio_compute_scan_bytes incorrectly took a long rather than unsigned long. 7) Various minor tidy ups. Driver cleanups (in no particular order) 1) Another set of devm_ allocations patches from Sachin Kamat. 2) tsl2x7x - 0 to NULL cleanup. 3) hmc5843 - fix missing > in MODULE_AUTHOR 4) Set of strict_strto* to kstrto* conversions. 5) mxs-lradc - fix ordering of resource removal to match creation 6) mxs-lradc - add MODULE_ALIAS 7) adc7606 - drop a work pending test duplicated in core functions. 8) hmc5843 - devm_ allocation patch 9) Series of redundant breaks removed. 10) ad2s1200 - pr_err -> dev_err 11) adjd_s311 - use INT_TIME 12) ST sensors - large set of cleanups from Lee Jones and removed restriction to using only triggers provided by the st_sensors themselves from Dennis Ciocca. 13) dummy and tmp006 provide sampling_frequency via info_mask_shared_by_all. 14) tcs3472 - fix incorrect buffer size and wrong device pointer used in suspend / resume functions. 15) max1363 - use defaults for buffer setup ops as provided by the triggered buffer helpers as they are the same as were specified in max1363 driver. 16) Trivial tidy ups in a number of other drivers.
2 parents 9076b09 + 074b6a8 commit 3ffdea3

108 files changed

Lines changed: 3913 additions & 1145 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/ABI/testing/sysfs-bus-iio‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,3 +811,14 @@ Description:
811811
Writing '1' stores the current device configuration into
812812
on-chip EEPROM. After power-up or chip reset the device will
813813
automatically load the saved configuration.
814+
815+
What: /sys/.../iio:deviceX/in_intensity_red_integration_time
816+
What: /sys/.../iio:deviceX/in_intensity_green_integration_time
817+
What: /sys/.../iio:deviceX/in_intensity_blue_integration_time
818+
What: /sys/.../iio:deviceX/in_intensity_clear_integration_time
819+
What: /sys/.../iio:deviceX/in_illuminance_integration_time
820+
KernelVersion: 3.12
821+
Contact: linux-iio@vger.kernel.org
822+
Description:
823+
This attribute is used to get/set the integration time in
824+
seconds.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
* Sharp GP2AP020A00F I2C Proximity/ALS sensor
2+
3+
The proximity detector sensor requires power supply
4+
for its built-in led. It is also defined by this binding.
5+
6+
Required properties:
7+
8+
- compatible : should be "sharp,gp2ap020a00f"
9+
- reg : the I2C slave address of the light sensor
10+
- interrupts : interrupt specifier for the sole interrupt generated
11+
by the device
12+
- vled-supply : VLED power supply, as covered in ../regulator/regulator.txt
13+
14+
Example:
15+
16+
gp2ap020a00f@39 {
17+
compatible = "sharp,gp2ap020a00f";
18+
reg = <0x39>;
19+
interrupts = <2 0>;
20+
vled-supply = <...>;
21+
};

‎MAINTAINERS‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4195,7 +4195,7 @@ S: Maintained
41954195
F: drivers/media/rc/iguanair.c
41964196

41974197
IIO SUBSYSTEM AND DRIVERS
4198-
M: Jonathan Cameron <jic23@cam.ac.uk>
4198+
M: Jonathan Cameron <jic23@kernel.org>
41994199
L: linux-iio@vger.kernel.org
42004200
S: Maintained
42014201
F: drivers/iio/
@@ -7947,7 +7947,7 @@ S: Maintained
79477947
F: drivers/staging/media/go7007/
79487948

79497949
STAGING - INDUSTRIAL IO
7950-
M: Jonathan Cameron <jic23@cam.ac.uk>
7950+
M: Jonathan Cameron <jic23@kernel.org>
79517951
L: linux-iio@vger.kernel.org
79527952
S: Odd Fixes
79537953
F: drivers/staging/iio/

‎drivers/iio/accel/bma180.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,13 +471,10 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
471471
struct iio_poll_func *pf = p;
472472
struct iio_dev *indio_dev = pf->indio_dev;
473473
struct bma180_data *data = iio_priv(indio_dev);
474+
int64_t time_ns = iio_get_time_ns();
474475
int bit, ret, i = 0;
475476

476477
mutex_lock(&data->mutex);
477-
if (indio_dev->scan_timestamp) {
478-
ret = indio_dev->scan_bytes / sizeof(s64) - 1;
479-
((s64 *)data->buff)[ret] = iio_get_time_ns();
480-
}
481478

482479
for_each_set_bit(bit, indio_dev->buffer->scan_mask,
483480
indio_dev->masklength) {
@@ -490,7 +487,7 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
490487
}
491488
mutex_unlock(&data->mutex);
492489

493-
iio_push_to_buffers(indio_dev, (u8 *)data->buff);
490+
iio_push_to_buffers_with_timestamp(indio_dev, data->buff, time_ns);
494491
err:
495492
iio_trigger_notify_done(indio_dev->trig);
496493

‎drivers/iio/accel/hid-sensor-accel-3d.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,11 @@ static const struct iio_info accel_3d_info = {
182182
};
183183

184184
/* Function to push data to buffer */
185-
static void hid_sensor_push_data(struct iio_dev *indio_dev, u8 *data, int len)
185+
static void hid_sensor_push_data(struct iio_dev *indio_dev, const void *data,
186+
int len)
186187
{
187188
dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n");
188-
iio_push_to_buffers(indio_dev, (u8 *)data);
189+
iio_push_to_buffers(indio_dev, data);
189190
}
190191

191192
/* Callback handler to send event after all samples are received and captured */
@@ -200,7 +201,7 @@ static int accel_3d_proc_event(struct hid_sensor_hub_device *hsdev,
200201
accel_state->common_attributes.data_ready);
201202
if (accel_state->common_attributes.data_ready)
202203
hid_sensor_push_data(indio_dev,
203-
(u8 *)accel_state->accel_val,
204+
accel_state->accel_val,
204205
sizeof(accel_state->accel_val));
205206

206207
return 0;

‎drivers/iio/accel/st_accel_core.c‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -452,16 +452,17 @@ static const struct iio_trigger_ops st_accel_trigger_ops = {
452452
int st_accel_common_probe(struct iio_dev *indio_dev,
453453
struct st_sensors_platform_data *plat_data)
454454
{
455-
int err;
456455
struct st_sensor_data *adata = iio_priv(indio_dev);
456+
int irq = adata->get_irq_data_ready(indio_dev);
457+
int err;
457458

458459
indio_dev->modes = INDIO_DIRECT_MODE;
459460
indio_dev->info = &accel_info;
460461

461462
err = st_sensors_check_device_support(indio_dev,
462463
ARRAY_SIZE(st_accel_sensors), st_accel_sensors);
463464
if (err < 0)
464-
goto st_accel_common_probe_error;
465+
return err;
465466

466467
adata->num_data_channels = ST_ACCEL_NUMBER_DATA_CHANNELS;
467468
adata->multiread_bit = adata->sensor->multi_read_bit;
@@ -478,13 +479,13 @@ int st_accel_common_probe(struct iio_dev *indio_dev,
478479

479480
err = st_sensors_init_sensor(indio_dev, plat_data);
480481
if (err < 0)
481-
goto st_accel_common_probe_error;
482+
return err;
482483

483-
if (adata->get_irq_data_ready(indio_dev) > 0) {
484-
err = st_accel_allocate_ring(indio_dev);
485-
if (err < 0)
486-
goto st_accel_common_probe_error;
484+
err = st_accel_allocate_ring(indio_dev);
485+
if (err < 0)
486+
return err;
487487

488+
if (irq > 0) {
488489
err = st_sensors_allocate_trigger(indio_dev,
489490
ST_ACCEL_TRIGGER_OPS);
490491
if (err < 0)
@@ -495,15 +496,14 @@ int st_accel_common_probe(struct iio_dev *indio_dev,
495496
if (err)
496497
goto st_accel_device_register_error;
497498

498-
return err;
499+
return 0;
499500

500501
st_accel_device_register_error:
501-
if (adata->get_irq_data_ready(indio_dev) > 0)
502+
if (irq > 0)
502503
st_sensors_deallocate_trigger(indio_dev);
503504
st_accel_probe_trigger_error:
504-
if (adata->get_irq_data_ready(indio_dev) > 0)
505-
st_accel_deallocate_ring(indio_dev);
506-
st_accel_common_probe_error:
505+
st_accel_deallocate_ring(indio_dev);
506+
507507
return err;
508508
}
509509
EXPORT_SYMBOL(st_accel_common_probe);
@@ -513,10 +513,10 @@ void st_accel_common_remove(struct iio_dev *indio_dev)
513513
struct st_sensor_data *adata = iio_priv(indio_dev);
514514

515515
iio_device_unregister(indio_dev);
516-
if (adata->get_irq_data_ready(indio_dev) > 0) {
516+
if (adata->get_irq_data_ready(indio_dev) > 0)
517517
st_sensors_deallocate_trigger(indio_dev);
518-
st_accel_deallocate_ring(indio_dev);
519-
}
518+
519+
st_accel_deallocate_ring(indio_dev);
520520
}
521521
EXPORT_SYMBOL(st_accel_common_remove);
522522

‎drivers/iio/adc/Kconfig‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,16 @@ config MCP320X
145145
This driver can also be built as a module. If so, the module will be
146146
called mcp320x.
147147

148+
config MCP3422
149+
tristate "Microchip Technology MCP3422/3/4 driver"
150+
depends on I2C
151+
help
152+
Say yes here to build support for Microchip Technology's MCP3422,
153+
MCP3423 or MCP3424 analog to digital converters.
154+
155+
This driver can also be built as a module. If so, the module will be
156+
called mcp3422.
157+
148158
config NAU7802
149159
tristate "Nuvoton NAU7802 ADC driver"
150160
depends on I2C
@@ -167,6 +177,7 @@ config TI_ADC081C
167177
config TI_AM335X_ADC
168178
tristate "TI's AM335X ADC driver"
169179
depends on MFD_TI_AM335X_TSCADC
180+
select IIO_KFIFO_BUF
170181
help
171182
Say yes here to build support for Texas Instruments ADC
172183
driver which is also a MFD client.

‎drivers/iio/adc/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o
1616
obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o
1717
obj-$(CONFIG_MAX1363) += max1363.o
1818
obj-$(CONFIG_MCP320X) += mcp320x.o
19+
obj-$(CONFIG_MCP3422) += mcp3422.o
1920
obj-$(CONFIG_NAU7802) += nau7802.o
2021
obj-$(CONFIG_TI_ADC081C) += ti-adc081c.o
2122
obj-$(CONFIG_TI_AM335X_ADC) += ti_am335x_adc.o

‎drivers/iio/adc/ad7266.c‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ static irqreturn_t ad7266_trigger_handler(int irq, void *p)
9696

9797
ret = spi_read(st->spi, st->data, 4);
9898
if (ret == 0) {
99-
if (indio_dev->scan_timestamp)
100-
((s64 *)st->data)[1] = pf->timestamp;
101-
iio_push_to_buffers(indio_dev, (u8 *)st->data);
99+
iio_push_to_buffers_with_timestamp(indio_dev, st->data,
100+
pf->timestamp);
102101
}
103102

104103
iio_trigger_notify_done(indio_dev->trig);
@@ -293,7 +292,7 @@ static const struct iio_info ad7266_info = {
293292
.driver_module = THIS_MODULE,
294293
};
295294

296-
static unsigned long ad7266_available_scan_masks[] = {
295+
static const unsigned long ad7266_available_scan_masks[] = {
297296
0x003,
298297
0x00c,
299298
0x030,
@@ -303,22 +302,22 @@ static unsigned long ad7266_available_scan_masks[] = {
303302
0x000,
304303
};
305304

306-
static unsigned long ad7266_available_scan_masks_diff[] = {
305+
static const unsigned long ad7266_available_scan_masks_diff[] = {
307306
0x003,
308307
0x00c,
309308
0x030,
310309
0x000,
311310
};
312311

313-
static unsigned long ad7266_available_scan_masks_fixed[] = {
312+
static const unsigned long ad7266_available_scan_masks_fixed[] = {
314313
0x003,
315314
0x000,
316315
};
317316

318317
struct ad7266_chan_info {
319318
const struct iio_chan_spec *channels;
320319
unsigned int num_channels;
321-
unsigned long *scan_masks;
320+
const unsigned long *scan_masks;
322321
};
323322

324323
#define AD7266_CHAN_INFO_INDEX(_differential, _signed, _fixed) \

‎drivers/iio/adc/ad7298.c‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,14 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)
159159
struct iio_poll_func *pf = p;
160160
struct iio_dev *indio_dev = pf->indio_dev;
161161
struct ad7298_state *st = iio_priv(indio_dev);
162-
s64 time_ns = 0;
163162
int b_sent;
164163

165164
b_sent = spi_sync(st->spi, &st->ring_msg);
166165
if (b_sent)
167166
goto done;
168167

169-
if (indio_dev->scan_timestamp) {
170-
time_ns = iio_get_time_ns();
171-
memcpy((u8 *)st->rx_buf + indio_dev->scan_bytes - sizeof(s64),
172-
&time_ns, sizeof(time_ns));
173-
}
174-
175-
iio_push_to_buffers(indio_dev, (u8 *)st->rx_buf);
168+
iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf,
169+
iio_get_time_ns());
176170

177171
done:
178172
iio_trigger_notify_done(indio_dev->trig);

0 commit comments

Comments
 (0)