All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] serial: core: Fix serial_base_match() after fixing controller port name
@ 2023-08-02 11:48 Tony Lindgren
  2023-08-02 13:48 ` Greg Kroah-Hartman
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Tony Lindgren @ 2023-08-02 11:48 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 seemed unnecessary.

Let's fix the issue by checking against dev->type and drv->name.

Fixes: 1ef2c2df1199 ("serial: core: Fix serial core controller port name to show controller id")
Reported-by: kernel test robot <oliver.sang@intel.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/tty/serial/serial_base.h     |  3 +++
 drivers/tty/serial/serial_base_bus.c | 10 ++++++++--
 drivers/tty/serial/serial_ctrl.c     |  2 +-
 drivers/tty/serial/serial_port.c     |  2 +-
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/serial_base.h b/drivers/tty/serial/serial_base.h
--- a/drivers/tty/serial/serial_base.h
+++ b/drivers/tty/serial/serial_base.h
@@ -6,6 +6,9 @@
  * Author: Tony Lindgren <tony@atomide.com>
  */
 
+#define SERIAL_BASE_CTRL_NAME	"ctrl"
+#define SERIAL_BASE_PORT_NAME	"port"
+
 #define to_serial_base_ctrl_device(d) container_of((d), struct serial_ctrl_device, dev)
 #define to_serial_base_port_device(d) container_of((d), struct serial_port_device, dev)
 
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 &&
+	    !strncmp(SERIAL_BASE_CTRL_NAME, drv->name, 4))
+		return 1;
 
-	return !strncmp(dev_name(dev), drv->name, len);
+	if (dev->type == &serial_port_type &&
+	    !strncmp(SERIAL_BASE_PORT_NAME, drv->name, 4))
+		return 1;
+
+	return 0;
 }
 
 static struct bus_type serial_base_bus_type = {
diff --git a/drivers/tty/serial/serial_ctrl.c b/drivers/tty/serial/serial_ctrl.c
--- a/drivers/tty/serial/serial_ctrl.c
+++ b/drivers/tty/serial/serial_ctrl.c
@@ -47,7 +47,7 @@ void serial_ctrl_unregister_port(struct uart_driver *drv, struct uart_port *port
 }
 
 static struct device_driver serial_ctrl_driver = {
-	.name = "ctrl",
+	.name = SERIAL_BASE_CTRL_NAME,
 	.suppress_bind_attrs = true,
 	.probe = serial_ctrl_probe,
 	.remove = serial_ctrl_remove,
diff --git a/drivers/tty/serial/serial_port.c b/drivers/tty/serial/serial_port.c
--- a/drivers/tty/serial/serial_port.c
+++ b/drivers/tty/serial/serial_port.c
@@ -83,7 +83,7 @@ void uart_remove_one_port(struct uart_driver *drv, struct uart_port *port)
 EXPORT_SYMBOL(uart_remove_one_port);
 
 static struct device_driver serial_port_driver = {
-	.name = "port",
+	.name = SERIAL_BASE_PORT_NAME,
 	.suppress_bind_attrs = true,
 	.probe = serial_port_probe,
 	.remove = serial_port_remove,
-- 
2.41.0

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

* Re: [PATCH] serial: core: Fix serial_base_match() after fixing controller port name
  2023-08-02 11:48 [PATCH] serial: core: Fix serial_base_match() after fixing controller port name Tony Lindgren
@ 2023-08-02 13:48 ` Greg Kroah-Hartman
  2023-08-02 21:44   ` Andy Shevchenko
  2023-08-02 18:32 ` Mark Brown
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2023-08-02 13:48 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Jiri Slaby, Andy Shevchenko, Andy Shevchenko, Dhruva Gole,
	Ilpo Järvinen, John Ogness, Johan Hovold,
	Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-kernel,
	linux-serial, kernel test robot

On Wed, Aug 02, 2023 at 02:48:43PM +0300, Tony Lindgren wrote:
> While fixing DEVNAME to be more usable, I broke serial_base_match() as
> the ctrl and port prefix for device seemed unnecessary.
> 
> Let's fix the issue by checking against dev->type and drv->name.
> 
> Fixes: 1ef2c2df1199 ("serial: core: Fix serial core controller port name to show controller id")
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/tty/serial/serial_base.h     |  3 +++
>  drivers/tty/serial/serial_base_bus.c | 10 ++++++++--
>  drivers/tty/serial/serial_ctrl.c     |  2 +-
>  drivers/tty/serial/serial_port.c     |  2 +-
>  4 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/serial/serial_base.h b/drivers/tty/serial/serial_base.h
> --- a/drivers/tty/serial/serial_base.h
> +++ b/drivers/tty/serial/serial_base.h
> @@ -6,6 +6,9 @@
>   * Author: Tony Lindgren <tony@atomide.com>
>   */
>  
> +#define SERIAL_BASE_CTRL_NAME	"ctrl"
> +#define SERIAL_BASE_PORT_NAME	"port"
> +
>  #define to_serial_base_ctrl_device(d) container_of((d), struct serial_ctrl_device, dev)
>  #define to_serial_base_port_device(d) container_of((d), struct serial_port_device, dev)
>  
> 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 &&
> +	    !strncmp(SERIAL_BASE_CTRL_NAME, drv->name, 4))

maybe:
	    !strncmp(SERIAL_BASE_CTRL_NAME, drv->name, strlen(SERIAL_BASE_CTRL_NAME))

as "4" is a magic number :)


thanks,

greg k-h

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

* Re: [PATCH] serial: core: Fix serial_base_match() after fixing controller port name
  2023-08-02 11:48 [PATCH] serial: core: Fix serial_base_match() after fixing controller port name Tony Lindgren
  2023-08-02 13:48 ` Greg Kroah-Hartman
@ 2023-08-02 18:32 ` Mark Brown
  2023-08-03  5:13 ` Jiri Slaby
  2023-08-03  7:00 ` Anders Roxell
  3 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2023-08-02 18:32 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Andy Shevchenko,
	Dhruva Gole, Ilpo Järvinen, John Ogness, Johan Hovold,
	Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-kernel,
	linux-serial, kernel test robot

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

On Wed, Aug 02, 2023 at 02:48:43PM +0300, Tony Lindgren wrote:
> While fixing DEVNAME to be more usable, I broke serial_base_match() as
> the ctrl and port prefix for device seemed unnecessary.
> 
> Let's fix the issue by checking against dev->type and drv->name.

This fixes boot on at least i.MX8MP-EVK:

Tested-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] serial: core: Fix serial_base_match() after fixing controller port name
  2023-08-02 13:48 ` Greg Kroah-Hartman
@ 2023-08-02 21:44   ` Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2023-08-02 21:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Tony Lindgren, Jiri Slaby, Dhruva Gole, Ilpo Järvinen,
	John Ogness, Johan Hovold, Sebastian Andrzej Siewior,
	Vignesh Raghavendra, linux-kernel, linux-serial,
	kernel test robot

On Wed, Aug 02, 2023 at 03:48:26PM +0200, Greg Kroah-Hartman wrote:
> On Wed, Aug 02, 2023 at 02:48:43PM +0300, Tony Lindgren wrote:
> > While fixing DEVNAME to be more usable, I broke serial_base_match() as
> > the ctrl and port prefix for device seemed unnecessary.
> > 
> > Let's fix the issue by checking against dev->type and drv->name.

...

> > +	    !strncmp(SERIAL_BASE_CTRL_NAME, drv->name, 4))
> 
> maybe:
> 	    !strncmp(SERIAL_BASE_CTRL_NAME, drv->name, strlen(SERIAL_BASE_CTRL_NAME))
> 
> as "4" is a magic number :)

str_has_prefix() hides that.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] serial: core: Fix serial_base_match() after fixing controller port name
  2023-08-02 11:48 [PATCH] serial: core: Fix serial_base_match() after fixing controller port name Tony Lindgren
  2023-08-02 13:48 ` Greg Kroah-Hartman
  2023-08-02 18:32 ` Mark Brown
@ 2023-08-03  5:13 ` Jiri Slaby
  2023-08-03  6:56   ` Tony Lindgren
  2023-08-03  7:00 ` Anders Roxell
  3 siblings, 1 reply; 7+ messages in thread
From: Jiri Slaby @ 2023-08-03  5:13 UTC (permalink / raw)
  To: Tony Lindgren, Greg Kroah-Hartman, 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

On 02. 08. 23, 13:48, Tony Lindgren wrote:
> While fixing DEVNAME to be more usable, I broke serial_base_match() as
> the ctrl and port prefix for device seemed unnecessary.

It's not completely clear to me what you are actually fixing. Please 
elaborate in more detail.

> Let's fix the issue by checking against dev->type and drv->name.
> 
> Fixes: 1ef2c2df1199 ("serial: core: Fix serial core controller port name to show controller id")


> Reported-by: kernel test robot <oliver.sang@intel.com>

Then we are missing a Link here.

> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>   drivers/tty/serial/serial_base.h     |  3 +++
>   drivers/tty/serial/serial_base_bus.c | 10 ++++++++--
>   drivers/tty/serial/serial_ctrl.c     |  2 +-
>   drivers/tty/serial/serial_port.c     |  2 +-
>   4 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/serial/serial_base.h b/drivers/tty/serial/serial_base.h
> --- a/drivers/tty/serial/serial_base.h
> +++ b/drivers/tty/serial/serial_base.h
> @@ -6,6 +6,9 @@
>    * Author: Tony Lindgren <tony@atomide.com>
>    */
>   
> +#define SERIAL_BASE_CTRL_NAME	"ctrl"
> +#define SERIAL_BASE_PORT_NAME	"port"

Could you make those char[] instead? The compiler/linker will hopefully 
(will it?) de-dup the occurrences, but the arrays would look cleaner and 
safer from this POV.

>   #define to_serial_base_ctrl_device(d) container_of((d), struct serial_ctrl_device, dev)
>   #define to_serial_base_port_device(d) container_of((d), struct serial_port_device, dev)
>   
> 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 &&
> +	    !strncmp(SERIAL_BASE_CTRL_NAME, drv->name, 4))
> +		return 1;
>   
> -	return !strncmp(dev_name(dev), drv->name, len);
> +	if (dev->type == &serial_port_type &&
> +	    !strncmp(SERIAL_BASE_PORT_NAME, drv->name, 4))
> +		return 1;
> +
> +	return 0;
>   }
>   
>   static struct bus_type serial_base_bus_type = {
> diff --git a/drivers/tty/serial/serial_ctrl.c b/drivers/tty/serial/serial_ctrl.c
> --- a/drivers/tty/serial/serial_ctrl.c
> +++ b/drivers/tty/serial/serial_ctrl.c
> @@ -47,7 +47,7 @@ void serial_ctrl_unregister_port(struct uart_driver *drv, struct uart_port *port
>   }
>   
>   static struct device_driver serial_ctrl_driver = {
> -	.name = "ctrl",
> +	.name = SERIAL_BASE_CTRL_NAME,
>   	.suppress_bind_attrs = true,
>   	.probe = serial_ctrl_probe,
>   	.remove = serial_ctrl_remove,
> diff --git a/drivers/tty/serial/serial_port.c b/drivers/tty/serial/serial_port.c
> --- a/drivers/tty/serial/serial_port.c
> +++ b/drivers/tty/serial/serial_port.c
> @@ -83,7 +83,7 @@ void uart_remove_one_port(struct uart_driver *drv, struct uart_port *port)
>   EXPORT_SYMBOL(uart_remove_one_port);
>   
>   static struct device_driver serial_port_driver = {
> -	.name = "port",
> +	.name = SERIAL_BASE_PORT_NAME,
>   	.suppress_bind_attrs = true,
>   	.probe = serial_port_probe,
>   	.remove = serial_port_remove,

-- 
js
suse labs


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

* Re: [PATCH] serial: core: Fix serial_base_match() after fixing controller port name
  2023-08-03  5:13 ` Jiri Slaby
@ 2023-08-03  6:56   ` Tony Lindgren
  0 siblings, 0 replies; 7+ messages in thread
From: Tony Lindgren @ 2023-08-03  6:56 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: Greg Kroah-Hartman, Andy Shevchenko, Andy Shevchenko,
	Dhruva Gole, Ilpo Järvinen, John Ogness, Johan Hovold,
	Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-kernel,
	linux-serial, kernel test robot

* Jiri Slaby <jirislaby@kernel.org> [230803 05:13]:
> On 02. 08. 23, 13:48, Tony Lindgren wrote:
> > @@ -6,6 +6,9 @@
> >    * Author: Tony Lindgren <tony@atomide.com>
> >    */
> > +#define SERIAL_BASE_CTRL_NAME	"ctrl"
> > +#define SERIAL_BASE_PORT_NAME	"port"
> 
> Could you make those char[] instead? The compiler/linker will hopefully
> (will it?) de-dup the occurrences, but the arrays would look cleaner and
> safer from this POV.

Heh yeah so we already have that in serial_ctrl_type.name and
serial_port_type.name so let's just check against those for a
minimal fix.

Regards,

Tony

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

* Re: [PATCH] serial: core: Fix serial_base_match() after fixing controller port name
  2023-08-02 11:48 [PATCH] serial: core: Fix serial_base_match() after fixing controller port name Tony Lindgren
                   ` (2 preceding siblings ...)
  2023-08-03  5:13 ` Jiri Slaby
@ 2023-08-03  7:00 ` Anders Roxell
  3 siblings, 0 replies; 7+ messages in thread
From: Anders Roxell @ 2023-08-03  7:00 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Andy Shevchenko,
	Dhruva Gole, Ilpo Järvinen, John Ogness, Johan Hovold,
	Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-kernel,
	linux-serial, kernel test robot

On 2023-08-02 14:48, Tony Lindgren wrote:
> While fixing DEVNAME to be more usable, I broke serial_base_match() as
> the ctrl and port prefix for device seemed unnecessary.
> 
> Let's fix the issue by checking against dev->type and drv->name.
> 
> Fixes: 1ef2c2df1199 ("serial: core: Fix serial core controller port name to show controller id")
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Signed-off-by: Tony Lindgren <tony@atomide.com>

This fixes boot on e850-96.

Tested-by: Anders Roxell <anders.roxell@linaro.org>

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

end of thread, other threads:[~2023-08-03  7:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-02 11:48 [PATCH] serial: core: Fix serial_base_match() after fixing controller port name Tony Lindgren
2023-08-02 13:48 ` Greg Kroah-Hartman
2023-08-02 21:44   ` Andy Shevchenko
2023-08-02 18:32 ` Mark Brown
2023-08-03  5:13 ` Jiri Slaby
2023-08-03  6:56   ` Tony Lindgren
2023-08-03  7:00 ` Anders Roxell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.