Skip to contentSkip to conversation

crypto: qat - simplify adf_service_mask_to_string helper

PATCH In review Thorsten Blum 3 participants 3 messages May 27 – Jun 5

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: qat - simplify adf_service_mask_to_string helper

Use a single scnprintf() for each set bit and drop the offset in the else branch to simplify adf_service_mask_to_string().

---
 drivers/crypto/intel/qat/qat_common/adf_cfg_services.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/crypto/intel/qat/qat_common/adf_cfg_services.c +3 -4
index 21b21ac78e53..baf563c6f9b7 100644
@@ -93,10 +93,9 @@ static int adf_service_mask_to_string(unsigned long mask, char *buf, size_t len)
 	for_each_set_bit(bit, &mask, SVC_COUNT) {
 		if (offset)
 			offset += scnprintf(buf + offset, len - offset,
-					    ADF_SERVICES_DELIMITER);
-
-		offset += scnprintf(buf + offset, len - offset, "%s",
-				    adf_cfg_services[bit]);
+				ADF_SERVICES_DELIMITER "%s", adf_cfg_services[bit]);
+		else
+			offset += scnprintf(buf, len, "%s", adf_cfg_services[bit]);
 	}
 
 	return 0;
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Thorsten Blum

Use a single scnprintf() for each set bit and drop the offset in the else branch to simplify adf_service_mask_to_string().

Quoted 22 lines
---
 drivers/crypto/intel/qat/qat_common/adf_cfg_services.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/crypto/intel/qat/qat_common/adf_cfg_services.c +3 -4
index 21b21ac78e53..baf563c6f9b7 100644
@@ -93,10 +93,9 @@ static int adf_service_mask_to_string(unsigned long mask, char *buf, size_t len)
 	for_each_set_bit(bit, &mask, SVC_COUNT) {
 		if (offset)
 			offset += scnprintf(buf + offset, len - offset,
-					    ADF_SERVICES_DELIMITER);
-
-		offset += scnprintf(buf + offset, len - offset, "%s",
-				    adf_cfg_services[bit]);
+				ADF_SERVICES_DELIMITER "%s", adf_cfg_services[bit]);
+		else
+			offset += scnprintf(buf, len, "%s", adf_cfg_services[bit]);
 	}
 
 	return 0;
maintainer
#2 lore raw
In reply to Thorsten Blum
Quoted 7 lines · Thorsten Blum

Use a single scnprintf() for each set bit and drop the offset in the else branch to simplify adf_service_mask_to_string().

---
 drivers/crypto/intel/qat/qat_common/adf_cfg_services.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Patch 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