First round of iio fixes post the 3.9 merge window.

1) Some little fixes for the ad5064 dac driver.
 2) A build warning 'fix' for a false positive in st_sensors
 3) A couple of missing dependencies on IIO_BUFFER.
 
 So nothing major and these mostly showed the advantages of the randconfig
 builds various people have performed.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.19 (GNU/Linux)
 
 iQIcBAABAgAGBQJRNjamAAoJEFSFNJnE9BaIUwMP/jed+bdUW1fYtGjv6vRmG9fj
 XQK7pMIrk5STiE8UJAMf4vavtXA8lSKK32cAVeUaOXh2huxIXXG+6X/fIu0pfQ+F
 CZNtnl41WVfp0sYA7Pw+on9bXMv8HajJKlbzbe9sBKKyqkpO3EvUZpWyKEBt5cQi
 HMa6gmrditBzkjSXabDH/7lrQE0kN4jSFZUAdRYCVt5oxTs+OzdjH4sUjfwX4/Pg
 YzdZKnqdqftuV/o7Mf1B0D7/7bc15KhNA+QAdBf7tuncvCmGFm2hdLf6DHAdHXsQ
 D0ZcVo5Txg+Md4J3ZOvy45pO667l9KSETLXQq2cBMRMZt0ARCOyxGjxxmYpqUxKO
 r369/tkL/LAV1BOvWZmK9j5W2KOwXtYSigtjZbVPjnYPYCPOlVwgxPZj7J9N8vb/
 nM08QAV6oj9R9UZ4K06K4BoV4W4VD3xaHSTJyxMujlr7R7Eh9aUNH+xsbvkXEDnt
 A8e/n2CLqBjl9M0uTydG5eX9aDzq21ykz/xF1qnz2BsB53zaxizexw2ywXIdAQvD
 waFBUORnUBSZor4cUbO63njhr02NXqA87M+0C3OE/Xvfmn5ygjnPMe1fjcGHeyf+
 fcE7EPzG23ChMZzoNdTDgpjGddvqCTQ95JGUKR55AETt8hv5PpUeUd3B1d5s7tGZ
 LuM8g3lZhYho+RVYkLC5
 =hA1D
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-3.9a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus

Jonathan writes:

"First round of iio fixes post the 3.9 merge window.

1) Some little fixes for the ad5064 dac driver.
2) A build warning 'fix' for a false positive in st_sensors
3) A couple of missing dependencies on IIO_BUFFER.

So nothing major and these mostly showed the advantages of the randconfig
builds various people have performed."
This commit is contained in:
Greg Kroah-Hartman 2013-03-06 05:48:24 +08:00
commit 1223ad3240
4 changed files with 49 additions and 34 deletions

View File

@ -62,7 +62,7 @@ st_sensors_match_odr_error:
int st_sensors_set_odr(struct iio_dev *indio_dev, unsigned int odr) int st_sensors_set_odr(struct iio_dev *indio_dev, unsigned int odr)
{ {
int err; int err;
struct st_sensor_odr_avl odr_out; struct st_sensor_odr_avl odr_out = {0, 0};
struct st_sensor_data *sdata = iio_priv(indio_dev); struct st_sensor_data *sdata = iio_priv(indio_dev);
err = st_sensors_match_odr(sdata->sensor, odr, &odr_out); err = st_sensors_match_odr(sdata->sensor, odr, &odr_out);
@ -114,7 +114,7 @@ st_sensors_match_odr_error:
static int st_sensors_set_fullscale(struct iio_dev *indio_dev, unsigned int fs) static int st_sensors_set_fullscale(struct iio_dev *indio_dev, unsigned int fs)
{ {
int err, i; int err, i = 0;
struct st_sensor_data *sdata = iio_priv(indio_dev); struct st_sensor_data *sdata = iio_priv(indio_dev);
err = st_sensors_match_fs(sdata->sensor, fs, &i); err = st_sensors_match_fs(sdata->sensor, fs, &i);
@ -139,14 +139,13 @@ st_accel_set_fullscale_error:
int st_sensors_set_enable(struct iio_dev *indio_dev, bool enable) int st_sensors_set_enable(struct iio_dev *indio_dev, bool enable)
{ {
bool found;
u8 tmp_value; u8 tmp_value;
int err = -EINVAL; int err = -EINVAL;
struct st_sensor_odr_avl odr_out; bool found = false;
struct st_sensor_odr_avl odr_out = {0, 0};
struct st_sensor_data *sdata = iio_priv(indio_dev); struct st_sensor_data *sdata = iio_priv(indio_dev);
if (enable) { if (enable) {
found = false;
tmp_value = sdata->sensor->pw.value_on; tmp_value = sdata->sensor->pw.value_on;
if ((sdata->sensor->odr.addr == sdata->sensor->pw.addr) && if ((sdata->sensor->odr.addr == sdata->sensor->pw.addr) &&
(sdata->sensor->odr.mask == sdata->sensor->pw.mask)) { (sdata->sensor->odr.mask == sdata->sensor->pw.mask)) {

View File

@ -27,7 +27,6 @@
#define AD5064_ADDR(x) ((x) << 20) #define AD5064_ADDR(x) ((x) << 20)
#define AD5064_CMD(x) ((x) << 24) #define AD5064_CMD(x) ((x) << 24)
#define AD5064_ADDR_DAC(chan) (chan)
#define AD5064_ADDR_ALL_DAC 0xF #define AD5064_ADDR_ALL_DAC 0xF
#define AD5064_CMD_WRITE_INPUT_N 0x0 #define AD5064_CMD_WRITE_INPUT_N 0x0
@ -131,15 +130,15 @@ static int ad5064_write(struct ad5064_state *st, unsigned int cmd,
} }
static int ad5064_sync_powerdown_mode(struct ad5064_state *st, static int ad5064_sync_powerdown_mode(struct ad5064_state *st,
unsigned int channel) const struct iio_chan_spec *chan)
{ {
unsigned int val; unsigned int val;
int ret; int ret;
val = (0x1 << channel); val = (0x1 << chan->address);
if (st->pwr_down[channel]) if (st->pwr_down[chan->channel])
val |= st->pwr_down_mode[channel] << 8; val |= st->pwr_down_mode[chan->channel] << 8;
ret = ad5064_write(st, AD5064_CMD_POWERDOWN_DAC, 0, val, 0); ret = ad5064_write(st, AD5064_CMD_POWERDOWN_DAC, 0, val, 0);
@ -169,7 +168,7 @@ static int ad5064_set_powerdown_mode(struct iio_dev *indio_dev,
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
st->pwr_down_mode[chan->channel] = mode + 1; st->pwr_down_mode[chan->channel] = mode + 1;
ret = ad5064_sync_powerdown_mode(st, chan->channel); ret = ad5064_sync_powerdown_mode(st, chan);
mutex_unlock(&indio_dev->mlock); mutex_unlock(&indio_dev->mlock);
return ret; return ret;
@ -205,7 +204,7 @@ static ssize_t ad5064_write_dac_powerdown(struct iio_dev *indio_dev,
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
st->pwr_down[chan->channel] = pwr_down; st->pwr_down[chan->channel] = pwr_down;
ret = ad5064_sync_powerdown_mode(st, chan->channel); ret = ad5064_sync_powerdown_mode(st, chan);
mutex_unlock(&indio_dev->mlock); mutex_unlock(&indio_dev->mlock);
return ret ? ret : len; return ret ? ret : len;
} }
@ -258,7 +257,7 @@ static int ad5064_write_raw(struct iio_dev *indio_dev,
switch (mask) { switch (mask) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
if (val > (1 << chan->scan_type.realbits) || val < 0) if (val >= (1 << chan->scan_type.realbits) || val < 0)
return -EINVAL; return -EINVAL;
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
@ -292,34 +291,44 @@ static const struct iio_chan_spec_ext_info ad5064_ext_info[] = {
{ }, { },
}; };
#define AD5064_CHANNEL(chan, bits) { \ #define AD5064_CHANNEL(chan, addr, bits) { \
.type = IIO_VOLTAGE, \ .type = IIO_VOLTAGE, \
.indexed = 1, \ .indexed = 1, \
.output = 1, \ .output = 1, \
.channel = (chan), \ .channel = (chan), \
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \ IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
.address = AD5064_ADDR_DAC(chan), \ .address = addr, \
.scan_type = IIO_ST('u', (bits), 16, 20 - (bits)), \ .scan_type = IIO_ST('u', (bits), 16, 20 - (bits)), \
.ext_info = ad5064_ext_info, \ .ext_info = ad5064_ext_info, \
} }
#define DECLARE_AD5064_CHANNELS(name, bits) \ #define DECLARE_AD5064_CHANNELS(name, bits) \
const struct iio_chan_spec name[] = { \ const struct iio_chan_spec name[] = { \
AD5064_CHANNEL(0, bits), \ AD5064_CHANNEL(0, 0, bits), \
AD5064_CHANNEL(1, bits), \ AD5064_CHANNEL(1, 1, bits), \
AD5064_CHANNEL(2, bits), \ AD5064_CHANNEL(2, 2, bits), \
AD5064_CHANNEL(3, bits), \ AD5064_CHANNEL(3, 3, bits), \
AD5064_CHANNEL(4, bits), \ AD5064_CHANNEL(4, 4, bits), \
AD5064_CHANNEL(5, bits), \ AD5064_CHANNEL(5, 5, bits), \
AD5064_CHANNEL(6, bits), \ AD5064_CHANNEL(6, 6, bits), \
AD5064_CHANNEL(7, bits), \ AD5064_CHANNEL(7, 7, bits), \
}
#define DECLARE_AD5065_CHANNELS(name, bits) \
const struct iio_chan_spec name[] = { \
AD5064_CHANNEL(0, 0, bits), \
AD5064_CHANNEL(1, 3, bits), \
} }
static DECLARE_AD5064_CHANNELS(ad5024_channels, 12); static DECLARE_AD5064_CHANNELS(ad5024_channels, 12);
static DECLARE_AD5064_CHANNELS(ad5044_channels, 14); static DECLARE_AD5064_CHANNELS(ad5044_channels, 14);
static DECLARE_AD5064_CHANNELS(ad5064_channels, 16); static DECLARE_AD5064_CHANNELS(ad5064_channels, 16);
static DECLARE_AD5065_CHANNELS(ad5025_channels, 12);
static DECLARE_AD5065_CHANNELS(ad5045_channels, 14);
static DECLARE_AD5065_CHANNELS(ad5065_channels, 16);
static const struct ad5064_chip_info ad5064_chip_info_tbl[] = { static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
[ID_AD5024] = { [ID_AD5024] = {
.shared_vref = false, .shared_vref = false,
@ -328,7 +337,7 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
}, },
[ID_AD5025] = { [ID_AD5025] = {
.shared_vref = false, .shared_vref = false,
.channels = ad5024_channels, .channels = ad5025_channels,
.num_channels = 2, .num_channels = 2,
}, },
[ID_AD5044] = { [ID_AD5044] = {
@ -338,7 +347,7 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
}, },
[ID_AD5045] = { [ID_AD5045] = {
.shared_vref = false, .shared_vref = false,
.channels = ad5044_channels, .channels = ad5045_channels,
.num_channels = 2, .num_channels = 2,
}, },
[ID_AD5064] = { [ID_AD5064] = {
@ -353,7 +362,7 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
}, },
[ID_AD5065] = { [ID_AD5065] = {
.shared_vref = false, .shared_vref = false,
.channels = ad5064_channels, .channels = ad5065_channels,
.num_channels = 2, .num_channels = 2,
}, },
[ID_AD5628_1] = { [ID_AD5628_1] = {
@ -429,6 +438,7 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
{ {
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
struct ad5064_state *st; struct ad5064_state *st;
unsigned int midscale;
unsigned int i; unsigned int i;
int ret; int ret;
@ -465,11 +475,6 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
goto error_free_reg; goto error_free_reg;
} }
for (i = 0; i < st->chip_info->num_channels; ++i) {
st->pwr_down_mode[i] = AD5064_LDAC_PWRDN_1K;
st->dac_cache[i] = 0x8000;
}
indio_dev->dev.parent = dev; indio_dev->dev.parent = dev;
indio_dev->name = name; indio_dev->name = name;
indio_dev->info = &ad5064_info; indio_dev->info = &ad5064_info;
@ -477,6 +482,13 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
indio_dev->channels = st->chip_info->channels; indio_dev->channels = st->chip_info->channels;
indio_dev->num_channels = st->chip_info->num_channels; indio_dev->num_channels = st->chip_info->num_channels;
midscale = (1 << indio_dev->channels[0].scan_type.realbits) / 2;
for (i = 0; i < st->chip_info->num_channels; ++i) {
st->pwr_down_mode[i] = AD5064_LDAC_PWRDN_1K;
st->dac_cache[i] = midscale;
}
ret = iio_device_register(indio_dev); ret = iio_device_register(indio_dev);
if (ret) if (ret)
goto error_disable_reg; goto error_disable_reg;

View File

@ -5,6 +5,7 @@
config INV_MPU6050_IIO config INV_MPU6050_IIO
tristate "Invensense MPU6050 devices" tristate "Invensense MPU6050 devices"
depends on I2C && SYSFS depends on I2C && SYSFS
select IIO_BUFFER
select IIO_TRIGGERED_BUFFER select IIO_TRIGGERED_BUFFER
help help
This driver supports the Invensense MPU6050 devices. This driver supports the Invensense MPU6050 devices.

View File

@ -227,14 +227,17 @@ struct st_sensor_data {
}; };
#ifdef CONFIG_IIO_BUFFER #ifdef CONFIG_IIO_BUFFER
irqreturn_t st_sensors_trigger_handler(int irq, void *p);
int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf);
#endif
#ifdef CONFIG_IIO_TRIGGER
int st_sensors_allocate_trigger(struct iio_dev *indio_dev, int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
const struct iio_trigger_ops *trigger_ops); const struct iio_trigger_ops *trigger_ops);
void st_sensors_deallocate_trigger(struct iio_dev *indio_dev); void st_sensors_deallocate_trigger(struct iio_dev *indio_dev);
irqreturn_t st_sensors_trigger_handler(int irq, void *p);
int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf);
#else #else
static inline int st_sensors_allocate_trigger(struct iio_dev *indio_dev, static inline int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
const struct iio_trigger_ops *trigger_ops) const struct iio_trigger_ops *trigger_ops)