Lines Matching refs:tok
549 static void add_token_u8(int *err, struct opal_dev *cmd, u8 tok) in add_token_u8() argument
554 cmd->cmd[cmd->pos++] = tok; in add_token_u8()
732 const struct opal_resp_tok *tok; in response_get_token() local
745 tok = &resp->toks[n]; in response_get_token()
746 if (tok->len == 0) { in response_get_token()
751 return tok; in response_get_token()
754 static ssize_t response_parse_tiny(struct opal_resp_tok *tok, in response_parse_tiny() argument
757 tok->pos = pos; in response_parse_tiny()
758 tok->len = 1; in response_parse_tiny()
759 tok->width = OPAL_WIDTH_TINY; in response_parse_tiny()
762 tok->type = OPAL_DTA_TOKENID_SINT; in response_parse_tiny()
764 tok->type = OPAL_DTA_TOKENID_UINT; in response_parse_tiny()
765 tok->stored.u = pos[0] & 0x3f; in response_parse_tiny()
768 return tok->len; in response_parse_tiny()
771 static ssize_t response_parse_short(struct opal_resp_tok *tok, in response_parse_short() argument
774 tok->pos = pos; in response_parse_short()
775 tok->len = (pos[0] & SHORT_ATOM_LEN_MASK) + 1; in response_parse_short()
776 tok->width = OPAL_WIDTH_SHORT; in response_parse_short()
779 tok->type = OPAL_DTA_TOKENID_BYTESTRING; in response_parse_short()
781 tok->type = OPAL_DTA_TOKENID_SINT; in response_parse_short()
786 tok->type = OPAL_DTA_TOKENID_UINT; in response_parse_short()
787 if (tok->len > 9) { in response_parse_short()
791 for (i = tok->len - 1; i > 0; i--) { in response_parse_short()
795 tok->stored.u = u_integer; in response_parse_short()
798 return tok->len; in response_parse_short()
801 static ssize_t response_parse_medium(struct opal_resp_tok *tok, in response_parse_medium() argument
804 tok->pos = pos; in response_parse_medium()
805 tok->len = (((pos[0] & MEDIUM_ATOM_LEN_MASK) << 8) | pos[1]) + 2; in response_parse_medium()
806 tok->width = OPAL_WIDTH_MEDIUM; in response_parse_medium()
809 tok->type = OPAL_DTA_TOKENID_BYTESTRING; in response_parse_medium()
811 tok->type = OPAL_DTA_TOKENID_SINT; in response_parse_medium()
813 tok->type = OPAL_DTA_TOKENID_UINT; in response_parse_medium()
815 return tok->len; in response_parse_medium()
818 static ssize_t response_parse_long(struct opal_resp_tok *tok, in response_parse_long() argument
821 tok->pos = pos; in response_parse_long()
822 tok->len = ((pos[1] << 16) | (pos[2] << 8) | pos[3]) + 4; in response_parse_long()
823 tok->width = OPAL_WIDTH_LONG; in response_parse_long()
826 tok->type = OPAL_DTA_TOKENID_BYTESTRING; in response_parse_long()
828 tok->type = OPAL_DTA_TOKENID_SINT; in response_parse_long()
830 tok->type = OPAL_DTA_TOKENID_UINT; in response_parse_long()
832 return tok->len; in response_parse_long()
835 static ssize_t response_parse_token(struct opal_resp_tok *tok, in response_parse_token() argument
838 tok->pos = pos; in response_parse_token()
839 tok->len = 1; in response_parse_token()
840 tok->type = OPAL_DTA_TOKENID_TOKEN; in response_parse_token()
841 tok->width = OPAL_WIDTH_TOKEN; in response_parse_token()
843 return tok->len; in response_parse_token()
917 const struct opal_resp_tok *tok; in response_get_string() local
920 tok = response_get_token(resp, n); in response_get_string()
921 if (IS_ERR(tok)) in response_get_string()
924 if (tok->type != OPAL_DTA_TOKENID_BYTESTRING) { in response_get_string()
929 switch (tok->width) { in response_get_string()
945 *store = tok->pos + skip; in response_get_string()
947 return tok->len - skip; in response_get_string()
952 const struct opal_resp_tok *tok; in response_get_u64() local
954 tok = response_get_token(resp, n); in response_get_u64()
955 if (IS_ERR(tok)) in response_get_u64()
958 if (tok->type != OPAL_DTA_TOKENID_UINT) { in response_get_u64()
959 pr_debug("Token is not unsigned int: %d\n", tok->type); in response_get_u64()
963 if (tok->width != OPAL_WIDTH_TINY && tok->width != OPAL_WIDTH_SHORT) { in response_get_u64()
964 pr_debug("Atom is not short or tiny: %d\n", tok->width); in response_get_u64()
968 return tok->stored.u; in response_get_u64()
982 const struct opal_resp_tok *tok; in response_status() local
984 tok = response_get_token(resp, 0); in response_status()
985 if (response_token_matches(tok, OPAL_ENDOFSESSION)) in response_status()
991 tok = response_get_token(resp, resp->num - 5); in response_status()
992 if (!response_token_matches(tok, OPAL_STARTLIST)) in response_status()
995 tok = response_get_token(resp, resp->num - 1); in response_status()
996 if (!response_token_matches(tok, OPAL_ENDLIST)) in response_status()