hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/regulator/max8925-regulator.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Regulators driver for Maxim max8925
34 *
45 * Copyright (C) 2009 Marvell International Ltd.
56 * Haojian Zhuang <haojian.zhuang@marvell.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.
107 */
118 #include <linux/kernel.h>
129 #include <linux/module.h>
....@@ -159,6 +156,8 @@
159156 { \
160157 .desc = { \
161158 .name = "SDV" #_id, \
159
+ .of_match = of_match_ptr("SDV" #_id), \
160
+ .regulators_node = of_match_ptr("regulators"), \
162161 .ops = &max8925_regulator_sdv_ops, \
163162 .type = REGULATOR_VOLTAGE, \
164163 .id = MAX8925_ID_SD##_id, \
....@@ -175,6 +174,8 @@
175174 { \
176175 .desc = { \
177176 .name = "LDO" #_id, \
177
+ .of_match = of_match_ptr("LDO" #_id), \
178
+ .regulators_node = of_match_ptr("regulators"), \
178179 .ops = &max8925_regulator_ldo_ops, \
179180 .type = REGULATOR_VOLTAGE, \
180181 .id = MAX8925_ID_LDO##_id, \
....@@ -186,34 +187,6 @@
186187 .vol_reg = MAX8925_LDOVOUT##_id, \
187188 .enable_reg = MAX8925_LDOCTL##_id, \
188189 }
189
-
190
-#ifdef CONFIG_OF
191
-static struct of_regulator_match max8925_regulator_matches[] = {
192
- { .name = "SDV1",},
193
- { .name = "SDV2",},
194
- { .name = "SDV3",},
195
- { .name = "LDO1",},
196
- { .name = "LDO2",},
197
- { .name = "LDO3",},
198
- { .name = "LDO4",},
199
- { .name = "LDO5",},
200
- { .name = "LDO6",},
201
- { .name = "LDO7",},
202
- { .name = "LDO8",},
203
- { .name = "LDO9",},
204
- { .name = "LDO10",},
205
- { .name = "LDO11",},
206
- { .name = "LDO12",},
207
- { .name = "LDO13",},
208
- { .name = "LDO14",},
209
- { .name = "LDO15",},
210
- { .name = "LDO16",},
211
- { .name = "LDO17",},
212
- { .name = "LDO18",},
213
- { .name = "LDO19",},
214
- { .name = "LDO20",},
215
-};
216
-#endif
217190
218191 static struct max8925_regulator_info max8925_regulator_info[] = {
219192 MAX8925_SDV(1, 637.5, 1425, 12.5),
....@@ -242,37 +215,6 @@
242215 MAX8925_LDO(20, 750, 3900, 50),
243216 };
244217
245
-#ifdef CONFIG_OF
246
-static int max8925_regulator_dt_init(struct platform_device *pdev,
247
- struct regulator_config *config,
248
- int ridx)
249
-{
250
- struct device_node *nproot, *np;
251
- int rcount;
252
-
253
- nproot = pdev->dev.parent->of_node;
254
- if (!nproot)
255
- return -ENODEV;
256
- np = of_get_child_by_name(nproot, "regulators");
257
- if (!np) {
258
- dev_err(&pdev->dev, "failed to find regulators node\n");
259
- return -ENODEV;
260
- }
261
-
262
- rcount = of_regulator_match(&pdev->dev, np,
263
- &max8925_regulator_matches[ridx], 1);
264
- of_node_put(np);
265
- if (rcount < 0)
266
- return rcount;
267
- config->init_data = max8925_regulator_matches[ridx].init_data;
268
- config->of_node = max8925_regulator_matches[ridx].of_node;
269
-
270
- return 0;
271
-}
272
-#else
273
-#define max8925_regulator_dt_init(x, y, z) (-1)
274
-#endif
275
-
276218 static int max8925_regulator_probe(struct platform_device *pdev)
277219 {
278220 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
....@@ -281,7 +223,7 @@
281223 struct max8925_regulator_info *ri;
282224 struct resource *res;
283225 struct regulator_dev *rdev;
284
- int i, regulator_idx;
226
+ int i;
285227
286228 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
287229 if (!res) {
....@@ -290,10 +232,8 @@
290232 }
291233 for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) {
292234 ri = &max8925_regulator_info[i];
293
- if (ri->vol_reg == res->start) {
294
- regulator_idx = i;
235
+ if (ri->vol_reg == res->start)
295236 break;
296
- }
297237 }
298238
299239 if (i == ARRAY_SIZE(max8925_regulator_info)) {
....@@ -303,12 +243,11 @@
303243 }
304244 ri->i2c = chip->i2c;
305245
306
- config.dev = &pdev->dev;
246
+ config.dev = chip->dev;
307247 config.driver_data = ri;
308248
309
- if (max8925_regulator_dt_init(pdev, &config, regulator_idx))
310
- if (pdata)
311
- config.init_data = pdata;
249
+ if (pdata)
250
+ config.init_data = pdata;
312251
313252 rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config);
314253 if (IS_ERR(rdev)) {