All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH v1 2/2] serial: 8250: Explicitly show we initialise ISA ports only once
Date: Tue, 18 Aug 2020 13:31:21 +0200	[thread overview]
Message-ID: <20200818113121.GA314369@kroah.com> (raw)
In-Reply-To: <20200731123733.22754-2-andriy.shevchenko@linux.intel.com>

On Fri, Jul 31, 2020 at 03:37:33PM +0300, Andy Shevchenko wrote:
> serial8250_isa_init_ports() uses home grown approach to make itself
> a singleton. Instead, explicitly show that we initialise ISA ports
> once by providing a helper function which calls the original function
> via DO_ONCE() macro.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/tty/serial/8250/8250_core.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
> index cae61d1ebec5..9c0d6693f745 100644
> --- a/drivers/tty/serial/8250/8250_core.c
> +++ b/drivers/tty/serial/8250/8250_core.c
> @@ -22,6 +22,7 @@
>  #include <linux/console.h>
>  #include <linux/sysrq.h>
>  #include <linux/delay.h>
> +#include <linux/once.h>
>  #include <linux/platform_device.h>
>  #include <linux/tty.h>
>  #include <linux/ratelimit.h>
> @@ -495,13 +496,8 @@ static inline void serial8250_apply_quirks(struct uart_8250_port *up)
>  static void __init serial8250_isa_init_ports(void)
>  {
>  	struct uart_8250_port *up;
> -	static int first = 1;
>  	int i, irqflag = 0;
>  
> -	if (!first)
> -		return;
> -	first = 0;
> -
>  	if (nr_uarts > UART_NR)
>  		nr_uarts = UART_NR;
>  
> @@ -555,6 +551,11 @@ static void __init serial8250_isa_init_ports(void)
>  	}
>  }
>  
> +static void __init serial8250_isa_init_ports_once(void)
> +{
> +	DO_ONCE(serial8250_isa_init_ports);

DO_ONCE() is there for fast-path code, where the code is then patched
out of the kernel after it is run.  That's not the case here and is not
needed, please just do this "normally".

thanks,

greg k-h

      reply	other threads:[~2020-08-18 11:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-31 12:37 [PATCH v1 1/2] serial: 8250: Let serial core initialise spin lock Andy Shevchenko
2020-07-31 12:37 ` [PATCH v1 2/2] serial: 8250: Explicitly show we initialise ISA ports only once Andy Shevchenko
2020-08-18 11:31   ` Greg Kroah-Hartman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200818113121.GA314369@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.