From: Dan Carpenter <dan.carpenter@oracle.com>
To: Marcel Holtmann <marcel@holtmann.org>,
Linus Walleij <linus.walleij@linaro.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
linux-bluetooth@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] Bluetooth: btbcm: Use strreplace() in btbcm_get_board_name()
Date: Wed, 15 Jun 2022 11:26:02 +0300 [thread overview]
Message-ID: <YqmXmsTX7dD+5HjN@kili> (raw)
The original code works but it's a bit iffy. The end of loop test
should be something like "board_type[i] != '\0'" but instead it is
is "i < board_type[i]". Fortunately, those two tests are equivalent so
long as the "board_type" is not an empty string.
It's much simpler to just call strreplace() instead.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/bluetooth/btbcm.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index 3006e2a0f37e..bcf254e2b138 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -498,7 +498,6 @@ static const char *btbcm_get_board_name(struct device *dev)
char *board_type;
const char *tmp;
int len;
- int i;
root = of_find_node_by_path("/");
if (!root)
@@ -511,10 +510,7 @@ static const char *btbcm_get_board_name(struct device *dev)
len = strlen(tmp) + 1;
board_type = devm_kzalloc(dev, len, GFP_KERNEL);
strscpy(board_type, tmp, len);
- for (i = 0; i < board_type[i]; i++) {
- if (board_type[i] == '/')
- board_type[i] = '-';
- }
+ strreplace(board_type, '/', '-');
of_node_put(root);
return board_type;
--
2.35.1
next reply other threads:[~2022-06-15 8:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 8:26 Dan Carpenter [this message]
2022-06-15 9:11 ` Bluetooth: btbcm: Use strreplace() in btbcm_get_board_name() bluez.test.bot
2022-06-15 21:50 ` [PATCH] " Linus Walleij
2022-06-16 7:54 ` Dan Carpenter
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=YqmXmsTX7dD+5HjN@kili \
--to=dan.carpenter@oracle.com \
--cc=johan.hedberg@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
/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