summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2012-11-06 17:08:43 -0200
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2012-11-06 17:10:57 -0200
commit84341fbe013bca49038174b03e95c2943a8e184c (patch)
treeaa1997883803f8e194c84eef833d5068853c96f0 /tools
parent4a2e20dfb3f94b0c5f0b8269b0dd84974a5dac56 (diff)
downloadkmod-84341fbe013bca49038174b03e95c2943a8e184c.tar.gz
tools: share function to convert prio to string
No change is expected in the final binary since right now only an inline function is shared. Later we expect to share more code.
Diffstat (limited to 'tools')
-rw-r--r--tools/depmod.c1
-rw-r--r--tools/kmod.h2
-rw-r--r--tools/log.h58
-rw-r--r--tools/modprobe.c32
-rw-r--r--tools/rmmod.c32
5 files changed, 60 insertions, 65 deletions
diff --git a/tools/depmod.c b/tools/depmod.c
index 8fd0f12..5d94c17 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -26,7 +26,6 @@
#include <getopt.h>
#include <errno.h>
#include <string.h>
-#include <syslog.h>
#include <limits.h>
#include <dirent.h>
#include <sys/utsname.h>
diff --git a/tools/kmod.h b/tools/kmod.h
index 7bf6c43..ceff861 100644
--- a/tools/kmod.h
+++ b/tools/kmod.h
@@ -38,3 +38,5 @@ extern const struct kmod_cmd kmod_cmd_list;
/* kmod.c */
extern const char *binname;
+
+#include "log.h"
diff --git a/tools/log.h b/tools/log.h
new file mode 100644
index 0000000..3527bd9
--- /dev/null
+++ b/tools/log.h
@@ -0,0 +1,58 @@
+/*
+ * kmod - log infrastructure
+ *
+ * Copyright (C) 2012 ProFUSION embedded systems
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <syslog.h>
+
+#include "kmod.h"
+
+_always_inline_ const char *prio_to_str(int prio);
+
+
+_always_inline_ const char *prio_to_str(int prio)
+{
+ const char *prioname;
+ char buf[32];
+
+ switch (prio) {
+ case LOG_CRIT:
+ prioname = "FATAL";
+ break;
+ case LOG_ERR:
+ prioname = "ERROR";
+ break;
+ case LOG_WARNING:
+ prioname = "WARNING";
+ break;
+ case LOG_NOTICE:
+ prioname = "NOTICE";
+ break;
+ case LOG_INFO:
+ prioname = "INFO";
+ break;
+ case LOG_DEBUG:
+ prioname = "DEBUG";
+ break;
+ default:
+ snprintf(buf, sizeof(buf), "LOG-%03d", prio);
+ prioname = buf;
+ }
+
+ return prioname;
+}
diff --git a/tools/modprobe.c b/tools/modprobe.c
index 7c8e2af..4cd6645 100644
--- a/tools/modprobe.c
+++ b/tools/modprobe.c
@@ -154,38 +154,6 @@ static inline void _show(const char *fmt, ...)
va_end(args);
}
-static _always_inline_ const char *prio_to_str(int prio)
-{
- const char *prioname;
- char buf[32];
-
- switch (prio) {
- case LOG_CRIT:
- prioname = "FATAL";
- break;
- case LOG_ERR:
- prioname = "ERROR";
- break;
- case LOG_WARNING:
- prioname = "WARNING";
- break;
- case LOG_NOTICE:
- prioname = "NOTICE";
- break;
- case LOG_INFO:
- prioname = "INFO";
- break;
- case LOG_DEBUG:
- prioname = "DEBUG";
- break;
- default:
- snprintf(buf, sizeof(buf), "LOG-%03d", prio);
- prioname = buf;
- }
-
- return prioname;
-}
-
static void log_modprobe(void *data, int priority, const char *file, int line,
const char *fn, const char *format, va_list args)
{
diff --git a/tools/rmmod.c b/tools/rmmod.c
index 1983f70..9d09515 100644
--- a/tools/rmmod.c
+++ b/tools/rmmod.c
@@ -62,38 +62,6 @@ static void help(void)
binname);
}
-static _always_inline_ const char *prio_to_str(int prio)
-{
- const char *prioname;
- char buf[32];
-
- switch (prio) {
- case LOG_CRIT:
- prioname = "FATAL";
- break;
- case LOG_ERR:
- prioname = "ERROR";
- break;
- case LOG_WARNING:
- prioname = "WARNING";
- break;
- case LOG_NOTICE:
- prioname = "NOTICE";
- break;
- case LOG_INFO:
- prioname = "INFO";
- break;
- case LOG_DEBUG:
- prioname = "DEBUG";
- break;
- default:
- snprintf(buf, sizeof(buf), "LOG-%03d", prio);
- prioname = buf;
- }
-
- return prioname;
-}
-
static void log_rmmod(void *data, int priority, const char *file, int line,
const char *fn, const char *format, va_list args)
{