Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp857328rwl; Thu, 10 Aug 2023 02:44:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVh695t1jVbs8gsySSzhZwXodhkhii2m/U3l2UkV1HMWr6N85pHOJvW0wCmAucoH+5caQ4 X-Received: by 2002:a05:6a20:ce84:b0:11f:6dc:4f38 with SMTP id if4-20020a056a20ce8400b0011f06dc4f38mr1714893pzb.55.1691660694503; Thu, 10 Aug 2023 02:44:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691660694; cv=none; d=google.com; s=arc-20160816; b=kJuAq6lcPLkCdbrlyWbeU1P1j7SbwRwbScfbgJlm8mjjnlSlaRljuveQNH5S0OI5It Ez0XES6rhAh+8UA80t4yCiXE2oAgeSryVwR7e1k7pUzID1qqaHVt0jp4Qr+QgP4zH0gL UKpDX2rrB/hlS7W67CaXfJTy+SGshM70Ac51X/w/jmrPRbH9qSRZkiCK5kw5Ry5Xa+Sy I0xMgR1sIB+0i3/NEJwtbSaa7S8jGRa0twa8f2g/xFzJQnDN/FH3gKjrPJT2tTbjMZ7I HEez/4QNzYzphWwIuQWb9R5mG/vFd9BfrjB0JIbY09GTXQa+clvMcRsYcYjlV9YblkX0 MAtQ== 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=yBJPO1i887TazF7Ar8HU2OtzGb/OW9vm//8mwZDBFV8=; fh=k7XzfpyqnKqnwxpqVF0NftrWa2FIpeAcHVbykF5xarA=; b=vpnwyBzq/p2/P3feWDrVIPFCbZ02rZBRPT0JAUxaWEAjNayfCDW8U/wYSY5d9qAKc9 8zBAYQM4XmCgGLPnVNstsDwHNuKMzIPfH1+PX065YnX4zoj470XWiPF1zfc2A1RhyoC5 nRIh1bnqDyrhKdPP4Mjo2Ul3lT+J4TolPVEju8o9WB/1Be/aoLAhs0pvTjiAz8Y+18zu syLuM28OYcUhBdl300EKWS/VBToyxzYpP0un8vNVVcUS9rd5cWQvTMlzXDPyCUI87Cz/ bX5yopjX/nes2Iok5Oe+Sn4KMuI1QWEBl6ilY3jaKa2Xf/hkdTJ0QLRFW71N6e4zO3+y Svtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hK2KkwV3; 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 u3-20020a056a00158300b00661cd40bd67si1245425pfk.314.2023.08.10.02.44.41; Thu, 10 Aug 2023 02:44:54 -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=hK2KkwV3; 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 S234658AbjHJJR0 (ORCPT + 99 others); Thu, 10 Aug 2023 05:17:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234644AbjHJJQn (ORCPT ); Thu, 10 Aug 2023 05:16:43 -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 B304D3ABA; Thu, 10 Aug 2023 02:16:05 -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 940BA654E3; Thu, 10 Aug 2023 09:16:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9CF4C433BD; Thu, 10 Aug 2023 09:16:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658965; bh=CVFOtvonh6meYc8HrCladmLIao6ps5X4Ijcg1YpOOr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hK2KkwV3BNAlyj3EAEWxUYhari6Nob9fTpmXvyB+udVapc04cylMees/Syyzoua15 B49vyYQm1vQ92N+/lrN8yPqKMOuVJkXomem9ei3w7cASUlLAQmJ/azRI72j8+K7D3D Etz1qAi03bKTD/L2QDWY0LI4oTWBUjTT2aCMdw2Zm7DVlD0RDF+8Ww47m9fmFbfmwK dx9CeoA+MJkuG1tjzpV/LYgdWEbrfgwLHUIgGZIuNRAIo77PFs3BcsnGKYiOLuwMjq O6pLf1dZ2kY+prE7YBLbthCwD9WVxPr9FwDsc42dQUIlXMbvTa+DSw7fo3sD9caTRa SkkodOsBwG3FQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 21/36] tty: don't pass write() to do_tty_write() Date: Thu, 10 Aug 2023 11:14:55 +0200 Message-ID: <20230810091510.13006-22-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 write() passed to do_tty_write() is always ld->ops->write(). Instead, align with iterate_tty_read() and pass the whole ld instead. This makes the code easier to follow as it is clear what the write is. And also the function signature is more readable. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/tty_io.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 54036a20a102..ea5041fbbf28 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -961,11 +961,8 @@ int tty_write_lock(struct tty_struct *tty, bool ndelay) * Split writes up in sane blocksizes to avoid * denial-of-service type attacks */ -static inline ssize_t do_tty_write( - ssize_t (*write)(struct tty_struct *, struct file *, const unsigned char *, size_t), - struct tty_struct *tty, - struct file *file, - struct iov_iter *from) +static inline ssize_t do_tty_write(struct tty_ldisc *ld, struct tty_struct *tty, + struct file *file, struct iov_iter *from) { size_t count = iov_iter_count(from); ssize_t ret, written = 0; @@ -1022,7 +1019,7 @@ static inline ssize_t do_tty_write( if (copy_from_iter(tty->write_buf, size, from) != size) break; - ret = write(tty, file, tty->write_buf, size); + ret = ld->ops->write(tty, file, tty->write_buf, size); if (ret <= 0) break; @@ -1093,7 +1090,7 @@ static ssize_t file_tty_write(struct file *file, struct kiocb *iocb, struct iov_ if (!ld->ops->write) ret = -EIO; else - ret = do_tty_write(ld->ops->write, tty, file, from); + ret = do_tty_write(ld, tty, file, from); tty_ldisc_deref(ld); return ret; } -- 2.41.0