crypto: qat - fix and cleanup RAS sysfs show functions
Subsystems (2)
Giovanni Cabiddu
maintainercover crypto: qat - fix and cleanup RAS sysfs show functions
This small series fixes a type mismatch bug in the RAS error counter sysfs interface of the Intel QAT driver and follows up with a cleanup to use the recommended sysfs output API.
Patch #1 fixes a type mismatch in the RAS sysfs show callbacks: the local counter variable was declared as 'unsigned long' while atomic_read() returns int, causing an implicit conversion and a wrong '%ld' format specifier. Patch #2 follows up by migrating the same callbacks from scnprintf() to the recommended sysfs_emit() API.
Atharv Dubey (1):
crypto: qat - replace scnprintf() with sysfs_emit()
Giovanni Cabiddu (1):
crypto: qat - fix type mismatch in RAS sysfs show functions
.../intel/qat/qat_common/adf_sysfs_ras_counters.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
base-commit: 8da773efcd2b505cca6bbd13aad4a28fda61cf37
Signature · 1 line
2.53.0
Giovanni Cabiddu
maintainerPATCH 1/2 crypto: qat - fix type mismatch in RAS sysfs show functions
ADF_RAS_ERR_CTR_READ() expands to atomic_read(), which returns int. The local variable 'counter' was declared as 'unsigned long', causing a type mismatch on the assignment. The format specifier '%ld' was consequently wrong in two ways: wrong length modifier and wrong signedness.
Use int to match the return type of atomic_read() and update the format specifier to '%d' accordingly.
--- .../intel/qat/qat_common/adf_sysfs_ras_counters.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/crypto/intel/qat/qat_common/adf_sysfs_ras_counters.c +6 -6
@@ -13,14 +13,14 @@ static ssize_t errors_correctable_show(struct device *dev, char *buf) {struct adf_accel_dev *accel_dev; -unsigned long counter; +int counter; accel_dev =adf_devmgr_pci_to_accel_dev (to_pci_dev (dev));if (!accel_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 scnprintf (buf,PAGE_SIZE ,"%d\n" , counter); } static ssize_t errors_nonfatal_show(struct device *dev,
@@ -28,14 +28,14 @@ static ssize_t errors_nonfatal_show(struct device *dev, char *buf) {struct adf_accel_dev *accel_dev; -unsigned long counter; +int counter; accel_dev =adf_devmgr_pci_to_accel_dev (to_pci_dev (dev));if (!accel_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 scnprintf (buf,PAGE_SIZE ,"%d\n" , counter); } static ssize_t errors_fatal_show(struct device *dev,
@@ -43,14 +43,14 @@ static ssize_t errors_fatal_show(struct device *dev, char *buf) {struct adf_accel_dev *accel_dev; -unsigned long counter; +int counter; accel_dev =adf_devmgr_pci_to_accel_dev (to_pci_dev (dev));if (!accel_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 scnprintf (buf,PAGE_SIZE ,"%d\n" , counter); } static ssize_t reset_error_counters_store(struct device *dev,
Signature · 1 line
2.53.0
Giovanni Cabiddu
maintainerPATCH 2/2 crypto: qat - replace scnprintf() with sysfs_emit()
In reply to Giovanni CabidduFrom: Atharv Dubey <[email protected]>
Replace scnprintf() with sysfs_emit() in the three RAS error counter sysfs show callbacks. sysfs_emit() is the recommended API for sysfs show functions as per Documentation/filesystems/sysfs.rst; it enforces the PAGE_SIZE limit implicitly, removing the need to pass it explicitly.
--- .../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 ,"%d\n" , counter); +return sysfs_emit (buf,"%d\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 ,"%d\n" , counter); +return sysfs_emit (buf,"%d\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 ,"%d\n" , counter); +return sysfs_emit (buf,"%d\n" , counter); } static ssize_t reset_error_counters_store(struct device *dev,
Signature · 1 line
2.53.0
Herbert Xu
maintainerQuoted 13 lines · Giovanni Cabiddu
This small series fixes a type mismatch bug in the RAS error counter sysfs interface of the Intel QAT driver and follows up with a cleanup to use the recommended sysfs output API.
Patch #1 fixes a type mismatch in the RAS sysfs show callbacks: the local counter variable was declared as 'unsigned long' while
atomic_read()returns int, causing an implicit conversion and a wrong '%ld' format specifier. Patch #2 follows up by migrating the same callbacks fromscnprintf()to the recommendedsysfs_emit()API.Atharv Dubey (1):
crypto: qat - replacescnprintf()withsysfs_emit()
Quoted 10 lines
Giovanni Cabiddu (1):
crypto: qat - fix type mismatch in RAS sysfs show functions.../intel/qat/qat_common/adf_sysfs_ras_counters.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)base-commit:
8da773efcd2b505cca6bbd13aad4a28fda61cf37Signature · 1 line
2.53.0
All applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt