/* Locking Note: Called without the rport lock held. This function will hold the rport lock, call an  */
int fc_rport_logoff(struct fc_rport_priv *rdata)
/* Locking Note: Called without the rport lock held. This function will hold the rport lock, call an  */
int fc_rport_logoff(struct fc_rport_priv *rdata)
{
	mutex_lock(&rdata->rp_mutex);
	FC_RPORT_DBG(rdata, "Remove port\n");
	if (rdata->rp_state == RPORT_ST_DELETE) {
		FC_RPORT_DBG(rdata, "Port in Delete state, not removing\n");
		goto out;
	}
	if (rdata->rp_state == RPORT_ST_RESTART)
		FC_RPORT_DBG(rdata, "Port in Restart state, deleting\n");
	else
		fc_rport_enter_logo(rdata);
	fc_rport_enter_delete(rdata, RPORT_EV_STOP);
out:
	mutex_unlock(&rdata->rp_mutex);
	return 0;
}