/* Return the port stats structure to user app. A NULL port struct pointer passed in means that we need to find out from the app what port to get stats for (used through board control device).  */
static int stli_getportstats(struct tty_struct *tty, struct stliport *portp, comstats_t __user *cp)
/* Return the port stats structure to user app. A NULL port struct pointer passed in means that we need to find out from the app what port to get stats for (used through board control device).  */
static int stli_getportstats(struct tty_struct *tty, struct stliport *portp, comstats_t __user *cp)
{
	struct stlibrd *brdp;
	int rc;
	if (!portp) {
		if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t)))
			return -EFAULT;
		portp = stli_getport(stli_comstats.brd, stli_comstats.panel,
			stli_comstats.port);
		if (!portp)
			return -ENODEV;
	}
	brdp = stli_brds[portp->brdnr];
	if (!brdp)
		return -ENODEV;
	if ((rc = stli_portcmdstats(tty, portp)) < 0)
		return rc;
	return copy_to_user(cp, &stli_comstats, sizeof(comstats_t)) ?
			-EFAULT : 0;
}