/* Walk a ucs2le string and return the number of bytes that the string will be after being converted to the given charset, not including any null termination required. Don't walk past maxbytes in the source buffer.  */
int cifs_ucs2_bytes(const __le16 *from, int maxbytes, const struct nls_table *codepage)
/* Walk a ucs2le string and return the number of bytes that the string will be after being converted to the given charset, not including any null termination required. Don't walk past maxbytes in the source buffer.  */
int cifs_ucs2_bytes(const __le16 *from, int maxbytes, const struct nls_table *codepage)
{
	int i;
	int charlen, outlen = 0;
	int maxwords = maxbytes / 2;
	char tmp[NLS_MAX_CHARSET_SIZE];
	for (i = 0; i < maxwords && from[i]; i++) {
		charlen = codepage->uni2char(le16_to_cpu(from[i]), tmp,
					     NLS_MAX_CHARSET_SIZE);
		if (charlen > 0)
			outlen += charlen;
		else
			outlen++;
	}
	return outlen;
}