Skip to content

Commit

Permalink
Merge tag 'iio-for-v3.7a' of git://git.kernel.org/pub/scm/linux/kerne…
Browse files Browse the repository at this point in the history
…l/git/jic23/iio into staging-next

First set of IIO rework and new drivers for 3.7 cycle.

New MXS adc driver form Marek Vasut with a minor addition
to the example code to support 4 byte reads.

First of I suspect many devm conversion patches form Julia Lawall
Some module_platform_driver uses that somehow got missed the
first time around.

Couple of other useful cleanups.
  • Loading branch information
Greg Kroah-Hartman committed Aug 16, 2012
2 parents c4f9e64 + bc2c90c commit 1021bb5
Show file tree
Hide file tree
Showing 30 changed files with 678 additions and 89 deletions.
15 changes: 15 additions & 0 deletions Documentation/devicetree/bindings/staging/iio/adc/mxs-lradc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
* Freescale i.MX28 LRADC device driver

Required properties:
- compatible: Should be "fsl,imx28-lradc"
- reg: Address and length of the register set for the device
- interrupts: Should contain the LRADC interrupts

Examples:

lradc@80050000 {
compatible = "fsl,imx28-lradc";
reg = <0x80050000 0x2000>;
interrupts = <10 14 15 16 17 18 19
20 21 22 23 24 25>;
};
42 changes: 8 additions & 34 deletions drivers/iio/adc/at91_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,6 @@ static int __devinit at91_adc_probe(struct platform_device *pdev)
goto error_free_device;
}

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(&pdev->dev, "No resource defined\n");
ret = -ENXIO;
goto error_ret;
}

platform_set_drvdata(pdev, idev);

idev->dev.parent = &pdev->dev;
Expand All @@ -566,18 +559,12 @@ static int __devinit at91_adc_probe(struct platform_device *pdev)
goto error_free_device;
}

if (!request_mem_region(res->start, resource_size(res),
"AT91 adc registers")) {
dev_err(&pdev->dev, "Resources are unavailable.\n");
ret = -EBUSY;
goto error_free_device;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

st->reg_base = ioremap(res->start, resource_size(res));
st->reg_base = devm_request_and_ioremap(&pdev->dev, res);
if (!st->reg_base) {
dev_err(&pdev->dev, "Failed to map registers.\n");
ret = -ENOMEM;
goto error_release_mem;
goto error_free_device;
}

/*
Expand All @@ -592,10 +579,10 @@ static int __devinit at91_adc_probe(struct platform_device *pdev)
idev);
if (ret) {
dev_err(&pdev->dev, "Failed to allocate IRQ.\n");
goto error_unmap_reg;
goto error_free_device;
}

st->clk = clk_get(&pdev->dev, "adc_clk");
st->clk = devm_clk_get(&pdev->dev, "adc_clk");
if (IS_ERR(st->clk)) {
dev_err(&pdev->dev, "Failed to get the clock.\n");
ret = PTR_ERR(st->clk);
Expand All @@ -605,7 +592,7 @@ static int __devinit at91_adc_probe(struct platform_device *pdev)
ret = clk_prepare(st->clk);
if (ret) {
dev_err(&pdev->dev, "Could not prepare the clock.\n");
goto error_free_clk;
goto error_free_irq;
}

ret = clk_enable(st->clk);
Expand All @@ -614,7 +601,7 @@ static int __devinit at91_adc_probe(struct platform_device *pdev)
goto error_unprepare_clk;
}

st->adc_clk = clk_get(&pdev->dev, "adc_op_clk");
st->adc_clk = devm_clk_get(&pdev->dev, "adc_op_clk");
if (IS_ERR(st->adc_clk)) {
dev_err(&pdev->dev, "Failed to get the ADC clock.\n");
ret = PTR_ERR(st->clk);
Expand All @@ -624,7 +611,7 @@ static int __devinit at91_adc_probe(struct platform_device *pdev)
ret = clk_prepare(st->adc_clk);
if (ret) {
dev_err(&pdev->dev, "Could not prepare the ADC clock.\n");
goto error_free_adc_clk;
goto error_disable_clk;
}

ret = clk_enable(st->adc_clk);
Expand Down Expand Up @@ -697,20 +684,12 @@ static int __devinit at91_adc_probe(struct platform_device *pdev)
clk_disable(st->adc_clk);
error_unprepare_adc_clk:
clk_unprepare(st->adc_clk);
error_free_adc_clk:
clk_put(st->adc_clk);
error_disable_clk:
clk_disable(st->clk);
error_unprepare_clk:
clk_unprepare(st->clk);
error_free_clk:
clk_put(st->clk);
error_free_irq:
free_irq(st->irq, idev);
error_unmap_reg:
iounmap(st->reg_base);
error_release_mem:
release_mem_region(res->start, resource_size(res));
error_free_device:
iio_device_free(idev);
error_ret:
Expand All @@ -720,20 +699,15 @@ static int __devinit at91_adc_probe(struct platform_device *pdev)
static int __devexit at91_adc_remove(struct platform_device *pdev)
{
struct iio_dev *idev = platform_get_drvdata(pdev);
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
struct at91_adc_state *st = iio_priv(idev);

iio_device_unregister(idev);
at91_adc_trigger_remove(idev);
at91_adc_buffer_remove(idev);
clk_disable_unprepare(st->adc_clk);
clk_put(st->adc_clk);
clk_disable(st->clk);
clk_unprepare(st->clk);
clk_put(st->clk);
free_irq(st->irq, idev);
iounmap(st->reg_base);
release_mem_region(res->start, resource_size(res));
iio_device_free(idev);

return 0;
Expand Down
10 changes: 10 additions & 0 deletions drivers/staging/iio/Documentation/generic_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ void process_scan(char *data,
print2byte(*(uint16_t *)(data + channels[k].location),
&channels[k]);
break;
case 4:
if (!channels[k].is_signed) {
uint32_t val = *(uint32_t *)
(data + channels[k].location);
printf("%05f ", ((float)val +
channels[k].offset)*
channels[k].scale);

}
break;
case 8:
if (channels[k].is_signed) {
int64_t val = *(int64_t *)
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/iio/accel/adis16201_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ static int adis16201_write_raw(struct iio_dev *indio_dev,
return -EINVAL;
}

static struct iio_chan_spec adis16201_channels[] = {
static const struct iio_chan_spec adis16201_channels[] = {
{
.type = IIO_VOLTAGE,
.indexed = 1,
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/iio/accel/adis16203_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ static int adis16203_read_raw(struct iio_dev *indio_dev,
}
}

static struct iio_chan_spec adis16203_channels[] = {
static const struct iio_chan_spec adis16203_channels[] = {
{
.type = IIO_VOLTAGE,
.indexed = 1,
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/iio/accel/adis16204_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ static int adis16204_write_raw(struct iio_dev *indio_dev,
return -EINVAL;
}

static struct iio_chan_spec adis16204_channels[] = {
static const struct iio_chan_spec adis16204_channels[] = {
{
.type = IIO_VOLTAGE,
.indexed = 1, /* Note was not previously indexed */
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/iio/accel/adis16209_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ static int adis16209_read_raw(struct iio_dev *indio_dev,
return -EINVAL;
}

static struct iio_chan_spec adis16209_channels[] = {
static const struct iio_chan_spec adis16209_channels[] = {
{
.type = IIO_VOLTAGE,
.indexed = 1,
Expand Down
9 changes: 3 additions & 6 deletions drivers/staging/iio/accel/adis16220_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,7 @@ static ssize_t adis16220_accel_bin_read(struct file *filp, struct kobject *kobj,
loff_t off,
size_t count)
{
struct device *dev = container_of(kobj, struct device, kobj);
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct iio_dev *indio_dev = dev_to_iio_dev(kobj_to_dev(kobj));

return adis16220_capture_buffer_read(indio_dev, buf,
off, count,
Expand All @@ -394,8 +393,7 @@ static ssize_t adis16220_adc1_bin_read(struct file *filp, struct kobject *kobj,
char *buf, loff_t off,
size_t count)
{
struct device *dev = container_of(kobj, struct device, kobj);
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct iio_dev *indio_dev = dev_to_iio_dev(kobj_to_dev(kobj));

return adis16220_capture_buffer_read(indio_dev, buf,
off, count,
Expand All @@ -416,8 +414,7 @@ static ssize_t adis16220_adc2_bin_read(struct file *filp, struct kobject *kobj,
char *buf, loff_t off,
size_t count)
{
struct device *dev = container_of(kobj, struct device, kobj);
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct iio_dev *indio_dev = dev_to_iio_dev(kobj_to_dev(kobj));

return adis16220_capture_buffer_read(indio_dev, buf,
off, count,
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/iio/accel/adis16240_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ static int adis16240_write_raw(struct iio_dev *indio_dev,
return -EINVAL;
}

static struct iio_chan_spec adis16240_channels[] = {
static const struct iio_chan_spec adis16240_channels[] = {
{
.type = IIO_VOLTAGE,
.indexed = 1,
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/iio/accel/kxsd9.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev,
.address = KXSD9_REG_##axis, \
}

static struct iio_chan_spec kxsd9_channels[] = {
static const struct iio_chan_spec kxsd9_channels[] = {
KXSD9_ACCEL_CHAN(X), KXSD9_ACCEL_CHAN(Y), KXSD9_ACCEL_CHAN(Z),
{
.type = IIO_VOLTAGE,
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/iio/accel/lis3l02dq_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *private)
.event_mask = LIS3L02DQ_EVENT_MASK, \
}

static struct iio_chan_spec lis3l02dq_channels[] = {
static const struct iio_chan_spec lis3l02dq_channels[] = {
LIS3L02DQ_CHAN(0, IIO_MOD_X),
LIS3L02DQ_CHAN(1, IIO_MOD_Y),
LIS3L02DQ_CHAN(2, IIO_MOD_Z),
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/iio/accel/sca3000_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ static IIO_DEVICE_ATTR(revision, S_IRUGO, sca3000_show_rev, NULL, 0);
.event_mask = SCA3000_EVENT_MASK, \
}

static struct iio_chan_spec sca3000_channels[] = {
static const struct iio_chan_spec sca3000_channels[] = {
SCA3000_CHAN(0, IIO_MOD_X),
SCA3000_CHAN(1, IIO_MOD_Y),
SCA3000_CHAN(2, IIO_MOD_Z),
Expand Down
12 changes: 12 additions & 0 deletions drivers/staging/iio/adc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,18 @@ config LPC32XX_ADC
activate only one via device tree selection. Provides direct access
via sysfs.

config MXS_LRADC
tristate "Freescale i.MX28 LRADC"
depends on ARCH_MXS
select IIO_BUFFER
select IIO_TRIGGERED_BUFFER
help
Say yes here to build support for i.MX28 LRADC convertor
built into these chips.

To compile this driver as a module, choose M here: the
module will be called mxs-lradc.

config SPEAR_ADC
tristate "ST SPEAr ADC"
depends on PLAT_SPEAR
Expand Down
1 change: 1 addition & 0 deletions drivers/staging/iio/adc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ obj-$(CONFIG_ADT7310) += adt7310.o
obj-$(CONFIG_ADT7410) += adt7410.o
obj-$(CONFIG_AD7280) += ad7280a.o
obj-$(CONFIG_LPC32XX_ADC) += lpc32xx_adc.o
obj-$(CONFIG_MXS_LRADC) += mxs-lradc.o
obj-$(CONFIG_SPEAR_ADC) += spear_adc.o
2 changes: 1 addition & 1 deletion drivers/staging/iio/adc/ad7192.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ static const struct iio_info ad7195_info = {
.scan_index = _si, \
.scan_type = IIO_ST('s', 24, 32, 0)}

static struct iio_chan_spec ad7192_channels[] = {
static const struct iio_chan_spec ad7192_channels[] = {
AD7192_CHAN_DIFF(1, 2, NULL, AD7192_CH_AIN1P_AIN2M, 0),
AD7192_CHAN_DIFF(3, 4, NULL, AD7192_CH_AIN3P_AIN4M, 1),
AD7192_CHAN_TEMP(0, AD7192_CH_TEMP, 2),
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/iio/adc/ad7298_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}, \
}

static struct iio_chan_spec ad7298_channels[] = {
static const struct iio_chan_spec ad7298_channels[] = {
{
.type = IIO_TEMP,
.indexed = 1,
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/iio/adc/ad7606.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct ad7606_platform_data {
struct ad7606_chip_info {
const char *name;
u16 int_vref_mv;
struct iio_chan_spec *channels;
const struct iio_chan_spec *channels;
unsigned num_channels;
};

Expand Down
6 changes: 3 additions & 3 deletions drivers/staging/iio/adc/ad7606_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ static const struct attribute_group ad7606_attribute_group_range = {
.scan_type = IIO_ST('s', 16, 16, 0), \
}

static struct iio_chan_spec ad7606_8_channels[] = {
static const struct iio_chan_spec ad7606_8_channels[] = {
AD7606_CHANNEL(0),
AD7606_CHANNEL(1),
AD7606_CHANNEL(2),
Expand All @@ -253,7 +253,7 @@ static struct iio_chan_spec ad7606_8_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(8),
};

static struct iio_chan_spec ad7606_6_channels[] = {
static const struct iio_chan_spec ad7606_6_channels[] = {
AD7606_CHANNEL(0),
AD7606_CHANNEL(1),
AD7606_CHANNEL(2),
Expand All @@ -263,7 +263,7 @@ static struct iio_chan_spec ad7606_6_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(6),
};

static struct iio_chan_spec ad7606_4_channels[] = {
static const struct iio_chan_spec ad7606_4_channels[] = {
AD7606_CHANNEL(0),
AD7606_CHANNEL(1),
AD7606_CHANNEL(2),
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/iio/adc/lpc32xx_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static const struct iio_info lpc32xx_adc_iio_info = {
.scan_index = _index, \
}

static struct iio_chan_spec lpc32xx_adc_iio_channels[] = {
static const struct iio_chan_spec lpc32xx_adc_iio_channels[] = {
LPC32XX_ADC_CHANNEL(0),
LPC32XX_ADC_CHANNEL(1),
LPC32XX_ADC_CHANNEL(2),
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/iio/adc/max1363.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ enum max1363_modes {
*/
struct max1363_chip_info {
const struct iio_info *info;
struct iio_chan_spec *channels;
const struct iio_chan_spec *channels;
int num_channels;
const enum max1363_modes *mode_list;
enum max1363_modes default_mode;
Expand Down
Loading

0 comments on commit 1021bb5

Please sign in to comment.