Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5622486rwb; Wed, 7 Sep 2022 05:49:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR7RmaythecQShKceEmhBW9MopKxhfr8vPPa5hvppXKcr6T3a4yEewUw9OrWEZHnQdF6tU/K X-Received: by 2002:a05:6402:5201:b0:448:7b26:b94f with SMTP id s1-20020a056402520100b004487b26b94fmr2998403edd.119.1662554971906; Wed, 07 Sep 2022 05:49:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662554971; cv=none; d=google.com; s=arc-20160816; b=WhzIXYa7/+X8jB3YGK+LbOpcgXrDNeTi1l145fk76DVwxvKq2acZ8hOI5HtzLxeAwp JB4dofs1D3rOSnjtJtDz0x7th6sSOQAt1Mf44sSa1e8lVpIZVbn2K51ehfEeNn6R17d8 Zi1zVkyciTTAwCFG69UCZQeXx36exti8DnncfHKIi/usMneoso6nrPo8F6Xb8sl7ay3u C43MFlyuIdnQoC22eMq4dLb/VUH83kcmqRbAGM5W72QmQT9Lllo/6KDq2vCf7xGBhIPS m4GBaKpwLY+lLwi1NYW33GJpG30SUJ1O8t8zKhdYOkeDh6IYJl+Bq54nnNKExwa/hLEE owNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:cc:to:from :date:references:in-reply-to:message-id:mime-version:user-agent :feedback-id:dkim-signature:dkim-signature; bh=93TgYd152lsMJGukyVn+n+/KYrXdTp+yDhOzZKjQ6j4=; b=wDSWD5VaM+FfscnUPC01sIJ+kIWywttaC20kBSKB8npoIgZFyvrAZp0JGlETBJrC9x hIsigLWdg4WKr0Dq0VDyJyt+1UnRHqym1P7M3SuSlyUKjWEbS9z/HOWf3k2tp7cwK8ZY Kh6rMvDblBydwswnd9WDx1EQeT2TSYaLwlq3D/eCFLHKlVHeKT5wuAO4UFizCOk4rUX0 EzJaUKHLQSw3J+0pwKspkwI7Y4tSMbTlTk0Y7CP2KbmNgup4ijJBN50TZCu+fws90WZQ vnNx5kd1x38Lw893XP94x/PlKVph7JWcKlMEYMMSNKRXJ2OxSGl2dbeoHT+QWVBlVEL8 fgcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=awpcaSjM; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=avHCxVUc; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wt2-20020a170906ee8200b0076fea31c3c2si2855004ejb.917.2022.09.07.05.49.06; Wed, 07 Sep 2022 05:49:31 -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=@arndb.de header.s=fm1 header.b=awpcaSjM; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=avHCxVUc; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229593AbiIGL7g (ORCPT + 99 others); Wed, 7 Sep 2022 07:59:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbiIGL7c (ORCPT ); Wed, 7 Sep 2022 07:59:32 -0400 Received: from wnew3-smtp.messagingengine.com (wnew3-smtp.messagingengine.com [64.147.123.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2BCAE03D; Wed, 7 Sep 2022 04:59:31 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id CF3F42B05B84; Wed, 7 Sep 2022 07:59:27 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute3.internal (MEProxy); Wed, 07 Sep 2022 07:59:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1662551967; x= 1662555567; bh=93TgYd152lsMJGukyVn+n+/KYrXdTp+yDhOzZKjQ6j4=; b=a wpcaSjMpvQxH/r24XuOYbW7qzgwqAdiOOcxmaxHRSpFS2LCPs7/QaE7SECr3bjYK 2Z+jM3dw7YVeZ8RXWAD7G7FUfk+9OS3ywJEyDpRJAe7FpvG4kn8iLIETYUC2kkd4 eYqMwh/QjEC4DT3fuqot48hq6mCjuNZWUI8khrReQASrv67oy9hh2WdIRJHDANKT ECnpC46+2xeAQE2iO1DLlrVGJx/+4bvljtivxPZkM2/eFoT2AVIwwXF0hNviWEpq DOGp/Nfe3w+yxCXNN5cPZcEEVqwFDyA/E1K3DLpHistUEIn/z3bmlTVTr5ygN47z Cvsrm/UjC2Fd3YRLfC83g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1662551967; x= 1662555567; bh=93TgYd152lsMJGukyVn+n+/KYrXdTp+yDhOzZKjQ6j4=; b=a vHCxVUc2IdvYCG0t9AqWn7NS7WrBBG4UCH6F/qqtXeczJkJrszU9X1x2ZwdoIX/o 9qLujK/2ikjuw90nv2kxe+NZrtQB37QxU8HR+t8ibz6DgkUrk93UJ6ieXq89vNsI /A+BKCEclvpZh0zRJoTINAHLB86Rjx91Yyqwlr1Xd4mQIwzm1xoiF/vM1C+QzzEo q0gx5JitIaESQZ/3OX9Racmy3WsUUfhIl/QdfHwXTkV4JpazE1QXscwrqpXcXrAT B1gOuIa/T5SEAmbA6PasO47lvyTWMOvkWuZh+gtFAjCAFBTIte9R6hrOZG4OwVBY fGNqnc2owYBFb3g/YRBkg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedttddggeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtgfesthhqredtreerjeenucfhrhhomhepfdet rhhnugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrg htthgvrhhnpefgkeeuleegieeghfduudeltdekfeffjeeuleehleefudettddtgfevueef feeigeenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomheprghrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id DB8EBB60083; Wed, 7 Sep 2022 07:59:25 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-927-gf4c98c8499-fm-20220826.002-gf4c98c84 Mime-Version: 1.0 Message-Id: <715b40ba-1bcc-4582-bed1-ef41126c7b94@www.fastmail.com> In-Reply-To: <4e9b4471-a6f2-4b16-d830-67d253ae4e6a@linux.intel.com> References: <20220906104805.23211-1-jslaby@suse.cz> <4e9b4471-a6f2-4b16-d830-67d253ae4e6a@linux.intel.com> Date: Wed, 07 Sep 2022 13:59:05 +0200 From: "Arnd Bergmann" To: =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , "Jiri Slaby" , "Johan Hovold" Cc: "Greg Kroah-Hartman" , linux-serial , LKML , "Tobias Klauser" , "Richard Genoud" , "Nicolas Ferre" , "Alexandre Belloni" , "Claudiu Beznea" , "Vladimir Zapolskiy" , "Liviu Dudau" , "Sudeep Holla" , "Lorenzo Pieralisi" , "Shawn Guo" , "Sascha Hauer" , "Pengutronix Kernel Team" , "Fabio Estevam" , "NXP Linux Team" , =?UTF-8?Q?Andreas_F=C3=A4rber?= , "Manivannan Sadhasivam" , "Russell King" , "Florian Fainelli" , bcm-kernel-feedback-list@broadcom.com, =?UTF-8?Q?Pali_Roh=C3=A1r?= , "Kevin Cernekee" , "Palmer Dabbelt" , "Paul Walmsley" , "Orson Zhai" , "Baolin Wang" , "Chunyan Zhang" , "Patrice Chotard" , linux-riscv@lists.infradead.org Subject: Re: [PATCH v3 0/4] tty: TX helpers Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Wed, Sep 7, 2022, at 12:16 PM, Ilpo J=C3=A4rvinen wrote: > On Wed, 7 Sep 2022, Jiri Slaby wrote: >> On 06. 09. 22, 13:30, Johan Hovold wrote: >> > On Tue, Sep 06, 2022 at 12:48:01PM +0200, Jiri Slaby wrote: >> > NAK >>=20 >> I'd love to come up with something nicer. That would be a function in >> serial-core calling hooks like I had [1] for example. But provided al= l those >> CPU workarounds/thunks, it'd be quite expensive to call two functions= per >> character. >>=20 >> Or creating a static inline (having =C2=B1 the macro content) and the= hooks as >> parameters and hope for optimizations to eliminate thunks (also sugge= sted in >> the past [1]). >>=20 >> [1] https://lore.kernel.org/all/20220411105405.9519-1-jslaby@suse.cz/ > > I second Jiri here. > > Saving lines in drivers is not that important compared with all removi= ng=20 > all the variants of the same thing that have crept there over the year= s. > > I suspect the main reason for the variants is that everybody just used=20 > other drivers as examples and therefore we've a few "main" variant=20 > branches depending on which of the drivers was used as an example for = the=20 > other. That is hardly a good enough reason to keep them different and = as=20 > long as each driver keeps its own function for this, it will eventuall= y=20 > lead to similar differentiation so e.g. a one-time band-aid similariza= tion=20 > would not help in the long run. > > Also, I don't understand why you see it unreadable when the actual cod= e is=20 > out in the open in that macro. It's formatted much better than e.g.=20 > read_poll_timeout() if you want an example of something that is hardly=20 > readable ;-). I agree though there's a learning-curve, albeit small, t= hat=20 > it actually creates a function but that doesn't seem to me as big of a= n=20 > obstacle you seem to think. I think it would help to replace the macro that defines the function with a set of macros that can be used in function bodies. This would avoid the __VA_ARGS__ stuff and allow readers that are unfamiliar with tty drivers to treat it as a function call. So e.g. instead of=20 static DEFINE_UART_PORT_TX_HELPER_LIMITED(altera_jtaguart_do_tx_chars, true, writel(ch, port->membase + ALTERA_JTAGUART_DATA_REG), ({})); the altera_jtaguart driver would contain a function like static int altera_jtaguart_do_tx_chars(struct uart_port *port, unsigned int count) { char ch; return uart_port_tx_helper_limited(port, ch, count, true, writel(ch, port->membase + ALTERA_JTAGUART_DATA_REG), ({})); } or some variation of that. It's a few more lines, but those extra lines would help me understand what is actually going on while still avoiding the usual bugs and duplication. If the caller of that function is itself trivial (like serial21285_tx_chars), then the intermediate function can be omitted in order to save some of the extra complexity. Arnd