hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/regulator/ab8500-ext.c
....@@ -1,7 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) ST-Ericsson SA 2010
3
- *
4
- * License Terms: GNU General Public License v2
54 *
65 * Authors: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
76 *
....@@ -479,7 +478,6 @@
479478 * struct ab8500_ext_regulator_info - ab8500 regulator information
480479 * @dev: device pointer
481480 * @desc: regulator description
482
- * @rdev: regulator device
483481 * @cfg: regulator configuration (extension of regulator FW configuration)
484482 * @update_bank: bank to control on/off
485483 * @update_reg: register to control on/off
....@@ -495,7 +493,6 @@
495493 struct ab8500_ext_regulator_info {
496494 struct device *dev;
497495 struct regulator_desc desc;
498
- struct regulator_dev *rdev;
499496 struct ab8500_ext_regulator_cfg *cfg;
500497 u8 update_bank;
501498 u8 update_reg;
....@@ -530,7 +527,7 @@
530527 info->update_bank, info->update_reg,
531528 info->update_mask, regval);
532529 if (ret < 0) {
533
- dev_err(rdev_get_dev(info->rdev),
530
+ dev_err(rdev_get_dev(rdev),
534531 "couldn't set enable bits for regulator\n");
535532 return ret;
536533 }
....@@ -566,7 +563,7 @@
566563 info->update_bank, info->update_reg,
567564 info->update_mask, regval);
568565 if (ret < 0) {
569
- dev_err(rdev_get_dev(info->rdev),
566
+ dev_err(rdev_get_dev(rdev),
570567 "couldn't set disable bits for regulator\n");
571568 return ret;
572569 }
....@@ -720,7 +717,7 @@
720717 return -EINVAL;
721718 }
722719
723
-static struct regulator_ops ab8500_ext_regulator_ops = {
720
+static const struct regulator_ops ab8500_ext_regulator_ops = {
724721 .enable = ab8500_ext_regulator_enable,
725722 .disable = ab8500_ext_regulator_disable,
726723 .is_enabled = ab8500_ext_regulator_is_enabled,
....@@ -735,6 +732,7 @@
735732 [AB8500_EXT_SUPPLY1] = {
736733 .desc = {
737734 .name = "VEXTSUPPLY1",
735
+ .of_match = of_match_ptr("ab8500_ext1"),
738736 .ops = &ab8500_ext_regulator_ops,
739737 .type = REGULATOR_VOLTAGE,
740738 .id = AB8500_EXT_SUPPLY1,
....@@ -752,6 +750,7 @@
752750 [AB8500_EXT_SUPPLY2] = {
753751 .desc = {
754752 .name = "VEXTSUPPLY2",
753
+ .of_match = of_match_ptr("ab8500_ext2"),
755754 .ops = &ab8500_ext_regulator_ops,
756755 .type = REGULATOR_VOLTAGE,
757756 .id = AB8500_EXT_SUPPLY2,
....@@ -769,6 +768,7 @@
769768 [AB8500_EXT_SUPPLY3] = {
770769 .desc = {
771770 .name = "VEXTSUPPLY3",
771
+ .of_match = of_match_ptr("ab8500_ext3"),
772772 .ops = &ab8500_ext_regulator_ops,
773773 .type = REGULATOR_VOLTAGE,
774774 .id = AB8500_EXT_SUPPLY3,
....@@ -785,30 +785,13 @@
785785 },
786786 };
787787
788
-static struct of_regulator_match ab8500_ext_regulator_match[] = {
789
- { .name = "ab8500_ext1", .driver_data = (void *) AB8500_EXT_SUPPLY1, },
790
- { .name = "ab8500_ext2", .driver_data = (void *) AB8500_EXT_SUPPLY2, },
791
- { .name = "ab8500_ext3", .driver_data = (void *) AB8500_EXT_SUPPLY3, },
792
-};
793
-
794788 static int ab8500_ext_regulator_probe(struct platform_device *pdev)
795789 {
796790 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
797791 struct ab8500_regulator_platform_data *pdata = &ab8500_regulator_plat_data;
798
- struct device_node *np = pdev->dev.of_node;
799792 struct regulator_config config = { };
800
- int i, err;
801
-
802
- if (np) {
803
- err = of_regulator_match(&pdev->dev, np,
804
- ab8500_ext_regulator_match,
805
- ARRAY_SIZE(ab8500_ext_regulator_match));
806
- if (err < 0) {
807
- dev_err(&pdev->dev,
808
- "Error parsing regulator init data: %d\n", err);
809
- return err;
810
- }
811
- }
793
+ struct regulator_dev *rdev;
794
+ int i;
812795
813796 if (!ab8500) {
814797 dev_err(&pdev->dev, "null mfd parent\n");
....@@ -844,23 +827,18 @@
844827
845828 config.dev = &pdev->dev;
846829 config.driver_data = info;
847
- config.of_node = ab8500_ext_regulator_match[i].of_node;
848
- config.init_data = (np) ?
849
- ab8500_ext_regulator_match[i].init_data :
850
- &pdata->ext_regulator[i];
830
+ config.init_data = &pdata->ext_regulator[i];
851831
852832 /* register regulator with framework */
853
- info->rdev = devm_regulator_register(&pdev->dev, &info->desc,
854
- &config);
855
- if (IS_ERR(info->rdev)) {
856
- err = PTR_ERR(info->rdev);
833
+ rdev = devm_regulator_register(&pdev->dev, &info->desc,
834
+ &config);
835
+ if (IS_ERR(rdev)) {
857836 dev_err(&pdev->dev, "failed to register regulator %s\n",
858837 info->desc.name);
859
- return err;
838
+ return PTR_ERR(rdev);
860839 }
861840
862
- dev_dbg(rdev_get_dev(info->rdev),
863
- "%s-probed\n", info->desc.name);
841
+ dev_dbg(&pdev->dev, "%s-probed\n", info->desc.name);
864842 }
865843
866844 return 0;