term/serial: Avoid double lookup of serial ports

The various functions to add a port used to return port->name, and
the callers would immediately iterate all registered ports to "find"
the one just created by comparing that return value with ... port->name.

This is a waste of cycles and code. Instead, have those functions
return "port" directly.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Benjamin Herrenschmidt authored and Daniel Kiper committed 2023-01-19 17:39:04 +01:00
1 parent b73a44b281
commit e37dbba665
6 files changed
+33 -45

No files matched your search

+3 -3
View File
@@ -217,7 +217,7 @@ dev_iterate (struct grub_ieee1275_devalias *alias)
return 0;
}
static const char *
static struct grub_serial_port *
add_port (struct ofserial_hash_ent *ent)
{
struct grub_serial_port *port;
@@ -245,10 +245,10 @@ add_port (struct ofserial_hash_ent *ent)
grub_serial_register (port);
return port->name;
return port;
}
const char *
const struct grub_serial_port *
grub_ofserial_add_port (const char *path)
{
struct ofserial_hash_ent *ent;