Add basic support for mini2440 board to barebox.
[barebox-mini2440.git] / commands / insmod.c
blobd3b4d1ad6bc71af953785d834a9fe90e6a75aa4c
1 #include <common.h>
2 #include <command.h>
3 #include <module.h>
4 #include <errno.h>
5 #include <fs.h>
6 #include <malloc.h>
8 static int do_insmod(struct command *cmdtp, int argc, char *argv[])
10 struct module *module;
11 void *buf;
12 int len;
14 if (argc < 2)
15 return COMMAND_ERROR_USAGE;
17 buf = read_file(argv[1], &len);
18 if (!buf) {
19 perror("insmod");
20 return 1;
23 module = load_module(buf, len);
25 free(buf);
27 if (module) {
28 if (module->init)
29 module->init();
32 return 0;
35 static const __maybe_unused char cmd_insmod_help[] =
36 "Usage: insmod <module>\n";
38 BAREBOX_CMD_START(insmod)
39 .cmd = do_insmod,
40 .usage = "insert a module",
41 BAREBOX_CMD_HELP(cmd_insmod_help)
42 BAREBOX_CMD_END