forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/drivers/regulator/ab3100.c
....@@ -1,8 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * drivers/regulator/ab3100.c
34 *
45 * Copyright (C) 2008-2009 ST-Ericsson AB
5
- * License terms: GNU General Public License (GPL) version 2
66 * Low-level control of the AB3100 IC Low Dropout (LDO)
77 * regulators, external regulator and buck converter
88 * Author: Mattias Wallin <mattias.wallin@stericsson.com>
....@@ -48,7 +48,6 @@
4848 * @regreg: regulator register number in the AB3100
4949 */
5050 struct ab3100_regulator {
51
- struct regulator_dev *rdev;
5251 struct device *dev;
5352 struct ab3100_platform_data *plfdata;
5453 u8 regreg;
....@@ -354,14 +353,13 @@
354353 return 0;
355354 }
356355
357
-static struct regulator_ops regulator_ops_fixed = {
358
- .list_voltage = regulator_list_voltage_linear,
356
+static const struct regulator_ops regulator_ops_fixed = {
359357 .enable = ab3100_enable_regulator,
360358 .disable = ab3100_disable_regulator,
361359 .is_enabled = ab3100_is_enabled_regulator,
362360 };
363361
364
-static struct regulator_ops regulator_ops_variable = {
362
+static const struct regulator_ops regulator_ops_variable = {
365363 .enable = ab3100_enable_regulator,
366364 .disable = ab3100_disable_regulator,
367365 .is_enabled = ab3100_is_enabled_regulator,
....@@ -370,7 +368,7 @@
370368 .list_voltage = regulator_list_voltage_table,
371369 };
372370
373
-static struct regulator_ops regulator_ops_variable_sleepable = {
371
+static const struct regulator_ops regulator_ops_variable_sleepable = {
374372 .enable = ab3100_enable_regulator,
375373 .disable = ab3100_disable_regulator,
376374 .is_enabled = ab3100_is_enabled_regulator,
....@@ -386,14 +384,14 @@
386384 * is an on/off switch plain an simple. The external
387385 * voltage is defined in the board set-up if any.
388386 */
389
-static struct regulator_ops regulator_ops_external = {
387
+static const struct regulator_ops regulator_ops_external = {
390388 .enable = ab3100_enable_regulator,
391389 .disable = ab3100_disable_regulator,
392390 .is_enabled = ab3100_is_enabled_regulator,
393391 .get_voltage = ab3100_get_voltage_regulator_external,
394392 };
395393
396
-static struct regulator_desc
394
+static const struct regulator_desc
397395 ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
398396 {
399397 .name = "LDO_A",
....@@ -402,7 +400,7 @@
402400 .n_voltages = 1,
403401 .type = REGULATOR_VOLTAGE,
404402 .owner = THIS_MODULE,
405
- .min_uV = LDO_A_VOLTAGE,
403
+ .fixed_uV = LDO_A_VOLTAGE,
406404 .enable_time = 200,
407405 },
408406 {
....@@ -412,7 +410,7 @@
412410 .n_voltages = 1,
413411 .type = REGULATOR_VOLTAGE,
414412 .owner = THIS_MODULE,
415
- .min_uV = LDO_C_VOLTAGE,
413
+ .fixed_uV = LDO_C_VOLTAGE,
416414 .enable_time = 200,
417415 },
418416 {
....@@ -422,7 +420,7 @@
422420 .n_voltages = 1,
423421 .type = REGULATOR_VOLTAGE,
424422 .owner = THIS_MODULE,
425
- .min_uV = LDO_D_VOLTAGE,
423
+ .fixed_uV = LDO_D_VOLTAGE,
426424 .enable_time = 200,
427425 },
428426 {
....@@ -500,7 +498,7 @@
500498 struct device_node *np,
501499 unsigned long id)
502500 {
503
- struct regulator_desc *desc;
501
+ const struct regulator_desc *desc;
504502 struct ab3100_regulator *reg;
505503 struct regulator_dev *rdev;
506504 struct regulator_config config = { };
....@@ -545,8 +543,6 @@
545543 return err;
546544 }
547545
548
- /* Then set a pointer back to the registered regulator */
549
- reg->rdev = rdev;
550546 return 0;
551547 }
552548
....@@ -609,18 +605,6 @@
609605 LDO_D_SETTING,
610606 };
611607
612
-static int ab3100_regulators_remove(struct platform_device *pdev)
613
-{
614
- int i;
615
-
616
- for (i = 0; i < AB3100_NUM_REGULATORS; i++) {
617
- struct ab3100_regulator *reg = &ab3100_regulators[i];
618
-
619
- reg->rdev = NULL;
620
- }
621
- return 0;
622
-}
623
-
624608 static int
625609 ab3100_regulator_of_probe(struct platform_device *pdev, struct device_node *np)
626610 {
....@@ -647,10 +631,8 @@
647631 pdev, NULL, ab3100_regulator_matches[i].init_data,
648632 ab3100_regulator_matches[i].of_node,
649633 (unsigned long)ab3100_regulator_matches[i].driver_data);
650
- if (err) {
651
- ab3100_regulators_remove(pdev);
634
+ if (err)
652635 return err;
653
- }
654636 }
655637
656638 return 0;
....@@ -705,14 +687,12 @@
705687
706688 /* Register the regulators */
707689 for (i = 0; i < AB3100_NUM_REGULATORS; i++) {
708
- struct regulator_desc *desc = &ab3100_regulator_desc[i];
690
+ const struct regulator_desc *desc = &ab3100_regulator_desc[i];
709691
710692 err = ab3100_regulator_register(pdev, plfdata, NULL, NULL,
711693 desc->id);
712
- if (err) {
713
- ab3100_regulators_remove(pdev);
694
+ if (err)
714695 return err;
715
- }
716696 }
717697
718698 return 0;
....@@ -723,7 +703,6 @@
723703 .name = "ab3100-regulators",
724704 },
725705 .probe = ab3100_regulators_probe,
726
- .remove = ab3100_regulators_remove,
727706 };
728707
729708 static __init int ab3100_regulators_init(void)