Skip to contentSkip to conversation

MIPS: ralink: remove ralink_halt()

PATCH In review NeilBrown 2 participants 3 messages Mar 20, 2018 – Mar 22, 2018

Subsystems (2)
lore
Share & tools
lore

NeilBrown

author
#0 lore raw

PATCH 1/1 MIPS: ralink: remove ralink_halt()

ralink_halt() does nothing that machine_halt()
doesn't already do, so it adds no value.

It actually causes incorrect behaviour due to the "unreachable()" at the end. This tell the compiler that the end of the function will never be reached, which isn't true. The compiler responds by not adding a 'return' instruction, so control simply moves on to whatever bytes come afterwards in memory. In my tested, that was the ralink_restart() function. This means that an attempt to 'halt' the machine would actually cause a reboot.

So remove ralink_halt() so that a 'halt' really does halt.

---
 arch/mips/ralink/reset.c | 7 -------
 1 file changed, 7 deletions(-)
arch/mips/ralink/reset.c +0 -7
index 64543d66e76b..e9531fea23a2 100644
@@ -96,16 +96,9 @@ static void ralink_restart(char *command)
 	unreachable();
 }
 
-static void ralink_halt(void)
-{
-	local_irq_disable();
-	unreachable();
-}
-
 static int __init mips_reboot_setup(void)
 {
 	_machine_restart = ralink_restart;
-	_machine_halt = ralink_halt;
 
 	return 0;
 }
Signature · 1 line
2.14.0.rc0.dirty
#1 lore raw
Quoted 13 lines · NeilBrown

ralink_halt() does nothing that machine_halt()
doesn't already do, so it adds no value.

It actually causes incorrect behaviour due to the "unreachable()" at the end. This tell the compiler that the end of the function will never be reached, which isn't true. The compiler responds by not adding a 'return' instruction, so control simply moves on to whatever bytes come afterwards in memory. In my tested, that was the ralink_restart() function. This means that an attempt to 'halt' the machine would actually cause a reboot.

Quoted 3 lines

So remove ralink_halt() so that a 'halt' really does halt.

Thanks, I've cosmetically tweaked the commit message (mainly reflow to 72 characters) and added:

Fixes c06e836ada59 ("MIPS: ralink: adds reset code")
Cc <[email protected]> # 3.9+

and applied for 4.16.

BTW, I'm intrigued to know if there's a particular reason you don't author / sign-off as "Neil Brown"? Its supposed to be real names, though "NeilBrown" is hardly difficult to figure out so I don't actually object.

Cheers
James

author
#2 lore raw
Quoted 24 lines · James Hogan
Quoted 13 lines · NeilBrown

ralink_halt() does nothing that machine_halt()
doesn't already do, so it adds no value.

It actually causes incorrect behaviour due to the "unreachable()" at the end. This tell the compiler that the end of the function will never be reached, which isn't true. The compiler responds by not adding a 'return' instruction, so control simply moves on to whatever bytes come afterwards in memory. In my tested, that was the ralink_restart() function. This means that an attempt to 'halt' the machine would actually cause a reboot.

Quoted 3 lines

So remove ralink_halt() so that a 'halt' really does halt.

Thanks, I've cosmetically tweaked the commit message (mainly reflow to 72 characters) and added:

Fixes c06e836ada59 ("MIPS: ralink: adds reset code")
Cc <[email protected]> # 3.9+
Quoted 6 lines

and applied for 4.16.

BTW, I'm intrigued to know if there's a particular reason you don't author / sign-off as "Neil Brown"? Its supposed to be real names, though "NeilBrown" is hardly difficult to figure out so I don't actually object.

I started using NeilBrown way back when I was an undergrad student and it stuck. When you grow up as a Brown, you know your name isn't going to make you unique. e.g. I'm not an author of "Red Hat Linux System Administration Unleashed" (he has a space in his name!!). So I chose a different way to make my name distinctive.
Yes, it isn't technically compliant - you are the second person to comment in the nearly twenty years I've been working on Linux :-)

Thanks,
NeilBrown