From patchwork Fri Aug 4 14:39:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 710473 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8473C04A6A for ; Fri, 4 Aug 2023 14:39:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231808AbjHDOjV (ORCPT ); Fri, 4 Aug 2023 10:39:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230079AbjHDOjR (ORCPT ); Fri, 4 Aug 2023 10:39:17 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64CEB46B2; Fri, 4 Aug 2023 07:39:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691159956; x=1722695956; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BdfhnFCNUuI8DazLAkJD8/rcKyTlng09fRJwpWeZK0U=; b=ishrlyCbFLEzgm8NDTSW2RxcLMh7r2PXe7+mF0jAcTLdzmF0VCbkzUuK 8V4ZQfWF7I5ba9VJ43+C2AJnSTEN5CR/VbncC/DwJTXfjhQ91SivIjLdG YtbVR+x9+tgCkPKFM8P4ZoqbEsscmcKsSSsb1z0/ewzU6wY+Nn2PvE6DS e9j0vbT3RaZtu7RVzElgRnfVb420CqtFJHXVHLKLFi8RupwgylFLO1XNl eevTCUxJUOZo/GUf6lO4JzRzdxy89QDfmXUdt8f2zCfe+/V1IAFthyq9o nBIp5AJJxPrV3OBUnvTd3TuyZTDPySWugP08pg/Wi9g5KIMEDmFhoihSE Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10792"; a="373816836" X-IronPort-AV: E=Sophos;i="6.01,255,1684825200"; d="scan'208";a="373816836" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2023 07:39:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10792"; a="723678947" X-IronPort-AV: E=Sophos;i="6.01,255,1684825200"; d="scan'208";a="723678947" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 04 Aug 2023 07:39:03 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9D1C5F4D; Fri, 4 Aug 2023 17:39:14 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Saravana Kannan , Andy Shevchenko , Stephen Boyd , Dario Binacchi , Tony Lindgren , linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org, linux-hardening@vger.kernel.org Cc: "Rafael J. Wysocki" , Peter De Schrijver , Prashant Gaikwad , Michael Turquette , Thierry Reding , Jonathan Hunter , Tero Kristo , Kees Cook , Andy Shevchenko Subject: [PATCH v2 4/4] clk: ti: Replace kstrdup() + strreplace() with kstrdup_and_replace() Date: Fri, 4 Aug 2023 17:39:10 +0300 Message-Id: <20230804143910.15504-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230804143910.15504-1-andriy.shevchenko@linux.intel.com> References: <20230804143910.15504-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Replace open coded functionality of kstrdup_and_replace() with a call. Signed-off-by: Andy Shevchenko --- drivers/clk/ti/clk.c | 4 ++-- drivers/clk/ti/clkctrl.c | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c index 3d636938a739..1862958ab412 100644 --- a/drivers/clk/ti/clk.c +++ b/drivers/clk/ti/clk.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -123,10 +124,9 @@ static struct device_node *ti_find_clock_provider(struct device_node *from, const char *n; char *tmp; - tmp = kstrdup(name, GFP_KERNEL); + tmp = kstrdup_and_replace(name, '-', '_', GFP_KERNEL); if (!tmp) return NULL; - strreplace(tmp, '-', '_'); /* Node named "clock" with "clock-output-names" */ for_each_of_allnodes_from(from, np) { diff --git a/drivers/clk/ti/clkctrl.c b/drivers/clk/ti/clkctrl.c index 8c40f10280b7..607e34d8e289 100644 --- a/drivers/clk/ti/clkctrl.c +++ b/drivers/clk/ti/clkctrl.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "clock.h" @@ -473,11 +474,11 @@ static const char * __init clkctrl_get_name(struct device_node *np) const int prefix_len = 11; const char *compat; const char *output; + const char *end; char *name; if (!of_property_read_string_index(np, "clock-output-names", 0, &output)) { - const char *end; int len; len = strlen(output); @@ -491,13 +492,13 @@ static const char * __init clkctrl_get_name(struct device_node *np) of_property_for_each_string(np, "compatible", prop, compat) { if (!strncmp("ti,clkctrl-", compat, prefix_len)) { + end = compat + prefix_len; /* Two letter minimum name length for l3, l4 etc */ - if (strnlen(compat + prefix_len, 16) < 2) + if (strnlen(end, 16) < 2) continue; - name = kasprintf(GFP_KERNEL, "%s", compat + prefix_len); + name = kstrdup_and_replace(end, '-', '_', GFP_KERNEL); if (!name) continue; - strreplace(name, '-', '_'); return name; }