Linux Serial subsystem development
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Martin Hundebøll" <martin@geanix.com>
Cc: linux-serial <linux-serial@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH v2 3/3] serial: 8250: skip platform device registration with no runtime ports
Date: Thu, 20 Oct 2022 16:00:43 +0300 (EEST)	[thread overview]
Message-ID: <f2383fb1-9420-c35c-fef1-3c4cc9df368@linux.intel.com> (raw)
In-Reply-To: <20221018133419.134110-3-martin@geanix.com>

[-- Attachment #1: Type: text/plain, Size: 1672 bytes --]

On Tue, 18 Oct 2022, Martin Hundebøll wrote:

> Skip registration of the platform device used for built-in ports, if no
> such ports are configured/created.
> 
> Signed-off-by: Martin Hundebøll <martin@geanix.com>

For the whole series:

Tested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

> ---
> 
> Change since v1:
>  * call serial8250_pnp_init() also when nr_uarts is zero
> 
>  drivers/tty/serial/8250/8250_core.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
> index ba48431ec6e2..f4a08fb74c31 100644
> --- a/drivers/tty/serial/8250/8250_core.c
> +++ b/drivers/tty/serial/8250/8250_core.c
> @@ -1186,6 +1186,14 @@ static int __init serial8250_init(void)
>  	if (ret)
>  		goto unreg_uart_drv;
>  
> +	if (nr_uarts == 0) {
> +		ret = platform_driver_register(&serial8250_isa_driver);
> +		if (ret)
> +			goto unreg_pnp;
> +
> +		goto out;
> +	}
> +

I'd reverse the condition:

	if (nr_uarts) {
		platform stuff
	}

	ret = platform_driver_register(&serial8250_isa_driver);
        if (ret == 0)
		goto out;
	if (!nr_uarts)
		goto unreg_pnp;

I believe the logic would be easier to follow if you do that.

-- 
 i.

>  	serial8250_isa_devs = platform_device_alloc("serial8250",
>  						    PLAT8250_DEV_LEGACY);
>  	if (!serial8250_isa_devs) {
> @@ -1230,7 +1238,9 @@ static void __exit serial8250_exit(void)
>  	serial8250_isa_devs = NULL;
>  
>  	platform_driver_unregister(&serial8250_isa_driver);
> -	platform_device_unregister(isa_dev);
> +
> +	if (nr_uarts)
> +		platform_device_unregister(isa_dev);
>  
>  	serial8250_pnp_exit();
>  
> 

  reply	other threads:[~2022-10-20 13:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18 13:34 [PATCH v2 1/3] serial: 8250: allow use of non-runtime configured uart ports Martin Hundebøll
2022-10-18 13:34 ` [PATCH v2 2/3] serial: 8250: allow zero runtime-configured ports Martin Hundebøll
2022-10-18 13:34 ` [PATCH v2 3/3] serial: 8250: skip platform device registration with no runtime ports Martin Hundebøll
2022-10-20 13:00   ` Ilpo Järvinen [this message]
2022-10-20 12:34 ` [PATCH v2 1/3] serial: 8250: allow use of non-runtime configured uart ports Ilpo Järvinen
2022-10-20 14:10   ` Martin Hundebøll
2022-10-20 14:14     ` Ilpo Järvinen
2022-10-20 18:34       ` Martin Hundebøll

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=f2383fb1-9420-c35c-fef1-3c4cc9df368@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=martin@geanix.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox