Commit f7046bf0 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

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

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

Jonathan writes:

	Second round of IIO cleanups for the 3.10 cycle

	1) A nice little removal of the unwanted private pointer from
	   struct iio_trigger.
	2) Some clean up of the ad799x driver.
	3) Couple of cleanups for the exynos_adc driver and some documentation.
	4) Move the mxs-lradc initialization a little earlier in the driver to avoid
	   wiping out the configuration just after setting it.

	A nice small set of worthy bits and bobs.
parents 698f57f4 2b684024
Samsung Exynos Analog to Digital Converter bindings
This devicetree binding are for the new adc driver written fori
The devicetree bindings are for the new ADC driver written for
Exynos4 and upward SoCs from Samsung.
New driver handles the following
......@@ -20,6 +20,9 @@ Required properties:
format is being dependent on which interrupt controller
the Samsung device uses.
- #io-channel-cells = <1>; As ADC has multiple outputs
- clocks From common clock binding: handle to adc clock.
- clock-names From common clock binding: Shall be "adc".
- vdd-supply VDD input supply.
Note: child nodes can be added for auto probing from device tree.
......@@ -31,6 +34,11 @@ adc: adc@12D10000 {
interrupts = <0 106 0>;
#io-channel-cells = <1>;
io-channel-ranges;
clocks = <&clock 303>;
clock-names = "adc";
vdd-supply = <&buck5_reg>;
};
......@@ -49,4 +57,4 @@ adc@12D10000 {
};
Note: Does not apply to ADC driver under arch/arm/plat-samsung/
Note: The child node can be added under the adc node or seperately.
Note: The child node can be added under the adc node or separately.
......@@ -25,7 +25,7 @@
int st_accel_trig_set_state(struct iio_trigger *trig, bool state)
{
struct iio_dev *indio_dev = trig->private_data;
struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
return st_sensors_set_dataready_irq(indio_dev, state);
}
......
......@@ -470,7 +470,7 @@ static int ad_sd_probe_trigger(struct iio_dev *indio_dev)
disable_irq_nosync(sigma_delta->spi->irq);
}
sigma_delta->trig->dev.parent = &sigma_delta->spi->dev;
sigma_delta->trig->private_data = sigma_delta;
iio_trigger_set_drvdata(sigma_delta->trig, sigma_delta);
ret = iio_trigger_register(sigma_delta->trig);
if (ret)
......
......@@ -188,7 +188,7 @@ static u8 at91_adc_get_trigger_value_by_name(struct iio_dev *idev,
static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
{
struct iio_dev *idev = trig->private_data;
struct iio_dev *idev = iio_trigger_get_drvdata(trig);
struct at91_adc_state *st = iio_priv(idev);
struct iio_buffer *buffer = idev->buffer;
struct at91_adc_reg_desc *reg = st->registers;
......@@ -254,7 +254,7 @@ static struct iio_trigger *at91_adc_allocate_trigger(struct iio_dev *idev,
return NULL;
trig->dev.parent = idev->dev.parent;
trig->private_data = idev;
iio_trigger_set_drvdata(trig, idev);
trig->ops = &at91_adc_trigger_ops;
ret = iio_trigger_register(trig);
......
......@@ -440,7 +440,7 @@ static struct platform_driver exynos_adc_driver = {
.driver = {
.name = "exynos-adc",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(exynos_adc_match),
.of_match_table = exynos_adc_match,
.pm = &exynos_adc_pm_ops,
},
};
......
......@@ -31,7 +31,7 @@
static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
bool state)
{
struct hid_sensor_common *st = trig->private_data;
struct hid_sensor_common *st = iio_trigger_get_drvdata(trig);
int state_val;
state_val = state ? 1 : 0;
......@@ -76,7 +76,7 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
}
trig->dev.parent = indio_dev->dev.parent;
trig->private_data = attrb;
iio_trigger_set_drvdata(trig, attrb);
trig->ops = &hid_sensor_trigger_ops;
ret = iio_trigger_register(trig);
......
......@@ -40,7 +40,7 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
if (err)
goto request_irq_error;
sdata->trig->private_data = indio_dev;
iio_trigger_set_drvdata(sdata->trig, indio_dev);
sdata->trig->ops = trigger_ops;
sdata->trig->dev.parent = sdata->dev;
......
......@@ -81,7 +81,7 @@ void itg3200_buffer_unconfigure(struct iio_dev *indio_dev)
static int itg3200_data_rdy_trigger_set_state(struct iio_trigger *trig,
bool state)
{
struct iio_dev *indio_dev = trig->private_data;
struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
int ret;
u8 msc;
......@@ -129,7 +129,7 @@ int itg3200_probe_trigger(struct iio_dev *indio_dev)
st->trig->dev.parent = &st->i2c->dev;
st->trig->ops = &itg3200_trigger_ops;
st->trig->private_data = indio_dev;
iio_trigger_set_drvdata(st->trig, indio_dev);
ret = iio_trigger_register(st->trig);
if (ret)
goto error_free_irq;
......
......@@ -25,7 +25,7 @@
int st_gyro_trig_set_state(struct iio_trigger *trig, bool state)
{
struct iio_dev *indio_dev = trig->private_data;
struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
return st_sensors_set_dataready_irq(indio_dev, state);
}
......
......@@ -19,7 +19,7 @@
static int adis_data_rdy_trigger_set_state(struct iio_trigger *trig,
bool state)
{
struct adis *adis = trig->private_data;
struct adis *adis = iio_trigger_get_drvdata(trig);
return adis_enable_irq(adis, state);
}
......@@ -57,7 +57,7 @@ int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev)
adis->trig->dev.parent = &adis->spi->dev;
adis->trig->ops = &adis_trigger_ops;
adis->trig->private_data = adis;
iio_trigger_set_drvdata(adis->trig, adis);
ret = iio_trigger_register(adis->trig);
indio_dev->trig = adis->trig;
......
......@@ -103,7 +103,7 @@ static int inv_mpu6050_set_enable(struct iio_dev *indio_dev, bool enable)
static int inv_mpu_data_rdy_trigger_set_state(struct iio_trigger *trig,
bool state)
{
return inv_mpu6050_set_enable(trig->private_data, state);
return inv_mpu6050_set_enable(iio_trigger_get_drvdata(trig), state);
}
static const struct iio_trigger_ops inv_mpu_trigger_ops = {
......@@ -130,8 +130,8 @@ int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev)
if (ret)
goto error_free_trig;
st->trig->dev.parent = &st->client->dev;
st->trig->private_data = indio_dev;
st->trig->ops = &inv_mpu_trigger_ops;
iio_trigger_set_drvdata(st->trig, indio_dev);
ret = iio_trigger_register(st->trig);
if (ret)
goto error_free_irq;
......
......@@ -10,9 +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->private_data
Device specific private data.
trig->owner
Typically set to THIS_MODULE. Used to ensure correct
ownership of core allocated resources.
......
......@@ -228,7 +228,7 @@ __lis3l02dq_write_data_ready_config(struct iio_dev *indio_dev, bool state)
static int lis3l02dq_data_rdy_trigger_set_state(struct iio_trigger *trig,
bool state)
{
struct iio_dev *indio_dev = trig->private_data;
struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
int ret = 0;
u8 t;
......@@ -252,7 +252,7 @@ static int lis3l02dq_data_rdy_trigger_set_state(struct iio_trigger *trig,
*/
static int lis3l02dq_trig_try_reen(struct iio_trigger *trig)
{
struct iio_dev *indio_dev = trig->private_data;
struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
struct lis3l02dq_state *st = iio_priv(indio_dev);
int i;
......@@ -290,7 +290,7 @@ int lis3l02dq_probe_trigger(struct iio_dev *indio_dev)
st->trig->dev.parent = &st->us->dev;
st->trig->ops = &lis3l02dq_trigger_ops;
st->trig->private_data = indio_dev;
iio_trigger_set_drvdata(st->trig, indio_dev);
ret = iio_trigger_register(st->trig);
if (ret)
goto error_free_trig;
......
......@@ -87,7 +87,6 @@ struct ad799x_state;
* struct ad799x_chip_info - chip specifc information
* @channel: channel specification
* @num_channels: number of channels
* @int_vref_mv: the internal reference voltage
* @monitor_mode: whether the chip supports monitor interrupts
* @default_config: device default configuration
* @event_attrs: pointer to the monitor event attribute group
......@@ -96,7 +95,6 @@ struct ad799x_state;
struct ad799x_chip_info {
struct iio_chan_spec channel[9];
int num_channels;
u16 int_vref_mv;
u16 default_config;
const struct iio_info *info;
};
......@@ -104,12 +102,13 @@ struct ad799x_chip_info {
struct ad799x_state {
struct i2c_client *client;
const struct ad799x_chip_info *chip_info;
struct iio_trigger *trig;
struct regulator *reg;
u16 int_vref_mv;
unsigned id;
char *name;
u16 config;
u8 *rx_buf;
unsigned int transfer_size;
};
/*
......
......@@ -48,13 +48,13 @@ static int ad799x_i2c_read16(struct ad799x_state *st, u8 reg, u16 *data)
struct i2c_client *client = st->client;
int ret = 0;
ret = i2c_smbus_read_word_data(client, reg);
ret = i2c_smbus_read_word_swapped(client, reg);
if (ret < 0) {
dev_err(&client->dev, "I2C read error\n");
return ret;
}
*data = swab16((u16)ret);
*data = (u16)ret;
return 0;
}
......@@ -80,7 +80,7 @@ static int ad799x_i2c_write16(struct ad799x_state *st, u8 reg, u16 data)
struct i2c_client *client = st->client;
int ret = 0;
ret = i2c_smbus_write_word_data(client, reg, swab16(data));
ret = i2c_smbus_write_word_swapped(client, reg, data);
if (ret < 0)
dev_err(&client->dev, "I2C write error\n");
......@@ -104,6 +104,13 @@ static int ad7997_8_update_scan_mode(struct iio_dev *indio_dev,
{
struct ad799x_state *st = iio_priv(indio_dev);
kfree(st->rx_buf);
st->rx_buf = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (!st->rx_buf)
return -ENOMEM;
st->transfer_size = bitmap_weight(scan_mask, indio_dev->masklength) * 2;
switch (st->id) {
case ad7997:
case ad7998:
......@@ -460,395 +467,114 @@ static const struct iio_info ad7993_4_7_8_info = {
#define AD799X_EV_MASK (IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | \
IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING))
#define AD799X_CHANNEL(_index, _realbits, _evmask) { \
.type = IIO_VOLTAGE, \
.indexed = 1, \
.channel = (_index), \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
.scan_index = (_index), \
.scan_type = IIO_ST('u', _realbits, 16, 12 - (_realbits)), \
.event_mask = (_evmask), \
}
static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
[ad7991] = {
.channel = {
[0] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 0,
.scan_type = IIO_ST('u', 12, 16, 0),
},
[1] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 1,
.scan_type = IIO_ST('u', 12, 16, 0),
},
[2] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 2,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 2,
.scan_type = IIO_ST('u', 12, 16, 0),
},
[3] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 3,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 3,
.scan_type = IIO_ST('u', 12, 16, 0),
},
[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
AD799X_CHANNEL(0, 12, 0),
AD799X_CHANNEL(1, 12, 0),
AD799X_CHANNEL(2, 12, 0),
AD799X_CHANNEL(3, 12, 0),
IIO_CHAN_SOFT_TIMESTAMP(4),
},
.num_channels = 5,
.int_vref_mv = 4096,
.info = &ad7991_info,
},
[ad7995] = {
.channel = {
[0] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 0,
.scan_type = IIO_ST('u', 10, 16, 2),
},
[1] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 1,
.scan_type = IIO_ST('u', 10, 16, 2),
},
[2] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 2,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 2,
.scan_type = IIO_ST('u', 10, 16, 2),
},
[3] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 3,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 3,
.scan_type = IIO_ST('u', 10, 16, 2),
},
[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
AD799X_CHANNEL(0, 10, 0),
AD799X_CHANNEL(1, 10, 0),
AD799X_CHANNEL(2, 10, 0),
AD799X_CHANNEL(3, 10, 0),
IIO_CHAN_SOFT_TIMESTAMP(4),
},
.num_channels = 5,
.int_vref_mv = 1024,
.info = &ad7991_info,
},
[ad7999] = {
.channel = {
[0] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 0,
.scan_type = IIO_ST('u', 8, 16, 4),
},
[1] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 1,
.scan_type = IIO_ST('u', 8, 16, 4),
},
[2] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 2,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 2,
.scan_type = IIO_ST('u', 8, 16, 4),
},
[3] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 3,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 3,
.scan_type = IIO_ST('u', 8, 16, 4),
},
[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
AD799X_CHANNEL(0, 8, 0),
AD799X_CHANNEL(1, 8, 0),
AD799X_CHANNEL(2, 8, 0),
AD799X_CHANNEL(3, 8, 0),
IIO_CHAN_SOFT_TIMESTAMP(4),
},
.num_channels = 5,
.int_vref_mv = 1024,
.info = &ad7991_info,
},
[ad7992] = {
.channel = {
[0] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 0,
.scan_type = IIO_ST('u', 12, 16, 0),
.event_mask = AD799X_EV_MASK,
},
[1] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 1,
.scan_type = IIO_ST('u', 12, 16, 0),
.event_mask = AD799X_EV_MASK,
},
[2] = IIO_CHAN_SOFT_TIMESTAMP(2),
AD799X_CHANNEL(0, 12, AD799X_EV_MASK),
AD799X_CHANNEL(1, 12, AD799X_EV_MASK),
IIO_CHAN_SOFT_TIMESTAMP(3),
},
.num_channels = 3,
.int_vref_mv = 4096,
.default_config = AD7998_ALERT_EN,
.info = &ad7992_info,
},
[ad7993] = {
.channel = {
[0] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 0,
.scan_type = IIO_ST('u', 10, 16, 2),
.event_mask = AD799X_EV_MASK,
},
[1] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
.scan_index = 1,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_type = IIO_ST('u', 10, 16, 2),
.event_mask = AD799X_EV_MASK,
},
[2] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 2,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 2,
.scan_type = IIO_ST('u', 10, 16, 2),
.event_mask = AD799X_EV_MASK,
},
[3] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 3,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 3,
.scan_type = IIO_ST('u', 10, 16, 2),
.event_mask = AD799X_EV_MASK,
},
[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
AD799X_CHANNEL(0, 10, AD799X_EV_MASK),
AD799X_CHANNEL(1, 10, AD799X_EV_MASK),
AD799X_CHANNEL(2, 10, AD799X_EV_MASK),
AD799X_CHANNEL(3, 10, AD799X_EV_MASK),
IIO_CHAN_SOFT_TIMESTAMP(4),
},
.num_channels = 5,
.int_vref_mv = 1024,
.default_config = AD7998_ALERT_EN,
.info = &ad7993_4_7_8_info,
},
[ad7994] = {
.channel = {
[0] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 0,
.scan_type = IIO_ST('u', 12, 16, 0),
.event_mask = AD799X_EV_MASK,
},
[1] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 1,
.scan_type = IIO_ST('u', 12, 16, 0),
.event_mask = AD799X_EV_MASK,
},
[2] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 2,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 2,
.scan_type = IIO_ST('u', 12, 16, 0),
.event_mask = AD799X_EV_MASK,
},
[3] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 3,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 3,
.scan_type = IIO_ST('u', 12, 16, 0),
.event_mask = AD799X_EV_MASK,
},
[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
AD799X_CHANNEL(0, 12, AD799X_EV_MASK),
AD799X_CHANNEL(1, 12, AD799X_EV_MASK),
AD799X_CHANNEL(2, 12, AD799X_EV_MASK),
AD799X_CHANNEL(3, 12, AD799X_EV_MASK),
IIO_CHAN_SOFT_TIMESTAMP(4),
},
.num_channels = 5,
.int_vref_mv = 4096,
.default_config = AD7998_ALERT_EN,
.info = &ad7993_4_7_8_info,
},
[ad7997] = {
.channel = {
[0] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 0,
.scan_type = IIO_ST('u', 10, 16, 2),
.event_mask = AD799X_EV_MASK,
},
[1] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 1,
.scan_type = IIO_ST('u', 10, 16, 2),
.event_mask = AD799X_EV_MASK,
},
[2] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 2,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 2,
.scan_type = IIO_ST('u', 10, 16, 2),
.event_mask = AD799X_EV_MASK,
},
[3] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 3,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.scan_index = 3,
.scan_type = IIO_ST('u', 10, 16, 2),
.event_mask = AD799X_EV_MASK,
},
[4] = {
.type = IIO_VOLTAGE,