Subject: Re: [PATCH]Enabling Auto poweron after power is restored.

From: Olof Johansson <[email-masked]>
Date: Mon, 4 Dec 2006 13:49:34 -0600

On Mon, 04 Dec 2006 09:48:58 -0600 Will Schmidt <[email-masked]> wrote:

> You could eliminate the temp variable rtas_poweron_auto_token, and
> rewrite as something like:
> 
>                if (rtas_token("ibm,power-off-ups") == RTAS_UNKNOWN_SERVICE) {
>                        rc = rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1);
>                        printk(KERN_EMERG "Power-off called instead %d\n", rc );
>                } else {
>                        rc = rtas_call(rtas_token("ibm,power-off-ups"),0, 1, NULL);
>                        printk(KERN_INFO "RTAS ibm,power-off-ups returned %d\n", rc);
>                }

It'd be even cleaner if you went the other way around instead, always
do the temp variable. I also renamed it since it was misleading:

void rtas_power_off(void)
{
	int rc;
	int rtas_poweroff_ups_token = rtas_token("ibm,power-off-ups");

 	if (rtas_flash_term_hook)
 		rtas_flash_term_hook(SYS_POWER_OFF);

	if (rtas_poweron_auto == 0 || 
		rtas_poweroff_ups_token == RTAS_UNKNOWN_SERVICE) {
		/* allow power on only with power button press */
		rc = rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1)
		printk(KERN_INFO "RTAS power-off returned %d\n", rc);
	} else {
		/* Enable the system to reboot if power comes back on */
		rc = rtas_call(rtas_poweroff_ups_token, 0, 1, NULL);
		printk(KERN_INFO "RTAS ibm,power-off-ups returned %d\n", rc);
	}
 	for (;;);
}

-Olof