Skip to contentSkip to conversation

cxl/feature: Remove redundant code of get supported features

PATCH Applied Li Ming 4 participants 5 messages May 16, 2025 – May 19, 2025 CXL

lore
Share & tools
lore

Li Ming

author reviewer
#0 lore raw

PATCH 1/1 cxl/feature: Remove redundant code of get supported features

In cxlctl_get_supported_features(), there is a code block that handles the case where the requested is equal to 0. But the code following the code block can also handle this situation. So the code block is not needed.

---
base-commit: 82f2b0b97b36ee3fcddf0f0780a9a0825d52fec3 v6.15-rc6

---
 drivers/cxl/core/features.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/cxl/core/features.c +0 -8
index 1498e2369c37..2d3a6d36a761 100644
@@ -416,14 +416,6 @@ static void *cxlctl_get_supported_features(struct cxl_features_state *cxlfs,
 
 	rpc_out->size = struct_size(feat_out, ents, requested);
 	feat_out = &rpc_out->get_sup_feats_out;
-	if (requested == 0) {
-		feat_out->num_entries = cpu_to_le16(requested);
-		feat_out->supported_feats =
-			cpu_to_le16(cxlfs->entries->num_features);
-		rpc_out->retval = CXL_MBOX_CMD_RC_SUCCESS;
-		*out_len = out_size;
-		return no_free_ptr(rpc_out);
-	}
 
 	for (i = start, pos = &feat_out->ents[0];
 	     i < cxlfs->entries->num_features; i++, pos++) {
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Li Ming

In cxlctl_get_supported_features(), there is a code block that handles the case where the requested is equal to 0. But the code following the code block can also handle this situation. So the code block is not needed.

Quoted 25 lines

---
base-commit: 82f2b0b97b36ee3fcddf0f0780a9a0825d52fec3 v6.15-rc6

---
 drivers/cxl/core/features.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/cxl/core/features.c +0 -8
index 1498e2369c37..2d3a6d36a761 100644
@@ -416,14 +416,6 @@ static void *cxlctl_get_supported_features(struct cxl_features_state *cxlfs,
 
 	rpc_out->size = struct_size(feat_out, ents, requested);
 	feat_out = &rpc_out->get_sup_feats_out;
-	if (requested == 0) {
-		feat_out->num_entries = cpu_to_le16(requested);
-		feat_out->supported_feats =
-			cpu_to_le16(cxlfs->entries->num_features);
-		rpc_out->retval = CXL_MBOX_CMD_RC_SUCCESS;
-		*out_len = out_size;
-		return no_free_ptr(rpc_out);
-	}
 
 	for (i = start, pos = &feat_out->ents[0];
 	     i < cxlfs->entries->num_features; i++, pos++) {
maintainer Applied
#3 lore raw
In reply to Li Ming
Quoted 6 lines · Li Ming

In cxlctl_get_supported_features(), there is a code block that handles the case where the requested is equal to 0. But the code following the code block can also handle this situation. So the code block is not needed.

Applied to cxl/next

Quoted 25 lines

---
base-commit: 82f2b0b97b36ee3fcddf0f0780a9a0825d52fec3 v6.15-rc6

---
 drivers/cxl/core/features.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/cxl/core/features.c +0 -8
index 1498e2369c37..2d3a6d36a761 100644
@@ -416,14 +416,6 @@ static void *cxlctl_get_supported_features(struct cxl_features_state *cxlfs,
 
 	rpc_out->size = struct_size(feat_out, ents, requested);
 	feat_out = &rpc_out->get_sup_feats_out;
-	if (requested == 0) {
-		feat_out->num_entries = cpu_to_le16(requested);
-		feat_out->supported_feats =
-			cpu_to_le16(cxlfs->entries->num_features);
-		rpc_out->retval = CXL_MBOX_CMD_RC_SUCCESS;
-		*out_len = out_size;
-		return no_free_ptr(rpc_out);
-	}
 
 	for (i = start, pos = &feat_out->ents[0];
 	     i < cxlfs->entries->num_features; i++, pos++) {
Reviewed-by on v1 1/1
#4 lore raw
In reply to Li Ming
Quoted 7 lines · Li Ming

In cxlctl_get_supported_features(), there is a code block that handles the case where the requested is equal to 0. But the code following the code block can also handle this situation. So the code block is not needed.

---

Quoted 27 lines

base-commit: 82f2b0b97b36ee3fcddf0f0780a9a0825d52fec3 v6.15-rc6

---
 drivers/cxl/core/features.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/cxl/core/features.c +0 -8
index 1498e2369c37..2d3a6d36a761 100644
@@ -416,14 +416,6 @@ static void *cxlctl_get_supported_features(struct cxl_features_state *cxlfs,
 
 	rpc_out->size = struct_size(feat_out, ents, requested);
 	feat_out = &rpc_out->get_sup_feats_out;
-	if (requested == 0) {
-		feat_out->num_entries = cpu_to_le16(requested);
-		feat_out->supported_feats =
-			cpu_to_le16(cxlfs->entries->num_features);
-		rpc_out->retval = CXL_MBOX_CMD_RC_SUCCESS;
-		*out_len = out_size;
-		return no_free_ptr(rpc_out);
-	}
 
 	for (i = start, pos = &feat_out->ents[0];
 	     i < cxlfs->entries->num_features; i++, pos++) {
Signature · 1 line
2.34.1
Signature · 1 line
Fan Ni