From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77E3DC433DB for ; Mon, 15 Feb 2021 18:08:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D2E864DEE for ; Mon, 15 Feb 2021 18:08:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230375AbhBOSHv (ORCPT ); Mon, 15 Feb 2021 13:07:51 -0500 Received: from mail-wm1-f50.google.com ([209.85.128.50]:51087 "EHLO mail-wm1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbhBOSHh (ORCPT ); Mon, 15 Feb 2021 13:07:37 -0500 Received: by mail-wm1-f50.google.com with SMTP id a132so506161wmc.0; Mon, 15 Feb 2021 10:07:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Uq9ok5qeaOLSPTWCnZGzu5H9WnX3D/qNhhgRdr5WRpY=; b=MZGOZZEXtVPbssSDkcTVU9d90bw1gtuvmTLZxzUbdRnwC+2FUVLZ7ciJzaStDxe54G ki2j7T79tE/rH9J7nHNGV9AnAtJcfOwjd9ATYMUI4NB6ykeFMkma2hHMOMyEiq2HCYZ9 YZ7sjZ56cIau1X1O9bpRnU3OKeGbTLsfzMXHNGW/C3bD56VHOOOI/SX7KfU6NBdGC/yy EPbeY7ZCkQWuS+Em7eRa6olThxb0qBb69/vRZFMG52Zzw1xDrpfTWiSg7wrrDAIWmaO/ 1lz7EXO7/OykdTXhj2HOZe4YMMSbhpNOhZ23gdYQqgs37xIeptYUzMrfY2z82Ha95iHF 4L5w== X-Gm-Message-State: AOAM531xRWbg31G7hip50MT/NRZ+mTpyA7SJOEvRNjZm5CW3vsLSorx/ YeLuvngNxwGOD9ugsZCmZh0= X-Google-Smtp-Source: ABdhPJxqLXrWVHWaQDbtqDJ1sogUJqeL92isd/Z4Sjj0G9Ucwa4zbxSzmbjXjOoxK5JwOxdwCnLZXw== X-Received: by 2002:a7b:c305:: with SMTP id k5mr85993wmj.57.1613412415233; Mon, 15 Feb 2021 10:06:55 -0800 (PST) Received: from kozik-lap (adsl-84-226-167-205.adslplus.ch. [84.226.167.205]) by smtp.googlemail.com with ESMTPSA id i10sm32418022wrp.0.2021.02.15.10.06.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 10:06:53 -0800 (PST) Date: Mon, 15 Feb 2021 19:06:52 +0100 From: Krzysztof Kozlowski To: Hector Martin Cc: linux-arm-kernel@lists.infradead.org, Marc Zyngier , Rob Herring , Arnd Bergmann , Olof Johansson , Mark Kettenis , Tony Lindgren , Mohamed Mediouni , Stan Skowronek , Alexander Graf , Will Deacon , Linus Walleij , Mark Rutland , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 17/25] tty: serial: samsung_tty: Separate S3C64XX ops structure Message-ID: <20210215180652.tbccd5dhsfjpdayp@kozik-lap> References: <20210215121713.57687-1-marcan@marcan.st> <20210215121713.57687-18-marcan@marcan.st> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210215121713.57687-18-marcan@marcan.st> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 15, 2021 at 09:17:05PM +0900, Hector Martin wrote: > Instead of patching a single global ops structure depending on the port > type, use a separate s3c64xx_serial_ops for the S3C64XX type. This > allows us to mark the structures as const. > > Also split out s3c64xx_serial_shutdown into a separate function now that > we have a separate ops structure; this avoids excessive branching > control flow and mirrors s3c64xx_serial_startup. tx_claimed and > rx_claimed are only used in the S3C24XX functions. > > Signed-off-by: Hector Martin > --- > drivers/tty/serial/samsung_tty.c | 69 ++++++++++++++++++++++++-------- > 1 file changed, 53 insertions(+), 16 deletions(-) > > diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c > index 8ae3e03fbd8c..6b661f3ec1ae 100644 > --- a/drivers/tty/serial/samsung_tty.c > +++ b/drivers/tty/serial/samsung_tty.c > @@ -1098,27 +1098,36 @@ static void s3c24xx_serial_shutdown(struct uart_port *port) > struct s3c24xx_uart_port *ourport = to_ourport(port); > > if (ourport->tx_claimed) { > - if (!s3c24xx_serial_has_interrupt_mask(port)) > - free_irq(ourport->tx_irq, ourport); > + free_irq(ourport->tx_irq, ourport); > ourport->tx_enabled = 0; > ourport->tx_claimed = 0; > ourport->tx_mode = 0; > } > > if (ourport->rx_claimed) { > - if (!s3c24xx_serial_has_interrupt_mask(port)) > - free_irq(ourport->rx_irq, ourport); > + free_irq(ourport->rx_irq, ourport); > ourport->rx_claimed = 0; > ourport->rx_enabled = 0; > } > > - /* Clear pending interrupts and mask all interrupts */ > - if (s3c24xx_serial_has_interrupt_mask(port)) { > - free_irq(port->irq, ourport); > + if (ourport->dma) > + s3c24xx_serial_release_dma(ourport); > > - wr_regl(port, S3C64XX_UINTP, 0xf); > - wr_regl(port, S3C64XX_UINTM, 0xf); > - } > + ourport->tx_in_progress = 0; > +} > + > +static void s3c64xx_serial_shutdown(struct uart_port *port) > +{ > + struct s3c24xx_uart_port *ourport = to_ourport(port); > + > + free_irq(port->irq, ourport); > + > + wr_regl(port, S3C64XX_UINTP, 0xf); > + wr_regl(port, S3C64XX_UINTM, 0xf); > + > + ourport->tx_enabled = 0; > + ourport->tx_mode = 0; > + ourport->rx_enabled = 0; For S3C64xx type this is not equivalent: the assignments were happening before free_irq() and wr_regl(). Honestly I don't know whether it matters (except some barriers coming from these functions) but please do not change the order of code in this patch. If needed, the re-ordering should be a patch on its own. With explanation why. > > if (ourport->dma) > s3c24xx_serial_release_dma(ourport); > @@ -1193,9 +1202,7 @@ static int s3c64xx_serial_startup(struct uart_port *port) > > /* For compatibility with s3c24xx Soc's */ > ourport->rx_enabled = 1; > - ourport->rx_claimed = 1; > ourport->tx_enabled = 0; > - ourport->tx_claimed = 1; > > spin_lock_irqsave(&port->lock, flags); > > @@ -1631,6 +1638,29 @@ static struct uart_ops s3c24xx_serial_ops = { > #endif > }; > > +static const struct uart_ops s3c64xx_serial_ops = { > + .pm = s3c24xx_serial_pm, > + .tx_empty = s3c24xx_serial_tx_empty, > + .get_mctrl = s3c24xx_serial_get_mctrl, > + .set_mctrl = s3c24xx_serial_set_mctrl, > + .stop_tx = s3c24xx_serial_stop_tx, > + .start_tx = s3c24xx_serial_start_tx, > + .stop_rx = s3c24xx_serial_stop_rx, > + .break_ctl = s3c24xx_serial_break_ctl, > + .startup = s3c64xx_serial_startup, > + .shutdown = s3c64xx_serial_shutdown, > + .set_termios = s3c24xx_serial_set_termios, > + .type = s3c24xx_serial_type, > + .release_port = s3c24xx_serial_release_port, > + .request_port = s3c24xx_serial_request_port, > + .config_port = s3c24xx_serial_config_port, > + .verify_port = s3c24xx_serial_verify_port, > +#if defined(CONFIG_SERIAL_SAMSUNG_CONSOLE) && defined(CONFIG_CONSOLE_POLL) > + .poll_get_char = s3c24xx_serial_get_poll_char, > + .poll_put_char = s3c24xx_serial_put_poll_char, > +#endif > +}; > + Make the s3c24xx_serial_ops const as well. Best regards, Krzysztof From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BD37C433E9 for ; Mon, 15 Feb 2021 18:08:03 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5005464DEB for ; Mon, 15 Feb 2021 18:08:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5005464DEB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=j6Faj2HnHP8KjlJKSxqBpmsBS1JPNdFnV1Sf/NgG9vI=; b=D/61+oPSoEknT1m4OouegaY55 TAHZt1erKHqUWoXg/aS5wWsiTWeJFBnLuovBosgiXaXBAuewsxYoPDLQvDbP+7gh1X6JsVS30LW7r WnDXD81KK3WuIcXcoI9CooMmhpwLJxwPmBN9KztdGqtqGbadjBWEWmZpypBJwJplonn7TjydjzO94 rw+g5WrlGFVu/DEo+CZOlNsHyRdKO2sc2nGlEC06lIrbgJxLt4Vq59DZROyITKtY2H7yLB/I+w1tO eZlG567ez9yqfFxh8UZBdtezUPL0iUXXcG7ZOx80lFEDVV1v/dcgc7Kg5dvzJVyrLGkYopjufrIk3 kbc+Adq9w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lBiGx-0000t6-VI; Mon, 15 Feb 2021 18:07:00 +0000 Received: from mail-wm1-f41.google.com ([209.85.128.41]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lBiGv-0000sY-Jd for linux-arm-kernel@lists.infradead.org; Mon, 15 Feb 2021 18:06:58 +0000 Received: by mail-wm1-f41.google.com with SMTP id w4so6919362wmi.4 for ; Mon, 15 Feb 2021 10:06:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Uq9ok5qeaOLSPTWCnZGzu5H9WnX3D/qNhhgRdr5WRpY=; b=po9GGfvBNRB45J2pbMuvMERwv7UM4YoBsm8dZwSgJzuCqzlTr5tW3B2ZWj36SCArvD m/9vvhxUqhQTxxjpG+y0JN7CpvtCYidnykNTHhapi/wvv1sVc61ri2aUswxcUU55SZBd TDBPQwDkQCV3X/neEc1ZATFndIwrdsQdlkOJgKgbLKXS6hLnDdnliVLPB8C1pJ3K0uh7 3cJ4KNysuOi82c5Qsoh8/oopRoAlwBMdI9mO0LFObkQovt79jVoE9AfdSVDSt135zYRJ s2juFy4xebDB859QlCi3leeuVmGG4+nUEOV2kH89Fjhld8VYBArysaf7JYnlqCiOmLun w/nQ== X-Gm-Message-State: AOAM531Pkf9BO4xBkwctI6TIF5Jmuxk6GAOCBJt9IZtAQFC02U81VEzi ybedqMPQAYKW/whyab8PKyU= X-Google-Smtp-Source: ABdhPJxqLXrWVHWaQDbtqDJ1sogUJqeL92isd/Z4Sjj0G9Ucwa4zbxSzmbjXjOoxK5JwOxdwCnLZXw== X-Received: by 2002:a7b:c305:: with SMTP id k5mr85993wmj.57.1613412415233; Mon, 15 Feb 2021 10:06:55 -0800 (PST) Received: from kozik-lap (adsl-84-226-167-205.adslplus.ch. [84.226.167.205]) by smtp.googlemail.com with ESMTPSA id i10sm32418022wrp.0.2021.02.15.10.06.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 10:06:53 -0800 (PST) Date: Mon, 15 Feb 2021 19:06:52 +0100 From: Krzysztof Kozlowski To: Hector Martin Subject: Re: [PATCH v2 17/25] tty: serial: samsung_tty: Separate S3C64XX ops structure Message-ID: <20210215180652.tbccd5dhsfjpdayp@kozik-lap> References: <20210215121713.57687-1-marcan@marcan.st> <20210215121713.57687-18-marcan@marcan.st> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210215121713.57687-18-marcan@marcan.st> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210215_130657_671293_49BE4A0B X-CRM114-Status: GOOD ( 27.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Arnd Bergmann , Rob Herring , Tony Lindgren , Marc Zyngier , Linus Walleij , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Alexander Graf , Olof Johansson , Mohamed Mediouni , Stan Skowronek , Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Kettenis Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Feb 15, 2021 at 09:17:05PM +0900, Hector Martin wrote: > Instead of patching a single global ops structure depending on the port > type, use a separate s3c64xx_serial_ops for the S3C64XX type. This > allows us to mark the structures as const. > > Also split out s3c64xx_serial_shutdown into a separate function now that > we have a separate ops structure; this avoids excessive branching > control flow and mirrors s3c64xx_serial_startup. tx_claimed and > rx_claimed are only used in the S3C24XX functions. > > Signed-off-by: Hector Martin > --- > drivers/tty/serial/samsung_tty.c | 69 ++++++++++++++++++++++++-------- > 1 file changed, 53 insertions(+), 16 deletions(-) > > diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c > index 8ae3e03fbd8c..6b661f3ec1ae 100644 > --- a/drivers/tty/serial/samsung_tty.c > +++ b/drivers/tty/serial/samsung_tty.c > @@ -1098,27 +1098,36 @@ static void s3c24xx_serial_shutdown(struct uart_port *port) > struct s3c24xx_uart_port *ourport = to_ourport(port); > > if (ourport->tx_claimed) { > - if (!s3c24xx_serial_has_interrupt_mask(port)) > - free_irq(ourport->tx_irq, ourport); > + free_irq(ourport->tx_irq, ourport); > ourport->tx_enabled = 0; > ourport->tx_claimed = 0; > ourport->tx_mode = 0; > } > > if (ourport->rx_claimed) { > - if (!s3c24xx_serial_has_interrupt_mask(port)) > - free_irq(ourport->rx_irq, ourport); > + free_irq(ourport->rx_irq, ourport); > ourport->rx_claimed = 0; > ourport->rx_enabled = 0; > } > > - /* Clear pending interrupts and mask all interrupts */ > - if (s3c24xx_serial_has_interrupt_mask(port)) { > - free_irq(port->irq, ourport); > + if (ourport->dma) > + s3c24xx_serial_release_dma(ourport); > > - wr_regl(port, S3C64XX_UINTP, 0xf); > - wr_regl(port, S3C64XX_UINTM, 0xf); > - } > + ourport->tx_in_progress = 0; > +} > + > +static void s3c64xx_serial_shutdown(struct uart_port *port) > +{ > + struct s3c24xx_uart_port *ourport = to_ourport(port); > + > + free_irq(port->irq, ourport); > + > + wr_regl(port, S3C64XX_UINTP, 0xf); > + wr_regl(port, S3C64XX_UINTM, 0xf); > + > + ourport->tx_enabled = 0; > + ourport->tx_mode = 0; > + ourport->rx_enabled = 0; For S3C64xx type this is not equivalent: the assignments were happening before free_irq() and wr_regl(). Honestly I don't know whether it matters (except some barriers coming from these functions) but please do not change the order of code in this patch. If needed, the re-ordering should be a patch on its own. With explanation why. > > if (ourport->dma) > s3c24xx_serial_release_dma(ourport); > @@ -1193,9 +1202,7 @@ static int s3c64xx_serial_startup(struct uart_port *port) > > /* For compatibility with s3c24xx Soc's */ > ourport->rx_enabled = 1; > - ourport->rx_claimed = 1; > ourport->tx_enabled = 0; > - ourport->tx_claimed = 1; > > spin_lock_irqsave(&port->lock, flags); > > @@ -1631,6 +1638,29 @@ static struct uart_ops s3c24xx_serial_ops = { > #endif > }; > > +static const struct uart_ops s3c64xx_serial_ops = { > + .pm = s3c24xx_serial_pm, > + .tx_empty = s3c24xx_serial_tx_empty, > + .get_mctrl = s3c24xx_serial_get_mctrl, > + .set_mctrl = s3c24xx_serial_set_mctrl, > + .stop_tx = s3c24xx_serial_stop_tx, > + .start_tx = s3c24xx_serial_start_tx, > + .stop_rx = s3c24xx_serial_stop_rx, > + .break_ctl = s3c24xx_serial_break_ctl, > + .startup = s3c64xx_serial_startup, > + .shutdown = s3c64xx_serial_shutdown, > + .set_termios = s3c24xx_serial_set_termios, > + .type = s3c24xx_serial_type, > + .release_port = s3c24xx_serial_release_port, > + .request_port = s3c24xx_serial_request_port, > + .config_port = s3c24xx_serial_config_port, > + .verify_port = s3c24xx_serial_verify_port, > +#if defined(CONFIG_SERIAL_SAMSUNG_CONSOLE) && defined(CONFIG_CONSOLE_POLL) > + .poll_get_char = s3c24xx_serial_get_poll_char, > + .poll_put_char = s3c24xx_serial_put_poll_char, > +#endif > +}; > + Make the s3c24xx_serial_ops const as well. Best regards, Krzysztof _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel