forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/iio/health/afe4404.c
....@@ -1,17 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * AFE4404 Heart Rate Monitors and Low-Cost Pulse Oximeters
34 *
4
- * Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/
5
+ * Copyright (C) 2015-2016 Texas Instruments Incorporated - https://www.ti.com/
56 * Andrew F. Davis <afd@ti.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
10
- *
11
- * This program is distributed in the hope that it will be useful, but
12
- * WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- * General Public License for more details.
157 */
168
179 #include <linux/device.h>
....@@ -258,20 +250,20 @@
258250 int *val, int *val2, long mask)
259251 {
260252 struct afe4404_data *afe = iio_priv(indio_dev);
261
- unsigned int value_reg = afe4404_channel_values[chan->address];
262
- unsigned int led_field = afe4404_channel_leds[chan->address];
263
- unsigned int offdac_field = afe4404_channel_offdacs[chan->address];
253
+ unsigned int value_reg, led_field, offdac_field;
264254 int ret;
265255
266256 switch (chan->type) {
267257 case IIO_INTENSITY:
268258 switch (mask) {
269259 case IIO_CHAN_INFO_RAW:
260
+ value_reg = afe4404_channel_values[chan->address];
270261 ret = regmap_read(afe->regmap, value_reg, val);
271262 if (ret)
272263 return ret;
273264 return IIO_VAL_INT;
274265 case IIO_CHAN_INFO_OFFSET:
266
+ offdac_field = afe4404_channel_offdacs[chan->address];
275267 ret = regmap_field_read(afe->fields[offdac_field], val);
276268 if (ret)
277269 return ret;
....@@ -281,6 +273,7 @@
281273 case IIO_CURRENT:
282274 switch (mask) {
283275 case IIO_CHAN_INFO_RAW:
276
+ led_field = afe4404_channel_leds[chan->address];
284277 ret = regmap_field_read(afe->fields[led_field], val);
285278 if (ret)
286279 return ret;
....@@ -303,19 +296,20 @@
303296 int val, int val2, long mask)
304297 {
305298 struct afe4404_data *afe = iio_priv(indio_dev);
306
- unsigned int led_field = afe4404_channel_leds[chan->address];
307
- unsigned int offdac_field = afe4404_channel_offdacs[chan->address];
299
+ unsigned int led_field, offdac_field;
308300
309301 switch (chan->type) {
310302 case IIO_INTENSITY:
311303 switch (mask) {
312304 case IIO_CHAN_INFO_OFFSET:
305
+ offdac_field = afe4404_channel_offdacs[chan->address];
313306 return regmap_field_write(afe->fields[offdac_field], val);
314307 }
315308 break;
316309 case IIO_CURRENT:
317310 switch (mask) {
318311 case IIO_CHAN_INFO_RAW:
312
+ led_field = afe4404_channel_leds[chan->address];
319313 return regmap_field_write(afe->fields[led_field], val);
320314 }
321315 break;
....@@ -527,7 +521,6 @@
527521 }
528522
529523 indio_dev->modes = INDIO_DIRECT_MODE;
530
- indio_dev->dev.parent = afe->dev;
531524 indio_dev->channels = afe4404_channels;
532525 indio_dev->num_channels = ARRAY_SIZE(afe4404_channels);
533526 indio_dev->name = AFE4404_DRIVER_NAME;