From nobody Wed Dec 17 09:23:05 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2397C4167B for ; Tue, 28 Nov 2023 19:49:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230309AbjK1Ttn (ORCPT ); Tue, 28 Nov 2023 14:49:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229586AbjK1Ttm (ORCPT ); Tue, 28 Nov 2023 14:49:42 -0500 Received: from mail11.truemail.it (mail11.truemail.it [IPv6:2001:4b7e:0:8::81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27C1510F0; Tue, 28 Nov 2023 11:49:45 -0800 (PST) Received: from francesco-nb.toradex.int (31-10-194-107.static.upc.ch [31.10.194.107]) by mail11.truemail.it (Postfix) with ESMTPA id 47FC0206FC; Tue, 28 Nov 2023 20:49:42 +0100 (CET) From: Francesco Dolcini To: Maximilian Luz , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Mark Gross Cc: Francesco Dolcini , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v1] platform/surface: aggregator: fix recv_buf() return value Date: Tue, 28 Nov 2023 20:49:35 +0100 Message-Id: <20231128194935.11350-1-francesco@dolcini.it> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Francesco Dolcini Serdev recv_buf() callback is supposed to return the amount of bytes consumed, therefore an int in between 0 and count. Do not return negative number in case of issue, when ssam_controller_receive_buf() returns ESHUTDOWN just returns 0, e.g. no bytes consumed, this keep the exact same behavior as it was before. This fixes a potential WARN in serdev-ttyport.c:ttyport_receive_buf(). Cc: Fixes: c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem") Signed-off-by: Francesco Dolcini Reviewed-by: Maximilian Luz --- drivers/platform/surface/aggregator/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/platform/surface/aggregator/core.c b/drivers/platform/= surface/aggregator/core.c index 1a6373dea109..6152be38398c 100644 --- a/drivers/platform/surface/aggregator/core.c +++ b/drivers/platform/surface/aggregator/core.c @@ -231,9 +231,12 @@ static int ssam_receive_buf(struct serdev_device *dev,= const unsigned char *buf, size_t n) { struct ssam_controller *ctrl; + int ret; =20 ctrl =3D serdev_device_get_drvdata(dev); - return ssam_controller_receive_buf(ctrl, buf, n); + ret =3D ssam_controller_receive_buf(ctrl, buf, n); + + return ret < 0 ? 0 : ret; } =20 static void ssam_write_wakeup(struct serdev_device *dev) --=20 2.25.1