FreeBSD/sys/dev/ntb/ntb_hw/ntb_hw.c
/*
 * ntb_set_ctx() - associate a driver context with an ntb device
 * @ntb:        NTB device context
 * @ctx:        Driver context
 * @ctx_ops:    Driver context operations
 *
 * Associate a driver context and operations with a ntb device.  The context is
 * provided by the client driver, and the driver may associate a different
 * context with each ntb device.
 *
 * Return: Zero if the context is associated, otherwise an error number.
 */
associate a driver context with an ntb device
@ntb:        NTB device context
@ctx:        Driver context
@ctx_ops:    Driver context operations

Associate a driver context and operations with a ntb device.  The context is
provided by the client driver, and the driver may associate a different
context with each ntb device.

Zero if the context is associated, otherwise an error number.
associate a driver context with an ntb device @ntb : NTB device context @ctx : Driver context @ctx_ops : Driver context operations Associate a driver context and operations with a ntb device . The context is provided by the client driver and the driver may associate a different context with each ntb device . Zero if the context is associated otherwise an error number .
int
ntb_set_ctx(struct ntb_softc *ntb, void *ctx, const struct ntb_ctx_ops *ops)
{
	if (ctx == NULL || ops == NULL)
		return (EINVAL);
	if (ntb->ctx_ops != NULL)
		return (EINVAL);
	CTX_LOCK(ntb);
	if (ntb->ctx_ops != NULL) {
		CTX_UNLOCK(ntb);
		return (EINVAL);
	}
	ntb->ntb_ctx = ctx;
	ntb->ctx_ops = ops;
	CTX_UNLOCK(ntb);
	return (0);
}
int ntb_set_ctx ( struct ntb_softc * ntb , void * ctx , const struct ntb_ctx_ops * ops ) { if ( ctx == NULL || ops == NULL ) return ( EINVAL ) ; if ( ntb -> ctx_ops != NULL ) return ( EINVAL ) ; CTX_LOCK ( ntb ) ; if ( ntb -> ctx_ops != NULL ) { CTX_UNLOCK ( ntb ) ; return ( EINVAL ) ; } ntb -> ntb_ctx = ctx ; ntb -> ctx_ops = ops ; CTX_UNLOCK ( ntb ) ; return ( 0 ) ; }
ntb_set_ctx() - associate a driver context with an ntb device
 @ntb:        NTB device context
 @ctx:        Driver context
 @ctx_ops:    Driver context operations
ntb_set_ctx () - associate a driver context with an ntb device @ntb : NTB device context @ctx : Driver context @ctx_ops : Driver context operations