From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32EFCC4332F for ; Thu, 21 Apr 2022 23:49:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 232A36B0081; Thu, 21 Apr 2022 19:48:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 190826B0082; Thu, 21 Apr 2022 19:48:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F25906B0083; Thu, 21 Apr 2022 19:48:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id DC12B6B0081 for ; Thu, 21 Apr 2022 19:48:58 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id C134480121 for ; Thu, 21 Apr 2022 23:48:58 +0000 (UTC) X-FDA: 79382529156.20.AD17139 Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) by imf24.hostedemail.com (Postfix) with ESMTP id AACAD180025 for ; Thu, 21 Apr 2022 23:48:56 +0000 (UTC) Received: by mail-qv1-f41.google.com with SMTP id x20so4856189qvl.10 for ; Thu, 21 Apr 2022 16:48:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PF/Z8BQ8fxOBlrER2fv/400ai3CQSf3kzChsoC/3ncM=; b=Fmg9GchsDQjutgHrWM/IG+EZhv+HiZ+dEvnMEDFKb+T+r+Q/Xm1YYliGP71kb6HN+W GLqoDr61dXwsDzPdRECJYcQarmk+T6H4rug3ZFdmtLaQYy7lzYaMsCU6dX3rUj64pGr7 difeOIk+oQYdWGlmXufNianxRUrB5l5qg89ze9Jteco8L9yFCLmSBz6753W5U7GVkTFf KV2WBL3T5cbnVEjKBJAhLxSEDGc8wbP1WK3nKE6ceGRyVxh4RU72LEeojkTBoTQAuVll 0zLDqezyxdzSEYDpBh/5eBMG/x+TQe220iuYVtOgctc18dzhEdeyciNQwMdPaIo0yI2x DdwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PF/Z8BQ8fxOBlrER2fv/400ai3CQSf3kzChsoC/3ncM=; b=RGMDtpo0fLr5FAw5J/2Y5SEgk3IsroIBmlF3rkPqX3VTkcsQhPTKkGO69hnkB5y+J8 X4NGX2S130v4A+8a6+OKbKxnX0UVQr73nb/rN4IcK4jqIvMcuFd7J+eqIwxL+PvGqLob XOHxvTD9DN+CyOP8ZoIWaKCNlljOKHbeKeMqFz5R+vCGynkxCrqTOsuE3l4yNsqDEqut U2fS7Efj+3pVcyxbmGZ3dYgyoQ8C1WBDqFMzZvc9v+/DjExWkIsCm5ymOxPHbcZMfBV7 UeKcPazdb3l0pNQ7pExSyAv5CSbuxJMhPU2M+3kongbZyfuefB58Y9xeiWBXSZVxfNVX 7t4Q== X-Gm-Message-State: AOAM5329T1EEyT5B205nTQxgr+GtxiwSvSkbR2wti1RXgrMvIG1LcXfu g+nv30K1xQFXtOhhWdx9bA== X-Google-Smtp-Source: ABdhPJwDhIK3eHTLsewAwF5FpbZ4NbS8mVZfkNqfhh2q7YLtu3tIrgjsNLqW2nO1uAxRcg8T77R/yw== X-Received: by 2002:ad4:5caa:0:b0:446:54ef:60d4 with SMTP id q10-20020ad45caa000000b0044654ef60d4mr1790926qvh.86.1650584937815; Thu, 21 Apr 2022 16:48:57 -0700 (PDT) Received: from moria.home.lan (c-73-219-103-14.hsd1.vt.comcast.net. [73.219.103.14]) by smtp.gmail.com with ESMTPSA id a1-20020a05622a02c100b002f342ccc1c5sm287372qtx.72.2022.04.21.16.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 16:48:56 -0700 (PDT) From: Kent Overstreet To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: Kent Overstreet , hch@lst.de, hannes@cmpxchg.org, akpm@linux-foundation.org, linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org, linux-input@vger.kernel.org, roman.gushchin@linux.dev Subject: [PATCH v2 4/8] clk: tegra: bpmp: Convert to printbuf Date: Thu, 21 Apr 2022 19:48:33 -0400 Message-Id: <20220421234837.3629927-10-kent.overstreet@gmail.com> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220421234837.3629927-1-kent.overstreet@gmail.com> References: <20220421234837.3629927-1-kent.overstreet@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: AACAD180025 X-Stat-Signature: 4unar3erg45tiy9r74tsewptypnpz1fg Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Fmg9Gchs; spf=pass (imf24.hostedemail.com: domain of kent.overstreet@gmail.com designates 209.85.219.41 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-HE-Tag: 1650584936-279731 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 --- 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 #include -#include +#include #include #include @@ -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.35.2