[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aUjAcQZ5JCxnk7Qp@aschofie-mobl2.lan>
Date: Sun, 21 Dec 2025 19:52:17 -0800
From: Alison Schofield <alison.schofield@...el.com>
To: Christophe JAILLET <christophe.jaillet@...adoo.fr>
CC: Davidlohr Bueso <dave@...olabs.net>, Jonathan Cameron
<jonathan.cameron@...wei.com>, Dave Jiang <dave.jiang@...el.com>, "Vishal
Verma" <vishal.l.verma@...el.com>, Ira Weiny <ira.weiny@...el.com>, "Dan
Williams" <dan.j.williams@...el.com>, <linux-kernel@...r.kernel.org>,
<kernel-janitors@...r.kernel.org>, <linux-cxl@...r.kernel.org>
Subject: Re: [PATCH] cxl: Slightly simplify emit_target_list()
On Sun, Dec 21, 2025 at 03:15:04PM +0100, Christophe JAILLET wrote:
> 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@...adoo.fr>
> ---
> 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;
Can this can be cleaned up further at the target_list_show() call
site which also checks for an impossible rc < 0 (twice).
> --
> 2.52.0
>
Powered by blists - more mailing lists