Lines Matching refs:tok
551 static void add_token_u8(int *err, struct opal_dev *cmd, u8 tok) in add_token_u8() argument
556 cmd->cmd[cmd->pos++] = tok; in add_token_u8()
734 const struct opal_resp_tok *tok; in response_get_token() local
747 tok = &resp->toks[n]; in response_get_token()
748 if (tok->len == 0) { in response_get_token()
753 return tok; in response_get_token()
756 static ssize_t response_parse_tiny(struct opal_resp_tok *tok, in response_parse_tiny() argument
759 tok->pos = pos; in response_parse_tiny()
760 tok->len = 1; in response_parse_tiny()
761 tok->width = OPAL_WIDTH_TINY; in response_parse_tiny()
764 tok->type = OPAL_DTA_TOKENID_SINT; in response_parse_tiny()
766 tok->type = OPAL_DTA_TOKENID_UINT; in response_parse_tiny()
767 tok->stored.u = pos[0] & 0x3f; in response_parse_tiny()
770 return tok->len; in response_parse_tiny()
773 static ssize_t response_parse_short(struct opal_resp_tok *tok, in response_parse_short() argument
776 tok->pos = pos; in response_parse_short()
777 tok->len = (pos[0] & SHORT_ATOM_LEN_MASK) + 1; in response_parse_short()
778 tok->width = OPAL_WIDTH_SHORT; in response_parse_short()
781 tok->type = OPAL_DTA_TOKENID_BYTESTRING; in response_parse_short()
783 tok->type = OPAL_DTA_TOKENID_SINT; in response_parse_short()
788 tok->type = OPAL_DTA_TOKENID_UINT; in response_parse_short()
789 if (tok->len > 9) { in response_parse_short()
793 for (i = tok->len - 1; i > 0; i--) { in response_parse_short()
797 tok->stored.u = u_integer; in response_parse_short()
800 return tok->len; in response_parse_short()
803 static ssize_t response_parse_medium(struct opal_resp_tok *tok, in response_parse_medium() argument
806 tok->pos = pos; in response_parse_medium()
807 tok->len = (((pos[0] & MEDIUM_ATOM_LEN_MASK) << 8) | pos[1]) + 2; in response_parse_medium()
808 tok->width = OPAL_WIDTH_MEDIUM; in response_parse_medium()
811 tok->type = OPAL_DTA_TOKENID_BYTESTRING; in response_parse_medium()
813 tok->type = OPAL_DTA_TOKENID_SINT; in response_parse_medium()
815 tok->type = OPAL_DTA_TOKENID_UINT; in response_parse_medium()
817 return tok->len; in response_parse_medium()
820 static ssize_t response_parse_long(struct opal_resp_tok *tok, in response_parse_long() argument
823 tok->pos = pos; in response_parse_long()
824 tok->len = ((pos[1] << 16) | (pos[2] << 8) | pos[3]) + 4; in response_parse_long()
825 tok->width = OPAL_WIDTH_LONG; in response_parse_long()
828 tok->type = OPAL_DTA_TOKENID_BYTESTRING; in response_parse_long()
830 tok->type = OPAL_DTA_TOKENID_SINT; in response_parse_long()
832 tok->type = OPAL_DTA_TOKENID_UINT; in response_parse_long()
834 return tok->len; in response_parse_long()
837 static ssize_t response_parse_token(struct opal_resp_tok *tok, in response_parse_token() argument
840 tok->pos = pos; in response_parse_token()
841 tok->len = 1; in response_parse_token()
842 tok->type = OPAL_DTA_TOKENID_TOKEN; in response_parse_token()
843 tok->width = OPAL_WIDTH_TOKEN; in response_parse_token()
845 return tok->len; in response_parse_token()
919 const struct opal_resp_tok *tok; in response_get_string() local
922 tok = response_get_token(resp, n); in response_get_string()
923 if (IS_ERR(tok)) in response_get_string()
926 if (tok->type != OPAL_DTA_TOKENID_BYTESTRING) { in response_get_string()
931 switch (tok->width) { in response_get_string()
947 *store = tok->pos + skip; in response_get_string()
949 return tok->len - skip; in response_get_string()
954 const struct opal_resp_tok *tok; in response_get_u64() local
956 tok = response_get_token(resp, n); in response_get_u64()
957 if (IS_ERR(tok)) in response_get_u64()
960 if (tok->type != OPAL_DTA_TOKENID_UINT) { in response_get_u64()
961 pr_debug("Token is not unsigned int: %d\n", tok->type); in response_get_u64()
965 if (tok->width != OPAL_WIDTH_TINY && tok->width != OPAL_WIDTH_SHORT) { in response_get_u64()
966 pr_debug("Atom is not short or tiny: %d\n", tok->width); in response_get_u64()
970 return tok->stored.u; in response_get_u64()
984 const struct opal_resp_tok *tok; in response_status() local
986 tok = response_get_token(resp, 0); in response_status()
987 if (response_token_matches(tok, OPAL_ENDOFSESSION)) in response_status()
993 tok = response_get_token(resp, resp->num - 5); in response_status()
994 if (!response_token_matches(tok, OPAL_STARTLIST)) in response_status()
997 tok = response_get_token(resp, resp->num - 1); in response_status()
998 if (!response_token_matches(tok, OPAL_ENDLIST)) in response_status()