#ifndef __iwl_fw_dhc_utils_h__
#define __iwl_fw_dhc_utils_h__
#include <linux/types.h>
#include "fw/img.h"
#include "api/commands.h"
#include "api/dhc.h"
static inline u32 iwl_dhc_resp_status(const struct iwl_fw *fw,
struct iwl_rx_packet *pkt)
{
if (iwl_fw_lookup_notif_ver(fw, IWL_ALWAYS_LONG_GROUP,
DEBUG_HOST_COMMAND, 1) >= 2) {
struct iwl_dhc_cmd_resp *resp = (void *)pkt->data;
if (iwl_rx_packet_payload_len(pkt) < sizeof(*resp))
return (u32)-1;
return le32_to_cpu(resp->status);
} else {
struct iwl_dhc_cmd_resp_v1 *resp = (void *)pkt->data;
if (iwl_rx_packet_payload_len(pkt) < sizeof(*resp))
return (u32)-1;
return le32_to_cpu(resp->status);
}
}
static inline void *iwl_dhc_resp_data(const struct iwl_fw *fw,
struct iwl_rx_packet *pkt,
unsigned int *len)
{
if (iwl_fw_lookup_notif_ver(fw, IWL_ALWAYS_LONG_GROUP,
DEBUG_HOST_COMMAND, 1) >= 2) {
struct iwl_dhc_cmd_resp *resp = (void *)pkt->data;
if (iwl_rx_packet_payload_len(pkt) < sizeof(*resp))
return ERR_PTR(-EINVAL);
*len = iwl_rx_packet_payload_len(pkt) - sizeof(*resp);
return (void *)&resp->data;
} else {
struct iwl_dhc_cmd_resp_v1 *resp = (void *)pkt->data;
if (iwl_rx_packet_payload_len(pkt) < sizeof(*resp))
return ERR_PTR(-EINVAL);
*len = iwl_rx_packet_payload_len(pkt) - sizeof(*resp);
return (void *)&resp->data;
}
}
#endif