forked from Minki/linux
8cb631ccbb
If a driver does not assign an of_node to a IIO device to IIO core will automatically assign the of_node of the parent device. This automatic assignment is done in the iio_device_register() function. There is a fair amount of drivers that currently manually assign the of_node of the IIO device. All but 4 of them can make use of the automatic assignment though. The exceptions are: * mxs-lradc-adc: Which uses the of_node of the parent of the parent. * stm32-dfsdm-adc, stm32-adc and stm32-dac: Which reference the of_node assigned to the IIO device before iio_device_register() is called. All other drivers are updated to use automatic assignment. This reduces the amount of boilerplate code involved in setting up the IIO device. The patch has mostly been auto-generated with the following semantic patch // <smpl> @exists@ expression indio_dev; expression parent; @@ indio_dev = \(devm_iio_device_alloc\|iio_device_alloc\)(&parent, ...) ... -indio_dev->dev.of_node = parent.of_node; @exists@ expression indio_dev; expression parent; @@ indio_dev = \(devm_iio_device_alloc\|iio_device_alloc\)(parent, ...) ... -indio_dev->dev.of_node = parent->of_node; // </smpl> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
67 lines
1.5 KiB
C
67 lines
1.5 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Generic sigma delta modulator driver
|
|
*
|
|
* Copyright (C) 2017, STMicroelectronics - All Rights Reserved
|
|
* Author: Arnaud Pouliquen <arnaud.pouliquen@st.com>.
|
|
*/
|
|
|
|
#include <linux/iio/iio.h>
|
|
#include <linux/iio/triggered_buffer.h>
|
|
#include <linux/module.h>
|
|
#include <linux/of_device.h>
|
|
|
|
static const struct iio_info iio_sd_mod_iio_info;
|
|
|
|
static const struct iio_chan_spec iio_sd_mod_ch = {
|
|
.type = IIO_VOLTAGE,
|
|
.indexed = 1,
|
|
.scan_type = {
|
|
.sign = 'u',
|
|
.realbits = 1,
|
|
.shift = 0,
|
|
},
|
|
};
|
|
|
|
static int iio_sd_mod_probe(struct platform_device *pdev)
|
|
{
|
|
struct device *dev = &pdev->dev;
|
|
struct iio_dev *iio;
|
|
|
|
iio = devm_iio_device_alloc(dev, 0);
|
|
if (!iio)
|
|
return -ENOMEM;
|
|
|
|
iio->name = dev_name(dev);
|
|
iio->info = &iio_sd_mod_iio_info;
|
|
iio->modes = INDIO_BUFFER_HARDWARE;
|
|
|
|
iio->num_channels = 1;
|
|
iio->channels = &iio_sd_mod_ch;
|
|
|
|
platform_set_drvdata(pdev, iio);
|
|
|
|
return devm_iio_device_register(&pdev->dev, iio);
|
|
}
|
|
|
|
static const struct of_device_id sd_adc_of_match[] = {
|
|
{ .compatible = "sd-modulator" },
|
|
{ .compatible = "ads1201" },
|
|
{ }
|
|
};
|
|
MODULE_DEVICE_TABLE(of, sd_adc_of_match);
|
|
|
|
static struct platform_driver iio_sd_mod_adc = {
|
|
.driver = {
|
|
.name = "iio_sd_adc_mod",
|
|
.of_match_table = of_match_ptr(sd_adc_of_match),
|
|
},
|
|
.probe = iio_sd_mod_probe,
|
|
};
|
|
|
|
module_platform_driver(iio_sd_mod_adc);
|
|
|
|
MODULE_DESCRIPTION("Basic sigma delta modulator");
|
|
MODULE_AUTHOR("Arnaud Pouliquen <arnaud.pouliquen@st.com>");
|
|
MODULE_LICENSE("GPL v2");
|