Lines Matching refs:tok
593 static void add_token_u8(int *err, struct opal_dev *cmd, u8 tok) in add_token_u8() argument
598 cmd->cmd[cmd->pos++] = tok; in add_token_u8()
776 const struct opal_resp_tok *tok; in response_get_token() local
789 tok = &resp->toks[n]; in response_get_token()
790 if (tok->len == 0) { in response_get_token()
795 return tok; in response_get_token()
798 static ssize_t response_parse_tiny(struct opal_resp_tok *tok, in response_parse_tiny() argument
801 tok->pos = pos; in response_parse_tiny()
802 tok->len = 1; in response_parse_tiny()
803 tok->width = OPAL_WIDTH_TINY; in response_parse_tiny()
806 tok->type = OPAL_DTA_TOKENID_SINT; in response_parse_tiny()
808 tok->type = OPAL_DTA_TOKENID_UINT; in response_parse_tiny()
809 tok->stored.u = pos[0] & 0x3f; in response_parse_tiny()
812 return tok->len; in response_parse_tiny()
815 static ssize_t response_parse_short(struct opal_resp_tok *tok, in response_parse_short() argument
818 tok->pos = pos; in response_parse_short()
819 tok->len = (pos[0] & SHORT_ATOM_LEN_MASK) + 1; in response_parse_short()
820 tok->width = OPAL_WIDTH_SHORT; in response_parse_short()
823 tok->type = OPAL_DTA_TOKENID_BYTESTRING; in response_parse_short()
825 tok->type = OPAL_DTA_TOKENID_SINT; in response_parse_short()
830 tok->type = OPAL_DTA_TOKENID_UINT; in response_parse_short()
831 if (tok->len > 9) { in response_parse_short()
835 for (i = tok->len - 1; i > 0; i--) { in response_parse_short()
839 tok->stored.u = u_integer; in response_parse_short()
842 return tok->len; in response_parse_short()
845 static ssize_t response_parse_medium(struct opal_resp_tok *tok, in response_parse_medium() argument
848 tok->pos = pos; in response_parse_medium()
849 tok->len = (((pos[0] & MEDIUM_ATOM_LEN_MASK) << 8) | pos[1]) + 2; in response_parse_medium()
850 tok->width = OPAL_WIDTH_MEDIUM; in response_parse_medium()
853 tok->type = OPAL_DTA_TOKENID_BYTESTRING; in response_parse_medium()
855 tok->type = OPAL_DTA_TOKENID_SINT; in response_parse_medium()
857 tok->type = OPAL_DTA_TOKENID_UINT; in response_parse_medium()
859 return tok->len; in response_parse_medium()
862 static ssize_t response_parse_long(struct opal_resp_tok *tok, in response_parse_long() argument
865 tok->pos = pos; in response_parse_long()
866 tok->len = ((pos[1] << 16) | (pos[2] << 8) | pos[3]) + 4; in response_parse_long()
867 tok->width = OPAL_WIDTH_LONG; in response_parse_long()
870 tok->type = OPAL_DTA_TOKENID_BYTESTRING; in response_parse_long()
872 tok->type = OPAL_DTA_TOKENID_SINT; in response_parse_long()
874 tok->type = OPAL_DTA_TOKENID_UINT; in response_parse_long()
876 return tok->len; in response_parse_long()
879 static ssize_t response_parse_token(struct opal_resp_tok *tok, in response_parse_token() argument
882 tok->pos = pos; in response_parse_token()
883 tok->len = 1; in response_parse_token()
884 tok->type = OPAL_DTA_TOKENID_TOKEN; in response_parse_token()
885 tok->width = OPAL_WIDTH_TOKEN; in response_parse_token()
887 return tok->len; in response_parse_token()
961 const struct opal_resp_tok *tok; in response_get_string() local
964 tok = response_get_token(resp, n); in response_get_string()
965 if (IS_ERR(tok)) in response_get_string()
968 if (tok->type != OPAL_DTA_TOKENID_BYTESTRING) { in response_get_string()
973 switch (tok->width) { in response_get_string()
989 *store = tok->pos + skip; in response_get_string()
991 return tok->len - skip; in response_get_string()
996 const struct opal_resp_tok *tok; in response_get_u64() local
998 tok = response_get_token(resp, n); in response_get_u64()
999 if (IS_ERR(tok)) in response_get_u64()
1002 if (tok->type != OPAL_DTA_TOKENID_UINT) { in response_get_u64()
1003 pr_debug("Token is not unsigned int: %d\n", tok->type); in response_get_u64()
1007 if (tok->width != OPAL_WIDTH_TINY && tok->width != OPAL_WIDTH_SHORT) { in response_get_u64()
1008 pr_debug("Atom is not short or tiny: %d\n", tok->width); in response_get_u64()
1012 return tok->stored.u; in response_get_u64()
1026 const struct opal_resp_tok *tok; in response_status() local
1028 tok = response_get_token(resp, 0); in response_status()
1029 if (response_token_matches(tok, OPAL_ENDOFSESSION)) in response_status()
1035 tok = response_get_token(resp, resp->num - 5); in response_status()
1036 if (!response_token_matches(tok, OPAL_STARTLIST)) in response_status()
1039 tok = response_get_token(resp, resp->num - 1); in response_status()
1040 if (!response_token_matches(tok, OPAL_ENDLIST)) in response_status()