]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: iwlwifi: dvm: fix various W=1 warnings
authorJohannes Berg <johannes.berg@intel.com>
Wed, 30 Apr 2025 12:57:27 +0000 (15:57 +0300)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Tue, 6 May 2025 19:22:11 +0000 (22:22 +0300)
Fix warnings occurring with W=1, mostly const and one about
pointer arithmetic.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20250430155443.3ef1e4f1cccb.Ic41d3f3721e8bd9df9cd50242232110c4a93e873@changeid
drivers/net/wireless/intel/iwlwifi/dvm/eeprom.c
drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c
drivers/net/wireless/intel/iwlwifi/dvm/main.c
drivers/net/wireless/intel/iwlwifi/dvm/rx.c
drivers/net/wireless/intel/iwlwifi/dvm/rxon.c

index cdc05f7e75a6187ba8234bf8b190c143f8f8a57e..35805cc02bf8040224104e58b3fd043ea6139a4b 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2005-2014, 2018-2019, 2021, 2024 Intel Corporation
+ * Copyright (C) 2005-2014, 2018-2019, 2021, 2024-2025 Intel Corporation
  */
 #include <linux/types.h>
 #include <linux/slab.h>
@@ -151,7 +151,7 @@ static u16 iwl_eeprom_query16(const u8 *eeprom, size_t eeprom_size, int offset)
 {
        if (WARN_ON(offset + sizeof(u16) > eeprom_size))
                return 0;
-       return le16_to_cpup((__le16 *)(eeprom + offset));
+       return le16_to_cpup((const __le16 *)(eeprom + offset));
 }
 
 static u32 eeprom_indirect_address(const u8 *eeprom, size_t eeprom_size,
@@ -204,8 +204,8 @@ static u32 eeprom_indirect_address(const u8 *eeprom, size_t eeprom_size,
        return (address & ADDRESS_MSK) + (offset << 1);
 }
 
-static const u8 *iwl_eeprom_query_addr(const u8 *eeprom, size_t eeprom_size,
-                                      u32 offset)
+static const void *iwl_eeprom_query_addr(const u8 *eeprom, size_t eeprom_size,
+                                        u32 offset)
 {
        u32 address = eeprom_indirect_address(eeprom, eeprom_size, offset);
 
@@ -218,10 +218,9 @@ static const u8 *iwl_eeprom_query_addr(const u8 *eeprom, size_t eeprom_size,
 static int iwl_eeprom_read_calib(const u8 *eeprom, size_t eeprom_size,
                                 struct iwl_nvm_data *data)
 {
-       struct iwl_eeprom_calib_hdr *hdr;
+       const struct iwl_eeprom_calib_hdr *hdr;
 
-       hdr = (void *)iwl_eeprom_query_addr(eeprom, eeprom_size,
-                                           EEPROM_CALIB_ALL);
+       hdr = iwl_eeprom_query_addr(eeprom, eeprom_size, EEPROM_CALIB_ALL);
        if (!hdr)
                return -ENODATA;
        data->calib_version = hdr->version;
@@ -295,7 +294,7 @@ struct iwl_eeprom_enhanced_txpwr {
 } __packed;
 
 static s8 iwl_get_max_txpwr_half_dbm(const struct iwl_nvm_data *data,
-                                    struct iwl_eeprom_enhanced_txpwr *txp)
+                                    const struct iwl_eeprom_enhanced_txpwr *txp)
 {
        s8 result = 0; /* (.5 dBm) */
 
@@ -329,7 +328,7 @@ static s8 iwl_get_max_txpwr_half_dbm(const struct iwl_nvm_data *data,
 
 static void
 iwl_eeprom_enh_txp_read_element(struct iwl_nvm_data *data,
-                               struct iwl_eeprom_enhanced_txpwr *txp,
+                               const struct iwl_eeprom_enhanced_txpwr *txp,
                                int n_channels, s8 max_txpower_avg)
 {
        int ch_idx;
@@ -360,20 +359,18 @@ static void iwl_eeprom_enhanced_txpower(struct device *dev,
                                        const u8 *eeprom, size_t eeprom_size,
                                        int n_channels)
 {
-       struct iwl_eeprom_enhanced_txpwr *txp_array, *txp;
+       const struct iwl_eeprom_enhanced_txpwr *txp_array, *txp;
        int idx, entries;
-       __le16 *txp_len;
+       const __le16 *txp_len;
        s8 max_txp_avg_halfdbm;
 
        BUILD_BUG_ON(sizeof(struct iwl_eeprom_enhanced_txpwr) != 8);
 
        /* the length is in 16-bit words, but we want entries */
-       txp_len = (__le16 *)iwl_eeprom_query_addr(eeprom, eeprom_size,
-                                                 EEPROM_TXP_SZ_OFFS);
+       txp_len = iwl_eeprom_query_addr(eeprom, eeprom_size, EEPROM_TXP_SZ_OFFS);
        entries = le16_to_cpup(txp_len) * 2 / EEPROM_TXP_ENTRY_LEN;
 
-       txp_array = (void *)iwl_eeprom_query_addr(eeprom, eeprom_size,
-                                                 EEPROM_TXP_OFFS);
+       txp_array = iwl_eeprom_query_addr(eeprom, eeprom_size, EEPROM_TXP_OFFS);
 
        for (idx = 0; idx < entries; idx++) {
                txp = &txp_array[idx];
@@ -426,7 +423,7 @@ static void iwl_init_band_reference(const struct iwl_cfg *cfg,
 
        offset |= INDIRECT_ADDRESS | INDIRECT_REGULATORY;
 
-       *ch_info = (void *)iwl_eeprom_query_addr(eeprom, eeprom_size, offset);
+       *ch_info = iwl_eeprom_query_addr(eeprom, eeprom_size, offset);
 
        switch (eeprom_band) {
        case 1:         /* 2.4GHz band */
@@ -1098,14 +1095,14 @@ iwl_parse_eeprom_data(struct iwl_trans *trans, const struct iwl_cfg *cfg,
                                    EEPROM_RAW_TEMPERATURE);
        if (!tmp)
                goto err_free;
-       data->raw_temperature = *(__le16 *)tmp;
+       data->raw_temperature = *(const __le16 *)tmp;
 
        tmp = iwl_eeprom_query_addr(eeprom, eeprom_size,
                                    EEPROM_KELVIN_TEMPERATURE);
        if (!tmp)
                goto err_free;
-       data->kelvin_temperature = *(__le16 *)tmp;
-       data->kelvin_voltage = *((__le16 *)tmp + 1);
+       data->kelvin_temperature = *(const __le16 *)tmp;
+       data->kelvin_voltage = *((const __le16 *)tmp + 1);
 
        radio_cfg =
                iwl_eeprom_query16(eeprom, eeprom_size, EEPROM_RADIO_CONFIG);
index 56d19a034c2414a1ef84fb8c105b9c7380fdcf8e..bd8f67b5bab521a7482b658f59218dee862dc326 100644 (file)
@@ -2,7 +2,7 @@
 /******************************************************************************
  *
  * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
- * Copyright(C) 2018 - 2019, 2022 - 2024 Intel Corporation
+ * Copyright(C) 2018 - 2019, 2022 - 2025 Intel Corporation
  *
  * Portions of this file are derived from the ipw3945 project, as well
  * as portions of the ieee80211 subsystem header files.
@@ -549,7 +549,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
 
        iwlagn_prepare_restart(priv);
 
-       memset((void *)&ctx->active, 0, sizeof(ctx->active));
+       memset((void *)(uintptr_t)&ctx->active, 0, sizeof(ctx->active));
        iwl_connection_init_rx_config(priv, ctx);
        iwlagn_set_rxon_chain(priv, ctx);
 
index a27a72cc017a300953794638ac973128069c4e6b..e4e2fc158e52d8c9c7f6741766bacc854f51794f 100644 (file)
@@ -2,7 +2,7 @@
 /******************************************************************************
  *
  * Copyright(c) 2003 - 2014, 2018 - 2022 Intel Corporation. All rights reserved.
- * Copyright(c) 2024 Intel Corporation. All rights reserved.
+ * Copyright(c) 2024-2025 Intel Corporation. All rights reserved.
  * Copyright(c) 2015 Intel Deutschland GmbH
  *
  * Portions of this file are derived from the ipw3945 project, as well
@@ -824,11 +824,11 @@ int iwl_alive_start(struct iwl_priv *priv)
        iwlagn_send_tx_ant_config(priv, priv->nvm_data->valid_tx_ant);
 
        if (iwl_is_associated_ctx(ctx) && !priv->wowlan) {
-               struct iwl_rxon_cmd *active_rxon =
-                               (struct iwl_rxon_cmd *)&ctx->active;
+               struct iwl_rxon_cmd *active = (void *)(uintptr_t)&ctx->active;
+
                /* apply any changes in staging */
                ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
-               active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
+               active->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
        } else {
                struct iwl_rxon_context *tmp;
                /* Initialize our rx_config data */
index 7f67e602940ca6f27962a344c69366102710a1ea..5f8b608240438af37547dc4ef0e3459f227d9d26 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2015 Intel Deutschland GmbH
- * Copyright(c) 2018, 2020-2021 Intel Corporation
+ * Copyright(c) 2018, 2020-2021, 2025 Intel Corporation
  *
  * Portions of this file are derived from the ipw3945 project, as well
  * as portionhelp of the ieee80211 subsystem header files.
@@ -50,7 +50,7 @@ static void iwlagn_rx_csa(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb)
         * See iwlagn_mac_channel_switch.
         */
        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
-       struct iwl_rxon_cmd *rxon = (void *)&ctx->active;
+       struct iwl_rxon_cmd *rxon = (void *)(uintptr_t)&ctx->active;
 
        if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status))
                return;
@@ -643,8 +643,8 @@ static void iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv,
        fraglen = len - hdrlen;
 
        if (fraglen) {
-               int offset = (void *)hdr + hdrlen -
-                            rxb_addr(rxb) + rxb_offset(rxb);
+               int offset = (u8 *)hdr + hdrlen -
+                            (u8 *)rxb_addr(rxb) + rxb_offset(rxb);
 
                skb_add_rx_frag(skb, 0, rxb_steal_page(rxb), offset,
                                fraglen, rxb->truesize);
index f80cce37e2c00cf8685d1146ea97ee3328df17e7..2d3c1627f283983ca8cc18d224f969f06258704f 100644 (file)
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /******************************************************************************
  *
- * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2014, 2025 Intel Corporation. All rights reserved.
  * Copyright(c) 2015 Intel Deutschland GmbH
  *****************************************************************************/
 
@@ -341,7 +341,7 @@ static int iwlagn_rxon_disconn(struct iwl_priv *priv,
                               struct iwl_rxon_context *ctx)
 {
        int ret;
-       struct iwl_rxon_cmd *active = (void *)&ctx->active;
+       struct iwl_rxon_cmd *active = (void *)(uintptr_t)&ctx->active;
 
        if (ctx->ctxid == IWL_RXON_CTX_BSS) {
                ret = iwlagn_disable_bss(priv, ctx, &ctx->staging);
@@ -441,7 +441,7 @@ static int iwlagn_rxon_connect(struct iwl_priv *priv,
                               struct iwl_rxon_context *ctx)
 {
        int ret;
-       struct iwl_rxon_cmd *active = (void *)&ctx->active;
+       struct iwl_rxon_cmd *active = (void *)(uintptr_t)&ctx->active;
 
        /* RXON timing must be before associated RXON */
        if (ctx->ctxid == IWL_RXON_CTX_BSS) {
@@ -1023,7 +1023,7 @@ static void iwl_calc_basic_rates(struct iwl_priv *priv,
 int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
 {
        /* cast away the const for active_rxon in this function */
-       struct iwl_rxon_cmd *active = (void *)&ctx->active;
+       struct iwl_rxon_cmd *active = (void *)(uintptr_t)&ctx->active;
        bool new_assoc = !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK);
        int ret;