From c4f9e64456ae3ed6f6c8df07cc903a292c755991 Mon Sep 17 00:00:00 2001 From: Devendra Naga Date: Thu, 16 Aug 2012 21:50:03 +0530 Subject: [PATCH] staging:csr: remove usage of CsrSnprintf and use scnprintf MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This change tries to achieve the removal of the csr driver defined snprintf and uses the kernel defined snprintf. After this change i got following build warnings, which are solved in this patch warnings generated: drivers/staging/csr/io.c:929:13: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 4 has type ‘u32’ drivers/staging/csr/io.c:929:13: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 5 has type ‘u32’ drivers/staging/csr/csr_wifi_hip_udi.c: In function ‘unifi_print_status’: drivers/staging/csr/csr_wifi_hip_udi.c:78:27: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 4 has type ‘u32’ drivers/staging/csr/csr_wifi_hip_udi.c:151:27: warning: format ‘%u’ expects type ‘unsigned int’, but argument 5 has type ‘long int’ drivers/staging/csr/csr_wifi_hip_udi.c:257:27: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 4 has type ‘u32’ drivers/staging/csr/csr_wifi_hip_udi.c:257:27: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 5 has type ‘u32’ drivers/staging/csr/csr_wifi_hip_udi.c:261:27: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 4 has type ‘u32’ Signed-off-by: Devendra Naga Signed-off-by: Greg Kroah-Hartman --- drivers/staging/csr/Makefile | 1 - drivers/staging/csr/csr_formatted_io.c | 27 ------ drivers/staging/csr/csr_formatted_io.h | 25 ------ drivers/staging/csr/csr_wifi_hip_card_sdio.c | 8 +- drivers/staging/csr/csr_wifi_hip_udi.c | 94 ++++++++++---------- drivers/staging/csr/csr_wifi_hip_unifi.h | 1 - drivers/staging/csr/io.c | 30 +++---- 7 files changed, 66 insertions(+), 120 deletions(-) delete mode 100644 drivers/staging/csr/csr_formatted_io.c delete mode 100644 drivers/staging/csr/csr_formatted_io.h diff --git a/drivers/staging/csr/Makefile b/drivers/staging/csr/Makefile index afda44b0a925..ab626edc5ba4 100644 --- a/drivers/staging/csr/Makefile +++ b/drivers/staging/csr/Makefile @@ -25,7 +25,6 @@ csr_wifi-y := bh.o \ unifi_event.o \ unifi_pdu_processing.o \ unifi_sme.o \ - csr_formatted_io.o \ csr_wifi_hip_card_sdio.o \ csr_wifi_hip_card_sdio_intr.o \ csr_wifi_hip_card_sdio_mem.o \ diff --git a/drivers/staging/csr/csr_formatted_io.c b/drivers/staging/csr/csr_formatted_io.c deleted file mode 100644 index 7213cc8fb577..000000000000 --- a/drivers/staging/csr/csr_formatted_io.c +++ /dev/null @@ -1,27 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ -#include -#include "csr_formatted_io.h" - -s32 CsrSnprintf(char *dest, size_t n, const char *fmt, ...) -{ - s32 r; - va_list args; - va_start(args, fmt); - r = vsnprintf(dest, n, fmt, args); - va_end(args); - - if (dest && (n > 0)) - { - dest[n - 1] = '\0'; - } - - return r; -} diff --git a/drivers/staging/csr/csr_formatted_io.h b/drivers/staging/csr/csr_formatted_io.h deleted file mode 100644 index 2e238cb98d51..000000000000 --- a/drivers/staging/csr/csr_formatted_io.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef CSR_FORMATTED_IO_H__ -#define CSR_FORMATTED_IO_H__ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -s32 CsrSnprintf(char *dest, size_t n, const char *fmt, ...); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/drivers/staging/csr/csr_wifi_hip_card_sdio.c b/drivers/staging/csr/csr_wifi_hip_card_sdio.c index 44ab00c53fec..cf148a0fec6a 100644 --- a/drivers/staging/csr/csr_wifi_hip_card_sdio.c +++ b/drivers/staging/csr/csr_wifi_hip_card_sdio.c @@ -1612,13 +1612,13 @@ static CsrResult card_allocate_memory_resources(card_t *card) /* Reset any state carried forward from a previous life */ card->fh_command_queue.q_rd_ptr = 0; card->fh_command_queue.q_wr_ptr = 0; - (void)CsrSnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH, + (void)scnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_cmd_q"); for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) { card->fh_traffic_queue[i].q_rd_ptr = 0; card->fh_traffic_queue[i].q_wr_ptr = 0; - (void)CsrSnprintf(card->fh_traffic_queue[i].name, + (void)scnprintf(card->fh_traffic_queue[i].name, UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_data_q%d", i); } #ifndef CSR_WIFI_HIP_TA_DISABLE @@ -1826,13 +1826,13 @@ static void card_init_soft_queues(card_t *card) /* Reset any state carried forward from a previous life */ card->fh_command_queue.q_rd_ptr = 0; card->fh_command_queue.q_wr_ptr = 0; - (void)CsrSnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH, + (void)scnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_cmd_q"); for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) { card->fh_traffic_queue[i].q_rd_ptr = 0; card->fh_traffic_queue[i].q_wr_ptr = 0; - (void)CsrSnprintf(card->fh_traffic_queue[i].name, + (void)scnprintf(card->fh_traffic_queue[i].name, UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_data_q%d", i); } #ifndef CSR_WIFI_HIP_TA_DISABLE diff --git a/drivers/staging/csr/csr_wifi_hip_udi.c b/drivers/staging/csr/csr_wifi_hip_udi.c index 07cfd36c4971..31a27cc60995 100644 --- a/drivers/staging/csr/csr_wifi_hip_udi.c +++ b/drivers/staging/csr/csr_wifi_hip_udi.c @@ -64,104 +64,104 @@ s32 unifi_print_status(card_t *card, char *str, s32 *remain) } i = n = 0; - written = CsrSnprintf(p, remaining, "Chip ID %u\n", + written = scnprintf(p, remaining, "Chip ID %u\n", (u16)card->chip_id); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "Chip Version %04X\n", + written = scnprintf(p, remaining, "Chip Version %04X\n", card->chip_version); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "HIP v%u.%u\n", + written = scnprintf(p, remaining, "HIP v%u.%u\n", (card->config_data.version >> 8) & 0xFF, card->config_data.version & 0xFF); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "Build %lu: %s\n", + written = scnprintf(p, remaining, "Build %u: %s\n", card->build_id, card->build_id_string); UNIFI_SNPRINTF_RET(p, remaining, written); cfg = &card->config_data; - written = CsrSnprintf(p, remaining, "sdio ctrl offset %u\n", + written = scnprintf(p, remaining, "sdio ctrl offset %u\n", cfg->sdio_ctrl_offset); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "fromhost sigbuf handle %u\n", + written = scnprintf(p, remaining, "fromhost sigbuf handle %u\n", cfg->fromhost_sigbuf_handle); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "tohost_sigbuf_handle %u\n", + written = scnprintf(p, remaining, "tohost_sigbuf_handle %u\n", cfg->tohost_sigbuf_handle); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "num_fromhost_sig_frags %u\n", + written = scnprintf(p, remaining, "num_fromhost_sig_frags %u\n", cfg->num_fromhost_sig_frags); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "num_tohost_sig_frags %u\n", + written = scnprintf(p, remaining, "num_tohost_sig_frags %u\n", cfg->num_tohost_sig_frags); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "num_fromhost_data_slots %u\n", + written = scnprintf(p, remaining, "num_fromhost_data_slots %u\n", cfg->num_fromhost_data_slots); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "num_tohost_data_slots %u\n", + written = scnprintf(p, remaining, "num_tohost_data_slots %u\n", cfg->num_tohost_data_slots); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "data_slot_size %u\n", + written = scnprintf(p, remaining, "data_slot_size %u\n", cfg->data_slot_size); UNIFI_SNPRINTF_RET(p, remaining, written); /* Added by protocol version 0x0001 */ - written = CsrSnprintf(p, remaining, "overlay_size %u\n", + written = scnprintf(p, remaining, "overlay_size %u\n", (u16)cfg->overlay_size); UNIFI_SNPRINTF_RET(p, remaining, written); /* Added by protocol version 0x0300 */ - written = CsrSnprintf(p, remaining, "data_slot_round %u\n", + written = scnprintf(p, remaining, "data_slot_round %u\n", cfg->data_slot_round); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "sig_frag_size %u\n", + written = scnprintf(p, remaining, "sig_frag_size %u\n", cfg->sig_frag_size); UNIFI_SNPRINTF_RET(p, remaining, written); /* Added by protocol version 0x0300 */ - written = CsrSnprintf(p, remaining, "tohost_sig_pad %u\n", + written = scnprintf(p, remaining, "tohost_sig_pad %u\n", cfg->tohost_signal_padding); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "\nInternal state:\n"); + written = scnprintf(p, remaining, "\nInternal state:\n"); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "Last PHY PANIC: %04x:%04x\n", + written = scnprintf(p, remaining, "Last PHY PANIC: %04x:%04x\n", card->last_phy_panic_code, card->last_phy_panic_arg); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "Last MAC PANIC: %04x:%04x\n", + written = scnprintf(p, remaining, "Last MAC PANIC: %04x:%04x\n", card->last_mac_panic_code, card->last_mac_panic_arg); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "fhsr: %u\n", + written = scnprintf(p, remaining, "fhsr: %u\n", (u16)card->from_host_signals_r); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "fhsw: %u\n", + written = scnprintf(p, remaining, "fhsw: %u\n", (u16)card->from_host_signals_w); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "thsr: %u\n", + written = scnprintf(p, remaining, "thsr: %u\n", (u16)card->to_host_signals_r); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "thsw: %u\n", + written = scnprintf(p, remaining, "thsw: %u\n", (u16)card->to_host_signals_w); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, - "fh buffer contains: %u signals, %u bytes\n", + written = scnprintf(p, remaining, + "fh buffer contains: %d signals, %ld bytes\n", card->fh_buffer.count, card->fh_buffer.ptr - card->fh_buffer.buf); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "paused: "); + written = scnprintf(p, remaining, "paused: "); UNIFI_SNPRINTF_RET(p, remaining, written); for (i = 0; i < sizeof(card->tx_q_paused_flag) / sizeof(card->tx_q_paused_flag[0]); i++) { - written = CsrSnprintf(p, remaining, card->tx_q_paused_flag[i]?"1" : "0"); + written = scnprintf(p, remaining, card->tx_q_paused_flag[i]?"1" : "0"); UNIFI_SNPRINTF_RET(p, remaining, written); } - written = CsrSnprintf(p, remaining, "\n"); + written = scnprintf(p, remaining, "\n"); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, + written = scnprintf(p, remaining, "fh command q: %u waiting, %u free of %u:\n", CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_command_queue), CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_command_queue), @@ -169,7 +169,7 @@ s32 unifi_print_status(card_t *card, char *str, s32 *remain) UNIFI_SNPRINTF_RET(p, remaining, written); for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) { - written = CsrSnprintf(p, remaining, + written = scnprintf(p, remaining, "fh traffic q[%u]: %u waiting, %u free of %u:\n", i, CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[i]), @@ -178,58 +178,58 @@ s32 unifi_print_status(card_t *card, char *str, s32 *remain) UNIFI_SNPRINTF_RET(p, remaining, written); } - written = CsrSnprintf(p, remaining, "fh data slots free: %u\n", + written = scnprintf(p, remaining, "fh data slots free: %u\n", card->from_host_data?CardGetFreeFromHostDataSlots(card) : 0); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "From host data slots:"); + written = scnprintf(p, remaining, "From host data slots:"); UNIFI_SNPRINTF_RET(p, remaining, written); n = card->config_data.num_fromhost_data_slots; for (i = 0; i < n && card->from_host_data; i++) { - written = CsrSnprintf(p, remaining, " %u", + written = scnprintf(p, remaining, " %u", (u16)card->from_host_data[i].bd.data_length); UNIFI_SNPRINTF_RET(p, remaining, written); } - written = CsrSnprintf(p, remaining, "\n"); + written = scnprintf(p, remaining, "\n"); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "To host data slots:"); + written = scnprintf(p, remaining, "To host data slots:"); UNIFI_SNPRINTF_RET(p, remaining, written); n = card->config_data.num_tohost_data_slots; for (i = 0; i < n && card->to_host_data; i++) { - written = CsrSnprintf(p, remaining, " %u", + written = scnprintf(p, remaining, " %u", (u16)card->to_host_data[i].data_length); UNIFI_SNPRINTF_RET(p, remaining, written); } - written = CsrSnprintf(p, remaining, "\n"); + written = scnprintf(p, remaining, "\n"); UNIFI_SNPRINTF_RET(p, remaining, written); #ifdef CSR_UNSAFE_SDIO_ACCESS - written = CsrSnprintf(p, remaining, "Host State: %s\n", states[card->host_state]); + written = scnprintf(p, remaining, "Host State: %s\n", states[card->host_state]); UNIFI_SNPRINTF_RET(p, remaining, written); r = unifi_check_io_status(card, &iostate); if (iostate == 1) { - written = CsrSnprintf(p, remaining, "I/O Check: F1 disabled\n"); + written = scnprintf(p, remaining, "I/O Check: F1 disabled\n"); UNIFI_SNPRINTF_RET(p, remaining, written); } else { if (iostate == 1) { - written = CsrSnprintf(p, remaining, "I/O Check: pending interrupt\n"); + written = scnprintf(p, remaining, "I/O Check: pending interrupt\n"); UNIFI_SNPRINTF_RET(p, remaining, written); } - written = CsrSnprintf(p, remaining, "BH reason interrupt = %d\n", + written = scnprintf(p, remaining, "BH reason interrupt = %d\n", card->bh_reason_unifi); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "BH reason host = %d\n", + written = scnprintf(p, remaining, "BH reason host = %d\n", card->bh_reason_host); UNIFI_SNPRINTF_RET(p, remaining, written); @@ -238,26 +238,26 @@ s32 unifi_print_status(card_t *card, char *str, s32 *remain) r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 2, &b); if ((r == CSR_RESULT_SUCCESS) && (!(b & 0x80))) { - written = CsrSnprintf(p, remaining, "fhsr: %u (driver thinks is %u)\n", + written = scnprintf(p, remaining, "fhsr: %u (driver thinks is %u)\n", b, card->from_host_signals_r); UNIFI_SNPRINTF_RET(p, remaining, written); break; } } iostate = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4); - written = CsrSnprintf(p, remaining, "thsw: %u (driver thinks is %u)\n", + written = scnprintf(p, remaining, "thsw: %u (driver thinks is %u)\n", iostate, card->to_host_signals_w); UNIFI_SNPRINTF_RET(p, remaining, written); } #endif - written = CsrSnprintf(p, remaining, "\nStats:\n"); + written = scnprintf(p, remaining, "\nStats:\n"); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "Total SDIO bytes: R=%lu W=%lu\n", + written = scnprintf(p, remaining, "Total SDIO bytes: R=%u W=%u\n", card->sdio_bytes_read, card->sdio_bytes_written); UNIFI_SNPRINTF_RET(p, remaining, written); - written = CsrSnprintf(p, remaining, "Interrupts generated on card: %lu\n", + written = scnprintf(p, remaining, "Interrupts generated on card: %u\n", card->unifi_interrupt_seq); UNIFI_SNPRINTF_RET(p, remaining, written); diff --git a/drivers/staging/csr/csr_wifi_hip_unifi.h b/drivers/staging/csr/csr_wifi_hip_unifi.h index dc3c60b49702..2923e2ef12f2 100644 --- a/drivers/staging/csr/csr_wifi_hip_unifi.h +++ b/drivers/staging/csr/csr_wifi_hip_unifi.h @@ -98,7 +98,6 @@ extern "C" { #include "csr_framework_ext.h" /* from the synergy porting folder */ #include "csr_sdio.h" /* from the synergy porting folder */ #include "csr_macro.h" /* from the synergy porting folder */ -#include "csr_formatted_io.h" /* from the synergy gsp folder */ #include "csr_wifi_result.h" /* Utility MACROS. Note that UNIFI_MAC_ADDRESS_CMP returns TRUE on success */ diff --git a/drivers/staging/csr/io.c b/drivers/staging/csr/io.c index deaff252eec3..4774dc852816 100644 --- a/drivers/staging/csr/io.c +++ b/drivers/staging/csr/io.c @@ -347,7 +347,7 @@ register_unifi_sdio(CsrSdioFunction *sdio_dev, int bus_id, struct device *dev) /* * We use the slot number as unifi device index. */ - snprintf(priv->proc_entry_name, 64, "driver/unifi%d", priv->instance); + scnprintf(priv->proc_entry_name, 64, "driver/unifi%d", priv->instance); /* * The following complex casting is in place in order to eliminate 64-bit compilation warning * "cast to/from pointer from/to integer of different size" @@ -904,54 +904,54 @@ uf_read_proc(char *page, char **start, off_t offset, int count, orig_p = p; - written = CsrSnprintf(p, remain, "UniFi SDIO Driver: %s %s %s\n", + written = scnprintf(p, remain, "UniFi SDIO Driver: %s %s %s\n", CSR_WIFI_VERSION, __DATE__, __TIME__); UNIFI_SNPRINTF_RET(p, remain, written); #ifdef CSR_SME_USERSPACE - written = CsrSnprintf(p, remain, "SME: CSR userspace "); + written = scnprintf(p, remain, "SME: CSR userspace "); UNIFI_SNPRINTF_RET(p, remain, written); #ifdef CSR_SUPPORT_WEXT - written = CsrSnprintf(p, remain, "with WEXT support\n"); + written = scnprintf(p, remain, "with WEXT support\n"); #else - written = CsrSnprintf(p, remain, "\n"); + written = scnprintf(p, remain, "\n"); #endif /* CSR_SUPPORT_WEXT */ UNIFI_SNPRINTF_RET(p, remain, written); #endif /* CSR_SME_USERSPACE */ #ifdef CSR_NATIVE_LINUX - written = CsrSnprintf(p, remain, "SME: native\n"); + written = scnprintf(p, remain, "SME: native\n"); UNIFI_SNPRINTF_RET(p, remain, written); #endif #ifdef CSR_SUPPORT_SME - written = CsrSnprintf(p, remain, - "Firmware (ROM) build:%lu, Patch:%lu\n", + written = scnprintf(p, remain, + "Firmware (ROM) build:%u, Patch:%u\n", priv->card_info.fw_build, priv->sme_versions.firmwarePatch); UNIFI_SNPRINTF_RET(p, remain, written); #endif p += unifi_print_status(priv->card, p, &remain); - written = CsrSnprintf(p, remain, "Last dbg str: %s\n", + written = scnprintf(p, remain, "Last dbg str: %s\n", priv->last_debug_string); UNIFI_SNPRINTF_RET(p, remain, written); - written = CsrSnprintf(p, remain, "Last dbg16:"); + written = scnprintf(p, remain, "Last dbg16:"); UNIFI_SNPRINTF_RET(p, remain, written); for (i = 0; i < 8; i++) { - written = CsrSnprintf(p, remain, " %04X", + written = scnprintf(p, remain, " %04X", priv->last_debug_word16[i]); UNIFI_SNPRINTF_RET(p, remain, written); } - written = CsrSnprintf(p, remain, "\n"); + written = scnprintf(p, remain, "\n"); UNIFI_SNPRINTF_RET(p, remain, written); - written = CsrSnprintf(p, remain, " "); + written = scnprintf(p, remain, " "); UNIFI_SNPRINTF_RET(p, remain, written); for (; i < 16; i++) { - written = CsrSnprintf(p, remain, " %04X", + written = scnprintf(p, remain, " %04X", priv->last_debug_word16[i]); UNIFI_SNPRINTF_RET(p, remain, written); } - written = CsrSnprintf(p, remain, "\n"); + written = scnprintf(p, remain, "\n"); UNIFI_SNPRINTF_RET(p, remain, written); *start = page; -- 2.34.1