Ejemplo n.º 1
0
static DEVICE_ATTR_READER(status_show, dev, buf)
{
	xbus_t *xbus;
	int ret;

	xbus = dev_to_xbus(dev);
	ret =
	    snprintf(buf, PAGE_SIZE, "%s\n",
		     (XBUS_FLAGS(xbus, CONNECTED)) ? "connected" : "missing");
	return ret;
}
Ejemplo n.º 2
0
static void astribank_release(struct device *dev)
{
	xbus_t *xbus;

	BUG_ON(!dev);
	xbus = dev_to_xbus(dev);
	if (XBUS_FLAGS(xbus, CONNECTED)) {
		XBUS_ERR(xbus, "Try to release CONNECTED device.\n");
		BUG();
	}
	if (!XBUS_IS(xbus, IDLE) && !XBUS_IS(xbus, FAIL)
	    && !XBUS_IS(xbus, DEACTIVATED)) {
		XBUS_ERR(xbus, "Try to release in state %s\n",
			 xbus_statename(XBUS_STATE(xbus)));
		BUG();
	}
	XBUS_INFO(xbus, "[%s] Astribank Release\n", xbus->label);
	xbus_free(xbus);
}
Ejemplo n.º 3
0
int xframe_receive(xbus_t *xbus, xframe_t *xframe)
{
	int		ret = 0;
	struct timeval	now;
	struct timeval	tv_received;
	int		usec;

	if(XFRAME_LEN(xframe) < RPACKET_HEADERSIZE) {
		static int	rate_limit;

		if((rate_limit++ % 1003) == 0) {
			XBUS_NOTICE(xbus, "short xframe\n");
			dump_xframe("short xframe", xbus, xframe, debug);
		}
		FREE_RECV_XFRAME(xbus, xframe);
		return -EPROTO;
	}
	if(!XBUS_FLAGS(xbus, CONNECTED)) {
		XBUS_DBG(GENERAL, xbus, "Dropped xframe. Is shutting down.\n");
		return -ENODEV;
	}
	tv_received = xframe->tv_received;
	/*
	 * We want to check that xframes do not mix PCM and other commands
	 */
	if(XPACKET_IS_PCM((xpacket_t *)xframe->packets)) {
		if(!XBUS_IS(xbus, READY))
			FREE_RECV_XFRAME(xbus, xframe);
		else
			xframe_receive_pcm(xbus, xframe);
	} else {
		XBUS_COUNTER(xbus, RX_CMD)++;
		ret = xframe_receive_cmd(xbus, xframe);
	}
	/* Calculate total processing time */
	do_gettimeofday(&now);
	usec = (now.tv_sec - tv_received.tv_sec) * 1000000 +
		now.tv_usec - tv_received.tv_usec;
	if(usec > xbus->max_rx_process)
		xbus->max_rx_process = usec;
	return ret;
}