hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/watchdog/diag288_wdt.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Watchdog driver for z/VM and LPAR using the diag 288 interface.
34 *
....@@ -25,13 +26,11 @@
2526 #include <linux/module.h>
2627 #include <linux/moduleparam.h>
2728 #include <linux/slab.h>
28
-#include <linux/miscdevice.h>
2929 #include <linux/watchdog.h>
3030 #include <linux/suspend.h>
3131 #include <asm/ebcdic.h>
3232 #include <asm/diag.h>
3333 #include <linux/io.h>
34
-#include <linux/uaccess.h>
3534
3635 #define MAX_CMDLEN 240
3736 #define DEFAULT_CMD "SYSTEM RESTART"
....@@ -69,7 +68,6 @@
6968 module_param_named(nowayout, nowayout_info, bool, 0444);
7069 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default = CONFIG_WATCHDOG_NOWAYOUT)");
7170
72
-MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
7371 MODULE_ALIAS("vmwatchdog");
7472
7573 static int __diag288(unsigned int func, unsigned int timeout,
....@@ -88,7 +86,7 @@
8886 "1:\n"
8987 EX_TABLE(0b, 1b)
9088 : "+d" (err) : "d"(__func), "d"(__timeout),
91
- "d"(__action), "d"(__len) : "1", "cc");
89
+ "d"(__action), "d"(__len) : "1", "cc", "memory");
9290 return err;
9391 }
9492
....@@ -274,12 +272,21 @@
274272 char ebc_begin[] = {
275273 194, 197, 199, 201, 213
276274 };
275
+ char *ebc_cmd;
277276
278277 watchdog_set_nowayout(&wdt_dev, nowayout_info);
279278
280279 if (MACHINE_IS_VM) {
281
- if (__diag288_vm(WDT_FUNC_INIT, 15,
282
- ebc_begin, sizeof(ebc_begin)) != 0) {
280
+ ebc_cmd = kmalloc(sizeof(ebc_begin), GFP_KERNEL);
281
+ if (!ebc_cmd) {
282
+ pr_err("The watchdog cannot be initialized\n");
283
+ return -ENOMEM;
284
+ }
285
+ memcpy(ebc_cmd, ebc_begin, sizeof(ebc_begin));
286
+ ret = __diag288_vm(WDT_FUNC_INIT, 15,
287
+ ebc_cmd, sizeof(ebc_begin));
288
+ kfree(ebc_cmd);
289
+ if (ret != 0) {
283290 pr_err("The watchdog cannot be initialized\n");
284291 return -EINVAL;
285292 }