[PATCH] cxl: Slightly simplify emit_target_list()

From: Christophe JAILLET

Date: Sun Dec 21 2025 - 09:16:24 EST


sysfs_emit_at() never returns a negative error code. It returns 0 or the
number of characters written in the buffer.

Remove the useless test. This simplifies the logic and saves a few lines of
code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
drivers/cxl/core/port.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index fef3aa0c6680..b77c1600beaa 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -151,7 +151,7 @@ static ssize_t emit_target_list(struct cxl_switch_decoder *cxlsd, char *buf)
{
struct cxl_decoder *cxld = &cxlsd->cxld;
ssize_t offset = 0;
- int i, rc = 0;
+ int i;

for (i = 0; i < cxld->interleave_ways; i++) {
struct cxl_dport *dport = cxlsd->target[i];
@@ -162,11 +162,9 @@ static ssize_t emit_target_list(struct cxl_switch_decoder *cxlsd, char *buf)

if (i + 1 < cxld->interleave_ways)
next = cxlsd->target[i + 1];
- rc = sysfs_emit_at(buf, offset, "%d%s", dport->port_id,
- next ? "," : "");
- if (rc < 0)
- return rc;
- offset += rc;
+ offset += sysfs_emit_at(buf, offset, "%d%s",
+ dport->port_id,
+ next ? "," : "");
}

return offset;
--
2.52.0