Merge tag 'iio-for-4.4a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes: First round of new driver, new functionality and cleanups for IIO in the 4.4 cycle New device support * APDS9960 ALS + proximity driver * bmg160 SPI devices. * HDC100x humidity sensors * Holt HI-8435 threshold detector * mma8453Q accelerometer added to the mma8452 driver * mma86452FC and mma8653FC accelerometers added to the mma8452 driver * mxc4005 accelerometer * PulsedLight LIDAR * SensorTech VZ89x volatile organic compound sensor * UPISEMI uS5182d ALS and proximity sensors New core functionality * triggered events - use triggers to check for changes in threshold type detectors on devices with out interrupt support. First user is the holt comparator. * chemical concentration and resistance channel types. New driver functionality * vf610 - buffer support. - followup coccinelle warning fix. Core rework * buffers - break out callback buffer to own module. - move buffer implementations to a new subdirectory * percolate the error code form iio_event_getfd out to userspace rather than giving a missleading error later on. Cleanups * adddac drivers - use BIT macro where appropriate. * meter drivers - use BIT macro where appropriate. * ad7303 - add an OF match table to line up with the binding docs. * adc128s052 - add an OF match table to line up with the binding docs. * adf4350 - add an OF match table to line up with the binding docs * as3935 - add an OF match table to line up with the binding docs. * berlin2-adc - use GENMASK and BIT for masks - prevent attempting to sample multiple channels at once by moving a mutex scop - coding style cleanups * bmg150_magn - kconfig sort order was wrong - fix it. * bmg160 - use i2c regmap and drop all uses of i2c_client - separate i2c and core driver * cc10001_adc - kconfig sort order was wrong - fix it. * evgen (dummy driver helper module) - move interrupt generation to irq_work to reduce differences between the dummy driver and real hardware drivers. * hmc5843 - set the name dynamically rather than to a fixed value for one of the suported parts. - export module alias information to allow autoprobing of module. * lpc32xx - on failure to get resource or irq return -ENXIO as uppose to -EBUSY * max1027 - set .of_match_table to actually allow OF style matching. * max5821 - add MODULE_DEVICE_TABLE for OF table. * mma8452 - refactor to separate out chip specific data. - add freefall / motion interrupt source for devices that do their interrupts slightly differently. - update copywrite notice. - leave naming of events directory in sysfs to the core * mcp320x - set .of_match_table so that it can be use for OF style matching. * mlx90614 - Implement filter configuration (note the datasheet changed as a result of the driver reviews to include the values we needed ;) * opt3001 - drop .owner field as assigned by platform driver core. * si7020 - replace a bitmask on the humidity values with a more correct range check. * stk310 - improved error handling. - use BIT macro where appropriate and use the resulting defines instead of magic numbers in the code. - fix indentation * st-sensors - add debugfs register read hook * tsl4531 - fix error handling in check_id * twl6030 - fix module autoload for OF * iio-trig-sysfs - document add and remove attribute * trigger in staging - code alignment fixes. - braces on both branches of if statement if needed for one. * xilinx-xadc - push interrupts into hardirq context as there isn't much in them any more and it avoids breaking PREEMPT_RT builds due to the use of a spinlock between the hardirq and the thread. Tools * event-monitor - report unsupported events. We keep expanding what can come from drivers so give a helpful error if one turns up in an out of date userspace program. * generic-buffer - helpful message about needing to enable a channel to start the buffer.
This commit is contained in:
@@ -35,8 +35,8 @@
|
||||
#define STK3310_REG_ID 0x3E
|
||||
#define STK3310_MAX_REG 0x80
|
||||
|
||||
#define STK3310_STATE_EN_PS 0x01
|
||||
#define STK3310_STATE_EN_ALS 0x02
|
||||
#define STK3310_STATE_EN_PS BIT(0)
|
||||
#define STK3310_STATE_EN_ALS BIT(1)
|
||||
#define STK3310_STATE_STANDBY 0x00
|
||||
|
||||
#define STK3310_CHIP_ID_VAL 0x13
|
||||
@@ -241,8 +241,11 @@ static int stk3310_write_event(struct iio_dev *indio_dev,
|
||||
struct stk3310_data *data = iio_priv(indio_dev);
|
||||
struct i2c_client *client = data->client;
|
||||
|
||||
regmap_field_read(data->reg_ps_gain, &index);
|
||||
if (val > stk3310_ps_max[index])
|
||||
ret = regmap_field_read(data->reg_ps_gain, &index);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (val < 0 || val > stk3310_ps_max[index])
|
||||
return -EINVAL;
|
||||
|
||||
if (dir == IIO_EV_DIR_RISING)
|
||||
@@ -266,9 +269,12 @@ static int stk3310_read_event_config(struct iio_dev *indio_dev,
|
||||
enum iio_event_direction dir)
|
||||
{
|
||||
unsigned int event_val;
|
||||
int ret;
|
||||
struct stk3310_data *data = iio_priv(indio_dev);
|
||||
|
||||
regmap_field_read(data->reg_int_ps, &event_val);
|
||||
ret = regmap_field_read(data->reg_int_ps, &event_val);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return event_val;
|
||||
}
|
||||
@@ -307,14 +313,16 @@ static int stk3310_read_raw(struct iio_dev *indio_dev,
|
||||
struct stk3310_data *data = iio_priv(indio_dev);
|
||||
struct i2c_client *client = data->client;
|
||||
|
||||
if (chan->type != IIO_LIGHT && chan->type != IIO_PROXIMITY)
|
||||
return -EINVAL;
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (chan->type == IIO_LIGHT)
|
||||
reg = STK3310_REG_ALS_DATA_MSB;
|
||||
else if (chan->type == IIO_PROXIMITY)
|
||||
reg = STK3310_REG_PS_DATA_MSB;
|
||||
else
|
||||
return -EINVAL;
|
||||
reg = STK3310_REG_PS_DATA_MSB;
|
||||
|
||||
mutex_lock(&data->lock);
|
||||
ret = regmap_bulk_read(data->regmap, reg, &buf, 2);
|
||||
if (ret < 0) {
|
||||
@@ -327,17 +335,23 @@ static int stk3310_read_raw(struct iio_dev *indio_dev,
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_INT_TIME:
|
||||
if (chan->type == IIO_LIGHT)
|
||||
regmap_field_read(data->reg_als_it, &index);
|
||||
ret = regmap_field_read(data->reg_als_it, &index);
|
||||
else
|
||||
regmap_field_read(data->reg_ps_it, &index);
|
||||
ret = regmap_field_read(data->reg_ps_it, &index);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
*val = stk3310_it_table[index][0];
|
||||
*val2 = stk3310_it_table[index][1];
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
if (chan->type == IIO_LIGHT)
|
||||
regmap_field_read(data->reg_als_gain, &index);
|
||||
ret = regmap_field_read(data->reg_als_gain, &index);
|
||||
else
|
||||
regmap_field_read(data->reg_ps_gain, &index);
|
||||
ret = regmap_field_read(data->reg_ps_gain, &index);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
*val = stk3310_scale_table[index][0];
|
||||
*val2 = stk3310_scale_table[index][1];
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
@@ -354,6 +368,9 @@ static int stk3310_write_raw(struct iio_dev *indio_dev,
|
||||
int index;
|
||||
struct stk3310_data *data = iio_priv(indio_dev);
|
||||
|
||||
if (chan->type != IIO_LIGHT && chan->type != IIO_PROXIMITY)
|
||||
return -EINVAL;
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_INT_TIME:
|
||||
index = stk3310_get_index(stk3310_it_table,
|
||||
@@ -368,7 +385,7 @@ static int stk3310_write_raw(struct iio_dev *indio_dev,
|
||||
ret = regmap_field_write(data->reg_ps_it, index);
|
||||
if (ret < 0)
|
||||
dev_err(&data->client->dev,
|
||||
"sensor configuration failed\n");
|
||||
"sensor configuration failed\n");
|
||||
mutex_unlock(&data->lock);
|
||||
return ret;
|
||||
|
||||
@@ -385,7 +402,7 @@ static int stk3310_write_raw(struct iio_dev *indio_dev,
|
||||
ret = regmap_field_write(data->reg_ps_gain, index);
|
||||
if (ret < 0)
|
||||
dev_err(&data->client->dev,
|
||||
"sensor configuration failed\n");
|
||||
"sensor configuration failed\n");
|
||||
mutex_unlock(&data->lock);
|
||||
return ret;
|
||||
}
|
||||
@@ -419,8 +436,8 @@ static int stk3310_set_state(struct stk3310_data *data, u8 state)
|
||||
dev_err(&client->dev, "failed to change sensor state\n");
|
||||
} else if (state != STK3310_STATE_STANDBY) {
|
||||
/* Don't reset the 'enabled' flags if we're going in standby */
|
||||
data->ps_enabled = !!(state & 0x01);
|
||||
data->als_enabled = !!(state & 0x02);
|
||||
data->ps_enabled = !!(state & STK3310_STATE_EN_PS);
|
||||
data->als_enabled = !!(state & STK3310_STATE_EN_ALS);
|
||||
}
|
||||
mutex_unlock(&data->lock);
|
||||
|
||||
@@ -435,7 +452,10 @@ static int stk3310_init(struct iio_dev *indio_dev)
|
||||
struct stk3310_data *data = iio_priv(indio_dev);
|
||||
struct i2c_client *client = data->client;
|
||||
|
||||
regmap_read(data->regmap, STK3310_REG_ID, &chipid);
|
||||
ret = regmap_read(data->regmap, STK3310_REG_ID, &chipid);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (chipid != STK3310_CHIP_ID_VAL &&
|
||||
chipid != STK3311_CHIP_ID_VAL) {
|
||||
dev_err(&client->dev, "invalid chip id: 0x%x\n", chipid);
|
||||
@@ -604,8 +624,13 @@ static int stk3310_probe(struct i2c_client *client,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (client->irq < 0)
|
||||
if (client->irq < 0) {
|
||||
client->irq = stk3310_gpio_probe(client);
|
||||
if (client->irq < 0) {
|
||||
ret = client->irq;
|
||||
goto err_standby;
|
||||
}
|
||||
}
|
||||
|
||||
if (client->irq >= 0) {
|
||||
ret = devm_request_threaded_irq(&client->dev, client->irq,
|
||||
@@ -614,17 +639,23 @@ static int stk3310_probe(struct i2c_client *client,
|
||||
IRQF_TRIGGER_FALLING |
|
||||
IRQF_ONESHOT,
|
||||
STK3310_EVENT, indio_dev);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
dev_err(&client->dev, "request irq %d failed\n",
|
||||
client->irq);
|
||||
client->irq);
|
||||
goto err_standby;
|
||||
}
|
||||
}
|
||||
|
||||
ret = iio_device_register(indio_dev);
|
||||
if (ret < 0) {
|
||||
dev_err(&client->dev, "device_register failed\n");
|
||||
stk3310_set_state(data, STK3310_STATE_STANDBY);
|
||||
goto err_standby;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_standby:
|
||||
stk3310_set_state(data, STK3310_STATE_STANDBY);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -648,7 +679,7 @@ static int stk3310_suspend(struct device *dev)
|
||||
|
||||
static int stk3310_resume(struct device *dev)
|
||||
{
|
||||
int state = 0;
|
||||
u8 state = 0;
|
||||
struct stk3310_data *data;
|
||||
|
||||
data = iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
|
||||
|
Reference in New Issue
Block a user