forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/iio/adc/twl4030-madc.c
....@@ -1,10 +1,11 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 *
34 * TWL4030 MADC module driver-This driver monitors the real time
45 * conversion of analog signals like battery temperature,
56 * battery type, battery level etc.
67 *
7
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8
+ * Copyright (C) 2011 Texas Instruments Incorporated - https://www.ti.com/
89 * J Keerthy <j-keerthy@ti.com>
910 *
1011 * Based on twl4030-madc.c
....@@ -12,21 +13,6 @@
1213 * Mikko Ylinen <mikko.k.ylinen@nokia.com>
1314 *
1415 * Amit Kucheria <amit.kucheria@canonical.com>
15
- *
16
- * This program is free software; you can redistribute it and/or
17
- * modify it under the terms of the GNU General Public License
18
- * version 2 as published by the Free Software Foundation.
19
- *
20
- * This program is distributed in the hope that it will be useful, but
21
- * WITHOUT ANY WARRANTY; without even the implied warranty of
22
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23
- * General Public License for more details.
24
- *
25
- * You should have received a copy of the GNU General Public License
26
- * along with this program; if not, write to the Free Software
27
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
28
- * 02110-1301 USA
29
- *
3016 */
3117
3218 #include <linux/device.h>
....@@ -167,7 +153,7 @@
167153 * struct twl4030_madc_data - a container for madc info
168154 * @dev: Pointer to device structure for madc
169155 * @lock: Mutex protecting this data structure
170
- * @regulator: Pointer to bias regulator for madc
156
+ * @usb3v1: Pointer to bias regulator for madc
171157 * @requests: Array of request struct corresponding to SW1, SW2 and RT
172158 * @use_second_irq: IRQ selection (main or co-processor)
173159 * @imr: Interrupt mask register of MADC
....@@ -175,7 +161,7 @@
175161 */
176162 struct twl4030_madc_data {
177163 struct device *dev;
178
- struct mutex lock; /* mutex protecting this data structure */
164
+ struct mutex lock;
179165 struct regulator *usb3v1;
180166 struct twl4030_madc_request requests[TWL4030_MADC_NUM_METHODS];
181167 bool use_second_irq;
....@@ -486,7 +472,7 @@
486472 struct twl4030_madc_data *madc = _madc;
487473 const struct twl4030_madc_conversion_method *method;
488474 u8 isr_val, imr_val;
489
- int i, len, ret;
475
+ int i, ret;
490476 struct twl4030_madc_request *r;
491477
492478 mutex_lock(&madc->lock);
....@@ -509,7 +495,7 @@
509495 ret = twl4030_madc_disable_irq(madc, i);
510496 if (ret < 0)
511497 dev_dbg(madc->dev, "Disable interrupt failed %d\n", i);
512
- madc->requests[i].result_pending = 1;
498
+ madc->requests[i].result_pending = true;
513499 }
514500 for (i = 0; i < TWL4030_MADC_NUM_METHODS; i++) {
515501 r = &madc->requests[i];
....@@ -518,11 +504,11 @@
518504 continue;
519505 method = &twl4030_conversion_methods[r->method];
520506 /* Read results */
521
- len = twl4030_madc_read_channels(madc, method->rbase,
522
- r->channels, r->rbuf, r->raw);
507
+ twl4030_madc_read_channels(madc, method->rbase,
508
+ r->channels, r->rbuf, r->raw);
523509 /* Free request */
524
- r->result_pending = 0;
525
- r->active = 0;
510
+ r->result_pending = false;
511
+ r->active = false;
526512 }
527513 mutex_unlock(&madc->lock);
528514
....@@ -535,15 +521,15 @@
535521 */
536522 for (i = 0; i < TWL4030_MADC_NUM_METHODS; i++) {
537523 r = &madc->requests[i];
538
- if (r->active == 0)
524
+ if (!r->active)
539525 continue;
540526 method = &twl4030_conversion_methods[r->method];
541527 /* Read results */
542
- len = twl4030_madc_read_channels(madc, method->rbase,
543
- r->channels, r->rbuf, r->raw);
528
+ twl4030_madc_read_channels(madc, method->rbase,
529
+ r->channels, r->rbuf, r->raw);
544530 /* Free request */
545
- r->result_pending = 0;
546
- r->active = 0;
531
+ r->result_pending = false;
532
+ r->active = false;
547533 }
548534 mutex_unlock(&madc->lock);
549535
....@@ -666,16 +652,16 @@
666652 ret = twl4030_madc_start_conversion(twl4030_madc, req->method);
667653 if (ret < 0)
668654 goto out;
669
- twl4030_madc->requests[req->method].active = 1;
655
+ twl4030_madc->requests[req->method].active = true;
670656 /* Wait until conversion is ready (ctrl register returns EOC) */
671657 ret = twl4030_madc_wait_conversion_ready(twl4030_madc, 5, method->ctrl);
672658 if (ret) {
673
- twl4030_madc->requests[req->method].active = 0;
659
+ twl4030_madc->requests[req->method].active = false;
674660 goto out;
675661 }
676662 ret = twl4030_madc_read_channels(twl4030_madc, method->rbase,
677663 req->channels, req->rbuf, req->raw);
678
- twl4030_madc->requests[req->method].active = 0;
664
+ twl4030_madc->requests[req->method].active = false;
679665
680666 out:
681667 mutex_unlock(&twl4030_madc->lock);
....@@ -786,8 +772,6 @@
786772 madc->dev = &pdev->dev;
787773
788774 iio_dev->name = dev_name(&pdev->dev);
789
- iio_dev->dev.parent = &pdev->dev;
790
- iio_dev->dev.of_node = pdev->dev.of_node;
791775 iio_dev->info = &twl4030_madc_iio_info;
792776 iio_dev->modes = INDIO_DIRECT_MODE;
793777 iio_dev->channels = twl4030_madc_iio_channels;