[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220604193042.1674951-26-kent.overstreet@gmail.com>
Date: Sat, 4 Jun 2022 15:30:34 -0400
From: Kent Overstreet <kent.overstreet@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Kent Overstreet <kent.overstreet@...il.com>, pmladek@...e.com,
rostedt@...dmis.org
Subject: [PATCH v3 25/33] clk: tegra: bpmp: Convert to printbuf
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@...il.com>
---
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 6ecf18f71c..301551174c 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>
@@ -360,39 +360,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.0
Powered by blists - more mailing lists