FreeBSD/sys/dev/txp/if_txp.c
/*
 * Handle simple commands sent to the typhoon
 */
Handle simple commands sent to the typhoon
Handle simple commands sent to the typhoon
static int
txp_command(struct txp_softc *sc, uint16_t id, uint16_t in1, uint32_t in2,
    uint32_t in3, uint16_t *out1, uint32_t *out2, uint32_t *out3, int wait)
{
	struct txp_rsp_desc *rsp;
	rsp = NULL;
	if (txp_ext_command(sc, id, in1, in2, in3, NULL, 0, &rsp, wait) != 0) {
		device_printf(sc->sc_dev, "command 0x%02x failed\n", id);
		return (-1);
	}
	if (wait == TXP_CMD_NOWAIT)
		return (0);
	KASSERT(rsp != NULL, ("rsp is NULL!\n"));
	if (out1 != NULL)
		*out1 = le16toh(rsp->rsp_par1);
	if (out2 != NULL)
		*out2 = le32toh(rsp->rsp_par2);
	if (out3 != NULL)
		*out3 = le32toh(rsp->rsp_par3);
	free(rsp, M_DEVBUF);
	return (0);
}
static int txp_command ( struct txp_softc * sc , uint16_t id , uint16_t in1 , uint32_t in2 , uint32_t in3 , uint16_t * out1 , uint32_t * out2 , uint32_t * out3 , int wait ) { struct txp_rsp_desc * rsp ; rsp = NULL ; if ( txp_ext_command ( sc , id , in1 , in2 , in3 , NULL , 0 , & rsp , wait ) != 0 ) { device_printf ( sc -> sc_dev , " \n " , id ) ; return ( -1 ) ; } if ( wait == TXP_CMD_NOWAIT ) return ( 0 ) ; KASSERT ( rsp != NULL , ( " \n " ) ) ; if ( out1 != NULL ) * out1 = le16toh ( rsp -> rsp_par1 ) ; if ( out2 != NULL ) * out2 = le32toh ( rsp -> rsp_par2 ) ; if ( out3 != NULL ) * out3 = le32toh ( rsp -> rsp_par3 ) ; free ( rsp , M_DEVBUF ) ; return ( 0 ) ; }
Handle simple commands sent to the typhoon
Handle simple commands sent to the typhoon