Commit 65a69228 authored by Christian Lamparter's avatar Christian Lamparter Committed by John W. Linville

carl9170: move checksum and txseq into subfunctions

Signed-off-by: default avatarChristian Lamparter <chunkeey@googlemail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 3f81f8f1
...@@ -146,13 +146,15 @@ static bool valid_cpu_addr(const u32 address) ...@@ -146,13 +146,15 @@ static bool valid_cpu_addr(const u32 address)
return false; return false;
} }
static int carl9170_fw(struct ar9170 *ar, const __u8 *data, size_t len) static int carl9170_fw_checksum(struct ar9170 *ar, const __u8 *data,
size_t len)
{ {
const struct carl9170fw_otus_desc *otus_desc; const struct carl9170fw_otus_desc *otus_desc;
const struct carl9170fw_chk_desc *chk_desc;
const struct carl9170fw_last_desc *last_desc; const struct carl9170fw_last_desc *last_desc;
const struct carl9170fw_txsq_desc *txsq_desc; const struct carl9170fw_chk_desc *chk_desc;
u16 if_comb_types; unsigned long fin, diff;
unsigned int dsc_len;
u32 crc32;
last_desc = carl9170_fw_find_desc(ar, LAST_MAGIC, last_desc = carl9170_fw_find_desc(ar, LAST_MAGIC,
sizeof(*last_desc), CARL9170FW_LAST_DESC_CUR_VER); sizeof(*last_desc), CARL9170FW_LAST_DESC_CUR_VER);
...@@ -170,10 +172,10 @@ static int carl9170_fw(struct ar9170 *ar, const __u8 *data, size_t len) ...@@ -170,10 +172,10 @@ static int carl9170_fw(struct ar9170 *ar, const __u8 *data, size_t len)
chk_desc = carl9170_fw_find_desc(ar, CHK_MAGIC, chk_desc = carl9170_fw_find_desc(ar, CHK_MAGIC,
sizeof(*chk_desc), CARL9170FW_CHK_DESC_CUR_VER); sizeof(*chk_desc), CARL9170FW_CHK_DESC_CUR_VER);
if (chk_desc) { if (!chk_desc) {
unsigned long fin, diff; dev_warn(&ar->udev->dev, "Unprotected firmware image.\n");
unsigned int dsc_len; return 0;
u32 crc32; }
dsc_len = min_t(unsigned int, len, dsc_len = min_t(unsigned int, len,
(unsigned long)chk_desc - (unsigned long)otus_desc); (unsigned long)chk_desc - (unsigned long)otus_desc);
...@@ -198,8 +200,40 @@ static int carl9170_fw(struct ar9170 *ar, const __u8 *data, size_t len) ...@@ -198,8 +200,40 @@ static int carl9170_fw(struct ar9170 *ar, const __u8 *data, size_t len)
dev_err(&ar->udev->dev, "descriptor check failed.\n"); dev_err(&ar->udev->dev, "descriptor check failed.\n");
return -EINVAL; return -EINVAL;
} }
return 0;
}
static int carl9170_fw_tx_sequence(struct ar9170 *ar)
{
const struct carl9170fw_txsq_desc *txsq_desc;
txsq_desc = carl9170_fw_find_desc(ar, TXSQ_MAGIC, sizeof(*txsq_desc),
CARL9170FW_TXSQ_DESC_CUR_VER);
if (txsq_desc) {
ar->fw.tx_seq_table = le32_to_cpu(txsq_desc->seq_table_addr);
if (!valid_cpu_addr(ar->fw.tx_seq_table))
return -EINVAL;
} else { } else {
dev_warn(&ar->udev->dev, "Unprotected firmware image.\n"); ar->fw.tx_seq_table = 0;
}
return 0;
}
static int carl9170_fw(struct ar9170 *ar, const __u8 *data, size_t len)
{
const struct carl9170fw_otus_desc *otus_desc;
int err;
u16 if_comb_types;
err = carl9170_fw_checksum(ar, data, len);
if (err)
return err;
otus_desc = carl9170_fw_find_desc(ar, OTUS_MAGIC,
sizeof(*otus_desc), CARL9170FW_OTUS_DESC_CUR_VER);
if (!otus_desc) {
return -ENODATA;
} }
#define SUPP(feat) \ #define SUPP(feat) \
...@@ -321,19 +355,8 @@ static int carl9170_fw(struct ar9170 *ar, const __u8 *data, size_t len) ...@@ -321,19 +355,8 @@ static int carl9170_fw(struct ar9170 *ar, const __u8 *data, size_t len)
ar->hw->wiphy->interface_modes |= if_comb_types; ar->hw->wiphy->interface_modes |= if_comb_types;
txsq_desc = carl9170_fw_find_desc(ar, TXSQ_MAGIC,
sizeof(*txsq_desc), CARL9170FW_TXSQ_DESC_CUR_VER);
if (txsq_desc) {
ar->fw.tx_seq_table = le32_to_cpu(txsq_desc->seq_table_addr);
if (!valid_cpu_addr(ar->fw.tx_seq_table))
return -EINVAL;
} else {
ar->fw.tx_seq_table = 0;
}
#undef SUPPORTED #undef SUPPORTED
return 0; return carl9170_fw_tx_sequence(ar);
} }
static struct carl9170fw_desc_head * static struct carl9170fw_desc_head *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment