crypto: qat - replace scnprintf() with sysfs_emit()
Subsystems (2)
PATCH v2 1/1 crypto: qat - replace scnprintf() with sysfs_emit()
Replace 3 sysfs functions in the Intel Qat Driver
to use sysfs_emit() instead of scnprintf().
- erros_correctable_show(): Replace scnprint() with sysfs_emit()
- errors_nonfatal_show(): Replace scnprint() with sysfs_emit()
- errors_fatal_show(): Replace scnprint() with sysfs_emit()
This change is in accordance with Documentation/filesystems/sysfs.rst, which recommends using sysfs_emit/sysfs_emit_at in all sysfs show() callbacks for buffer safety, clarity, and consistency.
---
Changes in v2:
- Update the Subject according to the suggestion in v1
- Link to v1: https://lore.kernel.org/r/[email protected]
--- drivers/crypto/intel/qat/qat_common/adf_sysfs_ras_counters.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/crypto/intel/qat/qat_common/adf_sysfs_ras_counters.c +3 -3
@@ -20,7 +20,7 @@ static ssize_t errors_correctable_show(struct device *dev,return -EINVAL ; counter =ADF_RAS_ERR_CTR_READ (accel_dev->ras_errors,ADF_RAS_CORR ); -return scnprintf (buf,PAGE_SIZE ,"%ld\n" , counter); +return sysfs_emit (buf,"%ld\n" , counter); } static ssize_t errors_nonfatal_show(struct device *dev,
@@ -35,7 +35,7 @@ static ssize_t errors_nonfatal_show(struct device *dev,return -EINVAL ; counter =ADF_RAS_ERR_CTR_READ (accel_dev->ras_errors,ADF_RAS_UNCORR ); -return scnprintf (buf,PAGE_SIZE ,"%ld\n" , counter); +return sysfs_emit (buf,"%ld\n" , counter); } static ssize_t errors_fatal_show(struct device *dev,
@@ -50,7 +50,7 @@ static ssize_t errors_fatal_show(struct device *dev,return -EINVAL ; counter =ADF_RAS_ERR_CTR_READ (accel_dev->ras_errors,ADF_RAS_FATAL ); -return scnprintf (buf,PAGE_SIZE ,"%ld\n" , counter); +return sysfs_emit (buf,"%ld\n" , counter); } static ssize_t reset_error_counters_store(struct device *dev,
---
base-commit: 8a30aeb0d1b4e4aaf7f7bae72f20f2ae75385ccb
change-id: 20260320-sysfs-7e19eeb06586
Best regards,
Signature · 1 line
Atharv Dubey <[email protected]>
Giovanni Cabiddu
maintainerQuoted 4 lines · Atharv Dubey
Replace 3 sysfs functions in the Intel Qat Driver
to usesysfs_emit()instead ofscnprintf().-
erros_correctable_show(): Replacescnprint()withsysfs_emit()
/s/erros/errors
/s/scnprint/scnprintf/g
Quoted 2 lines
-
errors_nonfatal_show(): Replacescnprint()withsysfs_emit()
-errors_fatal_show(): Replacescnprint()withsysfs_emit()
...
drivers/crypto/intel/qat/qat_common/adf_sysfs_ras_counters.c static ssize_t errors_fatal_show(struct device *dev, · line 53
Quoted 7 lines
static
ssize_terrors_fatal_show(struct device *dev,drivers/crypto/intel/qat/qat_common/adf_sysfs_ras_counters.c +1
-1@@ -50,7 +50,7 @@ static ssize_t errors_fatal_show(struct device *dev,return -EINVAL ; counter =ADF_RAS_ERR_CTR_READ (accel_dev->ras_errors,ADF_RAS_FATAL ); -return scnprintf (buf,PAGE_SIZE ,"%ld\n" , counter); +return sysfs_emit (buf,"%ld\n" , counter);
Remove spurious double space after "buf,".
Anyway, I just noticed that counter is declared as unsigned long and scnprintf() is using %d.
As ADF_RAS_ERR_CTR_READ() expands to atomic_read() which returns an int, I'm going to convert unsigned long counter in an interger.
I'm going to send a fix for the above and your patch on top (with fixes) in a small series. No action required for you. :-)
Thanks,
Signature · 1 line
Giovanni