Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6684463rdb; Fri, 15 Dec 2023 05:51:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjm/tJQA4vJwUmGcjJICQ96pPRkShLrs7iR4EY1SCp+jbwRhq2qRdGdyQTbOmT57qJRuRy X-Received: by 2002:a05:6a20:7f83:b0:190:c386:3eb2 with SMTP id d3-20020a056a207f8300b00190c3863eb2mr13872891pzj.38.1702648285585; Fri, 15 Dec 2023 05:51:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702648285; cv=none; d=google.com; s=arc-20160816; b=wxF5eKEJTPXRduKXxV/wap1TelUQa/BchuHTJvsvjAhXTbToj6GMc+Ts6LtRewEbGM kFqAz890815B1KLYxddilhqFeearn8DROBGwPBI6xRPQydmk3b76vrBlaRCA3zZwFMtY z2VluhjQkXJUjjvLKT9nbycTw/8L6MIuYdvjc6wFMlCPGZMIvarILG7/HJDt7s6YDASa BGdIM0nH/DqhjNOQVVDhMwyTpNP6USNmkbIQ//vUq0aZpA6GVCa1yIdE+dRg5TnBtPPl 6TSnNi1nVqmli7P6MhKbvEcMGv4iDHBnQpwQYswdF5jno5PV2A0YMtxqlzD0fjWg7Lsk mvYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=q9Y/nbNol1kgEuyvoCpWrou90kEOyVfn6jrqaskxJSA=; fh=UpmxsrcpNAXFU2dVr77h2oOGxOGVi9l0wCjqYWBl5uo=; b=JOoqEwli9Q2LcOoiVkr8ZAHobYP0n3e0SnjTplxm/wn0gWemnWInbDUuXbgHxnOIsk pSdK2pXQf0WtOX26YlKX4nifqUdQgnktmzXU8rViao45CsHPI/y2baU8iF9dbdyGvwfn o+mV4Lf9vL05rTC3OPEio2AwCaK9RuaEmkH7uarR1CZFztg2A/kzXQf7wh0wJ9+xV+hG aMsP/FSTIj7Fhx80RMxvYM+BhWdTWXOduraIvwmx/wI0dvVBm5COdkgPGASic2mkglWV /aUBiiDoao8KSm6bsfT/uc5yDfFP1toGpVq1AErK2yAgBp+cror1MWukVBB/mL09lthF VOtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QrD3v8Uq; spf=pass (google.com: domain of linux-bluetooth+bounces-609-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-609-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m128-20020a632686000000b005c66a7d710bsi12920899pgm.459.2023.12.15.05.51.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 05:51:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-609-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QrD3v8Uq; spf=pass (google.com: domain of linux-bluetooth+bounces-609-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-609-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4275828263B for ; Fri, 15 Dec 2023 13:51:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F5462F50D; Fri, 15 Dec 2023 13:51:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QrD3v8Uq" X-Original-To: linux-bluetooth@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCE7E30331; Fri, 15 Dec 2023 13:51:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40FD5C433C8; Fri, 15 Dec 2023 13:51:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702648274; bh=fGVG2zzj6pzT9iK1XgpYVOHwKem4iYVgV0aQbGa3PGQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QrD3v8UqIFJxXc8j8eX/CL6QTSLzOHhDiSwHp1PPIg0IgjFyfhPvDkpxkaU+/RBt9 pbPQJxIF1XT6/JEDiB62ZRM44tdT/NAo6XoxYMsQBRdnFli6zltKudD0JztCu2hTpl R4OpNg1SM+eZ8POSKlPEF+hWE59by9BSJV/a0STDPDpuWWUreHwOKPdzGiX4MlAYxQ DB+SiNrVDI2Eg8PoHglS7AnpTVSToUu5NywltYb11B+w8qTk71L9A88NbRCy3TE75l uYQo4VY/TjtulP/w6nGpMkKMabcwEvSQd/7QSd4gI5gC1z63tyVogjQ/MHq3cakhKn O65yCtrhcFQpA== Received: from johan by xi.lan with local (Exim 4.96.2) (envelope-from ) id 1rE8ar-0008Sk-1T; Fri, 15 Dec 2023 14:51:09 +0100 Date: Fri, 15 Dec 2023 14:51:09 +0100 From: Johan Hovold To: Francesco Dolcini , Greg Kroah-Hartman Cc: Jiri Slaby , linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, greybus-dev@lists.linaro.org, linux-iio@vger.kernel.org, netdev@vger.kernel.org, chrome-platform@lists.linux.dev, platform-driver-x86@vger.kernel.org, linux-serial@vger.kernel.org, linux-sound@vger.kernel.org, Francesco Dolcini , Luiz Augusto von Dentz , Alex Elder , Jonathan Cameron , Lee Jones , Jakub Kicinski , Paolo Abeni , Eric Dumazet , "David S. Miller" , Krzysztof Kozlowski , Hans de Goede , Ilpo =?utf-8?B?SsOkcnZpbmVu?= , Benson Leung , Tzung-Bi Shih , Rob Herring Subject: Re: [PATCH v1] treewide, serdev: change receive_buf() return type to size_t Message-ID: References: <20231214170146.641783-1-francesco@dolcini.it> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231214170146.641783-1-francesco@dolcini.it> On Thu, Dec 14, 2023 at 06:01:46PM +0100, Francesco Dolcini wrote: > From: Francesco Dolcini > > receive_buf() is called from ttyport_receive_buf() that expects values > ">= 0" from serdev_controller_receive_buf(), change its return type from > ssize_t to size_t. > > Suggested-by: Jiri Slaby > Link: https://lore.kernel.org/all/087be419-ec6b-47ad-851a-5e1e3ea5cfcc@kernel.org/ > Signed-off-by: Francesco Dolcini > --- > hello, > patch is based on current linux next. > > It has an obvious problem, it touches files from multiple subsystem in a single > patch that is complicated to review and eventually merge, just splitting this > would however not work, it will break bisectability and the build. > > I am looking for advise on the best way to move forward. > > I see the following options: > - keep it as it is > - break it down with a patch with each subsystem, and squash before applying > from a single (tty?) subsystem > - go for a multi stage approach, defining a new callback, move to it and in > the end remove the original one, likewise it was done for i2c lately > > --- > drivers/bluetooth/btmtkuart.c | 4 ++-- > drivers/bluetooth/btnxpuart.c | 4 ++-- > diff --git a/drivers/bluetooth/btmtkuart.c b/drivers/bluetooth/btmtkuart.c > index 3c84fcbda01a..e6bc4a73c9fc 100644 > --- a/drivers/bluetooth/btmtkuart.c > +++ b/drivers/bluetooth/btmtkuart.c > @@ -383,8 +383,8 @@ static void btmtkuart_recv(struct hci_dev *hdev, const u8 *data, size_t count) > } > } > > -static ssize_t btmtkuart_receive_buf(struct serdev_device *serdev, > - const u8 *data, size_t count) > +static size_t btmtkuart_receive_buf(struct serdev_device *serdev, > + const u8 *data, size_t count) > { > struct btmtkuart_dev *bdev = serdev_device_get_drvdata(serdev); > > diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c > index 1d592ac413d1..056bef5b2919 100644 > --- a/drivers/bluetooth/btnxpuart.c > +++ b/drivers/bluetooth/btnxpuart.c > @@ -1264,8 +1264,8 @@ static const struct h4_recv_pkt nxp_recv_pkts[] = { > { NXP_RECV_FW_REQ_V3, .recv = nxp_recv_fw_req_v3 }, > }; > > -static ssize_t btnxpuart_receive_buf(struct serdev_device *serdev, > - const u8 *data, size_t count) > +static size_t btnxpuart_receive_buf(struct serdev_device *serdev, > + const u8 *data, size_t count) > { > struct btnxpuart_dev *nxpdev = serdev_device_get_drvdata(serdev); A quick check of just the first two functions here shows that they can return negative values. > diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c > index e94e090cf0a1..3d7ae7fa5018 100644 > --- a/drivers/tty/serdev/serdev-ttyport.c > +++ b/drivers/tty/serdev/serdev-ttyport.c > @@ -27,19 +27,17 @@ static size_t ttyport_receive_buf(struct tty_port *port, const u8 *cp, > { > struct serdev_controller *ctrl = port->client_data; > struct serport *serport = serdev_controller_get_drvdata(ctrl); > - int ret; > + size_t ret; > > if (!test_bit(SERPORT_ACTIVE, &serport->flags)) > return 0; > > ret = serdev_controller_receive_buf(ctrl, cp, count); > > - dev_WARN_ONCE(&ctrl->dev, ret < 0 || ret > count, > - "receive_buf returns %d (count = %zu)\n", > + dev_WARN_ONCE(&ctrl->dev, ret > count, > + "receive_buf returns %zu (count = %zu)\n", > ret, count); > - if (ret < 0) > - return 0; > - else if (ret > count) > + if (ret > count) > return count; > > return ret; So please do not apply this patch until the various implementations have been fixed. Johan