From patchwork Thu Aug 3 07:10:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 130344 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp963637vqx; Thu, 3 Aug 2023 00:14:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGMT5fVuUzGNpFuYWGxatkGVl7ASMNOTok8UM3u9rt3xpmDbZ1ECcfrRrOzWKxVha120f23 X-Received: by 2002:a05:6e02:1069:b0:346:779a:ff70 with SMTP id q9-20020a056e02106900b00346779aff70mr15326209ilj.28.1691046891137; Thu, 03 Aug 2023 00:14:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691046891; cv=none; d=google.com; s=arc-20160816; b=l1fZ4HVfDugEs/tPEipIKX0wUAGrIqDjq6qtq6GuGon6SsLWfOzPyh2wTA3oCBIjXv cCjBKXDT2wWXZXH4PduP7/jKz+1aL7/3iv7C3eNWSxIWRxwHhVWZM6KM2ccFykD/+xff YgMAxlGnQwNQGwitNhPU+rwSwlRjJ+qp0lASA76R74gHxve4RiotB0xAmukeFGxyfo27 9afkFeoZ9ya/yAGRpoIxn6VmYhganyo11PMV+knQRSp/mRmvFzLTto/59rTQTE/VsEv0 i9+Rmgxo3wNesU9Q+edE3GW3HTGWvUEhV5+DWYaycyZVBI5WR7i71/QXQUNsytpr+UJI MLUQ== 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=SyaeUl84LRN5PlTHHTNzQPk/dAUEIu4UToGZnbg8ZPM=; fh=tjtRR0AeIV3H3iXvv6awkTuO8R/V4QglKkv3GjXJ/LQ=; b=J1qN7o4MhDGObeV0e50UYCCdxI7eoUQ0nCJm3RWU5PmeFkee6ijTJn5TdanD/5aR3D Z31vRqs7IAcPOCu28xThPERL1EOIBFURu/IM5xPagSfGVaPw65k9j7xzEOM2pFI4XUb8 OoDtGgazWXBLiUDiIiepYvLieEh1QVo4pluINMrxmopn95Bw5QRWr24j39dVbfSB59UU wNJwrL1mrCXH3xlCbRt4txMe0EAldtiPKdMPx1TEDT0ykVie8cTaDXAkSxtJcyWyqH7Y NDvn8b2ekQCsXEUCeL72GsTgzsxlAEqEO5olir8ZmpucBgINB5mGcAoN7Rf+W28aoc5v ivLg== 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 t33-20020a634461000000b00563b0cbe802si4660957pgk.109.2023.08.03.00.14.36; Thu, 03 Aug 2023 00:14:51 -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 S233343AbjHCHKq (ORCPT + 99 others); Thu, 3 Aug 2023 03:10:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232800AbjHCHKo (ORCPT ); Thu, 3 Aug 2023 03:10:44 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9DB23FF; Thu, 3 Aug 2023 00:10:43 -0700 (PDT) Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 3808380FE; Thu, 3 Aug 2023 07:10:41 +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 v2 1/1] serial: core: Fix serial_base_match() after fixing controller port name Date: Thu, 3 Aug 2023 10:10:32 +0300 Message-ID: <20230803071034.25571-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, RCVD_IN_DNSWL_BLOCKED,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: 1773191185233722419 X-GMAIL-MSGID: 1773191185233722419 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 Closes: https://lore.kernel.org/oe-lkp/202308021529.35b3ad6c-oliver.sang@intel.com Signed-off-by: Tony Lindgren Reviewed-by: Jiri Slaby Tested-by: Conor Dooley Tested-by: Biju Das --- 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 = {