[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220519172421.162394-25-kent.overstreet@gmail.com>
Date: Thu, 19 May 2022 13:24:17 -0400
From: Kent Overstreet <kent.overstreet@...il.com>
To: linux-kernel@...r.kernel.org, linux-mm@...r.kernel.org,
pmladek@...e.com, rostedt@...dmis.org, senozhatsky@...omium.org
Cc: Kent Overstreet <kent.overstreet@...il.com>,
andriy.shevchenko@...ux.intel.com, willy@...radead.org
Subject: [PATCH v2 24/28] 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..77a8c47806 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, "(");
+ pr_buf(&buf, "(");
if (info->flags & TEGRA_BPMP_CLK_HAS_MUX) {
- seq_buf_printf(&buf, "%smux", prefix);
+ pr_buf(&buf, "%smux", prefix);
prefix = ", ";
}
if ((info->flags & TEGRA_BPMP_CLK_HAS_SET_RATE) == 0) {
- seq_buf_printf(&buf, "%sfixed", prefix);
+ pr_buf(&buf, "%sfixed", prefix);
prefix = ", ";
}
if (info->flags & TEGRA_BPMP_CLK_IS_ROOT) {
- seq_buf_printf(&buf, "%sroot", prefix);
+ pr_buf(&buf, "%sroot", prefix);
prefix = ", ";
}
if (info->flags)
- seq_buf_printf(&buf, ")");
+ pr_buf(&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