lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 17 Apr 2013 10:37:25 +0800
From:	Axel Lin <axel.lin@...ics.com>
To:	Mark Brown <broonie@...nsource.wolfsonmicro.com>
Cc:	Guennadi Liakhovetski <g.liakhovetski@....de>,
	Liam Girdwood <lgirdwood@...il.com>,
	linux-kernel@...r.kernel.org
Subject: [PATCH] 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.

Signed-off-by: Axel Lin <axel.lin@...ics.com>
---
 drivers/regulator/as3711-regulator.c |   46 ++++++++++++++--------------------
 1 file changed, 19 insertions(+), 27 deletions(-)

diff --git a/drivers/regulator/as3711-regulator.c b/drivers/regulator/as3711-regulator.c
index 0539b3e..dd1a089 100644
--- a/drivers/regulator/as3711-regulator.c
+++ b/drivers/regulator/as3711-regulator.c
@@ -278,52 +278,44 @@ static struct as3711_regulator_info as3711_reg_info[] = {
 
 #define AS3711_REGULATOR_NUM ARRAY_SIZE(as3711_reg_info)
 
-static const char *as3711_regulator_of_names[AS3711_REGULATOR_NUM] = {
-	[AS3711_REGULATOR_SD_1] = "sd1",
-	[AS3711_REGULATOR_SD_2] = "sd2",
-	[AS3711_REGULATOR_SD_3] = "sd3",
-	[AS3711_REGULATOR_SD_4] = "sd4",
-	[AS3711_REGULATOR_LDO_1] = "ldo1",
-	[AS3711_REGULATOR_LDO_2] = "ldo2",
-	[AS3711_REGULATOR_LDO_3] = "ldo3",
-	[AS3711_REGULATOR_LDO_4] = "ldo4",
-	[AS3711_REGULATOR_LDO_5] = "ldo5",
-	[AS3711_REGULATOR_LDO_6] = "ldo6",
-	[AS3711_REGULATOR_LDO_7] = "ldo7",
-	[AS3711_REGULATOR_LDO_8] = "ldo8",
+static struct of_regulator_match as3711_regulator_matches[] = {
+	{ .name = "sd1" },
+	{ .name = "sd2" },
+	{ .name = "sd3" },
+	{ .name = "sd4" },
+	{ .name = "ldo1" },
+	{ .name = "ldo2" },
+	{ .name = "ldo3" },
+	{ .name = "ldo4" },
+	{ .name = "ldo5" },
+	{ .name = "ldo6" },
+	{ .name = "ldo7" },
+	{ .name = "ldo8" },
 };
 
 static int as3711_regulator_parse_dt(struct device *dev,
 				struct device_node **of_node, const int count)
 {
 	struct as3711_regulator_pdata *pdata = dev_get_platdata(dev);
-	struct device_node *regulators =
-		of_find_node_by_name(dev->parent->of_node, "regulators");
-	struct of_regulator_match *matches, *match;
+	struct device_node *regulators;
+	struct of_regulator_match *match;
 	int ret, i;
 
+	regulators = of_find_node_by_name(dev->parent->of_node, "regulators");
 	if (!regulators) {
 		dev_err(dev, "regulator node not found\n");
 		return -ENODEV;
 	}
 
-	matches = devm_kzalloc(dev, sizeof(*matches) * count, GFP_KERNEL);
-	if (!matches)
-		return -ENOMEM;
-
-	for (i = 0, match = matches; i < count; i++, match++) {
-		match->name = as3711_regulator_of_names[i];
-		match->driver_data = as3711_reg_info + i;
-	}
-
-	ret = of_regulator_match(dev->parent, regulators, matches, count);
+	ret = of_regulator_match(dev->parent, regulators,
+				 as3711_regulator_matches, count);
 	of_node_put(regulators);
 	if (ret < 0) {
 		dev_err(dev, "Error parsing regulator init data: %d\n", ret);
 		return ret;
 	}
 
-	for (i = 0, match = matches; i < count; i++, match++)
+	for (i = 0, match = as3711_regulator_matches; i < count; i++, match++)
 		if (match->of_node) {
 			pdata->init_data[i] = match->init_data;
 			of_node[i] = match->of_node;
-- 
1.7.10.4



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ