[4/5] watchdog: diag288_wdt: de-duplicate diag_stat_inc() calls

Message ID 20230203073958.1585738-5-egorenar@linux.ibm.com
State New
Headers
Series diag288 watchdog fixes and improvements |

Commit Message

Alexander Egorenkov Feb. 3, 2023, 7:39 a.m. UTC
  Call diag_stat_inc() from __diag288() to reduce code duplication.

Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
---
 drivers/watchdog/diag288_wdt.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
  

Comments

Guenter Roeck Feb. 3, 2023, 6:36 p.m. UTC | #1
On 2/2/23 23:39, Alexander Egorenkov wrote:
> Call diag_stat_inc() from __diag288() to reduce code duplication.
> 
> Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
> Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/watchdog/diag288_wdt.c | 11 +++--------
>   1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/watchdog/diag288_wdt.c b/drivers/watchdog/diag288_wdt.c
> index c717f47dd4c3..a29ad164b27a 100644
> --- a/drivers/watchdog/diag288_wdt.c
> +++ b/drivers/watchdog/diag288_wdt.c
> @@ -78,6 +78,8 @@ static int __diag288(unsigned int func, unsigned int timeout,
>   	union register_pair r3 = { .even = action, .odd = len, };
>   	int err;
>   
> +	diag_stat_inc(DIAG_STAT_X288);
> +
>   	err = -EINVAL;
>   	asm volatile(
>   		"	diag	%[r1],%[r3],0x288\n"
> @@ -100,14 +102,12 @@ static int __diag288_vm(unsigned int  func, unsigned int timeout, char *cmd)
>   	ASCEBC(cmd_buf, MAX_CMDLEN);
>   	EBC_TOUPPER(cmd_buf, MAX_CMDLEN);
>   
> -	diag_stat_inc(DIAG_STAT_X288);
>   	return __diag288(func, timeout, virt_to_phys(cmd_buf), len);
>   }
>   
>   static int __diag288_lpar(unsigned int func, unsigned int timeout,
>   			  unsigned long action)
>   {
> -	diag_stat_inc(DIAG_STAT_X288);
>   	return __diag288(func, timeout, action, 0);
>   }
>   
> @@ -135,12 +135,7 @@ static int wdt_start(struct watchdog_device *dev)
>   
>   static int wdt_stop(struct watchdog_device *dev)
>   {
> -	int ret;
> -
> -	diag_stat_inc(DIAG_STAT_X288);
> -	ret = __diag288(WDT_FUNC_CANCEL, 0, 0, 0);
> -
> -	return ret;
> +	return __diag288(WDT_FUNC_CANCEL, 0, 0, 0);
>   }
>   
>   static int wdt_ping(struct watchdog_device *dev)
  

Patch

diff --git a/drivers/watchdog/diag288_wdt.c b/drivers/watchdog/diag288_wdt.c
index c717f47dd4c3..a29ad164b27a 100644
--- a/drivers/watchdog/diag288_wdt.c
+++ b/drivers/watchdog/diag288_wdt.c
@@ -78,6 +78,8 @@  static int __diag288(unsigned int func, unsigned int timeout,
 	union register_pair r3 = { .even = action, .odd = len, };
 	int err;
 
+	diag_stat_inc(DIAG_STAT_X288);
+
 	err = -EINVAL;
 	asm volatile(
 		"	diag	%[r1],%[r3],0x288\n"
@@ -100,14 +102,12 @@  static int __diag288_vm(unsigned int  func, unsigned int timeout, char *cmd)
 	ASCEBC(cmd_buf, MAX_CMDLEN);
 	EBC_TOUPPER(cmd_buf, MAX_CMDLEN);
 
-	diag_stat_inc(DIAG_STAT_X288);
 	return __diag288(func, timeout, virt_to_phys(cmd_buf), len);
 }
 
 static int __diag288_lpar(unsigned int func, unsigned int timeout,
 			  unsigned long action)
 {
-	diag_stat_inc(DIAG_STAT_X288);
 	return __diag288(func, timeout, action, 0);
 }
 
@@ -135,12 +135,7 @@  static int wdt_start(struct watchdog_device *dev)
 
 static int wdt_stop(struct watchdog_device *dev)
 {
-	int ret;
-
-	diag_stat_inc(DIAG_STAT_X288);
-	ret = __diag288(WDT_FUNC_CANCEL, 0, 0, 0);
-
-	return ret;
+	return __diag288(WDT_FUNC_CANCEL, 0, 0, 0);
 }
 
 static int wdt_ping(struct watchdog_device *dev)