* [PATCH -next] wifi: wfx: Use devm_kmemdup to replace devm_kmalloc + memcpy
@ 2023-08-10 11:49 Li Zetao
2023-08-10 12:44 ` Jérôme Pouiller
2023-08-23 11:09 ` Kalle Valo
0 siblings, 2 replies; 3+ messages in thread
From: Li Zetao @ 2023-08-10 11:49 UTC (permalink / raw)
To: jerome.pouiller, kvalo; +Cc: lizetao1, linux-wireless
Use the helper function devm_kmemdup() rather than duplicating its
implementation, which helps to enhance code readability.
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
drivers/net/wireless/silabs/wfx/main.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/silabs/wfx/main.c b/drivers/net/wireless/silabs/wfx/main.c
index 0b50f7058bbb..ede822d771aa 100644
--- a/drivers/net/wireless/silabs/wfx/main.c
+++ b/drivers/net/wireless/silabs/wfx/main.c
@@ -293,13 +293,12 @@ struct wfx_dev *wfx_init_common(struct device *dev, const struct wfx_platform_da
hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
hw->wiphy->n_iface_combinations = ARRAY_SIZE(wfx_iface_combinations);
hw->wiphy->iface_combinations = wfx_iface_combinations;
- hw->wiphy->bands[NL80211_BAND_2GHZ] = devm_kmalloc(dev, sizeof(wfx_band_2ghz), GFP_KERNEL);
+ /* FIXME: also copy wfx_rates and wfx_2ghz_chantable */
+ hw->wiphy->bands[NL80211_BAND_2GHZ] = devm_kmemdup(dev, &wfx_band_2ghz,
+ sizeof(wfx_band_2ghz), GFP_KERNEL);
if (!hw->wiphy->bands[NL80211_BAND_2GHZ])
goto err;
- /* FIXME: also copy wfx_rates and wfx_2ghz_chantable */
- memcpy(hw->wiphy->bands[NL80211_BAND_2GHZ], &wfx_band_2ghz, sizeof(wfx_band_2ghz));
-
wdev = hw->priv;
wdev->hw = hw;
wdev->dev = dev;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH -next] wifi: wfx: Use devm_kmemdup to replace devm_kmalloc + memcpy
2023-08-10 11:49 [PATCH -next] wifi: wfx: Use devm_kmemdup to replace devm_kmalloc + memcpy Li Zetao
@ 2023-08-10 12:44 ` Jérôme Pouiller
2023-08-23 11:09 ` Kalle Valo
1 sibling, 0 replies; 3+ messages in thread
From: Jérôme Pouiller @ 2023-08-10 12:44 UTC (permalink / raw)
To: kvalo, Li Zetao; +Cc: lizetao1, linux-wireless
On Thursday 10 August 2023 13:49:39 CEST Li Zetao wrote:
> Use the helper function devm_kmemdup() rather than duplicating its
> implementation, which helps to enhance code readability.
>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>
> ---
> drivers/net/wireless/silabs/wfx/main.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/silabs/wfx/main.c b/drivers/net/wireless/silabs/wfx/main.c
> index 0b50f7058bbb..ede822d771aa 100644
> --- a/drivers/net/wireless/silabs/wfx/main.c
> +++ b/drivers/net/wireless/silabs/wfx/main.c
> @@ -293,13 +293,12 @@ struct wfx_dev *wfx_init_common(struct device *dev, const struct wfx_platform_da
> hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
> hw->wiphy->n_iface_combinations = ARRAY_SIZE(wfx_iface_combinations);
> hw->wiphy->iface_combinations = wfx_iface_combinations;
> - hw->wiphy->bands[NL80211_BAND_2GHZ] = devm_kmalloc(dev, sizeof(wfx_band_2ghz), GFP_KERNEL);
> + /* FIXME: also copy wfx_rates and wfx_2ghz_chantable */
> + hw->wiphy->bands[NL80211_BAND_2GHZ] = devm_kmemdup(dev, &wfx_band_2ghz,
> + sizeof(wfx_band_2ghz), GFP_KERNEL);
> if (!hw->wiphy->bands[NL80211_BAND_2GHZ])
> goto err;
>
> - /* FIXME: also copy wfx_rates and wfx_2ghz_chantable */
> - memcpy(hw->wiphy->bands[NL80211_BAND_2GHZ], &wfx_band_2ghz, sizeof(wfx_band_2ghz));
> -
> wdev = hw->priv;
> wdev->hw = hw;
> wdev->dev = dev;
> --
> 2.34.1
>
>
Make sense.
Reviewed-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
--
Jérôme Pouiller
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] wifi: wfx: Use devm_kmemdup to replace devm_kmalloc + memcpy
2023-08-10 11:49 [PATCH -next] wifi: wfx: Use devm_kmemdup to replace devm_kmalloc + memcpy Li Zetao
2023-08-10 12:44 ` Jérôme Pouiller
@ 2023-08-23 11:09 ` Kalle Valo
1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2023-08-23 11:09 UTC (permalink / raw)
To: Li Zetao; +Cc: jerome.pouiller, lizetao1, linux-wireless
Li Zetao <lizetao1@huawei.com> wrote:
> Use the helper function devm_kmemdup() rather than duplicating its
> implementation, which helps to enhance code readability.
>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>
> Reviewed-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Patch applied to wireless-next.git, thanks.
eaa8023e9bb3 wifi: wfx: Use devm_kmemdup to replace devm_kmalloc + memcpy
--
https://patchwork.kernel.org/project/linux-wireless/patch/20230810114939.2104013-1-lizetao1@huawei.com/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-23 11:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-10 11:49 [PATCH -next] wifi: wfx: Use devm_kmemdup to replace devm_kmalloc + memcpy Li Zetao
2023-08-10 12:44 ` Jérôme Pouiller
2023-08-23 11:09 ` Kalle Valo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox