1 --- nslu2-io.c.old 2da1d3f5c0aa0804c5769588337077ddcb35c5e9
2 +++ linux-2.6.12.2/arch/arm/mach-ixp4xx/nslu2-io.c e895da638b4aae16a11fafe52ae0b063645a9a12
7 +static int nslu2_shutdown_in_progress = 0;
9 static unsigned long init_jiffy = 0; //jiffies at init time
10 static unsigned long rb_presses = 0; //number of reset button presses
11 static unsigned long ontime = 50;
13 static irqreturn_t n2pb_handler (int irq, void *dev_id, struct pt_regs *regs)
17 - wake_up(&n2pb_waitq);
18 - remove_proc_entry(PWR_OFF_STR, NULL); //no parent
19 - n2_buzz(N2_BEEP_PITCH_MED, N2_BEEP_DUR_MED);
20 - ret = create_proc_entry(PWR_OFF_STR, 0, NULL);
21 - nslu2_io_debug((KERN_DEBUG "cpe ret = %p\n", ret));
23 -// WARNING: This is RUDE...it unconditionally pulls the power plug.
24 -// Your data will be at risk...since this is just a test system
25 -// I am leaving it enabled...eventually userland needs to get the
26 -// message, do an orderly shutdown and use an ioctl or something in
27 -// /proc/powerdowm to actually have us pull the plug.
29 - machine_power_off();
31 + if (!nslu2_shutdown_in_progress++) {
32 + wake_up(&n2pb_waitq);
33 + remove_proc_entry(PWR_OFF_STR, NULL); //no parent
34 + n2_buzz(N2_BEEP_PITCH_HIGH, N2_BEEP_DUR_SHORT); // Short, high-pitched "OK"
35 + ret = create_proc_entry(PWR_OFF_STR, 0, NULL);
36 + nslu2_io_debug((KERN_DEBUG "Powerbutton pressed. Shutting down. cpe ret = %p\n", ret));
37 + kill_proc(1,SIGINT,1); // Signal init to shut down
39 + n2_buzz(N2_BEEP_PITCH_LOW, N2_BEEP_DUR_MED); // Make a scary noise!
40 + nslu2_io_debug((KERN_DEBUG "Powerbutton pressed while already in shutdown")); // Whine!
45 -//==================================================================================================
47 -//static void do_rb_timeout(unsigned long data)
51 -// for (i = 0; i < rb_presses; i++)
52 -// n2_buzz(N2_BEEP_PITCH_MED,N2_BEEP_DUR_SHORT);
56 -//==================================================================================================
57 -// does nothing -- waiting for userland to define
58 -// This thing is sorta braindead...edge triggered IRQs aren't available in the drivers yet...so
59 -// we hang in a loop until the button is no longer pressed
66 static irqreturn_t n2rb_handler (int irq, void *dev_id, struct pt_regs *regs)
68 +// This doesn't reset the NSLU2. It powers it off. Close enough, since reset is unreliable
70 - static struct testr test[] = {
94 - nslu2_io_debug(("Reset Entry IRQ =%d Presses = %d Jiffies = %08lx\tIO = %x\tIOW = %x\n", irq, rb_presses, jiffies, (int)_IO('M',rb_presses), (int)_IOW('M',rb_presses,long)));
97 - while ((*IXP4XX_GPIO_GPINR & GPIO_RB_BM) == 0)
98 - ; //wait for button release
100 - if (rb_presses > 20)
102 - tone = (rb_presses * 50) + 200;
103 - ontime = (rb_presses*10) + 100;
104 - offtime = 500 - (rb_presses*20);
105 - nslu2_io_debug(("Ontime = %d\tOfftime = %d\tTone = %d\n",ontime,offtime,tone));
108 - n2bz_ioctl(NULL,NULL, N2BZ_BEEPS, rb_presses);
109 - n2lm_ioctl(NULL,NULL, test[rb_presses].ctl, test[rb_presses].param);
110 -// if (rb_presses == 0) {
111 -// init_jiffy = jiffies;
112 -// init_timer (&n2rb_timer);
113 -// n2rb_timer.function = do_rb_timeout;
116 -// if (rb_presses == 8)
118 -// if (rb_presses & 1)
119 -// n2lm_ledon(test[rb_presses]);
121 -// n2lm_ledoff(test[rb_presses]);
123 -// n2rb_timer.expires = (jiffies + RB_DELAY);
124 -// add_timer (&n2rb_timer);
125 -// if (rb_presses < 5) {
126 -// if (rb_presses > 0)
127 -// n2lm_ledoff(rb_presses);
128 -// n2lm_ledon(++rb_presses);
129 -// n2lm_timer_start(rb_presses);
132 - nslu2_io_debug((KERN_DEBUG "Reset Exit IRQ=%d Presses= %d Jiffies= %08lx\n", irq, rb_presses, jiffies));
133 - return IRQ_HANDLED;
135 + machine_power_off();
136 + return IRQ_HANDLED; // So we don't get a nobody cared error :-P
139 //==================================================================================================