From: Reza Arbab <arbab@linux.vnet.ibm.com>
To: Rob Herring <robh+dt@kernel.org>,
Frank Rowand <frowand.list@gmail.com>,
Grant Likely <grant.likely@linaro.org>,
Kevin Hao <haokexin@gmail.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] of: fix device compatibility scoring
Date: Thu, 5 May 2016 13:30:48 -0500 [thread overview]
Message-ID: <1462473048-10001-1-git-send-email-arbab@linux.vnet.ibm.com> (raw)
If a constraint given to __of_device_is_compatible() does not
match, we should just move to the next constraint without adding
to the compatibility score. Instead, the function immediately
returns 0.
Do not return from __of_device_is_compatible() until a complete
score has been calculated.
Signed-off-by: Reza Arbab <arbab@linux.vnet.ibm.com>
---
drivers/of/base.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 017dd94..942a60e 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -455,22 +455,18 @@ static int __of_device_is_compatible(const struct device_node *device,
break;
}
}
- if (!score)
- return 0;
}
/* Matching type is better than matching name */
if (type && type[0]) {
- if (!device->type || of_node_cmp(type, device->type))
- return 0;
- score += 2;
+ if (device->type && !of_node_cmp(type, device->type))
+ score += 2;
}
/* Matching name is a bit better than not */
if (name && name[0]) {
- if (!device->name || of_node_cmp(name, device->name))
- return 0;
- score++;
+ if (device->name && !of_node_cmp(name, device->name))
+ score++;
}
return score;
--
1.8.3.1
next reply other threads:[~2016-05-05 18:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-05 18:30 Reza Arbab [this message]
[not found] ` <1462473048-10001-1-git-send-email-arbab-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2016-05-05 19:47 ` [PATCH] of: fix device compatibility scoring Rob Herring
2016-05-06 15:10 ` Reza Arbab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462473048-10001-1-git-send-email-arbab@linux.vnet.ibm.com \
--to=arbab@linux.vnet.ibm.com \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=grant.likely@linaro.org \
--cc=haokexin@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).