Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3716434imm; Tue, 29 May 2018 12:12:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpF7tiw+4yqvUvT+E7cCDje3LnBU9WSovzag8Ccmr0YSlsPLKPpHZoELbcYASAqlgQ9ZQsG X-Received: by 2002:a17:902:7598:: with SMTP id j24-v6mr18891270pll.160.1527621159756; Tue, 29 May 2018 12:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527621159; cv=none; d=google.com; s=arc-20160816; b=TntiGr2OFpENef8lUj8N+OSzP48NhgnztKUwLy0o9EWnWsiDh8o6jdB/mUEiAkCaTn odVMl0Nt5DOK7keb+6jo7uTX1Uu3GmhENlA511eS6KRO/jzJy3RdnSnQSJwa1W7tfXtM /m4AOVBmSepWXC1YkXtfhjmfjOh+61XxvgJU8NV3qmWRBQcX9ryUyqGl6I2mVHD6CgTV SKYKBbnecLzwSoAFeyXHonUZPr5wxd8RJdn7/YEZxfETTHHZGz2kj2Ta6mRMP+xYmcyd 8ZXqC1qvrJSz9dmjqmLrbMjPFTORNXs9d9rrEY4sMgGMnGpIJj6S+xYWJ3mR6dDGZzOa CloQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=LwOtR5jVIHnlXBINxJT6EXEF+ZY3Zhkk+ASY9LiDUk4=; b=q5hda8wCVIOOHTCUBTRC4QQBc5eb7qfGBZvGp/TJ858Izjk+4xYp0/kH5l2OnO/+tZ d1Oi1MO7+U5W5wIX+AYWTBeEG6V/XoYLN+cctGx8PF1BM1RYNjBvZvpSnXzTwB6VMDFn /6XpMhLmS3myfEM+meUGBNCkg/E05VgyU1wk/2X9gMIuR3PlRMZ4OklQAKmYj6ltn9W0 wApxk+2evm1PE1Ck9RkiTXb/o0+5SXZbbH46VaOKnhA9JWnqsuyiUtjoFQdOVLlHtQKs zbfSFqer3CHG8zU5fvwAEh/QQGeXuVV/+ctZcxLtZut7N/TuAGqiPnA3z9O+1FSOsKHF hOKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IRtaHSRT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d191-v6si7941808pga.192.2018.05.29.12.12.25; Tue, 29 May 2018 12:12:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IRtaHSRT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966338AbeE2TLy (ORCPT + 99 others); Tue, 29 May 2018 15:11:54 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34636 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965614AbeE2TLu (ORCPT ); Tue, 29 May 2018 15:11:50 -0400 Received: by mail-wm0-f68.google.com with SMTP id q4-v6so30340415wmq.1; Tue, 29 May 2018 12:11:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=LwOtR5jVIHnlXBINxJT6EXEF+ZY3Zhkk+ASY9LiDUk4=; b=IRtaHSRTpkRfNMdW914pzZQaiy+8MXxfePnf8/NZPNKrXz446bG3B4+/fgDc9x6QVf ykP/rUDh/QP4gOiBbWd1G1ePGHdiCiojLq5VxOTIM/EBH4SPLwHbd11OYGkrbyvi5Lc4 7VboOQ2I9lKw6lnlSrACPl8nGTq4d/+zMxYrjvFmKm/utS5ax0zqf7/tQx7kZIGE+YWE QAW0yKuClxXG+BvGbfaHxfsE7RjMcHsTmn6KPKYz5jvc2KQVGtS8JysikLlYRMQF/j7E 2mCumQrL/9ec+BREcSU/C0S9QEXrV5ObBJtGccp/MuvAyUbyzjy3Q79ikb+RTxQiHCAv ejDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LwOtR5jVIHnlXBINxJT6EXEF+ZY3Zhkk+ASY9LiDUk4=; b=GT8QKx3U2AmXarKUGeqIm4dpnvvKGSvlvOWWOdmhil/L9/PSxX1ar/SHAnZj+ZW9wz 7Vjgk85sLynombDUOriJSApCbcCMc+Vx0WzgjQmlquCajdv1SbVpRWS3Mrf3kymvEr+E nlodtTCUI7Lticy7I/gW3Rt8u5ZvbVhCt1iO9K+VuCD+3P2D0CR80BkfuVK4NfAs87TQ 7GHx3Y6KGc0h0hOsOMQBc8mgniL6FA2aD/izS+iG2+D/Hgjv4+T33drsj6Tv3ZQiguAx 4BWnLav3Zv9xNsTdPnlc9kdZb9IHM8ruWPa/GhoQ8BYG/zsCf+lKKIZhoYA+5zCmBGIF fEPw== X-Gm-Message-State: ALKqPwddmZEsNTUjo0jVJQmGT6oAdXW3r0+lo7bv90GyZ4lwfOgclAH4 WjDT7ynH9NoXqlQomEfu5ZI= X-Received: by 2002:a1c:8409:: with SMTP id g9-v6mr113050wmd.90.1527621108918; Tue, 29 May 2018 12:11:48 -0700 (PDT) Received: from L80496.priv.atos.fr (abo-39-222-68.trs.modulonet.fr. [85.68.222.39]) by smtp.gmail.com with ESMTPSA id u69-v6sm22177114wma.37.2018.05.29.12.11.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 12:11:47 -0700 (PDT) From: Thibaut Robert To: Aditya Shankar , Ganesh Krishna , Greg Kroah-Hartman Cc: linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Thibaut Robert Subject: [PATCH 1/2] staging: wilc1000: fix some endianness sparse warnings Date: Tue, 29 May 2018 21:11:43 +0200 Message-Id: <20180529191143.13081-1-thibaut.robert@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit fix a few sparse warnings. It mostly consists of fixing the type declarations and avoiding the use of variables with mixed endianness values. Signed-off-by: Thibaut Robert --- drivers/staging/wilc1000/wilc_spi.c | 15 ++++++----- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +- drivers/staging/wilc1000/wilc_wlan.c | 26 +++++++++---------- drivers/staging/wilc1000/wilc_wlan_cfg.c | 8 +++--- drivers/staging/wilc1000/wilc_wlan_cfg.h | 4 +-- 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index 647526387784..e51f0d91a376 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -666,11 +666,11 @@ static int spi_data_write(struct wilc *wilc, u8 *b, u32 sz) static int spi_internal_write(struct wilc *wilc, u32 adr, u32 dat) { struct spi_device *spi = to_spi_device(wilc->dev); + __le32 le32dat = cpu_to_le32(dat); int result; - dat = cpu_to_le32(dat); - result = spi_cmd_complete(wilc, CMD_INTERNAL_WRITE, adr, (u8 *)&dat, 4, - 0); + result = spi_cmd_complete(wilc, CMD_INTERNAL_WRITE, adr, (u8 *)&le32dat, + 4, 0); if (result != N_OK) dev_err(&spi->dev, "Failed internal write cmd...\n"); @@ -689,7 +689,7 @@ static int spi_internal_read(struct wilc *wilc, u32 adr, u32 *data) return 0; } - *data = cpu_to_le32(*data); + le32_to_cpus(data); return 1; } @@ -706,15 +706,16 @@ static int wilc_spi_write_reg(struct wilc *wilc, u32 addr, u32 data) int result = N_OK; u8 cmd = CMD_SINGLE_WRITE; u8 clockless = 0; + __le32 le32data = cpu_to_le32(data); - data = cpu_to_le32(data); if (addr < 0x30) { /* Clockless register */ cmd = CMD_INTERNAL_WRITE; clockless = 1; } - result = spi_cmd_complete(wilc, cmd, addr, (u8 *)&data, 4, clockless); + result = spi_cmd_complete(wilc, cmd, addr, (u8 *)&le32data, 4, + clockless); if (result != N_OK) dev_err(&spi->dev, "Failed cmd, write reg (%08x)...\n", addr); @@ -769,7 +770,7 @@ static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, u32 *data) return 0; } - *data = cpu_to_le32(*data); + le32_to_cpus(data); return 1; } diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index e248702ee519..745bf5ca2622 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1431,7 +1431,7 @@ void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size) freq = ieee80211_channel_to_frequency(curr_channel, NL80211_BAND_2GHZ); - if (!ieee80211_is_action(buff[FRAME_TYPE_ID])) { + if (!ieee80211_is_action(cpu_to_le16(buff[FRAME_TYPE_ID]))) { cfg80211_rx_mgmt(priv->wdev, freq, 0, buff, size, 0); return; } diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 28c93f3f846e..a5ac1d26590b 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -560,7 +560,8 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) int ret = 0; int counter; int timeout; - u32 vmm_table[WILC_VMM_TBL_SIZE]; + __le32 vmm_table[WILC_VMM_TBL_SIZE]; + u32 table_entry; struct wilc_vif *vif; struct wilc *wilc; const struct wilc_hif_func *func; @@ -598,10 +599,10 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) if ((sum + vmm_sz) > LINUX_TX_SIZE) break; - vmm_table[i] = vmm_sz / 4; + table_entry = vmm_sz / 4; if (tqe->type == WILC_CFG_PKT) - vmm_table[i] |= BIT(10); - vmm_table[i] = cpu_to_le32(vmm_table[i]); + table_entry |= BIT(10); + vmm_table[i] = cpu_to_le32(table_entry); i++; sum += vmm_sz; @@ -704,8 +705,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) if (vmm_table[i] == 0) break; - vmm_table[i] = cpu_to_le32(vmm_table[i]); - vmm_sz = (vmm_table[i] & 0x3ff); + vmm_sz = (le32_to_cpu(vmm_table[i]) & 0x3ff); vmm_sz *= 4; header = (tqe->type << 31) | (tqe->buffer_size << 15) | @@ -715,8 +715,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) else header &= ~BIT(30); - header = cpu_to_le32(header); - memcpy(&txb[offset], &header, 4); + *((__le32 *)&txb[offset]) = cpu_to_le32(header); if (tqe->type == WILC_CFG_PKT) { buffer_offset = ETH_CONFIG_PKT_HDR_OFFSET; } else if (tqe->type == WILC_NET_PKT) { @@ -770,8 +769,7 @@ static void wilc_wlan_handle_rx_buff(struct wilc *wilc, u8 *buffer, int size) do { buff_ptr = buffer + offset; - memcpy(&header, buff_ptr, 4); - header = cpu_to_le32(header); + header = le32_to_cpup((__le32 *)buff_ptr); is_cfg_packet = (header >> 31) & 0x1; pkt_offset = (header >> 22) & 0x1ff; @@ -942,6 +940,7 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, u32 offset; u32 addr, size, size2, blksz; u8 *dma_buffer; + const __le32 *header; int ret = 0; blksz = BIT(12); @@ -952,10 +951,9 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, offset = 0; do { - memcpy(&addr, &buffer[offset], 4); - memcpy(&size, &buffer[offset + 4], 4); - addr = cpu_to_le32(addr); - size = cpu_to_le32(size); + header = (__le32 *)buffer + offset; + addr = le32_to_cpu(header[0]); + size = le32_to_cpu(header[1]); acquire_bus(wilc, ACQUIRE_ONLY); offset += 8; while (((int)size) && (offset < buffer_size)) { diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c b/drivers/staging/wilc1000/wilc_wlan_cfg.c index c0b9b700f4d7..4a914d8572aa 100644 --- a/drivers/staging/wilc1000/wilc_wlan_cfg.c +++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c @@ -275,14 +275,14 @@ static int wilc_wlan_cfg_set_bin(u8 *frame, u32 offset, u16 id, u8 *b, u32 size) static void wilc_wlan_parse_response_frame(u8 *info, int size) { - u32 wid, len = 0, i = 0; + u32 wid; + int len = 0, i = 0; while (size > 0) { i = 0; - wid = info[0] | (info[1] << 8); - wid = cpu_to_le32(wid); + wid = le16_to_cpup((__le16 *)info); - switch ((wid >> 12) & 0x7) { + switch (info[1] >> 4) { case WID_CHAR: do { if (g_cfg_byte[i].id == WID_NIL) diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.h b/drivers/staging/wilc1000/wilc_wlan_cfg.h index 08092a551840..9e029338bcab 100644 --- a/drivers/staging/wilc1000/wilc_wlan_cfg.h +++ b/drivers/staging/wilc1000/wilc_wlan_cfg.h @@ -18,12 +18,12 @@ struct wilc_cfg_byte { struct wilc_cfg_hword { u16 id; - u16 val; + __le16 val; }; struct wilc_cfg_word { u32 id; - u32 val; + __le32 val; }; struct wilc_cfg_str { -- 2.17.0