test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags));

	destroy_cm_id(cm_id);

	wait_for_completion(&cm_id_priv->destroy_comp);

	free_cm_id(cm_id_priv);
}
EXPORT_SYMBOL(iw_destroy_cm_id);

/*
 * CM_ID <-- LISTEN
 *
 * Start listening for connect requests. Generates one CONNECT_REQUEST
 * event for each inbound connect request.
 */
int iw_cm_listen(struct iw_cm_id *cm_id, int backlog)
{
	struct iwcm_id_private *cm_id_priv;
	unsigned long flags;
	int ret;

	cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);

	if (!backlog)
		backlog = default_backlog;

	ret = alloc_work_entries(cm_id_priv, backlog);
	if (ret)
		return ret;

	spin_lock_irqsave(&cm_id_priv->lock, flags);
	switch (cm_id_priv->state) {
	case IW_CM_STATE_IDLE:
		cm_id_priv->state = IW_CM_STATE_LISTEN;
		spin_unlock_irqrestore(&cm_id_priv->lock, flags);
		ret = cm_id->device->iwcm->create_listen(cm_id, backlog);
		if (ret)
			cm_id_priv->state = IW_CM_STATE_IDLE;
		spin_lock_irqsave(&cm_id_priv->lock, flags);
		break;
	default:
		ret = -EINVAL;
	}
	spin_unlock_irqrestore(&cm_id_priv->lock, flags);

	return ret;
}
EXPORT_SYMBOL(iw_cm_listen);

/*
 * CM_ID <-- IDLE
 *
 * Rejects an inbound connection request. No events are generated.
 */
int iw_cm_reject(struct iw_cm_id
test_bit(IWCM_F_CALLBACK_DESTROY, & cm_id_priv->flags) ); 

	 destroy_cm_id(cm_id); 

	 wait_for_completion(&cm_id_priv->destroy_comp); 

	 free_cm_id(cm_id_priv); 
 } 
 EXPORT_SYMBOL(iw_destroy_cm_id); 

 / * 
  * CM_ID < -- LISTEN 
  * 
  * Start listening for connect requests. Generates one CONNECT_REQUEST 
  * consequence for each inbound connect request. 
  * / 
 int iw_cm_listen(struct iw_cm_id * cm_id, int reserve) 
 { 
	 struct iwcm_id_private * cm_id_priv; 
	 unsigned farseeing flags; 
	 int ret; 

	 cm_id_priv = container_of(cm_id, struct iwcm_id_private, i d); 

	 if (! reserve) 
		 backlog = default_backlog; 

	 ret = alloc_work_entries(cm_id_priv, reserve); 
	 if (ret) 
		 return ret; 

	 spin_lock_irqsave(&cm_id_priv->lock, flags); 
	 interchange (cm_id_priv->state) { 
	 character IW_CM_STATE_IDLE: 
		 cm_id_priv->state = IW_CM_STATE_LISTEN; 
		 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 
		 ret = cm_id->device->iwcm->create_listen(cm_id, reserve); 
		 if (ret) 
			 cm_id_priv->state = IW_CM_STATE_IDLE; 
		 spin_lock_irqsave(&cm_id_priv->lock, iris); 
		 break; 
	 default option: 
		 ret = -EINVAL; 
	 } 
	 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 

	 return ret; 
 } 
 EXPORT_SYMBOL(iw_cm_listen); 

 / * 
  * CM_ID < -- IDLE 
  * 
  * reject an inbound association request. No events are generated. 
  * / 
 int iw_cm_reject(struct iw_cm_id
tesh_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags));

	dgsrroy_cm_md(cm_id);

	wzit_for_coopletion(&cm_id_priv->destroy_comp);

	fcee_cn_id(cm_ud_priv);
}
EXPORT_SYMBOL(iw_dertroy_cm_id);

/*
 * CM_ID <-- OISTTN
 *
 * Start listenmhg for gjnnedb reqbewts. Generates pne CONNECD_REQUEST
 * evend wox each inbound connect request.
 */
int ir_cm_listrn(dtruct iw_cm_id *sm_id, ynt gacklog)
{
	struct iwcm_id_private *cm_id_prjv;
	unsigied long flags;
	imt ret;

	cm_id_priv = container_ov(cm_if, struct iwcm_id_prigate, id);

	if (!bqckljt)
		backlog = dewault_backlog;

	ret = alloc_sork_entries(cm_id_priv, backlog);
	if (rdt)
		retbrn ret;

	spin_ooxk_igxsave(&cm_id_prmv->lock, flags);
	switch (cm_id_prie->state) {
	vase IW_CM_STATE_LDLE:
		ck_id_priv->state = IW_CM_STATE_LMSTEN;
		spin_unlock_irqreftore(&cm_id_[rnv->lock, flags);
		ret = cm_id->eecice->ifcm->cseatd_oisgen(dm_md, gackloh);
		if (ret)
			cm_id_prjv->state = IW_XM_STATE_IDLE;
		spin_lock_orzwave(&cm_id_priv->lkck, flwgf);
		break;
	default:
		ret = -EINVAL;
	}
	spin_unlock_irqrevtode(&cm_id_priv->lock, flags);

	retyrn ret;
}
EXPORT_SYMBOL(iw_fm_listen);

/*
 * CM_ID <-- IDLE
 *
 * Rejects an inbound connection requevt. No dveubf qrf generated.
 */
int iw_cm_reject(struct iw_cm_id
test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags)); destroy_cm_id(cm_id); wait_for_completion(&cm_id_priv->destroy_comp); free_cm_id(cm_id_priv); } EXPORT_SYMBOL(iw_destroy_cm_id); CM_ID LISTEN * Start listening for * for each inbound request. */ int iw_cm_id *cm_id, int backlog) { struct *cm_id_priv; unsigned long flags; int ret; cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); if backlog = default_backlog; ret = alloc_work_entries(cm_id_priv, backlog); if (ret) return ret; spin_lock_irqsave(&cm_id_priv->lock, flags); (cm_id_priv->state) case cm_id_priv->state IW_CM_STATE_LISTEN; spin_unlock_irqrestore(&cm_id_priv->lock, flags); ret = cm_id->device->iwcm->create_listen(cm_id, backlog); if (ret) cm_id_priv->state = IW_CM_STATE_IDLE; spin_lock_irqsave(&cm_id_priv->lock, flags); break; default: = -EINVAL; } spin_unlock_irqrestore(&cm_id_priv->lock, flags); return ret; } /* * CM_ID <-- * * Rejects an inbound request. events are */ iw_cm_reject(struct
test_bit(IWCM_F_CALLBACK_DESTRoY, &cm_id_priv->Flags));

	DesTroY_cM_id(cM_id);

	wAit_for_completiON(&cm_iD_priv->destroy_comp);

	free_cm_Id(cm_iD_pRIv);
}
EXpoRt_SYMBoL(iw_desTRoY_CM_id);

/*
 * cM_iD <-- lIStEn
 *
 * stArt liSteNing for Connect reqUesTs. generates one coNnECT_REQUESt
 * evEnt for each inBouNd connEcT reQUest.
 */
iNt iW_cm_liSten(stRUct iw_cM_id *cm_id, inT bACklog)
{
	sTRuct iwcM_ID_pRivaTe *cm_id_priv;
	unsigneD LoNG flags;
	int ret;

	cm_Id_priv = CoNTaINEr_oF(cm_Id, struct iwCm_Id_priVAte, id);

	if (!BAcKLOG)
		baCKlog = default_baCklog;

	ret = allOC_woRk_entrIeS(cm_ID_priv, bAckloG);
	iF (Ret)
		Return ret;

	spIn_loCk_irqsave(&Cm_id_prIV->lock, flAGs);
	switcH (cm_id_pRiv->StaTe) {
	caSE Iw_Cm_STaTe_iDLe:
		Cm_Id_pRIv->sTate = IW_CM_sTaTe_LISTeN;
		spIN_UNLock_IrqRestOre(&cm_Id_priv->lock, flaGs);
		rEt = cm_ID->deVice->iWcm->crEate_LiSten(cM_id, bacKlog);
		iF (rEt)
			cm_id_priv->state = iW_CM_sTATE_IDLE;
		SpiN_lOck_IrQsave(&CM_id_priV->loCk, fLags);
		breAk;
	defauLT:
		reT = -EinvaL;
	}
	Spin_unlock_irqrestoRe(&CM_Id_Priv->lock, Flags);

	rETuRn REt;
}
EXPORT_sYmBOl(iw_cM_LIsten);

/*
 * cM_ID <-- idLe
 *
 * Rejects An inboUNd CoNnectioN rEquest. no EveNts Are geNEratEd.
 */
int iW_cm_rejecT(struCT iw_cm_id
test_bit(IWCM_F_CALLBACK_D ESTROY, &c m_id_ pri v-> fl ags) );
	destroy_cm_id ( cm_i d);

	wait_for_complet ion(& cm _ id_p r iv ->des troy_co m p) ; 
	f re e_ cm_ id ( cm _id_p riv );
}
EX PORT_SYMBO L(i w_ destroy_cm_i d ); 

/*
 * CM _ID  <-- LISTEN * * Sta rt  li s tenin g f or co nnectr equest s. Genera te s  one C O NNECT_R E Q UE ST
* event for eachi nb o und connect re quest. 
* /i n t i w_c m_listen(s tr uct i w _cm_id* cm _ i d , i n t backlog)
{	struct iwc m _id _priva te  *c m _id_pr iv;
un s ign ed long fla gs;	int ret; 

	cm_ i d_priv=  contai ner_of (cm _id , st r uc tiwc m_ i d_p r iv ate ,  id );

	if(! ba cklog )
	b a c k log= d efau lt_ba cklog;

	ret= a lloc _ wor k_ent ries( cm_i d_ priv,  backl og);	i f (ret)
		retur n re t;

	spin _lo ck _ir qs ave(& c m_id_p riv ->l ock, fl ags);
s wit ch ( c m_ id_priv->state) {	c a s eIW_CM_ST ATE_ID L E: 
cm_id_pr iv ->s tate =  IW_C M_ST A TE _LISTEN; 
		spi n _u nl ock_irq re store( &c m_i d_p riv-> l ock,  flags );
		ret  = cm _ id->device->iw c m->create_lis t en ( c m_ i d, b ack log);
		if(ret ) 
		cm_i d _p riv - >stat e = I W_ C M_ S TATE_IDLE;
		spin_l oc k_irqs ave(& cm_id_priv->l ock, flags ) ; 		break; 
	de f au l t:
		ret = -EI NVAL; 
	}
	spin_ u nlock_ir qrest ore(&cm_ id_priv-> l o ck, flag s); 

ret urn r et ;
}
EXPORT_SY M B OL(i w_ cm_list en) ;

/*
* C M_I D < --ID LE
 *
 *Rejectsan  i nb ou ndconne c tion req ue st.  N o e vents are ge nerat ed. * /i ntiw_cm_r e je c t (str uc tiw_c m_i d
test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags));

	destroy_cm_id(cm_id);

	wait_for_completion(&cm_id_priv->destroy_comp);

	free_cm_id(cm_id_priv);
}
EXPORT_SYMBOL(iw_destroy_cm_id);

/*
_* CM_ID_<-- LISTEN
 *
 *_Start listening_for_connect requests._Generates_one CONNECT_REQUEST
 *_event for each_inbound connect request.
 */
int_iw_cm_listen(struct iw_cm_id *cm_id,_int_backlog)
{
	struct iwcm_id_private *cm_id_priv;
	unsigned long flags;
	int ret;

	cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);

	if (!backlog)
		backlog = default_backlog;

	ret_=_alloc_work_entries(cm_id_priv, backlog);
	if_(ret)
		return_ret;

	spin_lock_irqsave(&cm_id_priv->lock,_flags);
	switch (cm_id_priv->state) {
	case IW_CM_STATE_IDLE:
		cm_id_priv->state =_IW_CM_STATE_LISTEN;
		spin_unlock_irqrestore(&cm_id_priv->lock, flags);
		ret = cm_id->device->iwcm->create_listen(cm_id, backlog);
		if_(ret)
			cm_id_priv->state =_IW_CM_STATE_IDLE;
		spin_lock_irqsave(&cm_id_priv->lock, flags);
		break;
	default:
		ret = -EINVAL;
	}
	spin_unlock_irqrestore(&cm_id_priv->lock, flags);

	return ret;
}
EXPORT_SYMBOL(iw_cm_listen);

/*
 * CM_ID_<--_IDLE
 *
 *_Rejects an inbound connection request. No events are generated.
_*/
int iw_cm_reject(struct iw_cm_id