Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: rn5t618: Convert to new style DT parsing

Use the simplified DT parsing method to remove some duplicated
code.

Since this is a MFD subdevice and its device object doesn't have an
associated DT node, the configuration instance used to register the
regulators has been changed to point to the parent device.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Beniamino Galvani and committed by
Mark Brown
9075ccea f114040e

+4 -47
+4 -47
drivers/regulator/rn5t618-regulator.c
··· 31 31 #define REG(rid, ereg, emask, vreg, vmask, min, max, step) \ 32 32 [RN5T618_##rid] = { \ 33 33 .name = #rid, \ 34 + .of_match = of_match_ptr(#rid), \ 35 + .regulators_node = of_match_ptr("regulators"), \ 34 36 .id = RN5T618_##rid, \ 35 37 .type = REGULATOR_VOLTAGE, \ 36 38 .owner = THIS_MODULE, \ ··· 62 60 REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000), 63 61 }; 64 62 65 - static struct of_regulator_match rn5t618_matches[] = { 66 - [RN5T618_DCDC1] = { .name = "DCDC1" }, 67 - [RN5T618_DCDC2] = { .name = "DCDC2" }, 68 - [RN5T618_DCDC3] = { .name = "DCDC3" }, 69 - [RN5T618_LDO1] = { .name = "LDO1" }, 70 - [RN5T618_LDO2] = { .name = "LDO2" }, 71 - [RN5T618_LDO3] = { .name = "LDO3" }, 72 - [RN5T618_LDO4] = { .name = "LDO4" }, 73 - [RN5T618_LDO5] = { .name = "LDO5" }, 74 - [RN5T618_LDORTC1] = { .name = "LDORTC1" }, 75 - [RN5T618_LDORTC2] = { .name = "LDORTC2" }, 76 - }; 77 - 78 - static int rn5t618_regulator_parse_dt(struct platform_device *pdev) 79 - { 80 - struct device_node *np, *regulators; 81 - int ret; 82 - 83 - np = of_node_get(pdev->dev.parent->of_node); 84 - if (!np) 85 - return 0; 86 - 87 - regulators = of_get_child_by_name(np, "regulators"); 88 - if (!regulators) { 89 - dev_err(&pdev->dev, "regulators node not found\n"); 90 - return -EINVAL; 91 - } 92 - 93 - ret = of_regulator_match(&pdev->dev, regulators, rn5t618_matches, 94 - ARRAY_SIZE(rn5t618_matches)); 95 - of_node_put(regulators); 96 - if (ret < 0) { 97 - dev_err(&pdev->dev, "error parsing regulator init data: %d\n", 98 - ret); 99 - } 100 - 101 - return 0; 102 - } 103 - 104 63 static int rn5t618_regulator_probe(struct platform_device *pdev) 105 64 { 106 65 struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent); 107 66 struct regulator_config config = { }; 108 67 struct regulator_dev *rdev; 109 - int ret, i; 110 - 111 - ret = rn5t618_regulator_parse_dt(pdev); 112 - if (ret) 113 - return ret; 68 + int i; 114 69 115 70 for (i = 0; i < RN5T618_REG_NUM; i++) { 116 - config.dev = &pdev->dev; 117 - config.init_data = rn5t618_matches[i].init_data; 118 - config.of_node = rn5t618_matches[i].of_node; 71 + config.dev = pdev->dev.parent; 119 72 config.regmap = rn5t618->regmap; 120 73 121 74 rdev = devm_regulator_register(&pdev->dev,