浏览代码

Merge tag 'devicetree-fixes-for-4.0-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux

Pull more DeviceTree fixes vfom Rob Herring:

 - revert setting stdout-path as preferred console.  This caused
   regressions in PowerMACs and other systems.

 - yet another fix for stdout-path option parsing.

 - fix error path handling in of_irq_parse_one

* tag 'devicetree-fixes-for-4.0-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux:
  Revert "of: Fix premature bootconsole disable with 'stdout-path'"
  of: handle both '/' and ':' in path strings
  of: unittest: Add option string test case with longer path
  of/irq: Fix of_irq_parse_one() returned error codes
Linus Torvalds 10 年之前
父节点
当前提交
bb8ef2fbb8
共有 3 个文件被更改,包括 14 次插入12 次删除
  1. 2 9
      drivers/of/base.c
  2. 7 3
      drivers/of/irq.c
  3. 5 0
      drivers/of/unittest.c

+ 2 - 9
drivers/of/base.c

@@ -715,13 +715,8 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent,
 {
 {
 	struct device_node *child;
 	struct device_node *child;
 	int len;
 	int len;
-	const char *end;
 
 
-	end = strchr(path, ':');
-	if (!end)
-		end = strchrnul(path, '/');
-
-	len = end - path;
+	len = strcspn(path, "/:");
 	if (!len)
 	if (!len)
 		return NULL;
 		return NULL;
 
 
@@ -1893,10 +1888,8 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
 			name = of_get_property(of_chosen, "linux,stdout-path", NULL);
 			name = of_get_property(of_chosen, "linux,stdout-path", NULL);
 		if (IS_ENABLED(CONFIG_PPC) && !name)
 		if (IS_ENABLED(CONFIG_PPC) && !name)
 			name = of_get_property(of_aliases, "stdout", NULL);
 			name = of_get_property(of_aliases, "stdout", NULL);
-		if (name) {
+		if (name)
 			of_stdout = of_find_node_opts_by_path(name, &of_stdout_options);
 			of_stdout = of_find_node_opts_by_path(name, &of_stdout_options);
-			add_preferred_console("stdout-path", 0, NULL);
-		}
 	}
 	}
 
 
 	if (!of_aliases)
 	if (!of_aliases)

+ 7 - 3
drivers/of/irq.c

@@ -290,7 +290,7 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar
 	struct device_node *p;
 	struct device_node *p;
 	const __be32 *intspec, *tmp, *addr;
 	const __be32 *intspec, *tmp, *addr;
 	u32 intsize, intlen;
 	u32 intsize, intlen;
-	int i, res = -EINVAL;
+	int i, res;
 
 
 	pr_debug("of_irq_parse_one: dev=%s, index=%d\n", of_node_full_name(device), index);
 	pr_debug("of_irq_parse_one: dev=%s, index=%d\n", of_node_full_name(device), index);
 
 
@@ -323,15 +323,19 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar
 
 
 	/* Get size of interrupt specifier */
 	/* Get size of interrupt specifier */
 	tmp = of_get_property(p, "#interrupt-cells", NULL);
 	tmp = of_get_property(p, "#interrupt-cells", NULL);
-	if (tmp == NULL)
+	if (tmp == NULL) {
+		res = -EINVAL;
 		goto out;
 		goto out;
+	}
 	intsize = be32_to_cpu(*tmp);
 	intsize = be32_to_cpu(*tmp);
 
 
 	pr_debug(" intsize=%d intlen=%d\n", intsize, intlen);
 	pr_debug(" intsize=%d intlen=%d\n", intsize, intlen);
 
 
 	/* Check index */
 	/* Check index */
-	if ((index + 1) * intsize > intlen)
+	if ((index + 1) * intsize > intlen) {
+		res = -EINVAL;
 		goto out;
 		goto out;
+	}
 
 
 	/* Copy intspec into irq structure */
 	/* Copy intspec into irq structure */
 	intspec += index * intsize;
 	intspec += index * intsize;

+ 5 - 0
drivers/of/unittest.c

@@ -97,6 +97,11 @@ static void __init of_selftest_find_node_by_name(void)
 		 "option path test, subcase #1 failed\n");
 		 "option path test, subcase #1 failed\n");
 	of_node_put(np);
 	of_node_put(np);
 
 
+	np = of_find_node_opts_by_path("/testcase-data/testcase-device1:test/option", &options);
+	selftest(np && !strcmp("test/option", options),
+		 "option path test, subcase #2 failed\n");
+	of_node_put(np);
+
 	np = of_find_node_opts_by_path("/testcase-data:testoption", NULL);
 	np = of_find_node_opts_by_path("/testcase-data:testoption", NULL);
 	selftest(np, "NULL option path test failed\n");
 	selftest(np, "NULL option path test failed\n");
 	of_node_put(np);
 	of_node_put(np);