Commit 1180c883 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'iio-for-3.8b' of...

Merge tag 'iio-for-3.8b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Second round of new IIO drivers and cleanups for the 3.8 cycle.

Usual mixed bag of cleanups and minor improvements including
one reversion for a patch in the previous series.

* adt7310 and adt7410 drivers merged into one.
* Revert use devm_kcalloc in at91_adc (because it doesn't exist)
* unlocking fix for error path in the ad5449
* isl29018 suspend and resume support.
* improved pseudo floating point parsing for info_mask write
attributes (and hence into write_raw).  Reject some messed up
strings.
parents abcdc99f 1e45cf3c
......@@ -123,8 +123,10 @@ static int at91_adc_channel_init(struct iio_dev *idev)
idev->num_channels = bitmap_weight(&st->channels_mask,
st->num_channels) + 1;
chan_array = devm_kcalloc(&idev->dev, idev->num_channels + 1,
sizeof(*chan_array), GFP_KERNEL);
chan_array = devm_kzalloc(&idev->dev,
((idev->num_channels + 1) *
sizeof(struct iio_chan_spec)),
GFP_KERNEL);
if (!chan_array)
return -ENOMEM;
......@@ -268,8 +270,9 @@ static int at91_adc_trigger_init(struct iio_dev *idev)
struct at91_adc_state *st = iio_priv(idev);
int i, ret;
st->trig = devm_kcalloc(&idev->dev, st->trigger_number,
sizeof(*st->trig), GFP_KERNEL);
st->trig = devm_kzalloc(&idev->dev,
st->trigger_number * sizeof(st->trig),
GFP_KERNEL);
if (st->trig == NULL) {
ret = -ENOMEM;
......@@ -451,8 +454,9 @@ static int at91_adc_probe_dt(struct at91_adc_state *st,
st->registers->trigger_register = prop;
st->trigger_number = of_get_child_count(node);
st->trigger_list = devm_kcalloc(&idev->dev, st->trigger_number,
sizeof(*st->trigger_list), GFP_KERNEL);
st->trigger_list = devm_kzalloc(&idev->dev, st->trigger_number *
sizeof(struct at91_adc_trigger),
GFP_KERNEL);
if (!st->trigger_list) {
dev_err(&idev->dev, "Could not allocate trigger list memory.\n");
ret = -ENOMEM;
......
......@@ -124,12 +124,13 @@ static int ad5449_read(struct iio_dev *indio_dev, unsigned int addr,
ret = spi_sync(st->spi, &msg);
if (ret < 0)
return ret;
goto out_unlock;
*val = be16_to_cpu(st->data[1]);
mutex_unlock(&indio_dev->mlock);
return 0;
out_unlock:
mutex_unlock(&indio_dev->mlock);
return ret;
}
static int ad5449_read_raw(struct iio_dev *indio_dev,
......
......@@ -437,6 +437,8 @@ static ssize_t iio_write_channel_info(struct device *dev,
if (buf[0] == '-') {
negative = true;
buf++;
} else if (buf[0] == '+') {
buf++;
}
while (*buf) {
......@@ -445,8 +447,6 @@ static ssize_t iio_write_channel_info(struct device *dev,
integer = integer*10 + *buf - '0';
else {
fract += fract_mult*(*buf - '0');
if (fract_mult == 1)
break;
fract_mult /= 10;
}
} else if (*buf == '\n') {
......@@ -454,7 +454,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
break;
else
return -EINVAL;
} else if (*buf == '.') {
} else if (*buf == '.' && integer_part) {
integer_part = false;
} else {
return -EINVAL;
......
......@@ -126,18 +126,11 @@ config AD7192
To compile this driver as a module, choose M here: the
module will be called ad7192.
config ADT7310
tristate "Analog Devices ADT7310 temperature sensor driver"
depends on SPI
help
Say yes here to build support for Analog Devices ADT7310
temperature sensors.
config ADT7410
tristate "Analog Devices ADT7410 temperature sensor driver"
depends on I2C
tristate "Analog Devices ADT7310/ADT7410 temperature sensor driver"
depends on I2C || SPI_MASTER
help
Say yes here to build support for Analog Devices ADT7410
Say yes here to build support for Analog Devices ADT7310/ADT7410
temperature sensors.
config AD7280
......
......@@ -30,7 +30,6 @@ obj-$(CONFIG_AD7780) += ad7780.o
obj-$(CONFIG_AD7793) += ad7793.o
obj-$(CONFIG_AD7816) += ad7816.o
obj-$(CONFIG_AD7192) += ad7192.o
obj-$(CONFIG_ADT7310) += adt7310.o
obj-$(CONFIG_ADT7410) += adt7410.o
obj-$(CONFIG_AD7280) += ad7280a.o
obj-$(CONFIG_LPC32XX_ADC) += lpc32xx_adc.o
......
......@@ -117,7 +117,7 @@
*/
#define POLYNOM 0x2F
#define POLYNOM_ORDER 8
#define HIGHBIT 1 << (POLYNOM_ORDER - 1);
#define HIGHBIT (1 << (POLYNOM_ORDER - 1))
struct ad7280_state {
struct spi_device *spi;
......
This diff is collapsed.
This diff is collapsed.
......@@ -67,6 +67,7 @@ struct isl29018_chip {
unsigned int range;
unsigned int adc_bit;
int prox_scheme;
bool suspended;
};
static int isl29018_set_range(struct isl29018_chip *chip, unsigned long range,
......@@ -368,6 +369,10 @@ static int isl29018_read_raw(struct iio_dev *indio_dev,
struct isl29018_chip *chip = iio_priv(indio_dev);
mutex_lock(&chip->lock);
if (chip->suspended) {
mutex_unlock(&chip->lock);
return -EBUSY;
}
switch (mask) {
case IIO_CHAN_INFO_RAW:
case IIO_CHAN_INFO_PROCESSED:
......@@ -561,6 +566,7 @@ static int __devinit isl29018_probe(struct i2c_client *client,
chip->lux_scale = 1;
chip->range = 1000;
chip->adc_bit = 16;
chip->suspended = false;
chip->regmap = devm_regmap_init_i2c(client, &isl29018_regmap_config);
if (IS_ERR(chip->regmap)) {
......@@ -603,6 +609,44 @@ static int __devexit isl29018_remove(struct i2c_client *client)
return 0;
}
#ifdef CONFIG_PM_SLEEP
static int isl29018_suspend(struct device *dev)
{
struct isl29018_chip *chip = iio_priv(dev_get_drvdata(dev));
mutex_lock(&chip->lock);
/* Since this driver uses only polling commands, we are by default in
* auto shutdown (ie, power-down) mode.
* So we do not have much to do here.
*/
chip->suspended = true;
mutex_unlock(&chip->lock);
return 0;
}
static int isl29018_resume(struct device *dev)
{
struct isl29018_chip *chip = iio_priv(dev_get_drvdata(dev));
int err;
mutex_lock(&chip->lock);
err = isl29018_chip_init(chip);
if (!err)
chip->suspended = false;
mutex_unlock(&chip->lock);
return err;
}
static SIMPLE_DEV_PM_OPS(isl29018_pm_ops, isl29018_suspend, isl29018_resume);
#define ISL29018_PM_OPS (&isl29018_pm_ops)
#else
#define ISL29018_PM_OPS NULL
#endif
static const struct i2c_device_id isl29018_id[] = {
{"isl29018", 0},
{}
......@@ -620,6 +664,7 @@ static struct i2c_driver isl29018_driver = {
.class = I2C_CLASS_HWMON,
.driver = {
.name = "isl29018",
.pm = ISL29018_PM_OPS,
.owner = THIS_MODULE,
.of_match_table = isl29018_of_match,
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment