public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/1] serial: core: Fix serial_base_match() after fixing controller port name
@ 2023-08-03  7:10 Tony Lindgren
  2023-08-03  7:26 ` Jiri Slaby
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Tony Lindgren @ 2023-08-03  7:10 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko
  Cc: Andy Shevchenko, Dhruva Gole, Ilpo Järvinen, John Ogness,
	Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra,
	linux-kernel, linux-serial, kernel test robot

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 <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202308021529.35b3ad6c-oliver.sang@intel.com
Signed-off-by: Tony Lindgren <tony@atomide.com>
---

Changes since v1:
- Leave out magic numbers and use str_has_prefix() as suggested by Andy
  and Greg

- Improve patch description and add a link for Closes tag as suggested
  by Jiri

- Check the name against device_type name since we have it and leave
  out the changes to try to define names in the header because of the
  issues noted by Jiri

- Leave out Tested-by from Mark and Anders as the patch changed

---
 drivers/tty/serial/serial_base_bus.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/serial_base_bus.c b/drivers/tty/serial/serial_base_bus.c
--- 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 = {
-- 
2.41.0

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-08-06  6:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-03  7:10 [PATCH v2 1/1] serial: core: Fix serial_base_match() after fixing controller port name Tony Lindgren
2023-08-03  7:26 ` Jiri Slaby
2023-08-03  7:50 ` Greg Kroah-Hartman
2023-08-03  8:52   ` Conor Dooley
2023-08-03 15:34 ` Biju Das
2023-08-04 21:42 ` Guenter Roeck
2023-08-05  4:49   ` Tony Lindgren
2023-08-05 10:50     ` Guenter Roeck
2023-08-05 11:48       ` Tony Lindgren
2023-08-05 15:50         ` Guenter Roeck
2023-08-05 16:12           ` Guenter Roeck
2023-08-06  4:33             ` Tony Lindgren
2023-08-06  6:23               ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox