From: davidcomponentone@gmail.com
To: zbr@ioremap.net
Cc: davidcomponentone@gmail.com, gregkh@linuxfoundation.org,
yangyingliang@huawei.com, yang.guang5@zte.com.cn,
dan.carpenter@oracle.com, unixbhaskar@gmail.com,
ivan.zaentsev@wirenboard.ru, linux-kernel@vger.kernel.org,
Zeal Robot <zealci@zte.com.cn>
Subject: [PATCH v2] w1: w1_therm: use swap() to make code cleaner
Date: Mon, 20 Dec 2021 15:48:36 +0800 [thread overview]
Message-ID: <cca30ad2a63eb710736b0b968d489c509716ecbc.1639961946.git.yang.guang5@zte.com.cn> (raw)
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
next reply other threads:[~2021-12-20 7:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-20 7:48 davidcomponentone [this message]
2021-12-20 8:08 ` [PATCH v2] w1: w1_therm: use swap() to make code cleaner 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cca30ad2a63eb710736b0b968d489c509716ecbc.1639961946.git.yang.guang5@zte.com.cn \
--to=davidcomponentone@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=ivan.zaentsev@wirenboard.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=unixbhaskar@gmail.com \
--cc=yang.guang5@zte.com.cn \
--cc=yangyingliang@huawei.com \
--cc=zbr@ioremap.net \
--cc=zealci@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).