/* Convert 16bit integer in BCD encoding to decimal.  */
static gboolean convert_bcd_to_dec(guint16 bcd, guint16 *dec)
/* Convert 16bit integer in BCD encoding to decimal.  */
static gboolean convert_bcd_to_dec(guint16 bcd, guint16 *dec)
{
	gboolean rok = TRUE;
	guint16 result = 0;
	guint16 mult = 1;
	while (bcd) {
		if ((bcd & 0x0f) > 9)
			rok = FALSE;
		result += (bcd & 0x0f) * mult;
		bcd >>= 4;
		mult *= 10;
	}
	*dec = result;
	return rok;
}