diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-09-22 20:30:12 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-09-22 20:30:12 +0200 |
commit | 3ffdea3feca9e2c95c2e93e217d77c9c368f747a (patch) | |
tree | e970c502cbd02244344ee1449af072d0d7086bbd /drivers/iio/light/adjd_s311.c | |
parent | staging/lustre: fix coccinelle warnings (diff) | |
parent | iio: ti_am335x_adc: cleanup error case (diff) | |
download | linux-3ffdea3feca9e2c95c2e93e217d77c9c368f747a.tar.xz linux-3ffdea3feca9e2c95c2e93e217d77c9c368f747a.zip |
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.
Diffstat (limited to 'drivers/iio/light/adjd_s311.c')
-rw-r--r-- | drivers/iio/light/adjd_s311.c | 77 |
1 files changed, 22 insertions, 55 deletions
diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c index 23cff798598a..83d15c5baf64 100644 --- a/drivers/iio/light/adjd_s311.c +++ b/drivers/iio/light/adjd_s311.c @@ -114,43 +114,6 @@ static int adjd_s311_read_data(struct iio_dev *indio_dev, u8 reg, int *val) return 0; } -static ssize_t adjd_s311_read_int_time(struct iio_dev *indio_dev, - uintptr_t private, const struct iio_chan_spec *chan, char *buf) -{ - struct adjd_s311_data *data = iio_priv(indio_dev); - s32 ret; - - ret = i2c_smbus_read_word_data(data->client, - ADJD_S311_INT_REG(chan->address)); - if (ret < 0) - return ret; - - return sprintf(buf, "%d\n", ret & ADJD_S311_INT_MASK); -} - -static ssize_t adjd_s311_write_int_time(struct iio_dev *indio_dev, - uintptr_t private, const struct iio_chan_spec *chan, const char *buf, - size_t len) -{ - struct adjd_s311_data *data = iio_priv(indio_dev); - unsigned long int_time; - int ret; - - ret = kstrtoul(buf, 10, &int_time); - if (ret) - return ret; - - if (int_time > ADJD_S311_INT_MASK) - return -EINVAL; - - ret = i2c_smbus_write_word_data(data->client, - ADJD_S311_INT_REG(chan->address), int_time); - if (ret < 0) - return ret; - - return len; -} - static irqreturn_t adjd_s311_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; @@ -175,10 +138,7 @@ static irqreturn_t adjd_s311_trigger_handler(int irq, void *p) len += 2; } - if (indio_dev->scan_timestamp) - *(s64 *)((u8 *)data->buffer + ALIGN(len, sizeof(s64))) - = time_ns; - iio_push_to_buffers(indio_dev, (u8 *)data->buffer); + iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, time_ns); done: iio_trigger_notify_done(indio_dev->trig); @@ -186,25 +146,16 @@ done: return IRQ_HANDLED; } -static const struct iio_chan_spec_ext_info adjd_s311_ext_info[] = { - { - .name = "integration_time", - .read = adjd_s311_read_int_time, - .write = adjd_s311_write_int_time, - }, - { } -}; - #define ADJD_S311_CHANNEL(_color, _scan_idx) { \ .type = IIO_INTENSITY, \ .modified = 1, \ .address = (IDX_##_color), \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ - BIT(IIO_CHAN_INFO_HARDWAREGAIN), \ + BIT(IIO_CHAN_INFO_HARDWAREGAIN) | \ + BIT(IIO_CHAN_INFO_INT_TIME), \ .channel2 = (IIO_MOD_LIGHT_##_color), \ .scan_index = (_scan_idx), \ .scan_type = IIO_ST('u', 10, 16, 0), \ - .ext_info = adjd_s311_ext_info, \ } static const struct iio_chan_spec adjd_s311_channels[] = { @@ -236,6 +187,18 @@ static int adjd_s311_read_raw(struct iio_dev *indio_dev, return ret; *val = ret & ADJD_S311_CAP_MASK; return IIO_VAL_INT; + case IIO_CHAN_INFO_INT_TIME: + ret = i2c_smbus_read_word_data(data->client, + ADJD_S311_INT_REG(chan->address)); + if (ret < 0) + return ret; + *val = 0; + /* + * not documented, based on measurement: + * 4095 LSBs correspond to roughly 4 ms + */ + *val2 = ret & ADJD_S311_INT_MASK; + return IIO_VAL_INT_PLUS_MICRO; } return -EINVAL; } @@ -245,16 +208,20 @@ static int adjd_s311_write_raw(struct iio_dev *indio_dev, int val, int val2, long mask) { struct adjd_s311_data *data = iio_priv(indio_dev); - int ret; switch (mask) { case IIO_CHAN_INFO_HARDWAREGAIN: if (val < 0 || val > ADJD_S311_CAP_MASK) return -EINVAL; - ret = i2c_smbus_write_byte_data(data->client, + return i2c_smbus_write_byte_data(data->client, ADJD_S311_CAP_REG(chan->address), val); - return ret; + case IIO_CHAN_INFO_INT_TIME: + if (val != 0 || val2 < 0 || val2 > ADJD_S311_INT_MASK) + return -EINVAL; + + return i2c_smbus_write_word_data(data->client, + ADJD_S311_INT_REG(chan->address), val2); } return -EINVAL; } |