aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/isl9305.c
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2014-09-10 07:18:56 -0400
committerMark Brown <broonie@kernel.org>2014-09-10 07:18:56 -0400
commit93a127b11ac034b160ccdd32e27d791b98f52cf5 (patch)
treedf1b3afee7ca2ac7992b0a5b0ef429a8665cee5b /drivers/regulator/isl9305.c
parent3f7c69637511a39f4400dc8312bbcecaa592ab61 (diff)
regulator: isl9305: Convert to new style DT parsing
This removes some code and replaces it with data. Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator/isl9305.c')
-rw-r--r--drivers/regulator/isl9305.c62
1 files changed, 11 insertions, 51 deletions
diff --git a/drivers/regulator/isl9305.c b/drivers/regulator/isl9305.c
index b0d12d186b68..92fefd98da58 100644
--- a/drivers/regulator/isl9305.c
+++ b/drivers/regulator/isl9305.c
@@ -73,6 +73,8 @@ static const struct regulator_ops isl9305_ops = {
73static const struct regulator_desc isl9305_regulators[] = { 73static const struct regulator_desc isl9305_regulators[] = {
74 [ISL9305_DCD1] = { 74 [ISL9305_DCD1] = {
75 .name = "DCD1", 75 .name = "DCD1",
76 .of_match = of_match_ptr("dcd1"),
77 .regulators_node = of_match_ptr("regulators"),
76 .n_voltages = 0x70, 78 .n_voltages = 0x70,
77 .min_uV = 825000, 79 .min_uV = 825000,
78 .uV_step = 25000, 80 .uV_step = 25000,
@@ -85,6 +87,8 @@ static const struct regulator_desc isl9305_regulators[] = {
85 }, 87 },
86 [ISL9305_DCD2] = { 88 [ISL9305_DCD2] = {
87 .name = "DCD2", 89 .name = "DCD2",
90 .of_match = of_match_ptr("dcd2"),
91 .regulators_node = of_match_ptr("regulators"),
88 .n_voltages = 0x70, 92 .n_voltages = 0x70,
89 .min_uV = 825000, 93 .min_uV = 825000,
90 .uV_step = 25000, 94 .uV_step = 25000,
@@ -97,6 +101,8 @@ static const struct regulator_desc isl9305_regulators[] = {
97 }, 101 },
98 [ISL9305_LDO1] = { 102 [ISL9305_LDO1] = {
99 .name = "LDO1", 103 .name = "LDO1",
104 .of_match = of_match_ptr("ldo1"),
105 .regulators_node = of_match_ptr("regulators"),
100 .n_voltages = 0x37, 106 .n_voltages = 0x37,
101 .min_uV = 900000, 107 .min_uV = 900000,
102 .uV_step = 50000, 108 .uV_step = 50000,
@@ -109,6 +115,8 @@ static const struct regulator_desc isl9305_regulators[] = {
109 }, 115 },
110 [ISL9305_LDO2] = { 116 [ISL9305_LDO2] = {
111 .name = "LDO2", 117 .name = "LDO2",
118 .of_match = of_match_ptr("ldo2"),
119 .regulators_node = of_match_ptr("regulators"),
112 .n_voltages = 0x37, 120 .n_voltages = 0x37,
113 .min_uV = 900000, 121 .min_uV = 900000,
114 .uV_step = 50000, 122 .uV_step = 50000,
@@ -121,45 +129,6 @@ static const struct regulator_desc isl9305_regulators[] = {
121 }, 129 },
122}; 130};
123 131
124#ifdef CONFIG_OF
125static struct of_regulator_match isl9305_reg_matches[] = {
126 [ISL9305_DCD1] = { .name = "dcd1" },
127 [ISL9305_DCD2] = { .name = "dcd2" },
128 [ISL9305_LDO1] = { .name = "ldo1" },
129 [ISL9305_LDO2] = { .name = "ldo2" },
130};
131
132static struct of_regulator_match *isl9305_parse_dt(struct i2c_client *i2c)
133{
134 struct device_node *node = i2c->dev.of_node;
135 struct of_regulator_match *matches;
136 struct device_node *regs;
137 int count;
138
139 regs = of_get_child_by_name(node, "regulators");
140 if (!regs)
141 return NULL;
142
143 matches = devm_kmemdup(&i2c->dev, isl9305_reg_matches,
144 sizeof(isl9305_reg_matches), GFP_KERNEL);
145 if (!matches)
146 return NULL;
147
148 count = of_regulator_match(&i2c->dev, regs, matches,
149 ARRAY_SIZE(isl9305_reg_matches));
150 of_node_put(regs);
151 if ((count < 0) || (count > ARRAY_SIZE(isl9305_reg_matches)))
152 return NULL;
153
154 return matches;
155}
156#else
157static struct of_regulator_match *isl9305_parse_dt(struct i2c_client *i2c)
158{
159 return NULL;
160}
161#endif
162
163static const struct regmap_config isl9305_regmap = { 132static const struct regmap_config isl9305_regmap = {
164 .reg_bits = 8, 133 .reg_bits = 8,
165 .val_bits = 8, 134 .val_bits = 8,
@@ -173,13 +142,10 @@ static int isl9305_i2c_probe(struct i2c_client *i2c,
173{ 142{
174 struct regulator_config config = { }; 143 struct regulator_config config = { };
175 struct isl9305_pdata *pdata = i2c->dev.platform_data; 144 struct isl9305_pdata *pdata = i2c->dev.platform_data;
176 struct of_regulator_match *of_matches;
177 struct regulator_dev *rdev; 145 struct regulator_dev *rdev;
178 struct regmap *regmap; 146 struct regmap *regmap;
179 int i, ret; 147 int i, ret;
180 148
181 of_matches = isl9305_parse_dt(i2c);
182
183 regmap = devm_regmap_init_i2c(i2c, &isl9305_regmap); 149 regmap = devm_regmap_init_i2c(i2c, &isl9305_regmap);
184 if (IS_ERR(regmap)) { 150 if (IS_ERR(regmap)) {
185 ret = PTR_ERR(regmap); 151 ret = PTR_ERR(regmap);
@@ -190,16 +156,10 @@ static int isl9305_i2c_probe(struct i2c_client *i2c,
190 config.dev = &i2c->dev; 156 config.dev = &i2c->dev;
191 157
192 for (i = 0; i < ARRAY_SIZE(isl9305_regulators); i++) { 158 for (i = 0; i < ARRAY_SIZE(isl9305_regulators); i++) {
193 config.of_node = NULL; 159 if (pdata)
194 config.init_data = NULL;
195
196 if (of_matches) {
197 config.init_data = of_matches[i].init_data;
198 config.of_node = of_matches[i].of_node;
199 }
200
201 if (!config.init_data && pdata)
202 config.init_data = pdata->init_data[i]; 160 config.init_data = pdata->init_data[i];
161 else
162 config.init_data = NULL;
203 163
204 rdev = devm_regulator_register(&i2c->dev, 164 rdev = devm_regulator_register(&i2c->dev,
205 &isl9305_regulators[i], 165 &isl9305_regulators[i],