From patchwork Wed Aug 2 11:48:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 129795 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp408199vqx; Wed, 2 Aug 2023 05:11:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlGhf2rl3BxLOI+jXCD0Wg96i22dm8Ak66O/PJ69rJdN07QuhLi6QcjCgB6o9u3HkhpO8Zoc X-Received: by 2002:a17:903:454:b0:1b9:e937:9763 with SMTP id iw20-20020a170903045400b001b9e9379763mr12555008plb.12.1690978279030; Wed, 02 Aug 2023 05:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690978279; cv=none; d=google.com; s=arc-20160816; b=SQiCB9Q/cY4EsTLq9Woqp4n1PScBCg9wr8EkUkgY+XuI0lrSq1iP3bfUh9AegXMK/b p2Vi/FfHkIQy8SYWqxSoRtX9bYfF34Zlu5CpKZ9oLSQWKyLWqMDscCcOEXH4fxq43nR6 fQjwepWaUpZ+NcQcg+Pvt/N5LBDZ5HdOuqWTlsg4GL1HT7aJPfGuCROB+iC1PXa38co2 8BmSd6oFp7dofq6gbAYY4vlIXgVzkueaNqLYIpQjrp/ZMPdHIzfdqbv41R/ax6gwV6/6 xZY56DR+tuIaQ4zqV1VzSDVAB4xxSTWWcsrRm1hWY1woHDa6CUJD6HdgH4mqqn5+G4JE kxfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=LTwczgZHJGs0UB9/5H7Ctb5z6UrR97GK0iX88x8apHY=; fh=tjtRR0AeIV3H3iXvv6awkTuO8R/V4QglKkv3GjXJ/LQ=; b=TMk26FL+dHQs2eNMRXwqAfAw6tNOj280l2T8qtLLr+xg/iMu9TJkv+xL+gPeKLAy4j HeMHthjh4vWgYU/+9VyGzad3Lb7Wa0+YldAa1Us1CtWjX9+QPVOm32VzslkgrHaVPavX 5hfH8Yz/vwrGxflTHJZOld5ciAIEDNPpYLE2hrx2I5AdlDT2EIE8eY4pfKsnH/4qdR1K KzlkdpIj/b85d8M+QrTLzgpPnep65HiwZ4f4XydViIx+cBWYDNqkGceET0OeElCSjUHj c4gb1A0TBJ+7F+6Tnkk0HRBrW8Kz41lMQpRUKAIY7Cio/+EMAB9Zvqaku5V2/a2XkhRp CuGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iy5-20020a170903130500b001bbd639dff9si2238384plb.467.2023.08.02.05.10.34; Wed, 02 Aug 2023 05:11:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234322AbjHBLs6 (ORCPT + 99 others); Wed, 2 Aug 2023 07:48:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234320AbjHBLs5 (ORCPT ); Wed, 2 Aug 2023 07:48:57 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ED6F8213D; Wed, 2 Aug 2023 04:48:54 -0700 (PDT) Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 2673E80AE; Wed, 2 Aug 2023 11:48:51 +0000 (UTC) From: Tony Lindgren To: Greg Kroah-Hartman , Jiri Slaby , Andy Shevchenko Cc: Andy Shevchenko , Dhruva Gole , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , John Ogness , Johan Hovold , Sebastian Andrzej Siewior , Vignesh Raghavendra , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, kernel test robot Subject: [PATCH] serial: core: Fix serial_base_match() after fixing controller port name Date: Wed, 2 Aug 2023 14:48:43 +0300 Message-ID: <20230802114846.21899-1-tony@atomide.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773119240052273719 X-GMAIL-MSGID: 1773119240052273719 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 Signed-off-by: Tony Lindgren Tested-by: Mark Brown Tested-by: Anders Roxell --- 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 */ +#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,