From: Kent Overstreet <kent.overstreet@linux.dev>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org,
Kent Overstreet <kent.overstreet@gmail.com>,
linux-tegra@vger.kernel.org
Subject: [PATCH 02/11] clk: tegra: bpmp: Convert to printbuf
Date: Mon, 15 Aug 2022 13:26:04 -0400 [thread overview]
Message-ID: <20220815172613.621627-3-kent.overstreet@linux.dev> (raw)
In-Reply-To: <20220815172613.621627-1-kent.overstreet@linux.dev>
From: Kent Overstreet <kent.overstreet@gmail.com>
This converts from seq_buf to printbuf, which is similar but heap
allocates the string buffer.
Previously in this code the string buffer was allocated on the stack;
this means we've added a new potential memory allocation failure. This
is fine though since it's only for a dev_printk() message.
Memory allocation context: printbuf doesn't take gfp flags, instead we
prefer the new memalloc_no*_(save|restore) interfaces to be used. Here
the surrounding code is already allocating with GFP_KERNEL, so
everything is fine.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Cc: linux-tegra@vger.kernel.org
---
drivers/clk/tegra/clk-bpmp.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/clk/tegra/clk-bpmp.c b/drivers/clk/tegra/clk-bpmp.c
index 3748a39dae..7e3b48ed9d 100644
--- a/drivers/clk/tegra/clk-bpmp.c
+++ b/drivers/clk/tegra/clk-bpmp.c
@@ -5,7 +5,7 @@
#include <linux/clk-provider.h>
#include <linux/device.h>
-#include <linux/seq_buf.h>
+#include <linux/printbuf.h>
#include <linux/slab.h>
#include <soc/tegra/bpmp.h>
@@ -365,39 +365,38 @@ static void tegra_bpmp_clk_info_dump(struct tegra_bpmp *bpmp,
const struct tegra_bpmp_clk_info *info)
{
const char *prefix = "";
- struct seq_buf buf;
+ struct printbuf buf = PRINTBUF;
unsigned int i;
- char flags[64];
-
- seq_buf_init(&buf, flags, sizeof(flags));
if (info->flags)
- seq_buf_printf(&buf, "(");
+ prt_printf(&buf, "(");
if (info->flags & TEGRA_BPMP_CLK_HAS_MUX) {
- seq_buf_printf(&buf, "%smux", prefix);
+ prt_printf(&buf, "%smux", prefix);
prefix = ", ";
}
if ((info->flags & TEGRA_BPMP_CLK_HAS_SET_RATE) == 0) {
- seq_buf_printf(&buf, "%sfixed", prefix);
+ prt_printf(&buf, "%sfixed", prefix);
prefix = ", ";
}
if (info->flags & TEGRA_BPMP_CLK_IS_ROOT) {
- seq_buf_printf(&buf, "%sroot", prefix);
+ prt_printf(&buf, "%sroot", prefix);
prefix = ", ";
}
if (info->flags)
- seq_buf_printf(&buf, ")");
+ prt_printf(&buf, ")");
dev_printk(level, bpmp->dev, "%03u: %s\n", info->id, info->name);
- dev_printk(level, bpmp->dev, " flags: %lx %s\n", info->flags, flags);
+ dev_printk(level, bpmp->dev, " flags: %lx %s\n", info->flags, printbuf_str(&buf));
dev_printk(level, bpmp->dev, " parents: %u\n", info->num_parents);
for (i = 0; i < info->num_parents; i++)
dev_printk(level, bpmp->dev, " %03u\n", info->parents[i]);
+
+ printbuf_exit(&buf);
}
static int tegra_bpmp_probe_clocks(struct tegra_bpmp *bpmp,
--
2.36.1
next prev parent reply other threads:[~2022-08-15 17:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-15 17:26 Printbufs v6 Kent Overstreet
2022-08-15 17:26 ` [PATCH 01/11] mm/memcontrol.c: Convert to printbuf Kent Overstreet
2022-08-15 17:26 ` Kent Overstreet [this message]
2022-08-15 17:26 ` [PATCH 03/11] tools/testing/nvdimm: " Kent Overstreet
2022-08-15 17:26 ` [PATCH 04/11] powerpc: " Kent Overstreet
2022-08-15 17:26 ` [PATCH 05/11] x86/resctrl: " Kent Overstreet
2022-08-15 17:26 ` [PATCH 06/11] PCI/P2PDMA: " Kent Overstreet
2022-08-15 17:26 ` [PATCH 07/11] tracing: trace_events_synth: " Kent Overstreet
2022-08-15 17:43 ` Steven Rostedt
2022-08-15 17:58 ` Kent Overstreet
2022-08-15 18:28 ` Steven Rostedt
2022-08-15 17:26 ` [PATCH 08/11] d_path: prt_path() Kent Overstreet
2022-08-15 17:26 ` [PATCH 09/11] ACPI/APEI: Add missing include Kent Overstreet
2022-08-15 17:26 ` [PATCH 10/11] seq_buf: Move to kernel/tracing Kent Overstreet
2022-08-15 17:26 ` [PATCH 11/11] MAINTAINERS: Add entry for printbufs Kent Overstreet
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=20220815172613.621627-3-kent.overstreet@linux.dev \
--to=kent.overstreet@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=kent.overstreet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.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
all inboxes | Powered by JetHome®