From: Hungyu Lin Date: Sun, 7 Jun 2026 16:31:19 +0000 (+0000) Subject: dmaengine: qcom: hidma: use sysfs_emit() in sysfs show callbacks X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26f926b44dbfc035d5ba0ccfc4387a40aa9947c1;p=thirdparty%2Flinux.git dmaengine: qcom: hidma: use sysfs_emit() in sysfs show callbacks Replace sprintf() and strlen() patterns in sysfs show callbacks with sysfs_emit(). sysfs_emit() is the preferred helper for formatting sysfs output and simplifies the implementation. Signed-off-by: Hungyu Lin Reviewed-by: Frank Li Reviewed-by: Dmitry Baryshkov Link: https://patch.msgid.link/20260607163119.78717-1-dennylin0707@gmail.com Signed-off-by: Vinod Koul --- diff --git a/drivers/dma/qcom/hidma.c b/drivers/dma/qcom/hidma.c index 5a8dca8db5ceb..7a7f302a96991 100644 --- a/drivers/dma/qcom/hidma.c +++ b/drivers/dma/qcom/hidma.c @@ -624,12 +624,10 @@ static ssize_t hidma_show_values(struct device *dev, { struct hidma_dev *mdev = dev_get_drvdata(dev); - buf[0] = 0; - if (strcmp(attr->attr.name, "chid") == 0) - sprintf(buf, "%d\n", mdev->chidx); + return sysfs_emit(buf, "%d\n", mdev->chidx); - return strlen(buf); + return 0; } static inline void hidma_sysfs_uninit(struct hidma_dev *dev) diff --git a/drivers/dma/qcom/hidma_mgmt_sys.c b/drivers/dma/qcom/hidma_mgmt_sys.c index 930eae0a6257c..9672ef9ee8fc0 100644 --- a/drivers/dma/qcom/hidma_mgmt_sys.c +++ b/drivers/dma/qcom/hidma_mgmt_sys.c @@ -102,15 +102,12 @@ static ssize_t show_values(struct device *dev, struct device_attribute *attr, struct hidma_mgmt_dev *mdev = dev_get_drvdata(dev); unsigned int i; - buf[0] = 0; - for (i = 0; i < ARRAY_SIZE(hidma_mgmt_files); i++) { - if (strcmp(attr->attr.name, hidma_mgmt_files[i].name) == 0) { - sprintf(buf, "%d\n", hidma_mgmt_files[i].get(mdev)); - break; - } + if (strcmp(attr->attr.name, hidma_mgmt_files[i].name) == 0) + return sysfs_emit(buf, "%d\n", + hidma_mgmt_files[i].get(mdev)); } - return strlen(buf); + return 0; } static ssize_t set_values(struct device *dev, struct device_attribute *attr, @@ -143,15 +140,15 @@ static ssize_t show_values_channel(struct kobject *kobj, struct hidma_chan_attr *chattr; struct hidma_mgmt_dev *mdev; - buf[0] = 0; chattr = container_of(attr, struct hidma_chan_attr, attr); mdev = chattr->mdev; + if (strcmp(attr->attr.name, "priority") == 0) - sprintf(buf, "%d\n", mdev->priority[chattr->index]); + return sysfs_emit(buf, "%d\n", mdev->priority[chattr->index]); else if (strcmp(attr->attr.name, "weight") == 0) - sprintf(buf, "%d\n", mdev->weight[chattr->index]); + return sysfs_emit(buf, "%d\n", mdev->weight[chattr->index]); - return strlen(buf); + return 0; } static ssize_t set_values_channel(struct kobject *kobj,