* [PATCH] powerpc: use swap() to make code cleaner
@ 2021-11-04 6:17 davidcomponentone
2021-11-04 10:06 ` Stephen Rothwell
0 siblings, 1 reply; 7+ messages in thread
From: davidcomponentone @ 2021-11-04 6:17 UTC (permalink / raw)
To: mpe
Cc: davidcomponentone, benh, paulus, nathan, sfr, sxwjean,
aneesh.kumar, yang.guang5, linuxppc-dev, 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.
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
---
arch/powerpc/kernel/fadump.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index b7ceb041743c..5b40e2d46090 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -1265,7 +1265,6 @@ static void fadump_release_reserved_area(u64 start, u64 end)
static void sort_and_merge_mem_ranges(struct fadump_mrange_info *mrange_info)
{
struct fadump_memory_range *mem_ranges;
- struct fadump_memory_range tmp_range;
u64 base, size;
int i, j, idx;
@@ -1281,9 +1280,7 @@ static void sort_and_merge_mem_ranges(struct fadump_mrange_info *mrange_info)
idx = j;
}
if (idx != i) {
- tmp_range = mem_ranges[idx];
- mem_ranges[idx] = mem_ranges[i];
- mem_ranges[i] = tmp_range;
+ swap(mem_ranges[idx], mem_ranges[i]);
}
}
--
2.30.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] powerpc: use swap() to make code cleaner
2021-11-04 6:17 [PATCH] powerpc: use swap() to make code cleaner davidcomponentone
@ 2021-11-04 10:06 ` Stephen Rothwell
2021-11-04 11:33 ` Segher Boessenkool
0 siblings, 1 reply; 7+ messages in thread
From: Stephen Rothwell @ 2021-11-04 10:06 UTC (permalink / raw)
To: davidcomponentone
Cc: mpe, benh, paulus, nathan, sfr, sxwjean, aneesh.kumar,
yang.guang5, linuxppc-dev, linux-kernel, Zeal Robot
[-- Attachment #1: Type: text/plain, Size: 327 bytes --]
Hi,
On Thu, 4 Nov 2021 14:17:09 +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.
So if swap() is in the above include file, then you should include it.
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] powerpc: use swap() to make code cleaner
2021-11-04 10:06 ` Stephen Rothwell
@ 2021-11-04 11:33 ` Segher Boessenkool
2021-11-04 20:26 ` Stephen Rothwell
0 siblings, 1 reply; 7+ messages in thread
From: Segher Boessenkool @ 2021-11-04 11:33 UTC (permalink / raw)
To: Stephen Rothwell
Cc: davidcomponentone, sxwjean, Zeal Robot, linux-kernel, nathan,
yang.guang5, paulus, aneesh.kumar, linuxppc-dev
On Thu, Nov 04, 2021 at 09:06:56PM +1100, Stephen Rothwell wrote:
> On Thu, 4 Nov 2021 14:17:09 +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.
>
> So if swap() is in the above include file, then you should include it.
It is included from kernel.h already (which is included from delay.h).
Segher
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] powerpc: use swap() to make code cleaner
2021-11-04 11:33 ` Segher Boessenkool
@ 2021-11-04 20:26 ` Stephen Rothwell
0 siblings, 0 replies; 7+ messages in thread
From: Stephen Rothwell @ 2021-11-04 20:26 UTC (permalink / raw)
To: Segher Boessenkool
Cc: davidcomponentone, sxwjean, Zeal Robot, linux-kernel, nathan,
yang.guang5, paulus, aneesh.kumar, linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 911 bytes --]
Hi Segher,
On Thu, 4 Nov 2021 06:33:51 -0500 Segher Boessenkool <segher@kernel.crashing.org> wrote:
>
> On Thu, Nov 04, 2021 at 09:06:56PM +1100, Stephen Rothwell wrote:
> > On Thu, 4 Nov 2021 14:17:09 +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.
> >
> > So if swap() is in the above include file, then you should include it.
>
> It is included from kernel.h already (which is included from delay.h).
And that becomes a pain when include files get "cleaned up". :-(
$ grep kernel.h include/linux/delay.h
$
See commit
300424acf349 ("include/linux/delay.h: replace kernel.h with the necessary inclusions")
currently pending the Andrew Morton's patch queue (the above is a
linux-next commit).
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] powerpc: use swap() to make code cleaner
2021-12-18 1:59 davidcomponentone
@ 2021-12-26 21:52 ` Michael Ellerman
0 siblings, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2021-12-26 21:52 UTC (permalink / raw)
To: benh, davidcomponentone
Cc: mpe, yang.guang5, Zeal Robot, linux-kernel, paulus, linuxppc-dev
On Sat, 18 Dec 2021 09:59:17 +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.
>
>
Applied to powerpc/next.
[1/1] powerpc: use swap() to make code cleaner
https://git.kernel.org/powerpc/c/a605b39e8ef703828b9e26750ea1925a6a5ef848
cheers
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] powerpc: use swap() to make code cleaner
@ 2021-12-18 1:59 davidcomponentone
2021-12-26 21:52 ` Michael Ellerman
0 siblings, 1 reply; 7+ messages in thread
From: davidcomponentone @ 2021-12-18 1:59 UTC (permalink / raw)
To: benh
Cc: davidcomponentone, mpe, paulus, yang.guang5, linuxppc-dev,
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.
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>
---
arch/powerpc/platforms/powermac/pic.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index 4921bccf0376..75d8d7ec53db 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -311,11 +311,8 @@ static void __init pmac_pic_probe_oldstyle(void)
/* Check ordering of master & slave */
if (of_device_is_compatible(master, "gatwick")) {
- struct device_node *tmp;
BUG_ON(slave == NULL);
- tmp = master;
- master = slave;
- slave = tmp;
+ swap(master, slave);
}
/* We found a slave */
--
2.30.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] powerpc: use swap() to make code cleaner
@ 2021-11-04 1:09 davidcomponentone
0 siblings, 0 replies; 7+ messages in thread
From: davidcomponentone @ 2021-11-04 1:09 UTC (permalink / raw)
To: benh
Cc: davidcomponentone, mpe, paulus, linuxppc-dev, linux-kernel,
zealci, yang.guang5
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>
---
arch/powerpc/platforms/powermac/pic.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index 4921bccf0376..75d8d7ec53db 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -311,11 +311,8 @@ static void __init pmac_pic_probe_oldstyle(void)
/* Check ordering of master & slave */
if (of_device_is_compatible(master, "gatwick")) {
- struct device_node *tmp;
BUG_ON(slave == NULL);
- tmp = master;
- master = slave;
- slave = tmp;
+ swap(master, slave);
}
/* We found a slave */
--
2.30.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-12-26 21:54 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04 6:17 [PATCH] powerpc: use swap() to make code cleaner davidcomponentone
2021-11-04 10:06 ` Stephen Rothwell
2021-11-04 11:33 ` Segher Boessenkool
2021-11-04 20:26 ` Stephen Rothwell
-- strict thread matches above, loose matches on Subject: below --
2021-12-18 1:59 davidcomponentone
2021-12-26 21:52 ` Michael Ellerman
2021-11-04 1:09 davidcomponentone
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).