]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: wcn36xx: allocate chan_surveys with main struct
authorRosen Penev <rosenp@gmail.com>
Tue, 19 May 2026 02:03:17 +0000 (19:03 -0700)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Sat, 6 Jun 2026 15:46:28 +0000 (08:46 -0700)
Avoid allocating separately with a flexible array member. Simplifies
allocation slightly.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
Link: https://patch.msgid.link/20260519020317.635011-1-rosenp@gmail.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/wcn36xx/main.c
drivers/net/wireless/ath/wcn36xx/wcn36xx.h

index c3f0860873ded16a6d55ae3e27460a9cc31f026d..ad8a4bd910d2cdf2c0af15c90a3cf31681c5577e 100644 (file)
@@ -1568,7 +1568,8 @@ static int wcn36xx_probe(struct platform_device *pdev)
 
        wcnss = dev_get_drvdata(pdev->dev.parent);
 
-       hw = ieee80211_alloc_hw(sizeof(struct wcn36xx), &wcn36xx_ops);
+       n_channels = wcn_band_2ghz.n_channels + wcn_band_5ghz.n_channels;
+       hw = ieee80211_alloc_hw(struct_size(wcn, chan_survey, n_channels), &wcn36xx_ops);
        if (!hw) {
                wcn36xx_err("failed to alloc hw\n");
                ret = -ENOMEM;
@@ -1590,16 +1591,6 @@ static int wcn36xx_probe(struct platform_device *pdev)
                goto out_wq;
        }
 
-       n_channels = wcn_band_2ghz.n_channels + wcn_band_5ghz.n_channels;
-       wcn->chan_survey = devm_kcalloc(wcn->dev,
-                                       n_channels,
-                                       sizeof(struct wcn36xx_chan_survey),
-                                       GFP_KERNEL);
-       if (!wcn->chan_survey) {
-               ret = -ENOMEM;
-               goto out_wq;
-       }
-
        ret = dma_set_mask_and_coherent(wcn->dev, DMA_BIT_MASK(32));
        if (ret < 0) {
                wcn36xx_err("failed to set DMA mask: %d\n", ret);
index 7ee79593cd23dcc81dff7fca9c6a2cae3931731e..8c43f67bd780004fbd2f3479728bd30d890ee178 100644 (file)
@@ -298,7 +298,7 @@ struct wcn36xx {
        struct ieee80211_channel *channel;
 
        spinlock_t survey_lock;         /* protects chan_survey */
-       struct wcn36xx_chan_survey      *chan_survey;
+       struct wcn36xx_chan_survey      chan_survey[];
 };
 
 static inline bool wcn36xx_is_fw_version(struct wcn36xx *wcn,