Merge tag 'staging-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[muen/linux.git] / drivers / iio / adc / stm32-dfsdm-adc.c
index b28a716a23b279420c2b819f59c32a135e37645c..fcd4a1c00ca0574d02326602f68da118a499fca4 100644 (file)
@@ -8,11 +8,11 @@
 
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
-#include <linux/interrupt.h>
+#include <linux/iio/adc/stm32-dfsdm-adc.h>
 #include <linux/iio/buffer.h>
 #include <linux/iio/hw-consumer.h>
-#include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
+#include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
@@ -254,7 +254,8 @@ static int stm32_dfsdm_start_filter(struct stm32_dfsdm *dfsdm,
                                  DFSDM_CR1_RSWSTART(1));
 }
 
-static void stm32_dfsdm_stop_filter(struct stm32_dfsdm *dfsdm, unsigned int fl_id)
+static void stm32_dfsdm_stop_filter(struct stm32_dfsdm *dfsdm,
+                                   unsigned int fl_id)
 {
        /* Disable conversion */
        regmap_update_bits(dfsdm->regmap, DFSDM_CR1(fl_id),
@@ -338,7 +339,7 @@ static int stm32_dfsdm_channel_parse_of(struct stm32_dfsdm *dfsdm,
                                            "st,adc-channel-types", chan_idx,
                                            &of_str);
        if (!ret) {
-               val  = stm32_dfsdm_str2val(of_str, stm32_dfsdm_chan_type);
+               val = stm32_dfsdm_str2val(of_str, stm32_dfsdm_chan_type);
                if (val < 0)
                        return val;
        } else {
@@ -350,7 +351,7 @@ static int stm32_dfsdm_channel_parse_of(struct stm32_dfsdm *dfsdm,
                                            "st,adc-channel-clk-src", chan_idx,
                                            &of_str);
        if (!ret) {
-               val  = stm32_dfsdm_str2val(of_str, stm32_dfsdm_chan_src);
+               val = stm32_dfsdm_str2val(of_str, stm32_dfsdm_chan_src);
                if (val < 0)
                        return val;
        } else {
@@ -1104,7 +1105,6 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev)
        char *name;
        int ret, irq, val;
 
-
        dev_data = of_device_get_match_data(dev);
        iio = devm_iio_device_alloc(dev, sizeof(*adc));
        if (!iio) {
@@ -1122,8 +1122,8 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, adc);
 
        ret = of_property_read_u32(dev->of_node, "reg", &adc->fl_id);
-       if (ret != 0) {
-               dev_err(dev, "Missing reg property\n");
+       if (ret != 0 || adc->fl_id >= adc->dfsdm->num_fls) {
+               dev_err(dev, "Missing or bad reg property\n");
                return -EINVAL;
        }
 
@@ -1172,7 +1172,6 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev)
        if (ret < 0)
                goto err_cleanup;
 
-       dev_err(dev, "of_platform_populate\n");
        if (dev_data->type == DFSDM_AUDIO) {
                ret = of_platform_populate(np, NULL, NULL, dev);
                if (ret < 0) {