Files
linux/drivers/dma/idxd/defaults.c
Thorsten Blum 847164d470 dmaengine: idxd: Replace memset(0) + strscpy() with strscpy_pad()
Replace memset(0) followed by strscpy() with strscpy_pad() to improve
idxd_load_iaa_device_defaults(). This avoids zeroing the memory before
copying the strings and ensures the destination buffers are only written
to once, simplifying the code and improving efficiency.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20250810225858.2953-2-thorsten.blum@linux.dev
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2025-08-20 23:01:27 +05:30

52 lines
1.1 KiB
C

// SPDX-License-Identifier: GPL-2.0
/* Copyright(c) 2023 Intel Corporation. All rights rsvd. */
#include <linux/kernel.h>
#include "idxd.h"
int idxd_load_iaa_device_defaults(struct idxd_device *idxd)
{
struct idxd_engine *engine;
struct idxd_group *group;
struct idxd_wq *wq;
if (!test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags))
return 0;
wq = idxd->wqs[0];
if (wq->state != IDXD_WQ_DISABLED)
return -EPERM;
/* set mode to "dedicated" */
set_bit(WQ_FLAG_DEDICATED, &wq->flags);
wq->threshold = 0;
/* only setting up 1 wq, so give it all the wq space */
wq->size = idxd->max_wq_size;
/* set priority to 10 */
wq->priority = 10;
/* set type to "kernel" */
wq->type = IDXD_WQT_KERNEL;
/* set wq group to 0 */
group = idxd->groups[0];
wq->group = group;
group->num_wqs++;
/* set name to "iaa_crypto" */
strscpy_pad(wq->name, "iaa_crypto");
/* set driver_name to "crypto" */
strscpy_pad(wq->driver_name, "crypto");
engine = idxd->engines[0];
/* set engine group to 0 */
engine->group = idxd->groups[0];
engine->group->num_engines++;
return 0;
}