/* ide_fixstring() cleans up and (optionally) byte-swaps a text string, removing leading/trailing blanks and compressing internal blanks. It is primarily used to tidy up the model name/number fields as returned by the ATA_CMD_ID_ATA commands.  */
void ide_fixstring(u8 *s, const int bytecount, const int byteswap)
/* ide_fixstring() cleans up and (optionally) byte-swaps a text string, removing leading/trailing blanks and compressing internal blanks. It is primarily used to tidy up the model name/number fields as returned by the ATA_CMD_ID_ATA commands.  */
void ide_fixstring(u8 *s, const int bytecount, const int byteswap)
{
	u8 *p, *end = &s[bytecount & ~1];
	if (byteswap) {
		for (p = s ; p != end ; p += 2)
			be16_to_cpus((u16 *) p);
	}
	p = s;
	while (s != end && *s == ' ')
		++s;
	while (s != end && *s) {
		if (*s++ != ' ' || (s != end && *s && *s != ' '))
			*p++ = *(s-1);
	}
	while (p != end)
		*p++ = '\0';
}