aboutsummaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2015-03-11 17:15:07 +0800
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-03-17 15:34:37 +1100
commit4c33ce0ab8999672e8c2ef4088d3524be349e7bc (patch)
tree54ad315f57b70b52f8b05edb05591bd8e53d590b /external
parentd6fdddbccfc9a0d991ced7e25c6fdbe067128726 (diff)
downloadskiboot-4c33ce0ab8999672e8c2ef4088d3524be349e7bc.zip
skiboot-4c33ce0ab8999672e8c2ef4088d3524be349e7bc.tar.gz
skiboot-4c33ce0ab8999672e8c2ef4088d3524be349e7bc.tar.bz2
external/opal-prd: Add a helper for module loading
Rather than calling system("modprobe ...") in different locations, this change introduces an insert_module() helper function. We use this for the existing i2c modprobe, and add one for the ipmi devintf module too. We won't need the i2c-opal module, as it should be automatically loaded by the platform device. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external')
-rw-r--r--external/opal-prd/Makefile2
-rw-r--r--external/opal-prd/i2c.c7
-rw-r--r--external/opal-prd/module.c55
-rw-r--r--external/opal-prd/module.h23
-rw-r--r--external/opal-prd/opal-prd.c8
5 files changed, 90 insertions, 5 deletions
diff --git a/external/opal-prd/Makefile b/external/opal-prd/Makefile
index 4f4175c..a4923a6 100644
--- a/external/opal-prd/Makefile
+++ b/external/opal-prd/Makefile
@@ -16,7 +16,7 @@ ifndef V
Q_MKDIR=@echo ' MKDIR ' $@;
endif
-OBJS = opal-prd.o thunk.o pnor.o i2c.o libffs.o libflash.o ecc.o
+OBJS = opal-prd.o thunk.o pnor.o i2c.o module.o libffs.o libflash.o ecc.o
all: opal-prd
diff --git a/external/opal-prd/i2c.c b/external/opal-prd/i2c.c
index 436ae04..dfafd27 100644
--- a/external/opal-prd/i2c.c
+++ b/external/opal-prd/i2c.c
@@ -32,6 +32,7 @@
#include <linux/i2c-dev.h>
#include <ccan/list/list.h>
+#include "module.h"
#include "i2c.h"
struct i2c_bus {
@@ -211,10 +212,8 @@ void i2c_init(void)
FILE *f;
unsigned int chip, engine, port;
- /* Ensure i2c-dev is loaded (must be root ! might need to
- * move that to some helper script or something ...)
- */
- system("modprobe -a i2c-dev i2c-opal");
+ /* Ensure i2c-dev is loaded */
+ insert_module("i2c-dev");
/* Get directory of i2c char devs in sysfs */
devsdir = opendir(SYSFS "/class/i2c-dev");
diff --git a/external/opal-prd/module.c b/external/opal-prd/module.c
new file mode 100644
index 0000000..c483cd4
--- /dev/null
+++ b/external/opal-prd/module.c
@@ -0,0 +1,55 @@
+/* Copyright 2015 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ * See the License for the specific language governing permissions and
+ * imitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <err.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <module.h>
+
+int insert_module(const char *module)
+{
+ int status;
+ pid_t pid;
+
+ pid = fork();
+ if (!pid) {
+ execlp("modprobe", "modprobe", module, NULL);
+ err(EXIT_FAILURE, "Failed to run modprobe");
+ }
+
+ pid = waitpid(pid, &status, 0);
+ if (pid < 0) {
+ warn("waitpid failed for modprobe process");
+ return -1;
+ }
+
+ if (!WIFEXITED(status)) {
+ warnx("modprobe %s: process didn't exit cleanly", module);
+ return -1;
+ }
+
+ if (WEXITSTATUS(status) != 0) {
+ warnx("modprobe %s failed, status %d", module,
+ WEXITSTATUS(status));
+ return -1;
+ }
+
+ return 0;
+}
+
diff --git a/external/opal-prd/module.h b/external/opal-prd/module.h
new file mode 100644
index 0000000..3a9e4aa
--- /dev/null
+++ b/external/opal-prd/module.h
@@ -0,0 +1,23 @@
+/* Copyright 2015 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ * See the License for the specific language governing permissions and
+ * imitations under the License.
+ */
+
+#ifndef MODULES_H
+#define MODULES_H
+
+int insert_module(const char *module);
+
+#endif /* MODULES_H */
+
diff --git a/external/opal-prd/opal-prd.c b/external/opal-prd/opal-prd.c
index a209e82..6e7f89e 100644
--- a/external/opal-prd/opal-prd.c
+++ b/external/opal-prd/opal-prd.c
@@ -47,6 +47,7 @@
#include <opal.h>
#include "hostboot-interface.h"
+#include "module.h"
#include "pnor.h"
#include "i2c.h"
@@ -332,6 +333,11 @@ int hservice_i2c_write(uint64_t i_master, uint16_t i_devAddr,
i_offset, i_length, i_data);
}
+static void ipmi_init(struct opal_prd_ctx *ctx)
+{
+ insert_module("ipmi_devintf");
+}
+
static int ipmi_send(int fd, uint8_t netfn, uint8_t cmd, long seq,
uint8_t *buf, size_t len)
{
@@ -986,6 +992,8 @@ static int run_prd_daemon(struct opal_prd_ctx *ctx)
}
}
+ ipmi_init(ctx);
+
/* Test a scom */
if (ctx->debug) {
uint64_t val;