Skip to content

Commit 9886f57

Browse files
TomAi0ij-intel
authored andcommitted
platform/mellanox: mlxbf-bootctl: use sysfs_emit() instead of sprintf()
Follow the advice in Documentation/filesystems/sysfs.rst: show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. Signed-off-by: Ai Chao <[email protected]> Acked-by: Vadim Pasternak <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 6e4ab59 commit 9886f57

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/platform/mellanox/mlxbf-bootctl.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static ssize_t post_reset_wdog_show(struct device *dev,
177177
if (ret < 0)
178178
return ret;
179179

180-
return sprintf(buf, "%d\n", ret);
180+
return sysfs_emit(buf, "%d\n", ret);
181181
}
182182

183183
static ssize_t post_reset_wdog_store(struct device *dev,
@@ -206,7 +206,7 @@ static ssize_t mlxbf_bootctl_show(int smc_op, char *buf)
206206
if (action < 0)
207207
return action;
208208

209-
return sprintf(buf, "%s\n", mlxbf_bootctl_action_to_string(action));
209+
return sysfs_emit(buf, "%s\n", mlxbf_bootctl_action_to_string(action));
210210
}
211211

212212
static int mlxbf_bootctl_store(int smc_op, const char *buf, size_t count)
@@ -274,14 +274,14 @@ static ssize_t lifecycle_state_show(struct device *dev,
274274
* due to using the test bits.
275275
*/
276276
if (test_state) {
277-
return sprintf(buf, "%s(test)\n",
277+
return sysfs_emit(buf, "%s(test)\n",
278278
mlxbf_bootctl_lifecycle_states[lc_state]);
279279
} else if (use_dev_key &&
280280
(lc_state == MLXBF_BOOTCTL_SB_LIFECYCLE_GA_SECURE)) {
281-
return sprintf(buf, "Secured (development)\n");
281+
return sysfs_emit(buf, "Secured (development)\n");
282282
}
283283

284-
return sprintf(buf, "%s\n", mlxbf_bootctl_lifecycle_states[lc_state]);
284+
return sysfs_emit(buf, "%s\n", mlxbf_bootctl_lifecycle_states[lc_state]);
285285
}
286286

287287
static ssize_t secure_boot_fuse_state_show(struct device *dev,
@@ -332,9 +332,9 @@ static ssize_t secure_boot_fuse_state_show(struct device *dev,
332332
else
333333
status = valid ? "Invalid" : "Free";
334334
}
335-
buf_len += sprintf(buf + buf_len, "%d:%s ", key, status);
335+
buf_len += sysfs_emit(buf + buf_len, "%d:%s ", key, status);
336336
}
337-
buf_len += sprintf(buf + buf_len, "\n");
337+
buf_len += sysfs_emit(buf + buf_len, "\n");
338338

339339
return buf_len;
340340
}

0 commit comments

Comments
 (0)