From: Andres Salomon <dilinger@queued.net>
To: hpa@zytor.com
Cc: linux-kernel@vger.kernel.org, dsd@laptop.org, tglx@linutronix.de,
mingo@redhat.com, x86@kernel.org
Subject: [PATCH] x86: OLPC: some olpc-detection cleanups
Date: Thu, 23 Sep 2010 17:31:05 -0700 [thread overview]
Message-ID: <20100923173105.10fb92d1@debxo> (raw)
Following up on dsd's cleanups (3e3c4860), address some minor nits:
- rename check_ofw_arch to olpc_check_arch (as we're checking for OLPC)
- add a comment describing why we're checking..
- use sizeof(array) rather than hardcoding the size
- sprinkle some parens around
Signed-off-by: Andres Salomon <dilinger@queued.net>
---
arch/x86/kernel/olpc.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/olpc.c b/arch/x86/kernel/olpc.c
index 37c4993..361c2e0 100644
--- a/arch/x86/kernel/olpc.c
+++ b/arch/x86/kernel/olpc.c
@@ -183,18 +183,25 @@ err:
}
EXPORT_SYMBOL_GPL(olpc_ec_cmd);
-static bool __init check_ofw_architecture(void)
+/*
+ * Simply because OFW has been detected does not mean that the machine is
+ * an OLPC device; this ensures that OFW's "/architecture" property is set
+ * to "OLPC".
+ */
+static bool __init olpc_check_architecture(void)
{
size_t propsize;
char olpc_arch[5];
- const void *args[] = { NULL, "architecture", olpc_arch, (void *)5 };
+ const void *args[] = { NULL, "architecture", olpc_arch,
+ (void *)sizeof(olpc_arch) };
void *res[] = { &propsize };
if (olpc_ofw("getprop", args, res)) {
printk(KERN_ERR "ofw: getprop call failed!\n");
return false;
}
- return propsize == 5 && strncmp("OLPC", olpc_arch, 5) == 0;
+ return (propsize == sizeof(olpc_arch)) &&
+ (strncmp("OLPC", olpc_arch, sizeof(olpc_arch)) == 0);
}
static u32 __init get_board_revision(void)
@@ -213,7 +220,7 @@ static u32 __init get_board_revision(void)
static bool __init platform_detect(void)
{
- if (!check_ofw_architecture())
+ if (!olpc_check_architecture())
return false;
olpc_platform_info.flags |= OLPC_F_PRESENT;
olpc_platform_info.boardrev = get_board_revision();
--
1.5.6.5
reply other threads:[~2010-09-23 23:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20100923173105.10fb92d1@debxo \
--to=dilinger@queued.net \
--cc=dsd@laptop.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@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