aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Lindgren <[email protected]>2023-08-03 10:10:32 +0300
committerGreg Kroah-Hartman <[email protected]>2023-08-03 09:48:56 +0200
commit7d695d83767cdb4288b101affef6d1d1bcf44d31 (patch)
tree9aa15a225fec6444f166cd2531a377e4fe48bb5b
parent1ef2c2df11997b8135f34adcf2c200d3b4aacbe9 (diff)
serial: core: Fix serial_base_match() after fixing controller port name
While fixing DEVNAME to be more usable, I broke serial_base_match() as the ctrl and port prefix for device names seemed unnecessary. The prefixes are still needed by serial_base_match() to probe the serial base controller port, and serial tx is now broken. Let's fix the issue by checking against dev->type and drv->name instead of the prefixes that are no longer in the DEVNAME. Fixes: 1ef2c2df1199 ("serial: core: Fix serial core controller port name to show controller id") Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-lkp/[email protected] Signed-off-by: Tony Lindgren <[email protected]> Reviewed-by: Jiri Slaby <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r--drivers/tty/serial/serial_base_bus.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/tty/serial/serial_base_bus.c b/drivers/tty/serial/serial_base_bus.c
index 11e2ff9cbe4d..0892369f98d2 100644
--- a/drivers/tty/serial/serial_base_bus.c
+++ b/drivers/tty/serial/serial_base_bus.c
@@ -29,9 +29,15 @@ static const struct device_type serial_port_type = {
static int serial_base_match(struct device *dev, struct device_driver *drv)
{
- int len = strlen(drv->name);
+ if (dev->type == &serial_ctrl_type &&
+ str_has_prefix(drv->name, serial_ctrl_type.name))
+ return 1;
- return !strncmp(dev_name(dev), drv->name, len);
+ if (dev->type == &serial_port_type &&
+ str_has_prefix(drv->name, serial_port_type.name))
+ return 1;
+
+ return 0;
}
static struct bus_type serial_base_bus_type = {