diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-11-13 20:53:28 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-11-13 20:53:28 -0800 |
commit | 449fcf3ab0baf3dde9952385e6789f2ca10c3980 (patch) | |
tree | 180f10c2cdd63836e47725cddc8850ca7144091a /drivers/staging/iio | |
parent | 3c073991eb417b6f785ddc6afbbdc369eb84aa6a (diff) | |
parent | c14dd9d5f8beda9d8c621683b4e7d6cb5cd3cda7 (diff) | |
download | linux-stable-449fcf3ab0baf3dde9952385e6789f2ca10c3980.tar.gz linux-stable-449fcf3ab0baf3dde9952385e6789f2ca10c3980.tar.bz2 linux-stable-449fcf3ab0baf3dde9952385e6789f2ca10c3980.zip |
Merge tag 'staging-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging and IIO updates from Greg KH:
"Here is the "big" staging and IIO driver update for 4.15-rc1.
Lots and lots of little changes, almost all minor code cleanups as the
Outreachy application process happened during this development cycle.
Also happened was a lot of IIO driver activity, and the typec USB code
moving out of staging to drivers/usb (same commits are in the USB tree
on a persistent branch to not cause merge issues.)
Overall, it's a wash, I think we added a few hundred more lines than
removed, but really only a few thousand were modified at all.
All of these have been in linux-next for a while. There might be a
merge issue with Al's vfs tree in the pi433 driver (take his changes,
they are always better), and the media tree with some of the odd
atomisp cleanups (take the media tree's version)"
* tag 'staging-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (507 commits)
staging: lustre: add SPDX identifiers to all lustre files
staging: greybus: Remove redundant license text
staging: greybus: add SPDX identifiers to all greybus driver files
staging: ccree: simplify ioread/iowrite
staging: ccree: simplify registers access
staging: ccree: simplify error handling logic
staging: ccree: remove dead code
staging: ccree: handle limiting of DMA masks
staging: ccree: copy IV to DMAable memory
staging: fbtft: remove redundant initialization of buf
staging: sm750fb: Fix parameter mistake in poke32
staging: wilc1000: Fix bssid buffer offset in Txq
staging: fbtft: fb_ssd1331: fix mirrored display
staging: android: Fix checkpatch.pl error
staging: greybus: loopback: convert loopback to use generic async operations
staging: greybus: operation: add private data with get/set accessors
staging: greybus: loopback: Fix iteration count on async path
staging: greybus: loopback: Hold per-connection mutex across operations
staging: greybus/loopback: use ktime_get() for time intervals
staging: fsl-dpaa2/eth: Extra headroom in RX buffers
...
Diffstat (limited to 'drivers/staging/iio')
31 files changed, 306 insertions, 474 deletions
diff --git a/drivers/staging/iio/Documentation/device.txt b/drivers/staging/iio/Documentation/device.txt index 54ef0deed28f..ec42544a46aa 100644 --- a/drivers/staging/iio/Documentation/device.txt +++ b/drivers/staging/iio/Documentation/device.txt @@ -26,9 +26,6 @@ Then fill in the following: pointer to a structure with elements that tend to be fixed for large sets of different parts supported by a given driver. This contains: - * info->driver_module: - Set to THIS_MODULE. Used to ensure correct ownership - of various resources allocate by the core. * info->event_attrs: Attributes used to enable / disable hardware events. * info->attrs: diff --git a/drivers/staging/iio/Documentation/trigger.txt b/drivers/staging/iio/Documentation/trigger.txt index 7c0e505e4f04..299a1add98bf 100644 --- a/drivers/staging/iio/Documentation/trigger.txt +++ b/drivers/staging/iio/Documentation/trigger.txt @@ -10,10 +10,6 @@ struct iio_trig *trig = iio_trigger_alloc("<trigger format string>", ...); allocates a trigger structure. The key elements to then fill in within a driver are: -trig->owner - Typically set to THIS_MODULE. Used to ensure correct - ownership of core allocated resources. - trig->set_trigger_state: Function that enables / disables the underlying source of the trigger. diff --git a/drivers/staging/iio/accel/adis16201.c b/drivers/staging/iio/accel/adis16201.c index fbc240663621..2ebd27536216 100644 --- a/drivers/staging/iio/accel/adis16201.c +++ b/drivers/staging/iio/accel/adis16201.c @@ -284,7 +284,6 @@ static const struct iio_info adis16201_info = { .read_raw = adis16201_read_raw, .write_raw = adis16201_write_raw, .update_scan_mode = adis_update_scan_mode, - .driver_module = THIS_MODULE, }; static const char * const adis16201_status_error_msgs[] = { diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index 4e3fa7592d3f..b3e4571340ab 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -232,7 +232,6 @@ static const struct iio_info adis16203_info = { .read_raw = adis16203_read_raw, .write_raw = adis16203_write_raw, .update_scan_mode = adis_update_scan_mode, - .driver_module = THIS_MODULE, }; static const char * const adis16203_status_error_msgs[] = { diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c index 8485c024e3f5..7fcef9a2590a 100644 --- a/drivers/staging/iio/accel/adis16209.c +++ b/drivers/staging/iio/accel/adis16209.c @@ -285,7 +285,6 @@ static const struct iio_info adis16209_info = { .read_raw = adis16209_read_raw, .write_raw = adis16209_write_raw, .update_scan_mode = adis_update_scan_mode, - .driver_module = THIS_MODULE, }; static const char * const adis16209_status_error_msgs[] = { diff --git a/drivers/staging/iio/accel/adis16240.c b/drivers/staging/iio/accel/adis16240.c index 109cd94b5ac3..fff6d99089cc 100644 --- a/drivers/staging/iio/accel/adis16240.c +++ b/drivers/staging/iio/accel/adis16240.c @@ -361,7 +361,6 @@ static const struct iio_info adis16240_info = { .read_raw = adis16240_read_raw, .write_raw = adis16240_write_raw, .update_scan_mode = adis_update_scan_mode, - .driver_module = THIS_MODULE, }; static const char * const adis16240_status_error_msgs[] = { diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 6150d2780e22..cadfb96734ed 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -162,6 +162,7 @@ struct ad7192_state { u32 scale_avail[8][2]; u8 gpocon; u8 devid; + struct mutex lock; /* protect sensor state */ struct ad_sigma_delta sd; }; @@ -461,10 +462,10 @@ static int ad7192_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: switch (chan->type) { case IIO_VOLTAGE: - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); *val = st->scale_avail[AD7192_CONF_GAIN(st->conf)][0]; *val2 = st->scale_avail[AD7192_CONF_GAIN(st->conf)][1]; - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); return IIO_VAL_INT_PLUS_NANO; case IIO_TEMP: *val = 0; @@ -508,6 +509,7 @@ static int ad7192_write_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_SCALE: ret = -EINVAL; + mutex_lock(&st->lock); for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++) if (val2 == st->scale_avail[i][1]) { ret = 0; @@ -521,6 +523,7 @@ static int ad7192_write_raw(struct iio_dev *indio_dev, ad7192_calibrate_all(st); break; } + mutex_unlock(&st->lock); break; case IIO_CHAN_INFO_SAMP_FREQ: if (!val) { @@ -567,7 +570,6 @@ static const struct iio_info ad7192_info = { .write_raw_get_fmt = ad7192_write_raw_get_fmt, .attrs = &ad7192_attribute_group, .validate_trigger = ad_sd_validate_trigger, - .driver_module = THIS_MODULE, }; static const struct iio_info ad7195_info = { @@ -576,7 +578,6 @@ static const struct iio_info ad7195_info = { .write_raw_get_fmt = ad7192_write_raw_get_fmt, .attrs = &ad7195_attribute_group, .validate_trigger = ad_sd_validate_trigger, - .driver_module = THIS_MODULE, }; static const struct iio_chan_spec ad7192_channels[] = { @@ -632,6 +633,8 @@ static int ad7192_probe(struct spi_device *spi) st = iio_priv(indio_dev); + mutex_init(&st->lock); + st->avdd = devm_regulator_get(&spi->dev, "avdd"); if (IS_ERR(st->avdd)) return PTR_ERR(st->avdd); diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index f85dde9805e0..b736275c10f5 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -828,7 +828,6 @@ static const struct iio_info ad7280_info = { .read_raw = ad7280_read_raw, .event_attrs = &ad7280_event_attrs_group, .attrs = &ad7280_attrs_group, - .driver_module = THIS_MODULE, }; static const struct ad7280_platform_data ad7793_default_pdata = { diff --git a/drivers/staging/iio/adc/ad7606.c b/drivers/staging/iio/adc/ad7606.c index 18f5f139117e..25b9fcd5e3a4 100644 --- a/drivers/staging/iio/adc/ad7606.c +++ b/drivers/staging/iio/adc/ad7606.c @@ -373,26 +373,22 @@ static irqreturn_t ad7606_interrupt(int irq, void *dev_id) }; static const struct iio_info ad7606_info_no_os_or_range = { - .driver_module = THIS_MODULE, .read_raw = &ad7606_read_raw, }; static const struct iio_info ad7606_info_os_and_range = { - .driver_module = THIS_MODULE, .read_raw = &ad7606_read_raw, .write_raw = &ad7606_write_raw, .attrs = &ad7606_attribute_group_os_and_range, }; static const struct iio_info ad7606_info_os = { - .driver_module = THIS_MODULE, .read_raw = &ad7606_read_raw, .write_raw = &ad7606_write_raw, .attrs = &ad7606_attribute_group_os, }; static const struct iio_info ad7606_info_range = { - .driver_module = THIS_MODULE, .read_raw = &ad7606_read_raw, .write_raw = &ad7606_write_raw, .attrs = &ad7606_attribute_group_range, diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index dec3ba6eba8a..a7797af579b9 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -155,7 +155,6 @@ static const struct ad7780_chip_info ad7780_chip_info_tbl[] = { static const struct iio_info ad7780_info = { .read_raw = ad7780_read_raw, - .driver_module = THIS_MODULE, }; static int ad7780_probe(struct spi_device *spi) diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 17d280581e24..bfe180a475ee 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -335,7 +335,6 @@ static const struct attribute_group ad7816_event_attribute_group = { static const struct iio_info ad7816_info = { .attrs = &ad7816_attribute_group, .event_attrs = &ad7816_event_attribute_group, - .driver_module = THIS_MODULE, }; /* diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index b2bce26499f5..2d33632c00e8 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2087,13 +2087,11 @@ EXPORT_SYMBOL_GPL(adt7316_pm_ops); static const struct iio_info adt7316_info = { .attrs = &adt7316_attribute_group, .event_attrs = &adt7316_event_attribute_group, - .driver_module = THIS_MODULE, }; static const struct iio_info adt7516_info = { .attrs = &adt7516_attribute_group, .event_attrs = &adt7516_event_attribute_group, - .driver_module = THIS_MODULE, }; /* diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index a6f249e9c1e1..2fe916c48848 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -569,7 +569,6 @@ static const struct attribute_group ad7150_event_attribute_group = { static const struct iio_info ad7150_info = { .event_attrs = &ad7150_event_attribute_group, - .driver_module = THIS_MODULE, .read_raw = &ad7150_read_raw, .read_event_config = &ad7150_read_event_config, .write_event_config = &ad7150_write_event_config, diff --git a/drivers/staging/iio/cdc/ad7152.c b/drivers/staging/iio/cdc/ad7152.c index ff10d1f0a7e4..61377ca444de 100644 --- a/drivers/staging/iio/cdc/ad7152.c +++ b/drivers/staging/iio/cdc/ad7152.c @@ -441,7 +441,6 @@ static const struct iio_info ad7152_info = { .read_raw = ad7152_read_raw, .write_raw = ad7152_write_raw, .write_raw_get_fmt = ad7152_write_raw_get_fmt, - .driver_module = THIS_MODULE, }; static const struct iio_chan_spec ad7152_channels[] = { diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c index cdcb4fccf3fe..a124853a05f0 100644 --- a/drivers/staging/iio/cdc/ad7746.c +++ b/drivers/staging/iio/cdc/ad7746.c @@ -667,7 +667,6 @@ static const struct iio_info ad7746_info = { .attrs = &ad7746_attribute_group, .read_raw = ad7746_read_raw, .write_raw = ad7746_write_raw, - .driver_module = THIS_MODULE, }; /* diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c index 6da46ede7ee0..c73eff1f8d73 100644 --- a/drivers/staging/iio/frequency/ad9832.c +++ b/drivers/staging/iio/frequency/ad9832.c @@ -290,7 +290,6 @@ static const struct attribute_group ad9832_attribute_group = { static const struct iio_info ad9832_info = { .attrs = &ad9832_attribute_group, - .driver_module = THIS_MODULE, }; static int ad9832_probe(struct spi_device *spi) diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c index 995acdd7c942..4c6d4043903e 100644 --- a/drivers/staging/iio/frequency/ad9834.c +++ b/drivers/staging/iio/frequency/ad9834.c @@ -381,12 +381,10 @@ static const struct attribute_group ad9833_attribute_group = { static const struct iio_info ad9834_info = { .attrs = &ad9834_attribute_group, - .driver_module = THIS_MODULE, }; static const struct iio_info ad9833_info = { .attrs = &ad9833_attribute_group, - .driver_module = THIS_MODULE, }; static int ad9834_probe(struct spi_device *spi) diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c index 967524583d8a..4e7630caf7d3 100644 --- a/drivers/staging/iio/gyro/adis16060_core.c +++ b/drivers/staging/iio/gyro/adis16060_core.c @@ -103,7 +103,6 @@ static int adis16060_read_raw(struct iio_dev *indio_dev, static const struct iio_info adis16060_info = { .read_raw = adis16060_read_raw, - .driver_module = THIS_MODULE, }; static const struct iio_chan_spec adis16060_channels[] = { diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 3d539eeb0e26..2b28fb9c0048 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -575,7 +575,6 @@ out: static const struct iio_info ad5933_info = { .read_raw = ad5933_read_raw, .attrs = &ad5933_attribute_group, - .driver_module = THIS_MODULE, }; static int ad5933_ring_preenable(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c index 786e93f16ce9..42ed9c015aaf 100644 --- a/drivers/staging/iio/light/tsl2x7x.c +++ b/drivers/staging/iio/light/tsl2x7x.c @@ -15,112 +15,112 @@ * more details. */ -#include <linux/kernel.h> -#include <linux/i2c.h> -#include <linux/errno.h> #include <linux/delay.h> -#include <linux/mutex.h> +#include <linux/errno.h> +#include <linux/i2c.h> #include <linux/interrupt.h> -#include <linux/slab.h> +#include <linux/kernel.h> #include <linux/module.h> +#include <linux/mutex.h> +#include <linux/slab.h> #include <linux/iio/events.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h> #include "tsl2x7x.h" /* Cal defs*/ -#define PROX_STAT_CAL 0 -#define PROX_STAT_SAMP 1 -#define MAX_SAMPLES_CAL 200 +#define PROX_STAT_CAL 0 +#define PROX_STAT_SAMP 1 +#define MAX_SAMPLES_CAL 200 /* TSL2X7X Device ID */ -#define TRITON_ID 0x00 -#define SWORDFISH_ID 0x30 -#define HALIBUT_ID 0x20 +#define TRITON_ID 0x00 +#define SWORDFISH_ID 0x30 +#define HALIBUT_ID 0x20 /* Lux calculation constants */ -#define TSL2X7X_LUX_CALC_OVER_FLOW 65535 +#define TSL2X7X_LUX_CALC_OVER_FLOW 65535 /* TAOS Register definitions - note: * depending on device, some of these register are not used and the * register address is benign. */ /* 2X7X register offsets */ -#define TSL2X7X_MAX_CONFIG_REG 16 +#define TSL2X7X_MAX_CONFIG_REG 16 /* Device Registers and Masks */ -#define TSL2X7X_CNTRL 0x00 -#define TSL2X7X_ALS_TIME 0X01 -#define TSL2X7X_PRX_TIME 0x02 -#define TSL2X7X_WAIT_TIME 0x03 -#define TSL2X7X_ALS_MINTHRESHLO 0X04 -#define TSL2X7X_ALS_MINTHRESHHI 0X05 -#define TSL2X7X_ALS_MAXTHRESHLO 0X06 -#define TSL2X7X_ALS_MAXTHRESHHI 0X07 -#define TSL2X7X_PRX_MINTHRESHLO 0X08 -#define TSL2X7X_PRX_MINTHRESHHI 0X09 -#define TSL2X7X_PRX_MAXTHRESHLO 0X0A -#define TSL2X7X_PRX_MAXTHRESHHI 0X0B -#define TSL2X7X_PERSISTENCE 0x0C -#define TSL2X7X_PRX_CONFIG 0x0D -#define TSL2X7X_PRX_COUNT 0x0E -#define TSL2X7X_GAIN 0x0F -#define TSL2X7X_NOTUSED 0x10 -#define TSL2X7X_REVID 0x11 -#define TSL2X7X_CHIPID 0x12 -#define TSL2X7X_STATUS 0x13 -#define TSL2X7X_ALS_CHAN0LO 0x14 -#define TSL2X7X_ALS_CHAN0HI 0x15 -#define TSL2X7X_ALS_CHAN1LO 0x16 -#define TSL2X7X_ALS_CHAN1HI 0x17 -#define TSL2X7X_PRX_LO 0x18 -#define TSL2X7X_PRX_HI 0x19 +#define TSL2X7X_CNTRL 0x00 +#define TSL2X7X_ALS_TIME 0X01 +#define TSL2X7X_PRX_TIME 0x02 +#define TSL2X7X_WAIT_TIME 0x03 +#define TSL2X7X_ALS_MINTHRESHLO 0X04 +#define TSL2X7X_ALS_MINTHRESHHI 0X05 +#define TSL2X7X_ALS_MAXTHRESHLO 0X06 +#define TSL2X7X_ALS_MAXTHRESHHI 0X07 +#define TSL2X7X_PRX_MINTHRESHLO 0X08 +#define TSL2X7X_PRX_MINTHRESHHI 0X09 +#define TSL2X7X_PRX_MAXTHRESHLO 0X0A +#define TSL2X7X_PRX_MAXTHRESHHI 0X0B +#define TSL2X7X_PERSISTENCE 0x0C +#define TSL2X7X_PRX_CONFIG 0x0D +#define TSL2X7X_PRX_COUNT 0x0E +#define TSL2X7X_GAIN 0x0F +#define TSL2X7X_NOTUSED 0x10 +#define TSL2X7X_REVID 0x11 +#define TSL2X7X_CHIPID 0x12 +#define TSL2X7X_STATUS 0x13 +#define TSL2X7X_ALS_CHAN0LO 0x14 +#define TSL2X7X_ALS_CHAN0HI 0x15 +#define TSL2X7X_ALS_CHAN1LO 0x16 +#define TSL2X7X_ALS_CHAN1HI 0x17 +#define TSL2X7X_PRX_LO 0x18 +#define TSL2X7X_PRX_HI 0x19 /* tsl2X7X cmd reg masks */ -#define TSL2X7X_CMD_REG 0x80 -#define TSL2X7X_CMD_SPL_FN 0x60 +#define TSL2X7X_CMD_REG 0x80 +#define TSL2X7X_CMD_SPL_FN 0x60 -#define TSL2X7X_CMD_PROX_INT_CLR 0X05 -#define TSL2X7X_CMD_ALS_INT_CLR 0x06 -#define TSL2X7X_CMD_PROXALS_INT_CLR 0X07 +#define TSL2X7X_CMD_PROX_INT_CLR 0X05 +#define TSL2X7X_CMD_ALS_INT_CLR 0x06 +#define TSL2X7X_CMD_PROXALS_INT_CLR 0X07 /* tsl2X7X cntrl reg masks */ -#define TSL2X7X_CNTL_ADC_ENBL 0x02 -#define TSL2X7X_CNTL_PWR_ON 0x01 +#define TSL2X7X_CNTL_ADC_ENBL 0x02 +#define TSL2X7X_CNTL_PWR_ON 0x01 /* tsl2X7X status reg masks */ -#define TSL2X7X_STA_ADC_VALID 0x01 -#define TSL2X7X_STA_PRX_VALID 0x02 -#define TSL2X7X_STA_ADC_PRX_VALID (TSL2X7X_STA_ADC_VALID |\ - TSL2X7X_STA_PRX_VALID) -#define TSL2X7X_STA_ALS_INTR 0x10 -#define TSL2X7X_STA_PRX_INTR 0x20 +#define TSL2X7X_STA_ADC_VALID 0x01 +#define TSL2X7X_STA_PRX_VALID 0x02 +#define TSL2X7X_STA_ADC_PRX_VALID (TSL2X7X_STA_ADC_VALID | \ + TSL2X7X_STA_PRX_VALID) +#define TSL2X7X_STA_ALS_INTR 0x10 +#define TSL2X7X_STA_PRX_INTR 0x20 /* tsl2X7X cntrl reg masks */ -#define TSL2X7X_CNTL_REG_CLEAR 0x00 -#define TSL2X7X_CNTL_PROX_INT_ENBL 0X20 -#define TSL2X7X_CNTL_ALS_INT_ENBL 0X10 -#define TSL2X7X_CNTL_WAIT_TMR_ENBL 0X08 -#define TSL2X7X_CNTL_PROX_DET_ENBL 0X04 -#define TSL2X7X_CNTL_PWRON 0x01 -#define TSL2X7X_CNTL_ALSPON_ENBL 0x03 -#define TSL2X7X_CNTL_INTALSPON_ENBL 0x13 -#define TSL2X7X_CNTL_PROXPON_ENBL 0x0F -#define TSL2X7X_CNTL_INTPROXPON_ENBL 0x2F +#define TSL2X7X_CNTL_REG_CLEAR 0x00 +#define TSL2X7X_CNTL_PROX_INT_ENBL 0X20 +#define TSL2X7X_CNTL_ALS_INT_ENBL 0X10 +#define TSL2X7X_CNTL_WAIT_TMR_ENBL 0X08 +#define TSL2X7X_CNTL_PROX_DET_ENBL 0X04 +#define TSL2X7X_CNTL_PWRON 0x01 +#define TSL2X7X_CNTL_ALSPON_ENBL 0x03 +#define TSL2X7X_CNTL_INTALSPON_ENBL 0x13 +#define TSL2X7X_CNTL_PROXPON_ENBL 0x0F +#define TSL2X7X_CNTL_INTPROXPON_ENBL 0x2F /*Prox diode to use */ -#define TSL2X7X_DIODE0 0x10 -#define TSL2X7X_DIODE1 0x20 -#define TSL2X7X_DIODE_BOTH 0x30 +#define TSL2X7X_DIODE0 0x10 +#define TSL2X7X_DIODE1 0x20 +#define TSL2X7X_DIODE_BOTH 0x30 /* LED Power */ -#define TSL2X7X_mA100 0x00 -#define TSL2X7X_mA50 0x40 -#define TSL2X7X_mA25 0x80 -#define TSL2X7X_mA13 0xD0 -#define TSL2X7X_MAX_TIMER_CNT (0xFF) +#define TSL2X7X_100_mA 0x00 +#define TSL2X7X_50_mA 0x40 +#define TSL2X7X_25_mA 0x80 +#define TSL2X7X_13_mA 0xD0 +#define TSL2X7X_MAX_TIMER_CNT 0xFF -#define TSL2X7X_MIN_ITIME 3 +#define TSL2X7X_MIN_ITIME 3 /* TAOS txx2x7x Device family members */ enum { @@ -142,11 +142,6 @@ enum { TSL2X7X_CHIP_SUSPENDED = 2 }; -struct tsl2x7x_parse_result { - int integer; - int fract; -}; - /* Per-device data */ struct tsl2x7x_als_info { u16 als_ch0; @@ -174,7 +169,7 @@ struct tsl2X7X_chip { struct i2c_client *client; u16 prox_data; struct tsl2x7x_als_info als_cur_info; - struct tsl2x7x_settings tsl2x7x_settings; + struct tsl2x7x_settings settings; struct tsl2X7X_platform_data *pdata; int als_time_scale; int als_saturation; @@ -192,25 +187,25 @@ struct tsl2X7X_chip { }; /* Different devices require different coefficents */ -static const struct tsl2x7x_lux tsl2x71_lux_table[] = { +static const struct tsl2x7x_lux tsl2x71_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = { { 14461, 611, 1211 }, { 18540, 352, 623 }, { 0, 0, 0 }, }; -static const struct tsl2x7x_lux tmd2x71_lux_table[] = { +static const struct tsl2x7x_lux tmd2x71_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = { { 11635, 115, 256 }, { 15536, 87, 179 }, { 0, 0, 0 }, }; -static const struct tsl2x7x_lux tsl2x72_lux_table[] = { +static const struct tsl2x7x_lux tsl2x72_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = { { 14013, 466, 917 }, { 18222, 310, 552 }, { 0, 0, 0 }, }; -static const struct tsl2x7x_lux tmd2x72_lux_table[] = { +static const struct tsl2x7x_lux tmd2x72_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = { { 13218, 130, 262 }, { 17592, 92, 169 }, { 0, 0, 0 }, @@ -248,14 +243,14 @@ static const struct tsl2x7x_settings tsl2x7x_default_settings = { .prox_pulse_count = 8 }; -static const s16 tsl2X7X_als_gainadj[] = { +static const s16 tsl2x7x_als_gain[] = { 1, 8, 16, 120 }; -static const s16 tsl2X7X_prx_gainadj[] = { +static const s16 tsl2x7x_prx_gain[] = { 1, 2, 4, @@ -353,9 +348,9 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev) /* clear any existing interrupt status */ ret = i2c_smbus_write_byte(chip->client, - (TSL2X7X_CMD_REG | + TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN | - TSL2X7X_CMD_ALS_INT_CLR)); + TSL2X7X_CMD_ALS_INT_CLR); if (ret < 0) { dev_err(&chip->client->dev, "i2c_write_command failed - err = %d\n", ret); @@ -369,7 +364,7 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev) chip->als_cur_info.als_ch0 = ch0; chip->als_cur_info.als_ch1 = ch1; - if ((ch0 >= chip->als_saturation) || (ch1 >= chip->als_saturation)) { + if (ch0 >= chip->als_saturation || ch1 >= chip->als_saturation) { lux = TSL2X7X_LUX_CALC_OVER_FLOW; goto return_max; } @@ -389,11 +384,10 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev) if (p->ratio == 0) { lux = 0; } else { - ch0lux = DIV_ROUND_UP(ch0 * p->ch0, - tsl2X7X_als_gainadj[chip->tsl2x7x_settings.als_gain]); - ch1lux = DIV_ROUND_UP(ch1 * p->ch1, - tsl2X7X_als_gainadj[chip->tsl2x7x_settings.als_gain]); - lux = ch0lux - ch1lux; + lux = DIV_ROUND_UP(ch0 * p->ch0, + tsl2x7x_als_gain[chip->settings.als_gain]) - + DIV_ROUND_UP(ch1 * p->ch1, + tsl2x7x_als_gain[chip->settings.als_gain]); } /* note: lux is 31 bit max at this point */ @@ -419,7 +413,7 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev) */ lux64 = lux; - lux64 = lux64 * chip->tsl2x7x_settings.als_gain_trim; + lux64 = lux64 * chip->settings.als_gain_trim; lux64 >>= 8; lux = lux64; lux = (lux + 500) / 1000; @@ -472,7 +466,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev) case tmd2771: if (!(ret & TSL2X7X_STA_ADC_VALID)) goto prox_poll_err; - break; + break; case tsl2572: case tsl2672: case tmd2672: @@ -480,7 +474,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev) case tmd2772: if (!(ret & TSL2X7X_STA_PRX_VALID)) goto prox_poll_err; - break; + break; } for (i = 0; i < 2; i++) { @@ -514,12 +508,10 @@ static void tsl2x7x_defaults(struct tsl2X7X_chip *chip) { /* If Operational settings defined elsewhere.. */ if (chip->pdata && chip->pdata->platform_default_settings) - memcpy(&chip->tsl2x7x_settings, - chip->pdata->platform_default_settings, + memcpy(&chip->settings, chip->pdata->platform_default_settings, sizeof(tsl2x7x_default_settings)); else - memcpy(&chip->tsl2x7x_settings, - &tsl2x7x_default_settings, + memcpy(&chip->settings, &tsl2x7x_default_settings, sizeof(tsl2x7x_default_settings)); /* Load up the proper lux table. */ @@ -529,8 +521,8 @@ static void tsl2x7x_defaults(struct tsl2X7X_chip *chip) sizeof(chip->pdata->platform_lux_table)); else memcpy(chip->tsl2x7x_device_lux, - (struct tsl2x7x_lux *)tsl2x7x_default_lux_table_group[chip->id], - MAX_DEFAULT_TABLE_BYTES); + tsl2x7x_default_lux_table_group[chip->id], + TSL2X7X_DEFAULT_TABLE_BYTES); } /** @@ -542,9 +534,7 @@ static void tsl2x7x_defaults(struct tsl2X7X_chip *chip) static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev) { struct tsl2X7X_chip *chip = iio_priv(indio_dev); - int gain_trim_val; - int ret; - int lux_val; + int ret, lux_val; ret = i2c_smbus_read_byte_data(chip->client, TSL2X7X_CMD_REG | TSL2X7X_CNTRL); @@ -575,16 +565,16 @@ static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev) return lux_val; } - gain_trim_val = ((chip->tsl2x7x_settings.als_cal_target) - * chip->tsl2x7x_settings.als_gain_trim) / lux_val; - if ((gain_trim_val < 250) || (gain_trim_val > 4000)) + ret = (chip->settings.als_cal_target * chip->settings.als_gain_trim) / + lux_val; + if (ret < 250 || ret > 4000) return -ERANGE; - chip->tsl2x7x_settings.als_gain_trim = gain_trim_val; + chip->settings.als_gain_trim = ret; dev_info(&chip->client->dev, "%s als_calibrate completed\n", chip->client->name); - return (int)gain_trim_val; + return ret; } static int tsl2x7x_chip_on(struct iio_dev *indio_dev) @@ -602,34 +592,30 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev) chip->pdata->power_on(indio_dev); /* Non calculated parameters */ - chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = - chip->tsl2x7x_settings.prx_time; - chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] = - chip->tsl2x7x_settings.wait_time; - chip->tsl2x7x_config[TSL2X7X_PRX_CONFIG] = - chip->tsl2x7x_settings.prox_config; + chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prx_time; + chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] = chip->settings.wait_time; + chip->tsl2x7x_config[TSL2X7X_PRX_CONFIG] = chip->settings.prox_config; chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHLO] = - (chip->tsl2x7x_settings.als_thresh_low) & 0xFF; + (chip->settings.als_thresh_low) & 0xFF; chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHHI] = - (chip->tsl2x7x_settings.als_thresh_low >> 8) & 0xFF; + (chip->settings.als_thresh_low >> 8) & 0xFF; chip->tsl2x7x_config[TSL2X7X_ALS_MAXTHRESHLO] = - (chip->tsl2x7x_settings.als_thresh_high) & 0xFF; + (chip->settings.als_thresh_high) & 0xFF; chip->tsl2x7x_config[TSL2X7X_ALS_MAXTHRESHHI] = - (chip->tsl2x7x_settings.als_thresh_high >> 8) & 0xFF; - chip->tsl2x7x_config[TSL2X7X_PERSISTENCE] = - chip->tsl2x7x_settings.persistence; + (chip->settings.als_thresh_high >> 8) & 0xFF; + chip->tsl2x7x_config[TSL2X7X_PERSISTENCE] = chip->settings.persistence; chip->tsl2x7x_config[TSL2X7X_PRX_COUNT] = - chip->tsl2x7x_settings.prox_pulse_count; + chip->settings.prox_pulse_count; chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHLO] = - (chip->tsl2x7x_settings.prox_thres_low) & 0xFF; + (chip->settings.prox_thres_low) & 0xFF; chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHHI] = - (chip->tsl2x7x_settings.prox_thres_low >> 8) & 0xFF; + (chip->settings.prox_thres_low >> 8) & 0xFF; chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHLO] = - (chip->tsl2x7x_settings.prox_thres_high) & 0xFF; + (chip->settings.prox_thres_high) & 0xFF; chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHHI] = - (chip->tsl2x7x_settings.prox_thres_high >> 8) & 0xFF; + (chip->settings.prox_thres_high >> 8) & 0xFF; /* and make sure we're not already on */ if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) { @@ -639,7 +625,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev) } /* determine als integration register */ - als_count = (chip->tsl2x7x_settings.als_time * 100 + 135) / 270; + als_count = (chip->settings.als_time * 100 + 135) / 270; if (!als_count) als_count = 1; /* ensure at least one cycle */ @@ -649,9 +635,9 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev) /* Set the gain based on tsl2x7x_settings struct */ chip->tsl2x7x_config[TSL2X7X_GAIN] = - chip->tsl2x7x_settings.als_gain | - (TSL2X7X_mA100 | TSL2X7X_DIODE1) - | ((chip->tsl2x7x_settings.prox_gain) << 2); + chip->settings.als_gain | + (TSL2X7X_100_mA | TSL2X7X_DIODE1) | + (chip->settings.prox_gain << 2); /* set chip struct re scaling and saturation */ chip->als_saturation = als_count * 922; /* 90% of full scale */ @@ -706,18 +692,18 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev) chip->tsl2x7x_chip_status = TSL2X7X_CHIP_WORKING; - if (chip->tsl2x7x_settings.interrupts_en != 0) { + if (chip->settings.interrupts_en != 0) { dev_info(&chip->client->dev, "Setting Up Interrupt(s)\n"); reg_val = TSL2X7X_CNTL_PWR_ON | TSL2X7X_CNTL_ADC_ENBL; - if ((chip->tsl2x7x_settings.interrupts_en == 0x20) || - (chip->tsl2x7x_settings.interrupts_en == 0x30)) + if (chip->settings.interrupts_en == 0x20 || + chip->settings.interrupts_en == 0x30) reg_val |= TSL2X7X_CNTL_PROX_DET_ENBL; - reg_val |= chip->tsl2x7x_settings.interrupts_en; + reg_val |= chip->settings.interrupts_en; ret = i2c_smbus_write_byte_data(chip->client, - (TSL2X7X_CMD_REG | - TSL2X7X_CNTRL), reg_val); + TSL2X7X_CMD_REG | TSL2X7X_CNTRL, + reg_val); if (ret < 0) dev_err(&chip->client->dev, "%s: failed in tsl2x7x_IOCTL_INT_SET.\n", @@ -766,8 +752,7 @@ static int tsl2x7x_chip_off(struct iio_dev *indio_dev) * put device back into proper state, and unlock * resource. */ -static -int tsl2x7x_invoke_change(struct iio_dev *indio_dev) +static int tsl2x7x_invoke_change(struct iio_dev *indio_dev) { struct tsl2X7X_chip *chip = iio_priv(indio_dev); int device_status = chip->tsl2x7x_chip_status; @@ -791,9 +776,8 @@ unlock: return ret; } -static -void tsl2x7x_prox_calculate(int *data, int length, - struct tsl2x7x_prox_stat *statP) +static void tsl2x7x_prox_calculate(int *data, int length, + struct tsl2x7x_prox_stat *statP) { int i; int sample_sum; @@ -837,25 +821,25 @@ static void tsl2x7x_prox_cal(struct iio_dev *indio_dev) u8 tmp_irq_settings; u8 current_state = chip->tsl2x7x_chip_status; - if (chip->tsl2x7x_settings.prox_max_samples_cal > MAX_SAMPLES_CAL) { + if (chip->settings.prox_max_samples_cal > MAX_SAMPLES_CAL) { dev_err(&chip->client->dev, "max prox samples cal is too big: %d\n", - chip->tsl2x7x_settings.prox_max_samples_cal); - chip->tsl2x7x_settings.prox_max_samples_cal = MAX_SAMPLES_CAL; + chip->settings.prox_max_samples_cal); + chip->settings.prox_max_samples_cal = MAX_SAMPLES_CAL; } /* have to stop to change settings */ tsl2x7x_chip_off(indio_dev); /* Enable proximity detection save just in case prox not wanted yet*/ - tmp_irq_settings = chip->tsl2x7x_settings.interrupts_en; - chip->tsl2x7x_settings.interrupts_en |= TSL2X7X_CNTL_PROX_INT_ENBL; + tmp_irq_settings = chip->settings.interrupts_en; + chip->settings.interrupts_en |= TSL2X7X_CNTL_PROX_INT_ENBL; /*turn on device if not already on*/ tsl2x7x_chip_on(indio_dev); /*gather the samples*/ - for (i = 0; i < chip->tsl2x7x_settings.prox_max_samples_cal; i++) { + for (i = 0; i < chip->settings.prox_max_samples_cal; i++) { usleep_range(15000, 17500); tsl2x7x_get_prox(indio_dev); prox_history[i] = chip->prox_data; @@ -866,25 +850,25 @@ static void tsl2x7x_prox_cal(struct iio_dev *indio_dev) tsl2x7x_chip_off(indio_dev); calP = &prox_stat_data[PROX_STAT_CAL]; tsl2x7x_prox_calculate(prox_history, - chip->tsl2x7x_settings.prox_max_samples_cal, - calP); - chip->tsl2x7x_settings.prox_thres_high = (calP->max << 1) - calP->mean; + chip->settings.prox_max_samples_cal, calP); + chip->settings.prox_thres_high = (calP->max << 1) - calP->mean; dev_info(&chip->client->dev, " cal min=%d mean=%d max=%d\n", calP->min, calP->mean, calP->max); dev_info(&chip->client->dev, "%s proximity threshold set to %d\n", - chip->client->name, chip->tsl2x7x_settings.prox_thres_high); + chip->client->name, chip->settings.prox_thres_high); /* back to the way they were */ - chip->tsl2x7x_settings.interrupts_en = tmp_irq_settings; + chip->settings.interrupts_en = tmp_irq_settings; if (current_state == TSL2X7X_CHIP_WORKING) tsl2x7x_chip_on(indio_dev); } -static ssize_t in_illuminance0_calibscale_available_show(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t +in_illuminance0_calibscale_available_show(struct device *dev, + struct device_attribute *attr, + char *buf) { struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev)); @@ -900,69 +884,23 @@ static ssize_t in_illuminance0_calibscale_available_show(struct device *dev, return snprintf(buf, PAGE_SIZE, "%s\n", "1 8 16 120"); } -static ssize_t in_proximity0_calibscale_available_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - return snprintf(buf, PAGE_SIZE, "%s\n", "1 2 4 8"); -} - -static ssize_t in_illuminance0_integration_time_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev)); - int y, z; - - y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.als_time) + 1; - z = y * TSL2X7X_MIN_ITIME; - y /= 1000; - z %= 1000; - - return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z); -} - -static ssize_t in_illuminance0_integration_time_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct tsl2X7X_chip *chip = iio_priv(indio_dev); - struct tsl2x7x_parse_result result; - int ret; - - ret = iio_str_to_fixpoint(buf, 100, &result.integer, &result.fract); - if (ret) - return ret; - - result.fract /= 3; - chip->tsl2x7x_settings.als_time = - TSL2X7X_MAX_TIMER_CNT - (u8)result.fract; - - dev_info(&chip->client->dev, "%s: als time = %d", - __func__, chip->tsl2x7x_settings.als_time); - - tsl2x7x_invoke_change(indio_dev); - - return IIO_VAL_INT_PLUS_MICRO; -} +static IIO_CONST_ATTR(in_proximity0_calibscale_available, "1 2 4 8"); static IIO_CONST_ATTR(in_illuminance0_integration_time_available, ".00272 - .696"); static ssize_t in_illuminance0_target_input_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev)); - return snprintf(buf, PAGE_SIZE, "%d\n", - chip->tsl2x7x_settings.als_cal_target); + return snprintf(buf, PAGE_SIZE, "%d\n", chip->settings.als_cal_target); } static ssize_t in_illuminance0_target_input_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2X7X_chip *chip = iio_priv(indio_dev); @@ -973,7 +911,7 @@ static ssize_t in_illuminance0_target_input_store(struct device *dev, return -EINVAL; if (value) - chip->tsl2x7x_settings.als_cal_target = value; + chip->settings.als_cal_target = value; ret = tsl2x7x_invoke_change(indio_dev); if (ret < 0) @@ -982,111 +920,9 @@ static ssize_t in_illuminance0_target_input_store(struct device *dev, return len; } -/* persistence settings */ -static ssize_t in_intensity0_thresh_period_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev)); - int y, z, filter_delay; - - /* Determine integration time */ - y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.als_time) + 1; - z = y * TSL2X7X_MIN_ITIME; - filter_delay = z * (chip->tsl2x7x_settings.persistence & 0x0F); - y = filter_delay / 1000; - z = filter_delay % 1000; - - return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z); -} - -static ssize_t in_intensity0_thresh_period_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct tsl2X7X_chip *chip = iio_priv(indio_dev); - struct tsl2x7x_parse_result result; - int y, z, filter_delay; - int ret; - - ret = iio_str_to_fixpoint(buf, 100, &result.integer, &result.fract); - if (ret) - return ret; - - y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.als_time) + 1; - z = y * TSL2X7X_MIN_ITIME; - - filter_delay = - DIV_ROUND_UP((result.integer * 1000) + result.fract, z); - - chip->tsl2x7x_settings.persistence &= 0xF0; - chip->tsl2x7x_settings.persistence |= (filter_delay & 0x0F); - - dev_info(&chip->client->dev, "%s: als persistence = %d", - __func__, filter_delay); - - ret = tsl2x7x_invoke_change(indio_dev); - if (ret < 0) - return ret; - - return IIO_VAL_INT_PLUS_MICRO; -} - -static ssize_t in_proximity0_thresh_period_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev)); - int y, z, filter_delay; - - /* Determine integration time */ - y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.prx_time) + 1; - z = y * TSL2X7X_MIN_ITIME; - filter_delay = z * ((chip->tsl2x7x_settings.persistence & 0xF0) >> 4); - y = filter_delay / 1000; - z = filter_delay % 1000; - - return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z); -} - -static ssize_t in_proximity0_thresh_period_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct tsl2X7X_chip *chip = iio_priv(indio_dev); - struct tsl2x7x_parse_result result; - int y, z, filter_delay; - int ret; - - ret = iio_str_to_fixpoint(buf, 100, &result.integer, &result.fract); - if (ret) - return ret; - - y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.prx_time) + 1; - z = y * TSL2X7X_MIN_ITIME; - - filter_delay = - DIV_ROUND_UP((result.integer * 1000) + result.fract, z); - - chip->tsl2x7x_settings.persistence &= 0x0F; - chip->tsl2x7x_settings.persistence |= ((filter_delay << 4) & 0xF0); - - dev_info(&chip->client->dev, "%s: prox persistence = %d", - __func__, filter_delay); - - ret = tsl2x7x_invoke_change(indio_dev); - if (ret < 0) - return ret; - - - return IIO_VAL_INT_PLUS_MICRO; -} - static ssize_t in_illuminance0_calibrate_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); bool value; @@ -1106,14 +942,14 @@ static ssize_t in_illuminance0_calibrate_store(struct device *dev, } static ssize_t in_illuminance0_lux_table_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev)); int i = 0; int offset = 0; - while (i < (TSL2X7X_MAX_LUX_TABLE_SIZE * 3)) { + while (i < TSL2X7X_MAX_LUX_TABLE_SIZE) { offset += snprintf(buf + offset, PAGE_SIZE, "%u,%u,%u,", chip->tsl2x7x_device_lux[i].ratio, chip->tsl2x7x_device_lux[i].ch0, @@ -1134,8 +970,8 @@ static ssize_t in_illuminance0_lux_table_show(struct device *dev, } static ssize_t in_illuminance0_lux_table_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2X7X_chip *chip = iio_priv(indio_dev); @@ -1176,8 +1012,8 @@ static ssize_t in_illuminance0_lux_table_store(struct device *dev, } static ssize_t in_proximity0_calibrate_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); bool value; @@ -1205,9 +1041,9 @@ static int tsl2x7x_read_interrupt_config(struct iio_dev *indio_dev, int ret; if (chan->type == IIO_INTENSITY) - ret = !!(chip->tsl2x7x_settings.interrupts_en & 0x10); + ret = !!(chip->settings.interrupts_en & 0x10); else - ret = !!(chip->tsl2x7x_settings.interrupts_en & 0x20); + ret = !!(chip->settings.interrupts_en & 0x20); return ret; } @@ -1223,14 +1059,14 @@ static int tsl2x7x_write_interrupt_config(struct iio_dev *indio_dev, if (chan->type == IIO_INTENSITY) { if (val) - chip->tsl2x7x_settings.interrupts_en |= 0x10; + chip->settings.interrupts_en |= 0x10; else - chip->tsl2x7x_settings.interrupts_en &= 0x20; + chip->settings.interrupts_en &= 0x20; } else { if (val) - chip->tsl2x7x_settings.interrupts_en |= 0x20; + chip->settings.interrupts_en |= 0x20; else - chip->tsl2x7x_settings.interrupts_en &= 0x10; + chip->settings.interrupts_en &= 0x10; } ret = tsl2x7x_invoke_change(indio_dev); @@ -1248,18 +1084,19 @@ static int tsl2x7x_write_event_value(struct iio_dev *indio_dev, int val, int val2) { struct tsl2X7X_chip *chip = iio_priv(indio_dev); - int ret = -EINVAL; + int ret = -EINVAL, y, z, filter_delay; + u8 time; switch (info) { case IIO_EV_INFO_VALUE: if (chan->type == IIO_INTENSITY) { switch (dir) { case IIO_EV_DIR_RISING: - chip->tsl2x7x_settings.als_thresh_high = val; + chip->settings.als_thresh_high = val; ret = 0; break; case IIO_EV_DIR_FALLING: - chip->tsl2x7x_settings.als_thresh_low = val; + chip->settings.als_thresh_low = val; ret = 0; break; default: @@ -1268,11 +1105,11 @@ static int tsl2x7x_write_event_value(struct iio_dev *indio_dev, } else { switch (dir) { case IIO_EV_DIR_RISING: - chip->tsl2x7x_settings.prox_thres_high = val; + chip->settings.prox_thres_high = val; ret = 0; break; case IIO_EV_DIR_FALLING: - chip->tsl2x7x_settings.prox_thres_low = val; + chip->settings.prox_thres_low = val; ret = 0; break; default: @@ -1280,6 +1117,33 @@ static int tsl2x7x_write_event_value(struct iio_dev *indio_dev, } } break; + case IIO_EV_INFO_PERIOD: + if (chan->type == IIO_INTENSITY) + time = chip->settings.als_time; + else + time = chip->settings.prx_time; + + y = (TSL2X7X_MAX_TIMER_CNT - time) + 1; + z = y * TSL2X7X_MIN_ITIME; + + filter_delay = DIV_ROUND_UP((val * 1000) + val2, z); + + if (chan->type == IIO_INTENSITY) { + chip->settings.persistence &= 0xF0; + chip->settings.persistence |= + (filter_delay & 0x0F); + dev_info(&chip->client->dev, "%s: ALS persistence = %d", + __func__, filter_delay); + } else { + chip->settings.persistence &= 0x0F; + chip->settings.persistence |= + ((filter_delay << 4) & 0xF0); + dev_info(&chip->client->dev, + "%s: Proximity persistence = %d", + __func__, filter_delay); + } + ret = 0; + break; default: break; } @@ -1298,18 +1162,19 @@ static int tsl2x7x_read_event_value(struct iio_dev *indio_dev, int *val, int *val2) { struct tsl2X7X_chip *chip = iio_priv(indio_dev); - int ret = -EINVAL; + int ret = -EINVAL, filter_delay, mult; + u8 time; switch (info) { case IIO_EV_INFO_VALUE: if (chan->type == IIO_INTENSITY) { switch (dir) { case IIO_EV_DIR_RISING: - *val = chip->tsl2x7x_settings.als_thresh_high; + *val = chip->settings.als_thresh_high; ret = IIO_VAL_INT; break; case IIO_EV_DIR_FALLING: - *val = chip->tsl2x7x_settings.als_thresh_low; + *val = chip->settings.als_thresh_low; ret = IIO_VAL_INT; break; default: @@ -1318,11 +1183,11 @@ static int tsl2x7x_read_event_value(struct iio_dev *indio_dev, } else { switch (dir) { case IIO_EV_DIR_RISING: - *val = chip->tsl2x7x_settings.prox_thres_high; + *val = chip->settings.prox_thres_high; ret = IIO_VAL_INT; break; case IIO_EV_DIR_FALLING: - *val = chip->tsl2x7x_settings.prox_thres_low; + *val = chip->settings.prox_thres_low; ret = IIO_VAL_INT; break; default: @@ -1330,6 +1195,23 @@ static int tsl2x7x_read_event_value(struct iio_dev *indio_dev, } } break; + case IIO_EV_INFO_PERIOD: + if (chan->type == IIO_INTENSITY) { + time = chip->settings.als_time; + mult = chip->settings.persistence & 0x0F; + } else { + time = chip->settings.prx_time; + mult = (chip->settings.persistence & 0xF0) >> 4; + } + + /* Determine integration time */ + *val = (TSL2X7X_MAX_TIMER_CNT - time) + 1; + *val2 = *val * TSL2X7X_MIN_ITIME; + filter_delay = *val2 * mult; + *val = filter_delay / 1000; + *val2 = filter_delay % 1000; + ret = IIO_VAL_INT_PLUS_MICRO; + break; default: break; } @@ -1379,18 +1261,20 @@ static int tsl2x7x_read_raw(struct iio_dev *indio_dev, break; case IIO_CHAN_INFO_CALIBSCALE: if (chan->type == IIO_LIGHT) - *val = - tsl2X7X_als_gainadj[chip->tsl2x7x_settings.als_gain]; + *val = tsl2x7x_als_gain[chip->settings.als_gain]; else - *val = - tsl2X7X_prx_gainadj[chip->tsl2x7x_settings.prox_gain]; + *val = tsl2x7x_prx_gain[chip->settings.prox_gain]; ret = IIO_VAL_INT; break; case IIO_CHAN_INFO_CALIBBIAS: - *val = chip->tsl2x7x_settings.als_gain_trim; + *val = chip->settings.als_gain_trim; ret = IIO_VAL_INT; break; - + case IIO_CHAN_INFO_INT_TIME: + *val = (TSL2X7X_MAX_TIMER_CNT - chip->settings.als_time) + 1; + *val2 = ((*val * TSL2X7X_MIN_ITIME) % 1000) / 1000; + ret = IIO_VAL_INT_PLUS_MICRO; + break; default: ret = -EINVAL; } @@ -1411,13 +1295,13 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev, if (chan->type == IIO_INTENSITY) { switch (val) { case 1: - chip->tsl2x7x_settings.als_gain = 0; + chip->settings.als_gain = 0; break; case 8: - chip->tsl2x7x_settings.als_gain = 1; + chip->settings.als_gain = 1; break; case 16: - chip->tsl2x7x_settings.als_gain = 2; + chip->settings.als_gain = 2; break; case 120: switch (chip->id) { @@ -1428,7 +1312,7 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev, case tmd2772: return -EINVAL; } - chip->tsl2x7x_settings.als_gain = 3; + chip->settings.als_gain = 3; break; case 128: switch (chip->id) { @@ -1439,7 +1323,7 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev, case tmd2771: return -EINVAL; } - chip->tsl2x7x_settings.als_gain = 3; + chip->settings.als_gain = 3; break; default: return -EINVAL; @@ -1447,16 +1331,16 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev, } else { switch (val) { case 1: - chip->tsl2x7x_settings.prox_gain = 0; + chip->settings.prox_gain = 0; break; case 2: - chip->tsl2x7x_settings.prox_gain = 1; + chip->settings.prox_gain = 1; break; case 4: - chip->tsl2x7x_settings.prox_gain = 2; + chip->settings.prox_gain = 2; break; case 8: - chip->tsl2x7x_settings.prox_gain = 3; + chip->settings.prox_gain = 3; break; default: return -EINVAL; @@ -1464,9 +1348,15 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev, } break; case IIO_CHAN_INFO_CALIBBIAS: - chip->tsl2x7x_settings.als_gain_trim = val; + chip->settings.als_gain_trim = val; break; + case IIO_CHAN_INFO_INT_TIME: + chip->settings.als_time = + TSL2X7X_MAX_TIMER_CNT - (val2 / TSL2X7X_MIN_ITIME); + dev_info(&chip->client->dev, "%s: als time = %d", + __func__, chip->settings.als_time); + break; default: return -EINVAL; } @@ -1474,12 +1364,8 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev, return tsl2x7x_invoke_change(indio_dev); } -static DEVICE_ATTR_RO(in_proximity0_calibscale_available); - static DEVICE_ATTR_RO(in_illuminance0_calibscale_available); -static DEVICE_ATTR_RW(in_illuminance0_integration_time); - static DEVICE_ATTR_RW(in_illuminance0_target_input); static DEVICE_ATTR_WO(in_illuminance0_calibrate); @@ -1488,10 +1374,6 @@ static DEVICE_ATTR_WO(in_proximity0_calibrate); static DEVICE_ATTR_RW(in_illuminance0_lux_table); -static DEVICE_ATTR_RW(in_intensity0_thresh_period); - -static DEVICE_ATTR_RW(in_proximity0_thresh_period); - /* Use the default register values to identify the Taos device */ static int tsl2x7x_device_id(int *id, int target) { @@ -1559,7 +1441,6 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private) static struct attribute *tsl2x7x_ALS_device_attrs[] = { &dev_attr_in_illuminance0_calibscale_available.attr, - &dev_attr_in_illuminance0_integration_time.attr, &iio_const_attr_in_illuminance0_integration_time_available.dev_attr.attr, &dev_attr_in_illuminance0_target_input.attr, &dev_attr_in_illuminance0_calibrate.attr, @@ -1574,49 +1455,31 @@ static struct attribute *tsl2x7x_PRX_device_attrs[] = { static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = { &dev_attr_in_illuminance0_calibscale_available.attr, - &dev_attr_in_illuminance0_integration_time.attr, &iio_const_attr_in_illuminance0_integration_time_available.dev_attr.attr, &dev_attr_in_illuminance0_target_input.attr, &dev_attr_in_illuminance0_calibrate.attr, &dev_attr_in_illuminance0_lux_table.attr, - &dev_attr_in_proximity0_calibrate.attr, + &iio_const_attr_in_proximity0_calibscale_available.dev_attr.attr, NULL }; static struct attribute *tsl2x7x_PRX2_device_attrs[] = { &dev_attr_in_proximity0_calibrate.attr, - &dev_attr_in_proximity0_calibscale_available.attr, + &iio_const_attr_in_proximity0_calibscale_available.dev_attr.attr, NULL }; static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = { &dev_attr_in_illuminance0_calibscale_available.attr, - &dev_attr_in_illuminance0_integration_time.attr, &iio_const_attr_in_illuminance0_integration_time_available.dev_attr.attr, &dev_attr_in_illuminance0_target_input.attr, &dev_attr_in_illuminance0_calibrate.attr, &dev_attr_in_illuminance0_lux_table.attr, &dev_attr_in_proximity0_calibrate.attr, - &dev_attr_in_proximity0_calibscale_available.attr, + &iio_const_attr_in_proximity0_calibscale_available.dev_attr.attr, NULL }; -static struct attribute *tsl2X7X_ALS_event_attrs[] = { - &dev_attr_in_intensity0_thresh_period.attr, - NULL, -}; - -static struct attribute *tsl2X7X_PRX_event_attrs[] = { - &dev_attr_in_proximity0_thresh_period.attr, - NULL, -}; - -static struct attribute *tsl2X7X_ALSPRX_event_attrs[] = { - &dev_attr_in_intensity0_thresh_period.attr, - &dev_attr_in_proximity0_thresh_period.attr, - NULL, -}; - static const struct attribute_group tsl2X7X_device_attr_group_tbl[] = { [ALS] = { .attrs = tsl2x7x_ALS_device_attrs, @@ -1635,26 +1498,9 @@ static const struct attribute_group tsl2X7X_device_attr_group_tbl[] = { }, }; -static const struct attribute_group tsl2X7X_event_attr_group_tbl[] = { - [ALS] = { - .attrs = tsl2X7X_ALS_event_attrs, - .name = "events", - }, - [PRX] = { - .attrs = tsl2X7X_PRX_event_attrs, - .name = "events", - }, - [ALSPRX] = { - .attrs = tsl2X7X_ALSPRX_event_attrs, - .name = "events", - }, -}; - static const struct iio_info tsl2X7X_device_info[] = { [ALS] = { .attrs = &tsl2X7X_device_attr_group_tbl[ALS], - .event_attrs = &tsl2X7X_event_attr_group_tbl[ALS], - .driver_module = THIS_MODULE, .read_raw = &tsl2x7x_read_raw, .write_raw = &tsl2x7x_write_raw, .read_event_value = &tsl2x7x_read_event_value, @@ -1664,8 +1510,6 @@ static const struct iio_info tsl2X7X_device_info[] = { }, [PRX] = { .attrs = &tsl2X7X_device_attr_group_tbl[PRX], - .event_attrs = &tsl2X7X_event_attr_group_tbl[PRX], - .driver_module = THIS_MODULE, .read_raw = &tsl2x7x_read_raw, .write_raw = &tsl2x7x_write_raw, .read_event_value = &tsl2x7x_read_event_value, @@ -1675,8 +1519,6 @@ static const struct iio_info tsl2X7X_device_info[] = { }, [ALSPRX] = { .attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX], - .event_attrs = &tsl2X7X_event_attr_group_tbl[ALSPRX], - .driver_module = THIS_MODULE, .read_raw = &tsl2x7x_read_raw, .write_raw = &tsl2x7x_write_raw, .read_event_value = &tsl2x7x_read_event_value, @@ -1686,8 +1528,6 @@ static const struct iio_info tsl2X7X_device_info[] = { }, [PRX2] = { .attrs = &tsl2X7X_device_attr_group_tbl[PRX2], - .event_attrs = &tsl2X7X_event_attr_group_tbl[PRX], - .driver_module = THIS_MODULE, .read_raw = &tsl2x7x_read_raw, .write_raw = &tsl2x7x_write_raw, .read_event_value = &tsl2x7x_read_event_value, @@ -1697,8 +1537,6 @@ static const struct iio_info tsl2X7X_device_info[] = { }, [ALSPRX2] = { .attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX2], - .event_attrs = &tsl2X7X_event_attr_group_tbl[ALSPRX], - .driver_module = THIS_MODULE, .read_raw = &tsl2x7x_read_raw, .write_raw = &tsl2x7x_write_raw, .read_event_value = &tsl2x7x_read_event_value, @@ -1719,6 +1557,10 @@ static const struct iio_event_spec tsl2x7x_events[] = { .dir = IIO_EV_DIR_FALLING, .mask_separate = BIT(IIO_EV_INFO_VALUE) | BIT(IIO_EV_INFO_ENABLE), + }, { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_EITHER, + .mask_separate = BIT(IIO_EV_INFO_PERIOD), }, }; @@ -1729,7 +1571,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = { .type = IIO_LIGHT, .indexed = 1, .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_INT_TIME), }, { .type = IIO_INTENSITY, .indexed = 1, @@ -1768,7 +1611,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = { .type = IIO_LIGHT, .indexed = 1, .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_INT_TIME), }, { .type = IIO_INTENSITY, .indexed = 1, @@ -1816,7 +1660,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = { .type = IIO_LIGHT, .indexed = 1, .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_INT_TIME), }, { .type = IIO_INTENSITY, .indexed = 1, @@ -1874,7 +1719,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp, return -EINVAL; } - ret = i2c_smbus_write_byte(clientp, (TSL2X7X_CMD_REG | TSL2X7X_CNTRL)); + ret = i2c_smbus_write_byte(clientp, TSL2X7X_CMD_REG | TSL2X7X_CNTRL); if (ret < 0) { dev_err(&clientp->dev, "write to cmd reg failed. err = %d\n", ret); @@ -1982,7 +1827,7 @@ static int tsl2x7x_remove(struct i2c_client *client) return 0; } -static struct i2c_device_id tsl2x7x_idtable[] = { +static const struct i2c_device_id tsl2x7x_idtable[] = { { "tsl2571", tsl2571 }, { "tsl2671", tsl2671 }, { "tmd2671", tmd2671 }, diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h index ecae92211216..df00f2ec1719 100644 --- a/drivers/staging/iio/light/tsl2x7x.h +++ b/drivers/staging/iio/light/tsl2x7x.h @@ -23,18 +23,19 @@ #define __TSL2X7X_H #include <linux/pm.h> -/* Max number of segments allowable in LUX table */ -#define TSL2X7X_MAX_LUX_TABLE_SIZE 9 -#define MAX_DEFAULT_TABLE_BYTES (sizeof(int) * TSL2X7X_MAX_LUX_TABLE_SIZE) - -struct iio_dev; - struct tsl2x7x_lux { unsigned int ratio; unsigned int ch0; unsigned int ch1; }; +/* Max number of segments allowable in LUX table */ +#define TSL2X7X_MAX_LUX_TABLE_SIZE 9 +/* The default LUX tables all have 3 elements. */ +#define TSL2X7X_DEF_LUX_TABLE_SZ 3 +#define TSL2X7X_DEFAULT_TABLE_BYTES (sizeof(struct tsl2x7x_lux) * \ + TSL2X7X_DEF_LUX_TABLE_SZ) + /** * struct tsl2x7x_default_settings - power on defaults unless * overridden by platform data. diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c index ce26abdeab92..c44eb577dc35 100644 --- a/drivers/staging/iio/meter/ade7753.c +++ b/drivers/staging/iio/meter/ade7753.c @@ -80,7 +80,7 @@ * @us: actual spi_device * @tx: transmit buffer * @rx: receive buffer - * @buf_lock: mutex to protect tx and rx + * @buf_lock: mutex to protect tx, rx and write frequency **/ struct ade7753_state { struct spi_device *us; @@ -107,6 +107,19 @@ static int ade7753_spi_write_reg_8(struct device *dev, return ret; } +static int __ade7753_spi_write_reg_16(struct device *dev, u8 reg_address, + u16 value) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct ade7753_state *st = iio_priv(indio_dev); + + st->tx[0] = ADE7753_WRITE_REG(reg_address); + st->tx[1] = (value >> 8) & 0xFF; + st->tx[2] = value & 0xFF; + + return spi_write(st->us, st->tx, 3); +} + static int ade7753_spi_write_reg_16(struct device *dev, u8 reg_address, u16 value) { @@ -115,10 +128,7 @@ static int ade7753_spi_write_reg_16(struct device *dev, u8 reg_address, struct ade7753_state *st = iio_priv(indio_dev); mutex_lock(&st->buf_lock); - st->tx[0] = ADE7753_WRITE_REG(reg_address); - st->tx[1] = (value >> 8) & 0xFF; - st->tx[2] = value & 0xFF; - ret = spi_write(st->us, st->tx, 3); + ret = __ade7753_spi_write_reg_16(dev, reg_address, value); mutex_unlock(&st->buf_lock); return ret; @@ -483,7 +493,7 @@ static ssize_t ade7753_write_frequency(struct device *dev, if (!val) return -EINVAL; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->buf_lock); t = 27900 / val; if (t > 0) @@ -501,10 +511,10 @@ static ssize_t ade7753_write_frequency(struct device *dev, reg &= ~(3 << 11); reg |= t << 11; - ret = ade7753_spi_write_reg_16(dev, ADE7753_MODE, reg); + ret = __ade7753_spi_write_reg_16(dev, ADE7753_MODE, reg); out: - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->buf_lock); return ret ? ret : len; } @@ -561,7 +571,6 @@ static const struct attribute_group ade7753_attribute_group = { static const struct iio_info ade7753_info = { .attrs = &ade7753_attribute_group, - .driver_module = THIS_MODULE, }; static int ade7753_probe(struct spi_device *spi) diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c index be0df3fe4230..3a1e342d75fb 100644 --- a/drivers/staging/iio/meter/ade7754.c +++ b/drivers/staging/iio/meter/ade7754.c @@ -601,7 +601,6 @@ static const struct attribute_group ade7754_attribute_group = { static const struct iio_info ade7754_info = { .attrs = &ade7754_attribute_group, - .driver_module = THIS_MODULE, }; static int ade7754_probe(struct spi_device *spi) diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index 40498af4dc46..7b7ffe5ed186 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -827,7 +827,6 @@ static const struct iio_info ade7758_info = { .attrs = &ade7758_attribute_group, .read_raw = &ade7758_read_raw, .write_raw = &ade7758_write_raw, - .driver_module = THIS_MODULE, }; static int ade7758_probe(struct spi_device *spi) diff --git a/drivers/staging/iio/meter/ade7758_trigger.c b/drivers/staging/iio/meter/ade7758_trigger.c index 5b35a7f08f4f..1f0d1a0cf889 100644 --- a/drivers/staging/iio/meter/ade7758_trigger.c +++ b/drivers/staging/iio/meter/ade7758_trigger.c @@ -53,7 +53,6 @@ static int ade7758_trig_try_reen(struct iio_trigger *trig) } static const struct iio_trigger_ops ade7758_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = &ade7758_data_rdy_trigger_set_state, .try_reenable = &ade7758_trig_try_reen, }; diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c index 02573c517d9d..d99cf508d8d0 100644 --- a/drivers/staging/iio/meter/ade7759.c +++ b/drivers/staging/iio/meter/ade7759.c @@ -60,7 +60,7 @@ /** * struct ade7759_state - device instance specific data * @us: actual spi_device - * @buf_lock: mutex to protect tx and rx + * @buf_lock: mutex to protect tx and rx and write frequency * @tx: transmit buffer * @rx: receive buffer **/ @@ -89,19 +89,30 @@ static int ade7759_spi_write_reg_8(struct device *dev, return ret; } -static int ade7759_spi_write_reg_16(struct device *dev, +/*Unlocked version of ade7759_spi_write_reg_16 function */ +static int __ade7759_spi_write_reg_16(struct device *dev, u8 reg_address, u16 value) { - int ret; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7759_state *st = iio_priv(indio_dev); - mutex_lock(&st->buf_lock); st->tx[0] = ADE7759_WRITE_REG(reg_address); st->tx[1] = (value >> 8) & 0xFF; st->tx[2] = value & 0xFF; - ret = spi_write(st->us, st->tx, 3); + return spi_write(st->us, st->tx, 3); +} + +static int ade7759_spi_write_reg_16(struct device *dev, + u8 reg_address, + u16 value) +{ + int ret; + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct ade7759_state *st = iio_priv(indio_dev); + + mutex_lock(&st->buf_lock); + ret = __ade7759_spi_write_reg_16(dev, reg_address, value); mutex_unlock(&st->buf_lock); return ret; @@ -429,7 +440,7 @@ static ssize_t ade7759_write_frequency(struct device *dev, if (!val) return -EINVAL; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->buf_lock); t = 27900 / val; if (t > 0) @@ -447,10 +458,10 @@ static ssize_t ade7759_write_frequency(struct device *dev, reg &= ~(3 << 13); reg |= t << 13; - ret = ade7759_spi_write_reg_16(dev, ADE7759_MODE, reg); + ret = __ade7759_spi_write_reg_16(dev, ADE7759_MODE, reg); out: - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->buf_lock); return ret ? ret : len; } @@ -493,7 +504,6 @@ static const struct attribute_group ade7759_attribute_group = { static const struct iio_info ade7759_info = { .attrs = &ade7759_attribute_group, - .driver_module = THIS_MODULE, }; static int ade7759_probe(struct spi_device *spi) diff --git a/drivers/staging/iio/meter/ade7854.c b/drivers/staging/iio/meter/ade7854.c index 70612da64a8b..90d07cdca4b8 100644 --- a/drivers/staging/iio/meter/ade7854.c +++ b/drivers/staging/iio/meter/ade7854.c @@ -530,7 +530,6 @@ static const struct attribute_group ade7854_attribute_group = { static const struct iio_info ade7854_info = { .attrs = &ade7854_attribute_group, - .driver_module = THIS_MODULE, }; int ade7854_probe(struct iio_dev *indio_dev, struct device *dev) diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c index a37e199225f4..aa62c64e9bc4 100644 --- a/drivers/staging/iio/resolver/ad2s1200.c +++ b/drivers/staging/iio/resolver/ad2s1200.c @@ -98,7 +98,6 @@ static const struct iio_chan_spec ad2s1200_channels[] = { static const struct iio_info ad2s1200_info = { .read_raw = ad2s1200_read_raw, - .driver_module = THIS_MODULE, }; static int ad2s1200_probe(struct spi_device *spi) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 3e00df74b18c..f8baab061eba 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -638,7 +638,6 @@ error_ret: static const struct iio_info ad2s1210_info = { .read_raw = ad2s1210_read_raw, .attrs = &ad2s1210_attribute_group, - .driver_module = THIS_MODULE, }; static int ad2s1210_setup_gpios(struct ad2s1210_state *st) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index b2270908f26f..59586947a936 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -48,7 +48,6 @@ error_ret: static const struct iio_info ad2s90_info = { .read_raw = ad2s90_read_raw, - .driver_module = THIS_MODULE, }; static const struct iio_chan_spec ad2s90_chan = { diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c index 4e0b4eedb53d..d80dcf82eba9 100644 --- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c +++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c @@ -172,7 +172,6 @@ static int iio_bfin_tmr_get_number(int irq) } static const struct iio_trigger_ops iio_bfin_tmr_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = iio_bfin_tmr_set_state, }; |