Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp857528rwl; Thu, 10 Aug 2023 02:45:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGE2Qa7AyGwJxwZgs73qpnSBBf2itgU88Ap7AyV97nin9bkbYYgt0Lq4zkR0xpqY+yOD3JL X-Received: by 2002:a9d:7553:0:b0:6b8:dcd2:8b9e with SMTP id b19-20020a9d7553000000b006b8dcd28b9emr1776008otl.7.1691660710181; Thu, 10 Aug 2023 02:45:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691660710; cv=none; d=google.com; s=arc-20160816; b=NuefD9wUipImZdOfIsKbvxgypMyJwhwYcN6v3L4VcvDeE5zO5MTdanFKF5RgpVOwSg 0wWrkIsIeB9EaCzokQjfh1FBjhTDig6T23rFrSegHmU4YYBLPjpnRCTIyQ7XYsI0tbCT 4udV2XJxne5u+pMtNB1MHWVF5B0IxUs/lTW9udwesGdZ7yR0tDLg9kuKEfIxWStEySHj xiNoe/sEOaumibjWitqtlnvDMQ+kfwlrk1DjNWYcbkQRJEhvAFsOzRNEUPlMrB/bvbeP jGWwa6AXzUPxdIKdeG7tX8Z4XTRdS5KSaHoSBkHrmP3IYv/vqfhxPzAt5LVJlxTq2iwu 6vmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Wy3IMjeGdsDx8mWTy7GacQeYx6fMzoi0hywp+RXzNPU=; fh=p1SnSzUoS47mNfhbCGZbUJwRFmNtWLLKEtajFGiqN/g=; b=08qqK4mWsUF3+5CF9XSsWDflL9i8rit+wYYU5UuTAqnLiJ2tYNMtRRT3bEo4+lejOR Lgx0miN8rb+ibkJYHQ1kgJqgYdvDb0cJUNeuWI1VZfkPI9Dikg/wuPAjsEHAMyp1Voq+ 70iIZP1jHAlRDoFpzohyDXuMv+IeBDgQGzfzG6chLzE/LK8Cd3TPxYW/bJdR5nQ2r6yO UuXVj3rBfzyQ7Jqr9xrKkBMTxDTcWHMhOJGsd0sGuxub6Gavz4MnagQGx64tnfehhEKT MVjREColI8GIu0D1l55IOPXkBWof6vpHuWPBJG1yPsEeLsqIWlMvsF6Xu9dPjta4t1Go w1sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n9c2JSXU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t30-20020a63955e000000b0053fbb36fc65si1321616pgn.382.2023.08.10.02.44.58; Thu, 10 Aug 2023 02:45:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n9c2JSXU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233017AbjHJJQD (ORCPT + 99 others); Thu, 10 Aug 2023 05:16:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234492AbjHJJPd (ORCPT ); Thu, 10 Aug 2023 05:15:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80B642696; Thu, 10 Aug 2023 02:15:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 13911654C2; Thu, 10 Aug 2023 09:15:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34DAAC433CA; Thu, 10 Aug 2023 09:15:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658931; bh=JI/gyP3Cm1MEGHxmTW2IZoSZ+iU2JTsNgxoLX4Jh4Ag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n9c2JSXUNhX4VtjROuDdB+IUdzlrOJwikdBhi0h8NpzN86Gb5r0AK/jqSvD2FlZl7 qeyoab2oh6dbU9nvC5TjACeTGvzvtq5gvws6L7V7kB0g0kH9cKHBgC6eMHOVNhxj7y kWwgMaIzWbBw4QlrDuUbry17vI4OIcqU4RPaZPrTGy/pYl8kPSwJAR0NYOu+FYp3I+ p1HCUvYO/zv7v4V1k+9fnkSkDdZB1uJHOmGRjoQLeb9u27RUOoFwCEdcmnQwVQpDe7 dRd4/0x8r7MU93F58WY+GVLMOj/0sSL2tdHbclRY8IeXOR6aF8S9LPJxU6stk0eCzA xDBaIGcTAYg2g== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Rob Herring Subject: [PATCH 10/36] tty: make counts in tty_port_client_operations hooks size_t Date: Thu, 10 Aug 2023 11:14:44 +0200 Message-ID: <20230810091510.13006-11-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The counts in tty_port_client_operations hooks' are currently represented by all 'int', 'unsigned int', and 'size_t'. Unify them all to unsigned 'size_t' for clarity. Note that size_t is used already in tty_buffer.c. So, eventually, it is spread for counts everywhere and this is the beginning. So the two changes namely: * ::receive_buf() is called from tty_ldisc_receive_buf(). And that expects values ">= 0" from ::receive_buf(), so switch its rettype to size_t is fine. tty_ldisc_receive_buf() types will be changed separately. * ::lookahead_buf()'s count comes from lookahead_bufs() and is already 'unsigned int'. Signed-off-by: Jiri Slaby (SUSE) Cc: Rob Herring --- drivers/tty/serdev/serdev-ttyport.c | 4 ++-- drivers/tty/tty_port.c | 11 +++++------ include/linux/tty_port.h | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c index f69ae27838e3..e3856814ce77 100644 --- a/drivers/tty/serdev/serdev-ttyport.c +++ b/drivers/tty/serdev/serdev-ttyport.c @@ -22,8 +22,8 @@ struct serport { * Callback functions from the tty port. */ -static int ttyport_receive_buf(struct tty_port *port, const u8 *cp, - const u8 *fp, size_t count) +static size_t ttyport_receive_buf(struct tty_port *port, const u8 *cp, + const u8 *fp, size_t count) { struct serdev_controller *ctrl = port->client_data; struct serport *serport = serdev_controller_get_drvdata(ctrl); diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c index 6bf58980c81d..7fd171b7c844 100644 --- a/drivers/tty/tty_port.c +++ b/drivers/tty/tty_port.c @@ -20,10 +20,9 @@ #include #include "tty.h" -static int tty_port_default_receive_buf(struct tty_port *port, const u8 *p, - const u8 *f, size_t count) +static size_t tty_port_default_receive_buf(struct tty_port *port, const u8 *p, + const u8 *f, size_t count) { - int ret; struct tty_struct *tty; struct tty_ldisc *ld; @@ -35,15 +34,15 @@ static int tty_port_default_receive_buf(struct tty_port *port, const u8 *p, if (!ld) return 0; - ret = tty_ldisc_receive_buf(ld, p, (char *)f, count); + count = tty_ldisc_receive_buf(ld, p, (char *)f, count); tty_ldisc_deref(ld); - return ret; + return count; } static void tty_port_default_lookahead_buf(struct tty_port *port, const u8 *p, - const u8 *f, unsigned int count) + const u8 *f, size_t count) { struct tty_struct *tty; struct tty_ldisc *ld; diff --git a/include/linux/tty_port.h b/include/linux/tty_port.h index 726575743367..6b367eb17979 100644 --- a/include/linux/tty_port.h +++ b/include/linux/tty_port.h @@ -39,10 +39,10 @@ struct tty_port_operations { }; struct tty_port_client_operations { - int (*receive_buf)(struct tty_port *port, const u8 *cp, const u8 *fp, - size_t count); + size_t (*receive_buf)(struct tty_port *port, const u8 *cp, const u8 *fp, + size_t count); void (*lookahead_buf)(struct tty_port *port, const u8 *cp, - const u8 *fp, unsigned int count); + const u8 *fp, size_t count); void (*write_wakeup)(struct tty_port *port); }; -- 2.41.0