summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLi Zhijian <lizhijian@fujitsu.com>2024-03-14 17:15:12 +0800
committerUlf Hansson <ulf.hansson@linaro.org>2024-04-02 12:21:39 +0200
commit4c7a022ca4dc951fddc5c060cba575104e3e62cf (patch)
tree252a6b50b67132de6f99aa146a082a4791e3a62d
parent0cbff48946cc6794aef6ed7beb7801015680cc45 (diff)
downloadlinux-4c7a022ca4dc951fddc5c060cba575104e3e62cf.tar.gz
linux-4c7a022ca4dc951fddc5c060cba575104e3e62cf.tar.bz2
linux-4c7a022ca4dc951fddc5c060cba575104e3e62cf.zip
mmc: core: Convert sprintf/snprintf to sysfs_emit
Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). sprintf() will be converted as weel if they have. Generally, this patch is generated by make coccicheck M=<path/to/file> MODE=patch \ COCCI=scripts/coccinelle/api/device_attr_show.cocci No functional change intended Signed-off-by: Li Zhijian <lizhijian@fujitsu.com> Link: https://lore.kernel.org/r/20240314091512.1323650-1-lizhijian@fujitsu.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/core/block.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 90c51b12148e..367509b5b646 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -234,7 +234,7 @@ static ssize_t power_ro_lock_show(struct device *dev,
else if (card->ext_csd.boot_ro_lock & EXT_CSD_BOOT_WP_B_PWR_WP_EN)
locked = 1;
- ret = snprintf(buf, PAGE_SIZE, "%d\n", locked);
+ ret = sysfs_emit(buf, "%d\n", locked);
mmc_blk_put(md);
@@ -296,9 +296,9 @@ static ssize_t force_ro_show(struct device *dev, struct device_attribute *attr,
int ret;
struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
- ret = snprintf(buf, PAGE_SIZE, "%d\n",
- get_disk_ro(dev_to_disk(dev)) ^
- md->read_only);
+ ret = sysfs_emit(buf, "%d\n",
+ get_disk_ro(dev_to_disk(dev)) ^
+ md->read_only);
mmc_blk_put(md);
return ret;
}