summaryrefslogtreecommitdiff
path: root/drivers/hte
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2023-10-10 17:11:23 +0300
committerDipen Patel <dipenp@nvidia.com>2023-10-28 00:09:22 +0300
commitfc62d5e214df2dd64f5d675f01b609d86a422a2b (patch)
tree9b99575858beed9cd7d1964ada041ae571a959df /drivers/hte
parentb7c3ca3553d1de5e86c85636828e186d30cd0628 (diff)
downloadlinux-fc62d5e214df2dd64f5d675f01b609d86a422a2b.tar.xz
hte: Use kasprintf() instead of fixed buffer formatting
Improve readability and maintainability by replacing a hardcoded string allocation and formatting by the use of the kasprintf() helper. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Dipen Patel <dipenp@nvidia.com>
Diffstat (limited to 'drivers/hte')
-rw-r--r--drivers/hte/hte.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/hte/hte.c b/drivers/hte/hte.c
index 1fd8d2d4528b..23a6eeb8c506 100644
--- a/drivers/hte/hte.c
+++ b/drivers/hte/hte.c
@@ -17,8 +17,6 @@
#include <linux/debugfs.h>
#include <linux/device.h>
-#define HTE_TS_NAME_LEN 10
-
/* Global list of the HTE devices */
static DEFINE_SPINLOCK(hte_lock);
static LIST_HEAD(hte_devices);
@@ -389,13 +387,10 @@ static int __hte_req_ts(struct hte_ts_desc *desc, hte_ts_cb_t cb,
atomic_inc(&gdev->ts_req);
- ei->line_name = NULL;
- if (!desc->attr.name) {
- ei->line_name = kzalloc(HTE_TS_NAME_LEN, GFP_KERNEL);
- if (ei->line_name)
- scnprintf(ei->line_name, HTE_TS_NAME_LEN, "ts_%u",
- desc->attr.line_id);
- }
+ if (desc->attr.name)
+ ei->line_name = NULL;
+ else
+ ei->line_name = kasprintf(GFP_KERNEL, "ts_%u", desc->attr.line_id);
hte_ts_dbgfs_init(desc->attr.name == NULL ?
ei->line_name : desc->attr.name, ei);