linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 linux-serial <linux-serial@vger.kernel.org>,
	 LKML <linux-kernel@vger.kernel.org>,
	 Madhavan Srinivasan <maddy@linux.ibm.com>,
	 Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	 Christophe Leroy <christophe.leroy@csgroup.eu>,
	 linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 02/33] powerpc/legacy_serial: cache serial port and info in add_legacy_port()
Date: Wed, 11 Jun 2025 14:15:59 +0300 (EEST)	[thread overview]
Message-ID: <17b17aa3-dfd9-0e8d-b2a1-010637db29d7@linux.intel.com> (raw)
In-Reply-To: <20250611100319.186924-3-jirislaby@kernel.org>

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

On Wed, 11 Jun 2025, Jiri Slaby (SUSE) wrote:

> Caching the port and info in local variables makes the code more compact
> and easier to understand.
> 
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: linuxppc-dev@lists.ozlabs.org

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

--
 i.

> ---
>  arch/powerpc/kernel/legacy_serial.c | 52 ++++++++++++++---------------
>  1 file changed, 26 insertions(+), 26 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
> index 1da2f6e7d2a1..d9080189c28c 100644
> --- a/arch/powerpc/kernel/legacy_serial.c
> +++ b/arch/powerpc/kernel/legacy_serial.c
> @@ -77,6 +77,8 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
>  				  phys_addr_t taddr, unsigned long irq,
>  				  upf_t flags, int irq_check_parent)
>  {
> +	struct plat_serial8250_port *legacy_port;
> +	struct legacy_serial_info *legacy_info;
>  	const __be32 *clk, *spd, *rs;
>  	u32 clock = BASE_BAUD * 16;
>  	u32 shift = 0;
> @@ -110,16 +112,17 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
>  	if (index >= legacy_serial_count)
>  		legacy_serial_count = index + 1;
>  
> +	legacy_port = &legacy_serial_ports[index];
> +	legacy_info = &legacy_serial_infos[index];
> +
>  	/* Check if there is a port who already claimed our slot */
> -	if (legacy_serial_infos[index].np != NULL) {
> +	if (legacy_info->np != NULL) {
>  		/* if we still have some room, move it, else override */
>  		if (legacy_serial_count < MAX_LEGACY_SERIAL_PORTS) {
>  			printk(KERN_DEBUG "Moved legacy port %d -> %d\n",
>  			       index, legacy_serial_count);
> -			legacy_serial_ports[legacy_serial_count] =
> -				legacy_serial_ports[index];
> -			legacy_serial_infos[legacy_serial_count] =
> -				legacy_serial_infos[index];
> +			legacy_serial_ports[legacy_serial_count] = *legacy_port;
> +			legacy_serial_infos[legacy_serial_count] = *legacy_info;
>  			legacy_serial_count++;
>  		} else {
>  			printk(KERN_DEBUG "Replacing legacy port %d\n", index);
> @@ -127,36 +130,33 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
>  	}
>  
>  	/* Now fill the entry */
> -	memset(&legacy_serial_ports[index], 0,
> -	       sizeof(struct plat_serial8250_port));
> +	memset(legacy_port, 0, sizeof(*legacy_port));
>  	if (iotype == UPIO_PORT)
> -		legacy_serial_ports[index].iobase = base;
> +		legacy_port->iobase = base;
>  	else
> -		legacy_serial_ports[index].mapbase = base;
> -
> -	legacy_serial_ports[index].iotype = iotype;
> -	legacy_serial_ports[index].uartclk = clock;
> -	legacy_serial_ports[index].irq = irq;
> -	legacy_serial_ports[index].flags = flags;
> -	legacy_serial_ports[index].regshift = shift;
> -	legacy_serial_infos[index].taddr = taddr;
> -	legacy_serial_infos[index].np = of_node_get(np);
> -	legacy_serial_infos[index].clock = clock;
> -	legacy_serial_infos[index].speed = spd ? be32_to_cpup(spd) : 0;
> -	legacy_serial_infos[index].irq_check_parent = irq_check_parent;
> +		legacy_port->mapbase = base;
> +
> +	legacy_port->iotype = iotype;
> +	legacy_port->uartclk = clock;
> +	legacy_port->irq = irq;
> +	legacy_port->flags = flags;
> +	legacy_port->regshift = shift;
> +	legacy_info->taddr = taddr;
> +	legacy_info->np = of_node_get(np);
> +	legacy_info->clock = clock;
> +	legacy_info->speed = spd ? be32_to_cpup(spd) : 0;
> +	legacy_info->irq_check_parent = irq_check_parent;
>  
>  	if (iotype == UPIO_TSI) {
> -		legacy_serial_ports[index].serial_in = tsi_serial_in;
> -		legacy_serial_ports[index].serial_out = tsi_serial_out;
> +		legacy_port->serial_in = tsi_serial_in;
> +		legacy_port->serial_out = tsi_serial_out;
>  	}
>  
> -	printk(KERN_DEBUG "Found legacy serial port %d for %pOF\n",
> -	       index, np);
> +	printk(KERN_DEBUG "Found legacy serial port %d for %pOF\n", index, np);
>  	printk(KERN_DEBUG "  %s=%llx, taddr=%llx, irq=%lx, clk=%d, speed=%d\n",
>  	       (iotype == UPIO_PORT) ? "port" : "mem",
>  	       (unsigned long long)base, (unsigned long long)taddr, irq,
> -	       legacy_serial_ports[index].uartclk,
> -	       legacy_serial_infos[index].speed);
> +	       legacy_port->uartclk, legacy_info->speed);
>  
>  	return index;
>  }
> 

  reply	other threads:[~2025-06-11 11:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250611100319.186924-1-jirislaby@kernel.org>
2025-06-11 10:02 ` [PATCH 02/33] powerpc/legacy_serial: cache serial port and info in add_legacy_port() Jiri Slaby (SUSE)
2025-06-11 11:15   ` Ilpo Järvinen [this message]
2025-06-11 10:02 ` [PATCH 05/33] powerpc/powermac: remove unneeded tty includes Jiri Slaby (SUSE)
2025-06-11 11:25   ` Ilpo Järvinen
2025-06-11 10:02 ` [PATCH 08/33] serial: 8250: sanitize uart_port::serial_{in,out}() types Jiri Slaby (SUSE)
2025-06-11 15:12   ` Andy Shevchenko
2025-06-23  6:55     ` Jiri Slaby
     [not found] ` <20250611100319.186924-8-jirislaby@kernel.org>
2025-07-31 14:35   ` [PATCH 07/33] tty: vt: use _IO() to define ioctl numbers Christophe Leroy
2025-07-31 14:41     ` Christophe Leroy
2025-07-31 20:58       ` Nicolas Pitre
2025-08-01  4:47         ` Jiri Slaby
2025-08-01  7:38           ` Greg KH

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=17b17aa3-dfd9-0e8d-b2a1-010637db29d7@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.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;
as well as URLs for NNTP newsgroup(s).