- switch (p_slot->state) {
- case STATIC_STATE:
- p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
- if (getstatus) {
- p_slot->state = BLINKINGOFF_STATE;
- info(msg_button_off, p_slot->number);
- } else {
- p_slot->state = BLINKINGON_STATE;
- info(msg_button_on, p_slot->number);
- }
- /* blink green LED and turn off amber */
- p_slot->hpc_ops->green_led_blink(p_slot);
- p_slot->hpc_ops->set_attention_status(p_slot, 0);
-
- schedule_delayed_work(&p_slot->work, 5*HZ);
- break;
- case BLINKINGOFF_STATE:
- case BLINKINGON_STATE:
- /*
- * Cancel if we are still blinking; this means that we
- * press the attention again before the 5 sec. limit
- * expires to cancel hot-add or hot-remove
- */
- info("Button cancel on Slot(%s)\n", p_slot->name);
- dbg("%s: button cancel\n", __FUNCTION__);
- cancel_delayed_work(&p_slot->work);
- if (p_slot->state == BLINKINGOFF_STATE)
- p_slot->hpc_ops->green_led_on(p_slot);
- else
- p_slot->hpc_ops->green_led_off(p_slot);
- p_slot->hpc_ops->set_attention_status(p_slot, 0);
- info(msg_button_cancel, p_slot->number);
- p_slot->state = STATIC_STATE;
- break;
- case POWEROFF_STATE:
- case POWERON_STATE:
- /*
- * Ignore if the slot is on power-on or power-off state;
- * this means that the previous attention button action
- * to hot-add or hot-remove is undergoing
- */
- info("Button ignore on Slot(%s)\n", p_slot->name);
- update_slot_info(p_slot);
- break;
- default:
- warn("Not a valid state\n");
- break;
- }
-}
-
-static void interrupt_event_handler(void *data)
-{
- struct event_info *info = data;
- struct slot *p_slot = info->p_slot;
-
- mutex_lock(&p_slot->lock);
- switch (info->event_type) {
- case INT_BUTTON_PRESS:
- handle_button_press_event(p_slot);
- break;
- case INT_POWER_FAULT:
- dbg("%s: power fault\n", __FUNCTION__);
- p_slot->hpc_ops->set_attention_status(p_slot, 1);
- p_slot->hpc_ops->green_led_off(p_slot);
- break;
- default:
- update_slot_info(p_slot);
- break;
+ while (change) {
+ change = 0;
+
+ for (loop = 0; loop < 10; loop++) {
+ if (ctrl->event_queue[loop].event_type != 0) {
+ dbg("%s:loop %x event_type %x\n", __FUNCTION__, loop,
+ ctrl->event_queue[loop].event_type);
+ hp_slot = ctrl->event_queue[loop].hp_slot;
+
+ p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
+
+ if (ctrl->event_queue[loop].event_type == INT_BUTTON_CANCEL) {
+ dbg("%s: button cancel\n", __FUNCTION__);
+ del_timer(&p_slot->task_event);
+
+ switch (p_slot->state) {
+ case BLINKINGOFF_STATE:
+ /* Wait for exclusive access to hardware */
+ down(&ctrl->crit_sect);
+
+ p_slot->hpc_ops->green_led_on(p_slot);
+
+ p_slot->hpc_ops->set_attention_status(p_slot, 0);
+
+ /* Done with exclusive hardware access */
+ up(&ctrl->crit_sect);
+ break;
+ case BLINKINGON_STATE:
+ /* Wait for exclusive access to hardware */
+ down(&ctrl->crit_sect);
+
+ p_slot->hpc_ops->green_led_off(p_slot);
+
+ p_slot->hpc_ops->set_attention_status(p_slot, 0);
+
+ /* Done with exclusive hardware access */
+ up(&ctrl->crit_sect);
+
+ break;
+ default:
+ warn("Not a valid state\n");
+ return;
+ }
+ info(msg_button_cancel, p_slot->number);
+ p_slot->state = STATIC_STATE;
+ } else if (ctrl->event_queue[loop].event_type == INT_BUTTON_PRESS) {
+ /* Button Pressed (No action on 1st press...) */
+ dbg("%s: Button pressed\n", __FUNCTION__);
+
+ p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
+ if (getstatus) {
+ /* slot is on */
+ dbg("%s: slot is on\n", __FUNCTION__);
+ p_slot->state = BLINKINGOFF_STATE;
+ info(msg_button_off, p_slot->number);
+ } else {
+ /* slot is off */
+ dbg("%s: slot is off\n", __FUNCTION__);
+ p_slot->state = BLINKINGON_STATE;
+ info(msg_button_on, p_slot->number);
+ }
+
+ /* Wait for exclusive access to hardware */
+ down(&ctrl->crit_sect);
+
+ /* blink green LED and turn off amber */
+ p_slot->hpc_ops->green_led_blink(p_slot);
+
+ p_slot->hpc_ops->set_attention_status(p_slot, 0);
+
+ /* Done with exclusive hardware access */
+ up(&ctrl->crit_sect);
+
+ init_timer(&p_slot->task_event);
+ p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */
+ p_slot->task_event.function = (void (*)(unsigned long)) pushbutton_helper_thread;
+ p_slot->task_event.data = (unsigned long) p_slot;
+
+ dbg("%s: add_timer p_slot = %p\n", __FUNCTION__,(void *) p_slot);
+ add_timer(&p_slot->task_event);
+ } else if (ctrl->event_queue[loop].event_type == INT_POWER_FAULT) {
+ /***********POWER FAULT********************/
+ dbg("%s: power fault\n", __FUNCTION__);
+ /* Wait for exclusive access to hardware */
+ down(&ctrl->crit_sect);
+
+ p_slot->hpc_ops->set_attention_status(p_slot, 1);
+
+ p_slot->hpc_ops->green_led_off(p_slot);
+
+ /* Done with exclusive hardware access */
+ up(&ctrl->crit_sect);
+ } else {
+ /* refresh notification */
+ if (p_slot)
+ update_slot_info(p_slot);
+ }
+
+ ctrl->event_queue[loop].event_type = 0;
+
+ change = 1;
+ }
+ } /* End of FOR loop */