diff options
Diffstat (limited to 'drivers/staging/wilc1000/wilc_spi.c')
-rw-r--r-- | drivers/staging/wilc1000/wilc_spi.c | 78 |
1 files changed, 33 insertions, 45 deletions
diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index 55d53c3..5ef8441 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -1,11 +1,9 @@ -/* ////////////////////////////////////////////////////////////////////////// */ -/* */ -/* Copyright (c) Atmel Corporation. All rights reserved. */ -/* */ -/* Module Name: wilc_spi.c */ -/* */ -/* */ -/* //////////////////////////////////////////////////////////////////////////// */ +/* + * Copyright (c) Atmel Corporation. All rights reserved. + * + * Module Name: wilc_spi.c + */ + #include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> @@ -410,7 +408,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz, if (len2 > ARRAY_SIZE(wb)) { dev_err(&spi->dev, "spi buffer size too small (%d) (%zu)\n", - len2, ARRAY_SIZE(wb)); + len2, ARRAY_SIZE(wb)); return N_FAIL; } /* zero spi write buffers. */ @@ -454,8 +452,8 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz, return N_FAIL; } - if ((cmd == CMD_INTERNAL_READ) || (cmd == CMD_SINGLE_READ) - || (cmd == CMD_DMA_READ) || (cmd == CMD_DMA_EXT_READ)) { + if ((cmd == CMD_INTERNAL_READ) || (cmd == CMD_SINGLE_READ) || + (cmd == CMD_DMA_READ) || (cmd == CMD_DMA_EXT_READ)) { int retry; /* u16 crc1, crc2; */ u8 crc[2]; @@ -929,14 +927,16 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) { struct spi_device *spi = to_spi_device(wilc->dev); int ret; + u32 tmp; + u32 byte_cnt; + int happened, j; + u32 unknown_mask; + u32 irq_flags; if (g_spi.has_thrpt_enh) { ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE, int_status); } else { - u32 tmp; - u32 byte_cnt; - ret = wilc_spi_read_reg(wilc, WILC_VMM_TO_HOST_SIZE, &byte_cnt); if (!ret) { @@ -946,37 +946,28 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) } tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK; - { - int happended, j; - - j = 0; - do { - u32 irq_flags; - - happended = 0; + j = 0; + do { + happened = 0; - wilc_spi_read_reg(wilc, 0x1a90, &irq_flags); - tmp |= ((irq_flags >> 27) << IRG_FLAGS_OFFSET); + wilc_spi_read_reg(wilc, 0x1a90, &irq_flags); + tmp |= ((irq_flags >> 27) << IRG_FLAGS_OFFSET); - if (g_spi.nint > 5) { - wilc_spi_read_reg(wilc, 0x1a94, - &irq_flags); - tmp |= (((irq_flags >> 0) & 0x7) << (IRG_FLAGS_OFFSET + 5)); - } + if (g_spi.nint > 5) { + wilc_spi_read_reg(wilc, 0x1a94, + &irq_flags); + tmp |= (((irq_flags >> 0) & 0x7) << (IRG_FLAGS_OFFSET + 5)); + } - { - u32 unkmown_mask; + unknown_mask = ~((1ul << g_spi.nint) - 1); - unkmown_mask = ~((1ul << g_spi.nint) - 1); + if ((tmp >> IRG_FLAGS_OFFSET) & unknown_mask) { + dev_err(&spi->dev, "Unexpected interrupt (2): j=%d, tmp=%x, mask=%x\n", j, tmp, unknown_mask); + happened = 1; + } - if ((tmp >> IRG_FLAGS_OFFSET) & unkmown_mask) { - dev_err(&spi->dev, "Unexpected interrupt (2): j=%d, tmp=%x, mask=%x\n", j, tmp, unkmown_mask); - happended = 1; - } - } - j++; - } while (happended); - } + j++; + } while (happened); *int_status = tmp; } @@ -1130,11 +1121,8 @@ static int wilc_spi_sync_ext(struct wilc *wilc, int nint) return 1; } -/******************************************** - * - * Global spi HIF function table - * - ********************************************/ + +/* Global spi HIF function table */ static const struct wilc_hif_func wilc_hif_spi = { .hif_init = wilc_spi_init, .hif_deinit = _wilc_spi_deinit, |