Commit 3315e169 authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Jens Axboe

blk-integrity: use sysfs_emit

The correct way to emit data into sysfs is via sysfs_emit(), use it.

Also perform some trivial syntactic cleanups.
Signed-off-by: default avatarThomas Weißschuh <linux@weissschuh.net>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20230309-kobj_release-gendisk_integrity-v3-1-ceccb4493c46@weissschuh.netSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 3f89ac58
...@@ -248,19 +248,18 @@ static ssize_t integrity_attr_store(struct kobject *kobj, ...@@ -248,19 +248,18 @@ static ssize_t integrity_attr_store(struct kobject *kobj,
static ssize_t integrity_format_show(struct blk_integrity *bi, char *page) static ssize_t integrity_format_show(struct blk_integrity *bi, char *page)
{ {
if (bi->profile && bi->profile->name) if (bi->profile && bi->profile->name)
return sprintf(page, "%s\n", bi->profile->name); return sysfs_emit(page, "%s\n", bi->profile->name);
else return sysfs_emit(page, "none\n");
return sprintf(page, "none\n");
} }
static ssize_t integrity_tag_size_show(struct blk_integrity *bi, char *page) static ssize_t integrity_tag_size_show(struct blk_integrity *bi, char *page)
{ {
return sprintf(page, "%u\n", bi->tag_size); return sysfs_emit(page, "%u\n", bi->tag_size);
} }
static ssize_t integrity_interval_show(struct blk_integrity *bi, char *page) static ssize_t integrity_interval_show(struct blk_integrity *bi, char *page)
{ {
return sprintf(page, "%u\n", return sysfs_emit(page, "%u\n",
bi->interval_exp ? 1 << bi->interval_exp : 0); bi->interval_exp ? 1 << bi->interval_exp : 0);
} }
...@@ -280,7 +279,7 @@ static ssize_t integrity_verify_store(struct blk_integrity *bi, ...@@ -280,7 +279,7 @@ static ssize_t integrity_verify_store(struct blk_integrity *bi,
static ssize_t integrity_verify_show(struct blk_integrity *bi, char *page) static ssize_t integrity_verify_show(struct blk_integrity *bi, char *page)
{ {
return sprintf(page, "%d\n", (bi->flags & BLK_INTEGRITY_VERIFY) != 0); return sysfs_emit(page, "%d\n", !!(bi->flags & BLK_INTEGRITY_VERIFY));
} }
static ssize_t integrity_generate_store(struct blk_integrity *bi, static ssize_t integrity_generate_store(struct blk_integrity *bi,
...@@ -299,13 +298,13 @@ static ssize_t integrity_generate_store(struct blk_integrity *bi, ...@@ -299,13 +298,13 @@ static ssize_t integrity_generate_store(struct blk_integrity *bi,
static ssize_t integrity_generate_show(struct blk_integrity *bi, char *page) static ssize_t integrity_generate_show(struct blk_integrity *bi, char *page)
{ {
return sprintf(page, "%d\n", (bi->flags & BLK_INTEGRITY_GENERATE) != 0); return sysfs_emit(page, "%d\n", !!(bi->flags & BLK_INTEGRITY_GENERATE));
} }
static ssize_t integrity_device_show(struct blk_integrity *bi, char *page) static ssize_t integrity_device_show(struct blk_integrity *bi, char *page)
{ {
return sprintf(page, "%u\n", return sysfs_emit(page, "%u\n",
(bi->flags & BLK_INTEGRITY_DEVICE_CAPABLE) != 0); !!(bi->flags & BLK_INTEGRITY_DEVICE_CAPABLE));
} }
static struct integrity_sysfs_entry integrity_format_entry = { static struct integrity_sysfs_entry integrity_format_entry = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment