From patchwork Fri Aug 4 14:39:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13341953 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 5D322C0729B for ; Fri, 4 Aug 2023 14:39:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231799AbjHDOjS (ORCPT ); Fri, 4 Aug 2023 10:39:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231796AbjHDOjQ (ORCPT ); Fri, 4 Aug 2023 10:39:16 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 693AC46B1; Fri, 4 Aug 2023 07:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691159955; x=1722695955; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rkrFpsjN1kkwBUnx7S3/fsHajYxtZIFrVprJT5SR/KE=; b=WLS5gvwbycHK2N2dq8jfKBdG6GzBUYrxQRqsvwdSOsaxGVYIUWifCJzr SKv6MGPp9DFpyxeI6ZDmeOJJeNe9C18IGCVoUi72563sIZoxzHGCmKzR5 ZGFT1BZ99bYhrjCEdJwTqkzcZ+oI9rmEqR2BmZ8K4Otwx9VAwJBARhHVe Ya8VTRv2JOfTMqXskBEVZqoGJ4+c/qnthf0792rOHuI2OfpU27pxlAeQq 8pFpPwve/vzoYVijEBjNmgpH1ZsAenkWa7RrNR31q+YKwQfq5P8oViwU+ wqEYxg89S8+W9AkLeBKwo4xXNHl1HugcoXTHNEnQvJhBrgNIsXxneuxmq g==; X-IronPort-AV: E=McAfee;i="6600,9927,10792"; a="373816828" X-IronPort-AV: E=Sophos;i="6.01,255,1684825200"; d="scan'208";a="373816828" 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:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10792"; a="723678949" X-IronPort-AV: E=Sophos;i="6.01,255,1684825200"; d="scan'208";a="723678949" 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 6E494BF; 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 1/4] lib/string_helpers: Add kstrdup_and_replace() helper Date: Fri, 4 Aug 2023 17:39:07 +0300 Message-Id: <20230804143910.15504-2-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 Duplicate a NULL-terminated string and replace all occurrences of the old character with a new one. In other words, provide functionality of kstrdup() + strreplace(). Signed-off-by: Andy Shevchenko --- include/linux/string_helpers.h | 2 ++ lib/string_helpers.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h index 789ab30045da..9d1f5bb74dd5 100644 --- a/include/linux/string_helpers.h +++ b/include/linux/string_helpers.h @@ -109,6 +109,8 @@ char *kstrdup_quotable(const char *src, gfp_t gfp); char *kstrdup_quotable_cmdline(struct task_struct *task, gfp_t gfp); char *kstrdup_quotable_file(struct file *file, gfp_t gfp); +char *kstrdup_and_replace(const char *src, char old, char new, gfp_t gfp); + char **kasprintf_strarray(gfp_t gfp, const char *prefix, size_t n); void kfree_strarray(char **array, size_t n); diff --git a/lib/string_helpers.c b/lib/string_helpers.c index d3b1dd718daf..9982344cca34 100644 --- a/lib/string_helpers.c +++ b/lib/string_helpers.c @@ -719,6 +719,21 @@ char *kstrdup_quotable_file(struct file *file, gfp_t gfp) } EXPORT_SYMBOL_GPL(kstrdup_quotable_file); +/* + * Returns duplicate string in which the @old characters are replaced by @new. + */ +char *kstrdup_and_replace(const char *src, char old, char new, gfp_t gfp) +{ + char *dst; + + dst = kstrdup(src, gfp); + if (!dst) + return NULL; + + return strreplace(dst, old, new); +} +EXPORT_SYMBOL_GPL(kstrdup_and_replace); + /** * kasprintf_strarray - allocate and fill array of sequential strings * @gfp: flags for the slab allocator From patchwork Fri Aug 4 14:39:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13341952 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 6D3C2C04FE2 for ; Fri, 4 Aug 2023 14:39:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229719AbjHDOjP (ORCPT ); Fri, 4 Aug 2023 10:39:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230020AbjHDOjO (ORCPT ); Fri, 4 Aug 2023 10:39:14 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AE5F46B2; Fri, 4 Aug 2023 07:39:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691159952; x=1722695952; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C+abYiF6wNXvU9smtguynoZRdwPpMDNeO7w58qCuOuc=; b=mV2csy/kDtGEGU2W1/LM6YhOA7NhRWf3t2pBP0GXHELsYO9UD9eO/GI6 +KWlp4Y1nmKIIvRFLsOkjpqNIsTbb3ZhiHo4Cot/sboYvUQu5lb/PCQGr ifw+Oh3MMqmnKu5q9SqAuKIlupn5p17dWH6SuwM2BEbVp2wDEVT6Tbad5 AueW4Vpl0u7oKdnxNO4aT3KkyDnvsAbJsvJsy6QzBKWBtso8Z4Qv9htNM VlKr92RmOrxFUowuox+E4uFgjBMvgwZQiPl8eajI7/WPha2Le9xGxd3pH qduYLr4c9B/4oBq41/xy3TOiGKLH8F27NYCtWEqIeHqClQ6BHdeBY1zAG Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10792"; a="436487304" X-IronPort-AV: E=Sophos;i="6.01,255,1684825200"; d="scan'208";a="436487304" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2023 07:39:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10792"; a="795444755" X-IronPort-AV: E=Sophos;i="6.01,255,1684825200"; d="scan'208";a="795444755" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 04 Aug 2023 07:39:03 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 84A24BAB; 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 2/4] driver core: Replace kstrdup() + strreplace() with kstrdup_and_replace() Date: Fri, 4 Aug 2023 17:39:08 +0300 Message-Id: <20230804143910.15504-3-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. Acked-by: Greg Kroah-Hartman Signed-off-by: Andy Shevchenko --- drivers/base/core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 46d1d78c5beb..704ba73e1459 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -28,6 +27,7 @@ #include #include #include +#include #include #include #include /* for dma_default_coherent */ @@ -3908,10 +3908,9 @@ const char *device_get_devnode(const struct device *dev, return dev_name(dev); /* replace '!' in the name with '/' */ - s = kstrdup(dev_name(dev), GFP_KERNEL); + s = kstrdup_and_replace(dev_name(dev), '!', '/', GFP_KERNEL); if (!s) return NULL; - strreplace(s, '!', '/'); return *tmp = s; } From patchwork Fri Aug 4 14:39:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13341951 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 CB659C04A94 for ; Fri, 4 Aug 2023 14:39:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231641AbjHDOjO (ORCPT ); Fri, 4 Aug 2023 10:39:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjHDOjN (ORCPT ); Fri, 4 Aug 2023 10:39:13 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB24146B1; Fri, 4 Aug 2023 07:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691159951; x=1722695951; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=treqQoCApe7X7F3bCvmb79fj9fFVPi/mHsyYWBfo0dA=; b=HCVkTWEbOlR/t7wlztoYRtqzjQCzRTatZsL988vf3E3bTQAkW4ZJ8+DS 1EeQTzDB/KbjFdROgHxYZA1ZKz4sSfZO03QNtDzL5pO4JsrROFMKX+CDn MxzexTaiF2tsZZ9BafU/hTzPB4PvI3T1b0WFLAvbXWQqJYYKrwMBmx6Oi MEJY/Xu3mUvk2UqhEHrilQq9eX5T7tZO+tXvc8u8zlJ03neM1us44xqeG z6dmtNhgJ59Cb0VL1Ww6BSu1U0pzLr4Ll8desPLZkXlojnTfQvc/hoDYJ LgC2PNmxkohRbpzkPqFl8Bhwalf6T5CRT6q33fD00S7xp7OfFkP+xm1cS A==; X-IronPort-AV: E=McAfee;i="6600,9927,10792"; a="436487285" X-IronPort-AV: E=Sophos;i="6.01,255,1684825200"; d="scan'208";a="436487285" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2023 07:39:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10792"; a="795444753" X-IronPort-AV: E=Sophos;i="6.01,255,1684825200"; d="scan'208";a="795444753" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 04 Aug 2023 07:39:03 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8EC2BF12; 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 3/4] clk: tegra: Replace kstrdup() + strreplace() with kstrdup_and_replace() Date: Fri, 4 Aug 2023 17:39:09 +0300 Message-Id: <20230804143910.15504-4-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/tegra/clk.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/clk/tegra/clk.c b/drivers/clk/tegra/clk.c index 333a3ff0db98..19037346f522 100644 --- a/drivers/clk/tegra/clk.c +++ b/drivers/clk/tegra/clk.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include @@ -384,12 +384,10 @@ static struct device_node *tegra_clk_get_of_node(struct clk_hw *hw) struct device_node *np; char *node_name; - node_name = kstrdup(hw->init->name, GFP_KERNEL); + node_name = kstrdup_and_replace(hw->init->name, '_', '-', GFP_KERNEL); if (!node_name) return NULL; - strreplace(node_name, '_', '-'); - for_each_child_of_node(tegra_car_np, np) { if (!strcmp(np->name, node_name)) break; 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: 13341955 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; }