pcmcia_device_query(p_dev); 
/* if a driver is already running, we can abort */ if (p_dev->dev.driver) goto err_put_module; 
static int bind_request(struct pcmcia_bus_socket *s, bind_info_t *bind_info){	struct pcmcia_driver *p_drv;	struct pcmcia_device *p_dev;	int ret = 0;	unsigned long flags;	s = pcmcia_get_bus_socket(s);	if (!s)		return -EINVAL;	ds_dbg(2, "bind_request(%d, '%s')\n", s->parent->sock,	       (char *)bind_info->dev_info);	p_drv = get_pcmcia_driver(&bind_info->dev_info);	if (!p_drv) {		ret = -EINVAL;		goto err_put;	}	if (!try_module_get(p_drv->owner)) {		ret = -EINVAL;		goto err_put_driver;	}	spin_lock_irqsave(&pcmcia_dev_list_lock, flags);        list_for_each_entry(p_dev, &s->devices_list, socket_device_list) {		if (p_dev->func == bind_info->function) {			if ((p_dev->dev.driver == &p_drv->drv)) {				if (p_dev->cardmgr) {					/* if there's already a device					 * registered, and it was registered					 * by userspace before, we need to					 * return the "instance". */					spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);					bind_info->instance = p_dev->instance;					ret = -EBUSY;					goto err_put_module;				} else {					/* the correct driver managed to bind					 * itself magically to the correct					 * device. */					spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);					p_dev->cardmgr = p_drv;					ret = 0;					goto err_put_module;				}			} else if (!p_dev->dev.driver) {				/* there's already a device available where				 * no device has been bound to yet. So we don't				 * need to register a device! */				spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);				goto rescan;			}		}	}	spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);	p_dev = pcmcia_device_add(s, bind_info->function);	if (!p_dev) {		ret = -EIO;		goto err_put_module;	}rescan:	p_dev->cardmgr = p_drv;	pcmcia_device_query(p_dev);	/*	 * Prevent this racing with a card insertion.	 */	down(&s->parent->skt_sem);	bus_rescan_devices(&pcmcia_bus_type);	up(&s->parent->skt_sem);	/* check whether the driver indeed matched. I don't care if this	 * is racy or not, because it can only happen on cardmgr access	 * paths...	 */	if (!(p_dev->dev.driver == &p_drv->drv))		p_dev->cardmgr = NULL; err_put_module:	module_put(p_drv->owner); err_put_driver:	put_driver(&p_drv->drv); err_put:	pcmcia_put_bus_socket(s);	return (ret);} /* bind_request */
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/1ad275e3e7d253d44f03868e85977c908e334fed/ds.c/clean/drivers/pcmcia/ds.c