Commit 20e6ce48 authored by Alexander Egorenkov's avatar Alexander Egorenkov Committed by Heiko Carstens
Browse files

watchdog: diag288_wdt: unify lpar and zvm diag288 helpers



Change naming of the internal diag288 helper functions
to improve overall readability and reduce confusion:
* Rename __diag288() to diag288().
* Get rid of the misnamed helper __diag288_lpar() that was used not only
  on LPARs but also zVM and KVM systems.
* Rename __diag288_vm() to diag288_str().

Reviewed-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarAlexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20230203073958.1585738-6-egorenar@linux.ibm.com


Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent 37900851
Loading
Loading
Loading
Loading
+13 −19
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ MODULE_ALIAS("vmwatchdog");

static char *cmd_buf;

static int __diag288(unsigned int func, unsigned int timeout,
static int diag288(unsigned int func, unsigned int timeout,
		   unsigned long action, unsigned int len)
{
	union register_pair r1 = { .even = func, .odd = timeout, };
@@ -92,7 +92,7 @@ static int __diag288(unsigned int func, unsigned int timeout,
	return err;
}

static int __diag288_vm(unsigned int  func, unsigned int timeout, char *cmd)
static int diag288_str(unsigned int func, unsigned int timeout, char *cmd)
{
	ssize_t len;

@@ -102,13 +102,7 @@ static int __diag288_vm(unsigned int func, unsigned int timeout, char *cmd)
	ASCEBC(cmd_buf, MAX_CMDLEN);
	EBC_TOUPPER(cmd_buf, MAX_CMDLEN);

	return __diag288(func, timeout, virt_to_phys(cmd_buf), len);
}

static int __diag288_lpar(unsigned int func, unsigned int timeout,
			  unsigned long action)
{
	return __diag288(func, timeout, action, 0);
	return diag288(func, timeout, virt_to_phys(cmd_buf), len);
}

static int wdt_start(struct watchdog_device *dev)
@@ -119,11 +113,10 @@ static int wdt_start(struct watchdog_device *dev)
	if (MACHINE_IS_VM) {
		func = conceal_on ? (WDT_FUNC_INIT | WDT_FUNC_CONCEAL)
			: WDT_FUNC_INIT;
		ret = __diag288_vm(func, dev->timeout, wdt_cmd);
		ret = diag288_str(func, dev->timeout, wdt_cmd);
		WARN_ON(ret != 0);
	} else {
		ret = __diag288_lpar(WDT_FUNC_INIT,
				     dev->timeout, LPARWDT_RESTART);
		ret = diag288(WDT_FUNC_INIT, dev->timeout, LPARWDT_RESTART, 0);
	}

	if (ret) {
@@ -135,7 +128,7 @@ static int wdt_start(struct watchdog_device *dev)

static int wdt_stop(struct watchdog_device *dev)
{
	return __diag288(WDT_FUNC_CANCEL, 0, 0, 0);
	return diag288(WDT_FUNC_CANCEL, 0, 0, 0);
}

static int wdt_ping(struct watchdog_device *dev)
@@ -152,10 +145,10 @@ static int wdt_ping(struct watchdog_device *dev)
		func = conceal_on ? (WDT_FUNC_INIT | WDT_FUNC_CONCEAL)
			: WDT_FUNC_INIT;

		ret = __diag288_vm(func, dev->timeout, wdt_cmd);
		ret = diag288_str(func, dev->timeout, wdt_cmd);
		WARN_ON(ret != 0);
	} else {
		ret = __diag288_lpar(WDT_FUNC_CHANGE, dev->timeout, 0);
		ret = diag288(WDT_FUNC_CHANGE, dev->timeout, 0, 0);
	}

	if (ret)
@@ -206,20 +199,21 @@ static int __init diag288_init(void)
			return -ENOMEM;
		}

		ret = __diag288_vm(WDT_FUNC_INIT, MIN_INTERVAL, "BEGIN");
		ret = diag288_str(WDT_FUNC_INIT, MIN_INTERVAL, "BEGIN");
		if (ret != 0) {
			pr_err("The watchdog cannot be initialized\n");
			kfree(cmd_buf);
			return -EINVAL;
		}
	} else {
		if (__diag288_lpar(WDT_FUNC_INIT, 30, LPARWDT_RESTART)) {
		if (diag288(WDT_FUNC_INIT, WDT_DEFAULT_TIMEOUT,
			    LPARWDT_RESTART, 0)) {
			pr_err("The watchdog cannot be initialized\n");
			return -EINVAL;
		}
	}

	if (__diag288_lpar(WDT_FUNC_CANCEL, 0, 0)) {
	if (diag288(WDT_FUNC_CANCEL, 0, 0, 0)) {
		pr_err("The watchdog cannot be deactivated\n");
		return -EINVAL;
	}