forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/iio/adc/cpcap-adc.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2017 Tony Lindgren <tony@atomide.com>
34 *
....@@ -5,15 +6,6 @@
56 * earlier driver found in the Motorola Linux kernel:
67 *
78 * Copyright (C) 2009-2010 Motorola, Inc.
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License version 2 as
11
- * published by the Free Software Foundation.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
179 */
1810
1911 #include <linux/delay.h>
....@@ -23,9 +15,9 @@
2315 #include <linux/interrupt.h>
2416 #include <linux/kernel.h>
2517 #include <linux/module.h>
26
-#include <linux/of.h>
27
-#include <linux/of_platform.h>
18
+#include <linux/mod_devicetable.h>
2819 #include <linux/platform_device.h>
20
+#include <linux/property.h>
2921 #include <linux/regmap.h>
3022
3123 #include <linux/iio/buffer.h>
....@@ -90,7 +82,7 @@
9082
9183 #define CPCAP_ADC_MAX_RETRIES 5 /* Calibration */
9284
93
-/**
85
+/*
9486 * struct cpcap_adc_ato - timing settings for cpcap adc
9587 *
9688 * Unfortunately no cpcap documentation available, please document when
....@@ -129,7 +121,7 @@
129121 bool done;
130122 };
131123
132
-/**
124
+/*
133125 * enum cpcap_adc_channel - cpcap adc channels
134126 */
135127 enum cpcap_adc_channel {
....@@ -160,7 +152,7 @@
160152 CPCAP_ADC_CHANNEL_NUM,
161153 };
162154
163
-/**
155
+/*
164156 * enum cpcap_adc_timing - cpcap adc timing options
165157 *
166158 * CPCAP_ADC_TIMING_IMM seems to be immediate with no timings.
....@@ -698,7 +690,7 @@
698690 break;
699691 case CPCAP_ADC_BATTI_PI17:
700692 index = req->bank_index;
701
- /* fallthrough */
693
+ fallthrough;
702694 default:
703695 req->result += conv_tbl[index].cal_offset;
704696 req->result += conv_tbl[index].align_offset;
....@@ -963,21 +955,9 @@
963955
964956 static int cpcap_adc_probe(struct platform_device *pdev)
965957 {
966
- const struct of_device_id *match;
967958 struct cpcap_adc *ddata;
968959 struct iio_dev *indio_dev;
969960 int error;
970
-
971
- match = of_match_device(of_match_ptr(cpcap_adc_id_table),
972
- &pdev->dev);
973
- if (!match)
974
- return -EINVAL;
975
-
976
- if (!match->data) {
977
- dev_err(&pdev->dev, "no configuration data found\n");
978
-
979
- return -ENODEV;
980
- }
981961
982962 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*ddata));
983963 if (!indio_dev) {
....@@ -986,15 +966,15 @@
986966 return -ENOMEM;
987967 }
988968 ddata = iio_priv(indio_dev);
989
- ddata->ato = match->data;
969
+ ddata->ato = device_get_match_data(&pdev->dev);
970
+ if (!ddata->ato)
971
+ return -ENODEV;
990972 ddata->dev = &pdev->dev;
991973
992974 mutex_init(&ddata->lock);
993975 init_waitqueue_head(&ddata->wq_data_avail);
994976
995977 indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;
996
- indio_dev->dev.parent = &pdev->dev;
997
- indio_dev->dev.of_node = pdev->dev.of_node;
998978 indio_dev->channels = cpcap_adc_channels;
999979 indio_dev->num_channels = ARRAY_SIZE(cpcap_adc_channels);
1000980 indio_dev->name = dev_name(&pdev->dev);
....@@ -1016,7 +996,7 @@
1016996
1017997 error = devm_request_threaded_irq(&pdev->dev, ddata->irq, NULL,
1018998 cpcap_adc_irq_thread,
1019
- IRQF_TRIGGER_NONE,
999
+ IRQF_TRIGGER_NONE | IRQF_ONESHOT,
10201000 "cpcap-adc", indio_dev);
10211001 if (error) {
10221002 dev_err(&pdev->dev, "could not get irq: %i\n",
....@@ -1037,7 +1017,7 @@
10371017 static struct platform_driver cpcap_adc_driver = {
10381018 .driver = {
10391019 .name = "cpcap_adc",
1040
- .of_match_table = of_match_ptr(cpcap_adc_id_table),
1020
+ .of_match_table = cpcap_adc_id_table,
10411021 },
10421022 .probe = cpcap_adc_probe,
10431023 };