From 67e015d08f9a9f53b1ec0a6c301ce1a9516ea69a Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Wed, 29 Jan 2014 17:41:04 +0800 Subject: [PATCH] platforms/powerpc: Check for a powerpc platform in the probe function Currently, we're always assuming a powerpc platform, as the powerpc probe() function always returns true. This change adds a check for some bits we need to work on a powerpc platform. Signed-off-by: Jeremy Kerr --- discover/platform-powerpc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index e2a8631..7761769 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -535,6 +536,20 @@ static int save_config(struct platform *p, struct config *config) static bool probe(struct platform *p, void *ctx) { struct platform_powerpc *platform; + struct stat statbuf; + int rc; + + /* we need a device tree and a working nvram binary */ + rc = stat("/proc/device-tree", &statbuf); + if (rc) + return false; + + if (!S_ISDIR(statbuf.st_mode)) + return false; + + rc = process_run_simple(ctx, "nvram", "--print-config", NULL); + if (!WIFEXITED(rc) || WEXITSTATUS(rc) != 0) + return false; platform = talloc(ctx, struct platform_powerpc); list_init(&platform->params); -- 2.39.2