Skip to content

Commit fc62d5e

Browse files
andy-shevpateldipen1984-nv
authored andcommitted
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>
1 parent b7c3ca3 commit fc62d5e

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

drivers/hte/hte.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#include <linux/debugfs.h>
1818
#include <linux/device.h>
1919

20-
#define HTE_TS_NAME_LEN 10
21-
2220
/* Global list of the HTE devices */
2321
static DEFINE_SPINLOCK(hte_lock);
2422
static LIST_HEAD(hte_devices);
@@ -389,13 +387,10 @@ static int __hte_req_ts(struct hte_ts_desc *desc, hte_ts_cb_t cb,
389387

390388
atomic_inc(&gdev->ts_req);
391389

392-
ei->line_name = NULL;
393-
if (!desc->attr.name) {
394-
ei->line_name = kzalloc(HTE_TS_NAME_LEN, GFP_KERNEL);
395-
if (ei->line_name)
396-
scnprintf(ei->line_name, HTE_TS_NAME_LEN, "ts_%u",
397-
desc->attr.line_id);
398-
}
390+
if (desc->attr.name)
391+
ei->line_name = NULL;
392+
else
393+
ei->line_name = kasprintf(GFP_KERNEL, "ts_%u", desc->attr.line_id);
399394

400395
hte_ts_dbgfs_init(desc->attr.name == NULL ?
401396
ei->line_name : desc->attr.name, ei);

0 commit comments

Comments
 (0)