/* try to get the lock to do some kind of harware access */ 
/* try to get the lock to do some kind of hardware access */ 
static void poll_hpc (void){	struct slot myslot;	struct slot *pslot = NULL;	struct list_head *pslotlist;	int rc;	int poll_state = POLL_LATCH_REGISTER;	u8 oldlatchlow = 0x00;	u8 curlatchlow = 0x00;	int poll_count = 0;	u8 ctrl_count = 0x00;	debug ("%s - Entry\n", __FUNCTION__);	while (!ibmphp_shutdown) {		if (ibmphp_shutdown) 			break;				/* try to get the lock to do some kind of harware access */		down (&semOperations);		switch (poll_state) {		case POLL_LATCH_REGISTER: 			oldlatchlow = curlatchlow;			ctrl_count = 0x00;			list_for_each (pslotlist, &ibmphp_slot_head) {				if (ctrl_count >= ibmphp_get_total_controllers())					break;				pslot = list_entry (pslotlist, struct slot, ibm_slot_list);				if (pslot->ctrl->ctlr_relative_id == ctrl_count) {					ctrl_count++;					if (READ_SLOT_LATCH (pslot->ctrl)) {						rc = ibmphp_hpc_readslot (pslot,									  READ_SLOTLATCHLOWREG,									  &curlatchlow);						if (oldlatchlow != curlatchlow)							process_changeinlatch (oldlatchlow,									       curlatchlow,									       pslot->ctrl);					}				}			}			++poll_count;			poll_state = POLL_SLEEP;			break;		case POLL_SLOTS:			list_for_each (pslotlist, &ibmphp_slot_head) {				pslot = list_entry (pslotlist, struct slot, ibm_slot_list);				// make a copy of the old status				memcpy ((void *) &myslot, (void *) pslot,					sizeof (struct slot));				rc = ibmphp_hpc_readslot (pslot, READ_ALLSTAT, NULL);				if ((myslot.status != pslot->status)				    || (myslot.ext_status != pslot->ext_status))					process_changeinstatus (pslot, &myslot);			}			ctrl_count = 0x00;			list_for_each (pslotlist, &ibmphp_slot_head) {				if (ctrl_count >= ibmphp_get_total_controllers())					break;				pslot = list_entry (pslotlist, struct slot, ibm_slot_list);				if (pslot->ctrl->ctlr_relative_id == ctrl_count) {					ctrl_count++;					if (READ_SLOT_LATCH (pslot->ctrl))						rc = ibmphp_hpc_readslot (pslot,									  READ_SLOTLATCHLOWREG,									  &curlatchlow);				}			}			++poll_count;			poll_state = POLL_SLEEP;			break;		case POLL_SLEEP:			/* don't sleep with a lock on the hardware */			up (&semOperations);			msleep(POLL_INTERVAL_SEC * 1000);			if (ibmphp_shutdown) 				break;						down (&semOperations);						if (poll_count >= POLL_LATCH_CNT) {				poll_count = 0;				poll_state = POLL_SLOTS;			} else				poll_state = POLL_LATCH_REGISTER;			break;		}			/* give up the harware semaphore */		up (&semOperations);		/* sleep for a short time just for good measure */		msleep(100);	}	up (&sem_exit);	debug ("%s - Exit\n", __FUNCTION__);}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/eaae4b3a84a3781543a32bcaf0a33306ae915574/ibmphp_hpc.c/buggy/drivers/pci/hotplug/ibmphp_hpc.c