forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-09 244b2c5ca8b14627e4a17755e5922221e121c771
kernel/drivers/iio/adc/mxs-lradc-adc.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Freescale MXS LRADC ADC driver
34 *
....@@ -7,16 +8,6 @@
78 * Authors:
89 * Marek Vasut <marex@denx.de>
910 * Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License as published by
13
- * the Free Software Foundation; either version 2 of the License, or
14
- * (at your option) any later version.
15
- *
16
- * This program is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU General Public License for more details.
2011 */
2112
2213 #include <linux/completion.h>
....@@ -466,6 +457,8 @@
466457
467458 trig = devm_iio_trigger_alloc(&iio->dev, "%s-dev%i", iio->name,
468459 iio->id);
460
+ if (!trig)
461
+ return -ENOMEM;
469462
470463 trig->dev.parent = adc->dev;
471464 iio_trigger_set_drvdata(trig, iio);
....@@ -576,8 +569,6 @@
576569
577570 static const struct iio_buffer_setup_ops mxs_lradc_adc_buffer_ops = {
578571 .preenable = &mxs_lradc_adc_buffer_preenable,
579
- .postenable = &iio_triggered_buffer_postenable,
580
- .predisable = &iio_triggered_buffer_predisable,
581572 .postdisable = &mxs_lradc_adc_buffer_postdisable,
582573 .validate_scan_mask = &mxs_lradc_adc_validate_scan_mask,
583574 };
....@@ -730,7 +721,6 @@
730721 platform_set_drvdata(pdev, iio);
731722
732723 iio->name = pdev->name;
733
- iio->dev.parent = dev;
734724 iio->dev.of_node = dev->parent->of_node;
735725 iio->info = &mxs_lradc_adc_iio_info;
736726 iio->modes = INDIO_DIRECT_MODE;
....@@ -767,13 +757,13 @@
767757
768758 ret = mxs_lradc_adc_trigger_init(iio);
769759 if (ret)
770
- goto err_trig;
760
+ return ret;
771761
772762 ret = iio_triggered_buffer_setup(iio, &iio_pollfunc_store_time,
773763 &mxs_lradc_adc_trigger_handler,
774764 &mxs_lradc_adc_buffer_ops);
775765 if (ret)
776
- return ret;
766
+ goto err_trig;
777767
778768 adc->vref_mv = mxs_lradc_adc_vref_mv[lradc->soc];
779769
....@@ -811,9 +801,9 @@
811801
812802 err_dev:
813803 mxs_lradc_adc_hw_stop(adc);
814
- mxs_lradc_adc_trigger_remove(iio);
815
-err_trig:
816804 iio_triggered_buffer_cleanup(iio);
805
+err_trig:
806
+ mxs_lradc_adc_trigger_remove(iio);
817807 return ret;
818808 }
819809
....@@ -824,8 +814,8 @@
824814
825815 iio_device_unregister(iio);
826816 mxs_lradc_adc_hw_stop(adc);
827
- mxs_lradc_adc_trigger_remove(iio);
828817 iio_triggered_buffer_cleanup(iio);
818
+ mxs_lradc_adc_trigger_remove(iio);
829819
830820 return 0;
831821 }