linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] w1: w1_therm: use swap() to make code cleaner
@ 2021-12-20  7:48 davidcomponentone
  2021-12-20  8:08 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: davidcomponentone @ 2021-12-20  7:48 UTC (permalink / raw)
  To: zbr
  Cc: davidcomponentone, gregkh, yangyingliang, yang.guang5,
	dan.carpenter, unixbhaskar, ivan.zaentsev, linux-kernel,
	Zeal Robot

From: Yang Guang <yang.guang5@zte.com.cn>

Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
opencoding it.

Changes from v1->v2:
- Delete the curly {} braces.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: David Yang <davidcomponentone@gmail.com>
Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
---
 drivers/w1/slaves/w1_therm.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index ca70c5f03206..565578002d79 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -1785,7 +1785,7 @@ static ssize_t alarms_store(struct device *device,
 	u8 new_config_register[3];	/* array of data to be written */
 	int temp, ret;
 	char *token = NULL;
-	s8 tl, th, tt;	/* 1 byte per value + temp ring order */
+	s8 tl, th;	/* 1 byte per value + temp ring order */
 	char *p_args, *orig;
 
 	p_args = orig = kmalloc(size, GFP_KERNEL);
@@ -1836,9 +1836,8 @@ static ssize_t alarms_store(struct device *device,
 	th = int_to_short(temp);
 
 	/* Reorder if required th and tl */
-	if (tl > th) {
-		tt = tl; tl = th; th = tt;
-	}
+	if (tl > th)
+		swap(tl, th);
 
 	/*
 	 * Read the scratchpad to change only the required bits
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] w1: w1_therm: use swap() to make code cleaner
  2021-12-20  7:48 [PATCH v2] w1: w1_therm: use swap() to make code cleaner davidcomponentone
@ 2021-12-20  8:08 ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2021-12-20  8:08 UTC (permalink / raw)
  To: davidcomponentone
  Cc: zbr, yangyingliang, yang.guang5, dan.carpenter, unixbhaskar,
	ivan.zaentsev, linux-kernel, Zeal Robot

On Mon, Dec 20, 2021 at 03:48:36PM +0800, davidcomponentone@gmail.com wrote:
> From: Yang Guang <yang.guang5@zte.com.cn>
> 
> Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
> opencoding it.
> 
> Changes from v1->v2:
> - Delete the curly {} braces.

version info goes below the --- line.  Please fix up and resend a v3.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] w1: w1_therm: use swap() to make code cleaner
  2021-11-05  7:32 ` [PATCH v2] " davidcomponentone
@ 2021-11-05  7:37   ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2021-11-05  7:37 UTC (permalink / raw)
  To: davidcomponentone
  Cc: dan.carpenter, ivan.zaentsev, linux-kernel, unixbhaskar,
	yang.guang5, yangyingliang, zbr, zealci

On Fri, Nov 05, 2021 at 03:32:44PM +0800, davidcomponentone@gmail.com wrote:
> From: Yang Guang <yang.guang5@zte.com.cn>
> 
> Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
> opencoding it.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
> ---
>  drivers/w1/slaves/w1_therm.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
> index ca70c5f03206..565578002d79 100644
> --- a/drivers/w1/slaves/w1_therm.c
> +++ b/drivers/w1/slaves/w1_therm.c
> @@ -1785,7 +1785,7 @@ static ssize_t alarms_store(struct device *device,
>  	u8 new_config_register[3];	/* array of data to be written */
>  	int temp, ret;
>  	char *token = NULL;
> -	s8 tl, th, tt;	/* 1 byte per value + temp ring order */
> +	s8 tl, th;	/* 1 byte per value + temp ring order */
>  	char *p_args, *orig;
>  
>  	p_args = orig = kmalloc(size, GFP_KERNEL);
> @@ -1836,9 +1836,8 @@ static ssize_t alarms_store(struct device *device,
>  	th = int_to_short(temp);
>  
>  	/* Reorder if required th and tl */
> -	if (tl > th) {
> -		tt = tl; tl = th; th = tt;
> -	}
> +	if (tl > th)
> +		swap(tl, th);
>  
>  	/*
>  	 * Read the scratchpad to change only the required bits
> -- 
> 2.30.2
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- This looks like a new version of a previously submitted patch, but you
  did not list below the --- line any changes from the previous version.
  Please read the section entitled "The canonical patch format" in the
  kernel file, Documentation/SubmittingPatches for what needs to be done
  here to properly describe this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] w1: w1_therm: use swap() to make code cleaner
  2021-11-04 11:09 [PATCH] " Dan Carpenter
@ 2021-11-05  7:32 ` davidcomponentone
  2021-11-05  7:37   ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: davidcomponentone @ 2021-11-05  7:32 UTC (permalink / raw)
  To: dan.carpenter
  Cc: davidcomponentone, gregkh, ivan.zaentsev, linux-kernel,
	unixbhaskar, yang.guang5, yangyingliang, zbr, zealci

From: Yang Guang <yang.guang5@zte.com.cn>

Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
opencoding it.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
---
 drivers/w1/slaves/w1_therm.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index ca70c5f03206..565578002d79 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -1785,7 +1785,7 @@ static ssize_t alarms_store(struct device *device,
 	u8 new_config_register[3];	/* array of data to be written */
 	int temp, ret;
 	char *token = NULL;
-	s8 tl, th, tt;	/* 1 byte per value + temp ring order */
+	s8 tl, th;	/* 1 byte per value + temp ring order */
 	char *p_args, *orig;
 
 	p_args = orig = kmalloc(size, GFP_KERNEL);
@@ -1836,9 +1836,8 @@ static ssize_t alarms_store(struct device *device,
 	th = int_to_short(temp);
 
 	/* Reorder if required th and tl */
-	if (tl > th) {
-		tt = tl; tl = th; th = tt;
-	}
+	if (tl > th)
+		swap(tl, th);
 
 	/*
 	 * Read the scratchpad to change only the required bits
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-20  8:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-20  7:48 [PATCH v2] w1: w1_therm: use swap() to make code cleaner davidcomponentone
2021-12-20  8:08 ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2021-11-04 11:09 [PATCH] " Dan Carpenter
2021-11-05  7:32 ` [PATCH v2] " davidcomponentone
2021-11-05  7:37   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).