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

regulator: as3711: Use a static of_regulator_match table for of_regulator_match

The same table can be used for multiple instance of pdev, so we don't need to
allocate memory for of_regulator_match table per pdev.

match->driver_data points to the corresponding entry of as3711_reg_info,
however it is not used in current code, thus this patch does not set
driver_data in the of_regulator_match table.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

authored by

Axel Lin and committed by
Mark Brown
d6c7d731 416d6759

+18 -25
+18 -25
drivers/regulator/as3711-regulator.c
··· 278 278 279 279 #define AS3711_REGULATOR_NUM ARRAY_SIZE(as3711_reg_info) 280 280 281 - static const char *as3711_regulator_of_names[AS3711_REGULATOR_NUM] = { 282 - [AS3711_REGULATOR_SD_1] = "sd1", 283 - [AS3711_REGULATOR_SD_2] = "sd2", 284 - [AS3711_REGULATOR_SD_3] = "sd3", 285 - [AS3711_REGULATOR_SD_4] = "sd4", 286 - [AS3711_REGULATOR_LDO_1] = "ldo1", 287 - [AS3711_REGULATOR_LDO_2] = "ldo2", 288 - [AS3711_REGULATOR_LDO_3] = "ldo3", 289 - [AS3711_REGULATOR_LDO_4] = "ldo4", 290 - [AS3711_REGULATOR_LDO_5] = "ldo5", 291 - [AS3711_REGULATOR_LDO_6] = "ldo6", 292 - [AS3711_REGULATOR_LDO_7] = "ldo7", 293 - [AS3711_REGULATOR_LDO_8] = "ldo8", 281 + static struct of_regulator_match 282 + as3711_regulator_matches[AS3711_REGULATOR_NUM] = { 283 + [AS3711_REGULATOR_SD_1] = { .name = "sd1" }, 284 + [AS3711_REGULATOR_SD_2] = { .name = "sd2" }, 285 + [AS3711_REGULATOR_SD_3] = { .name = "sd3" }, 286 + [AS3711_REGULATOR_SD_4] = { .name = "sd4" }, 287 + [AS3711_REGULATOR_LDO_1] = { .name = "ldo1" }, 288 + [AS3711_REGULATOR_LDO_2] = { .name = "ldo2" }, 289 + [AS3711_REGULATOR_LDO_3] = { .name = "ldo3" }, 290 + [AS3711_REGULATOR_LDO_4] = { .name = "ldo4" }, 291 + [AS3711_REGULATOR_LDO_5] = { .name = "ldo5" }, 292 + [AS3711_REGULATOR_LDO_6] = { .name = "ldo6" }, 293 + [AS3711_REGULATOR_LDO_7] = { .name = "ldo7" }, 294 + [AS3711_REGULATOR_LDO_8] = { .name = "ldo8" }, 294 295 }; 295 296 296 297 static int as3711_regulator_parse_dt(struct device *dev, ··· 300 299 struct as3711_regulator_pdata *pdata = dev_get_platdata(dev); 301 300 struct device_node *regulators = 302 301 of_find_node_by_name(dev->parent->of_node, "regulators"); 303 - struct of_regulator_match *matches, *match; 302 + struct of_regulator_match *match; 304 303 int ret, i; 305 304 306 305 if (!regulators) { ··· 308 307 return -ENODEV; 309 308 } 310 309 311 - matches = devm_kzalloc(dev, sizeof(*matches) * count, GFP_KERNEL); 312 - if (!matches) 313 - return -ENOMEM; 314 - 315 - for (i = 0, match = matches; i < count; i++, match++) { 316 - match->name = as3711_regulator_of_names[i]; 317 - match->driver_data = as3711_reg_info + i; 318 - } 319 - 320 - ret = of_regulator_match(dev->parent, regulators, matches, count); 310 + ret = of_regulator_match(dev->parent, regulators, 311 + as3711_regulator_matches, count); 321 312 of_node_put(regulators); 322 313 if (ret < 0) { 323 314 dev_err(dev, "Error parsing regulator init data: %d\n", ret); 324 315 return ret; 325 316 } 326 317 327 - for (i = 0, match = matches; i < count; i++, match++) 318 + for (i = 0, match = as3711_regulator_matches; i < count; i++, match++) 328 319 if (match->of_node) { 329 320 pdata->init_data[i] = match->init_data; 330 321 of_node[i] = match->of_node;