From: Dmitry Antipov <dmantipov@yandex.ru>
To: Jeff Johnson <quic_jjohnson@quicinc.com>
Cc: Kalle Valo <kvalo@kernel.org>,
ath10k@lists.infradead.org, linux-wireless@vger.kernel.org,
Dmitry Antipov <dmantipov@yandex.ru>
Subject: [PATCH] wifi: ath10k: prefer stack-allocated __le32 variables
Date: Fri, 27 Oct 2023 11:23:21 +0300 [thread overview]
Message-ID: <20231027082325.126606-1-dmantipov@yandex.ru> (raw)
There isn't too much sense to 'kzalloc()' buffer for the only
__le32 value which is going to be freed in the same function,
so switch to stack-allocated one in 'ath10k_sdio_writesb32()'
and 'ath10k_sdio_diag_read32()'. Compile tested only.
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
drivers/net/wireless/ath/ath10k/sdio.c | 47 +++++++-------------------
1 file changed, 13 insertions(+), 34 deletions(-)
diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c
index 56fbcfb80bf8..5ce1bad417cd 100644
--- a/drivers/net/wireless/ath/ath10k/sdio.c
+++ b/drivers/net/wireless/ath/ath10k/sdio.c
@@ -238,36 +238,25 @@ static int ath10k_sdio_write32(struct ath10k *ar, u32 addr, u32 val)
return ret;
}
-static int ath10k_sdio_writesb32(struct ath10k *ar, u32 addr, u32 val)
+static int ath10k_sdio_writesb32(struct ath10k *ar, u32 addr, u32 value)
{
struct ath10k_sdio *ar_sdio = ath10k_sdio_priv(ar);
struct sdio_func *func = ar_sdio->func;
- __le32 *buf;
+ __le32 val = __cpu_to_le32(value);
int ret;
- buf = kzalloc(sizeof(*buf), GFP_KERNEL);
- if (!buf)
- return -ENOMEM;
-
- *buf = cpu_to_le32(val);
-
sdio_claim_host(func);
- ret = sdio_writesb(func, addr, buf, sizeof(*buf));
- if (ret) {
+ ret = sdio_writesb(func, addr, &val, sizeof(val));
+ if (ret)
ath10k_warn(ar, "failed to write value 0x%x to fixed sb address 0x%x: %d\n",
- val, addr, ret);
- goto out;
- }
-
- ath10k_dbg(ar, ATH10K_DBG_SDIO, "sdio writesb32 addr 0x%x val 0x%x\n",
- addr, val);
+ value, addr, ret);
+ else
+ ath10k_dbg(ar, ATH10K_DBG_SDIO, "sdio writesb32 addr 0x%x val 0x%x\n",
+ addr, value);
-out:
sdio_release_host(func);
- kfree(buf);
-
return ret;
}
@@ -1758,24 +1747,14 @@ static int ath10k_sdio_hif_diag_read(struct ath10k *ar, u32 address, void *buf,
return ret;
}
-static int ath10k_sdio_diag_read32(struct ath10k *ar, u32 address,
- u32 *value)
+static int ath10k_sdio_diag_read32(struct ath10k *ar, u32 address, u32 *value)
{
- __le32 *val;
+ __le32 val;
int ret;
- val = kzalloc(sizeof(*val), GFP_KERNEL);
- if (!val)
- return -ENOMEM;
-
- ret = ath10k_sdio_hif_diag_read(ar, address, val, sizeof(*val));
- if (ret)
- goto out;
-
- *value = __le32_to_cpu(*val);
-
-out:
- kfree(val);
+ ret = ath10k_sdio_hif_diag_read(ar, address, &val, sizeof(val));
+ if (!ret)
+ *value = __le32_to_cpu(val);
return ret;
}
--
2.41.0
next reply other threads:[~2023-10-27 8:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-27 8:23 Dmitry Antipov [this message]
2023-10-27 9:08 ` [PATCH] wifi: ath10k: prefer stack-allocated __le32 variables Johannes Berg
2023-10-27 9:50 ` Dmitry Antipov
2023-10-27 9:53 ` Johannes Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231027082325.126606-1-dmantipov@yandex.ru \
--to=dmantipov@yandex.ru \
--cc=ath10k@lists.infradead.org \
--cc=kvalo@kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=quic_jjohnson@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).