list_for_each_entry(file, &port->file_list, port_list) for (id = 0; id < IB_UMAD_MAX_AGENTS; ++id) { if (!file->agent[id]) continue; ib_unregister_mad_agent(file->agent[id]); file->agent[id] = NULL; } 
/* * Now go through the list of files attached to this port and * unregister all of their MAD agents.  We need to hold * port->mutex while doing this to avoid racing with * ib_umad_close(), but we can't hold the mutex for writing * while calling ib_unregister_mad_agent(), since that might * deadlock by calling back into queue_packet().  So we * downgrade our lock to a read lock, and then drop and * reacquire the write lock for the next iteration. * * We do list_del_init() on the file's list_head so that the * list_del in ib_umad_close() is still OK, even after the * file is removed from the list. */ while (!list_empty(&port->file_list)) { file = list_entry(port->file_list.next, struct ib_umad_file, port_list);  file->agents_dead = 1; list_del_init(&file->port_list);  downgrade_write(&port->mutex);  for (id = 0; id < IB_UMAD_MAX_AGENTS; ++id) if (file->agent[id]) ib_unregister_mad_agent(file->agent[id]);  up_read(&port->mutex); down_write(&port->mutex); } 
static void ib_umad_kill_port(struct ib_umad_port *port){	struct ib_umad_file *file;	int id;	class_set_devdata(port->class_dev,    NULL);	class_set_devdata(port->sm_class_dev, NULL);	class_device_destroy(umad_class, port->dev->dev);	class_device_destroy(umad_class, port->sm_dev->dev);	cdev_del(port->dev);	cdev_del(port->sm_dev);	spin_lock(&port_lock);	umad_port[port->dev_num] = NULL;	spin_unlock(&port_lock);	down_write(&port->mutex);	port->ib_dev = NULL;	list_for_each_entry(file, &port->file_list, port_list)		for (id = 0; id < IB_UMAD_MAX_AGENTS; ++id) {			if (!file->agent[id])				continue;			ib_unregister_mad_agent(file->agent[id]);			file->agent[id] = NULL;		}	up_write(&port->mutex);	clear_bit(port->dev_num, dev_map);}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/94382f3562e350ed7c8f7dcd6fc968bdece31328/user_mad.c/clean/drivers/infiniband/core/user_mad.c