[PATCH 10/11] EDAC: Delete edac_stub.c

From: Borislav Petkov
Date: Thu Apr 06 2017 - 05:09:32 EST


From: Borislav Petkov <bp@xxxxxxx>

Move the remaining functionality to edac_mc.c. Convert "edac_report=" to
a module parameter.

Signed-off-by: Borislav Petkov <bp@xxxxxxx>
---
drivers/edac/Makefile | 2 +-
drivers/edac/edac_mc.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
drivers/edac/edac_stub.c | 37 -----------------------------
include/linux/edac.h | 26 +++------------------
4 files changed, 65 insertions(+), 61 deletions(-)
delete mode 100644 drivers/edac/edac_stub.c

diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index a8fb734cb28d..0fd9ffa63299 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -6,7 +6,7 @@
# GNU General Public License.
#

-obj-$(CONFIG_EDAC) := edac_stub.o edac_core.o
+obj-$(CONFIG_EDAC) := edac_core.o

edac_core-y := edac_mc.o edac_device.o edac_mc_sysfs.o
edac_core-y += edac_module.o edac_device_sysfs.o wq.o
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 735546ea6ebe..536b65aa6fac 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -43,6 +43,8 @@
int edac_op_state = EDAC_OPSTATE_INVAL;
EXPORT_SYMBOL_GPL(edac_op_state);

+static int edac_report = EDAC_REPORTING_ENABLED;
+
/* lock to memory controller's control array */
static DEFINE_MUTEX(mem_ctls_mutex);
static LIST_HEAD(mc_devices);
@@ -55,6 +57,65 @@ static void const *edac_mc_owner;

static struct bus_type mc_bus[EDAC_MAX_MCS];

+int get_edac_report_status(void)
+{
+ return edac_report;
+}
+EXPORT_SYMBOL_GPL(get_edac_report_status);
+
+void set_edac_report_status(int new)
+{
+ if (new == EDAC_REPORTING_ENABLED ||
+ new == EDAC_REPORTING_DISABLED ||
+ new == EDAC_REPORTING_FORCE)
+ edac_report = new;
+}
+EXPORT_SYMBOL_GPL(set_edac_report_status);
+
+static int edac_report_set(const char *str, const struct kernel_param *kp)
+{
+ if (!str)
+ return -EINVAL;
+
+ if (!strncmp(str, "on", 2))
+ edac_report = EDAC_REPORTING_ENABLED;
+ else if (!strncmp(str, "off", 3))
+ edac_report = EDAC_REPORTING_DISABLED;
+ else if (!strncmp(str, "force", 5))
+ edac_report = EDAC_REPORTING_FORCE;
+
+ return 0;
+}
+
+static int edac_report_get(char *buffer, const struct kernel_param *kp)
+{
+ int ret = 0;
+
+ switch (edac_report) {
+ case EDAC_REPORTING_ENABLED:
+ ret = sprintf(buffer, "on");
+ break;
+ case EDAC_REPORTING_DISABLED:
+ ret = sprintf(buffer, "off");
+ break;
+ case EDAC_REPORTING_FORCE:
+ ret = sprintf(buffer, "force");
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+
+ return ret;
+}
+
+static const struct kernel_param_ops edac_report_ops = {
+ .set = edac_report_set,
+ .get = edac_report_get,
+};
+
+module_param_cb(edac_report, &edac_report_ops, &edac_report, 0644);
+
unsigned edac_dimm_info_location(struct dimm_info *dimm, char *buf,
unsigned len)
{
diff --git a/drivers/edac/edac_stub.c b/drivers/edac/edac_stub.c
deleted file mode 100644
index 6aacc569401e..000000000000
--- a/drivers/edac/edac_stub.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * common EDAC components that must be in kernel
- *
- * Author: Dave Jiang <djiang@xxxxxxxxxx>
- *
- * 2007 (c) MontaVista Software, Inc.
- * 2010 (c) Advanced Micro Devices Inc.
- * Borislav Petkov <bp@xxxxxxxxx>
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- *
- */
-#include <linux/module.h>
-#include <linux/edac.h>
-#include <linux/atomic.h>
-#include <linux/device.h>
-
-int edac_report_status = EDAC_REPORTING_ENABLED;
-EXPORT_SYMBOL_GPL(edac_report_status);
-
-static int __init __maybe_unused edac_report_setup(char *str)
-{
- if (!str)
- return -EINVAL;
-
- if (!strncmp(str, "on", 2))
- set_edac_report_status(EDAC_REPORTING_ENABLED);
- else if (!strncmp(str, "off", 3))
- set_edac_report_status(EDAC_REPORTING_DISABLED);
- else if (!strncmp(str, "force", 5))
- set_edac_report_status(EDAC_REPORTING_FORCE);
-
- return 0;
-}
-__setup("edac_report=", edac_report_setup);
diff --git a/include/linux/edac.h b/include/linux/edac.h
index c55e93975079..faf87e1eca21 100644
--- a/include/linux/edac.h
+++ b/include/linux/edac.h
@@ -29,7 +29,9 @@ struct device;

extern int edac_op_state;

-extern struct bus_type *edac_get_sysfs_subsys(void);
+struct bus_type *edac_get_sysfs_subsys(void);
+int get_edac_report_status(void);
+void set_edac_report_status(int new);

enum {
EDAC_REPORTING_ENABLED,
@@ -37,28 +39,6 @@ enum {
EDAC_REPORTING_FORCE
};

-extern int edac_report_status;
-#ifdef CONFIG_EDAC
-static inline int get_edac_report_status(void)
-{
- return edac_report_status;
-}
-
-static inline void set_edac_report_status(int new)
-{
- edac_report_status = new;
-}
-#else
-static inline int get_edac_report_status(void)
-{
- return EDAC_REPORTING_DISABLED;
-}
-
-static inline void set_edac_report_status(int new)
-{
-}
-#endif
-
static inline void opstate_init(void)
{
switch (edac_op_state) {
--
2.11.0