lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <17b17aa3-dfd9-0e8d-b2a1-010637db29d7@linux.intel.com>
Date: Wed, 11 Jun 2025 14:15:59 +0300 (EEST)
From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To: "Jiri Slaby (SUSE)" <jirislaby@...nel.org>
cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>, 
    linux-serial <linux-serial@...r.kernel.org>, 
    LKML <linux-kernel@...r.kernel.org>, 
    Madhavan Srinivasan <maddy@...ux.ibm.com>, 
    Michael Ellerman <mpe@...erman.id.au>, Nicholas Piggin <npiggin@...il.com>, 
    Christophe Leroy <christophe.leroy@...roup.eu>, 
    linuxppc-dev@...ts.ozlabs.org
Subject: Re: [PATCH 02/33] powerpc/legacy_serial: cache serial port and info
 in add_legacy_port()

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@...nel.org>
> Cc: Madhavan Srinivasan <maddy@...ux.ibm.com>
> Cc: Michael Ellerman <mpe@...erman.id.au>
> Cc: Nicholas Piggin <npiggin@...il.com>
> Cc: Christophe Leroy <christophe.leroy@...roup.eu>
> Cc: linuxppc-dev@...ts.ozlabs.org

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@...ux.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;
>  }
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ