Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c2d3bffe authored by David S. Miller's avatar David S. Miller
Browse files

[SPARC]: Simplify and correct __cpu_find_by()



By using for_each_node_by_type().

Also, correct a spurioud test in check_cpu_node() on sparc64.
It is only called with nodes that have device_type "cpu".

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2f72ba43
Loading
Loading
Loading
Loading
+7 −18
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@


#include <asm/page.h>
#include <asm/page.h>
#include <asm/oplib.h>
#include <asm/oplib.h>
#include <asm/prom.h>
#include <asm/smp.h>
#include <asm/smp.h>
#include <asm/system.h>
#include <asm/system.h>
#include <asm/cpudata.h>
#include <asm/cpudata.h>
@@ -34,12 +35,6 @@ static int check_cpu_node(int nd, int *cur_inst,
			  int (*compare)(int, int, void *), void *compare_arg,
			  int (*compare)(int, int, void *), void *compare_arg,
			  int *prom_node, int *mid)
			  int *prom_node, int *mid)
{
{
	char node_str[128];

	prom_getstring(nd, "device_type", node_str, sizeof(node_str));
	if (strcmp(node_str, "cpu"))
		return -ENODEV;
	
	if (!compare(nd, *cur_inst, compare_arg)) {
	if (!compare(nd, *cur_inst, compare_arg)) {
		if (prom_node)
		if (prom_node)
			*prom_node = nd;
			*prom_node = nd;
@@ -59,19 +54,13 @@ static int check_cpu_node(int nd, int *cur_inst,
static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg,
static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg,
			 int *prom_node, int *mid)
			 int *prom_node, int *mid)
{
{
	int nd, cur_inst, err;
	struct device_node *dp;
	int cur_inst;


	nd = prom_root_node;
	cur_inst = 0;
	cur_inst = 0;

	for_each_node_by_type(dp, "cpu") {
	err = check_cpu_node(nd, &cur_inst, compare, compare_arg,
		int err = check_cpu_node(dp->node, &cur_inst,
			     prom_node, mid);
					 compare, compare_arg,
	if (!err)
		return 0;

	nd = prom_getchild(nd);
	while ((nd = prom_getsibling(nd)) != 0) {
		err = check_cpu_node(nd, &cur_inst, compare, compare_arg,
					 prom_node, mid);
					 prom_node, mid);
		if (!err)
		if (!err)
			return 0;
			return 0;
+0 −3
Original line number Original line Diff line number Diff line
@@ -66,9 +66,6 @@ static int check_cpu_node(struct device_node *dp, int *cur_inst,
			  void *compare_arg,
			  void *compare_arg,
			  struct device_node **dev_node, int *mid)
			  struct device_node **dev_node, int *mid)
{
{
	if (strcmp(dp->type, "cpu"))
		return -ENODEV;

	if (!compare(dp, *cur_inst, compare_arg)) {
	if (!compare(dp, *cur_inst, compare_arg)) {
		if (dev_node)
		if (dev_node)
			*dev_node = dp;
			*dev_node = dp;