Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp3523557rwo; Fri, 4 Aug 2023 06:17:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOflUSNcQ8kR0ichZuP9+3lu+j9KBeDqQs44wXSb9OB6N1mo8eC8dcD4PUYo8JTv8suq9C X-Received: by 2002:a05:6a00:842:b0:67e:18c6:d2c6 with SMTP id q2-20020a056a00084200b0067e18c6d2c6mr2505826pfk.5.1691155078788; Fri, 04 Aug 2023 06:17:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691155078; cv=none; d=google.com; s=arc-20160816; b=SPfwGVqu+PKlc9f5lDe2TD/oHjxPIHrL4MLqzD9D4kg1qMOAwcd/MerayiOmg/uMqz FSmp1m9uZddgkiV7Ztypt6FbzDF2lU9wh9E9120YO+xStndhhPmdSxifXnnLQhvXr8uy 187Pgrlx9DYdkdRtPgkCARgFsoULe1YvmDx1EEmmJl5p140bRL5hn7DUf246C9WqSYFn TmPql+22dndg2Rez4Z11FrZNDFKksf/Tj0nZf4DxkIAy/yUdywDr1qsr/E8UzHrrmAku YkGs+a2TwxD5f700GjjAEc2FYG976keqfR4sJa/5msEgL/m70ZKNCpfVAAJpyWqTzoxp onSg== 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=+9Cz22BQmxcJSvvLidHSCoBB61UhzhsmMF2lEUg6rcU=; fh=wxWR7S7XHVlqVIuoke4G1/IBIqVMAhyap/qryV8BrCQ=; b=x9acQ2pLnS+d+i+N3UUm12g8UkWZf0H9NZjD0u/QYc4T4o7Ee3AZ/mEvXyIlCVX9l9 AmgEkX3drkNWamA7WOfBdYGo6zmihM9iXPz0FoBKNP3Y3+ejdCMbND1KdBgLvekzjV/z hdshyBHXeEnBs06tUohq66l4Gxze/yCTMJHhXXfpIy6R2kQuTv9+Xp53ozs3f44pHXCr JFr3/1vHoPborRgjUPvqhiYRGPRvMSajFF2Vfazz0HHatJYbxVzoU+TJkUOEfZat3zCY CMKciyjeths4NwDmKIbrsfOzhJnfMkZqxZY4JoB3XPm41z+PJnsJvOhw9awdmRHkqP3D jHcw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eg27-20020a056a00801b00b006870ae2d479si1637981pfb.354.2023.08.04.06.17.46; Fri, 04 Aug 2023 06:17:58 -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 S229762AbjHDMgB (ORCPT + 99 others); Fri, 4 Aug 2023 08:36:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbjHDMgA (ORCPT ); Fri, 4 Aug 2023 08:36:00 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DB41546B3; Fri, 4 Aug 2023 05:35:55 -0700 (PDT) Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id C0E8880F7; Fri, 4 Aug 2023 12:35:52 +0000 (UTC) From: Tony Lindgren To: Greg Kroah-Hartman , Jiri Slaby , Andy Shevchenko Cc: Andy Shevchenko , Dhruva Gole , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , John Ogness , Johan Hovold , Sebastian Andrzej Siewior , Vignesh Raghavendra , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH] serial: 8250: Reinit port_id when adding back serial8250_isa_devs Date: Fri, 4 Aug 2023 15:35:44 +0300 Message-ID: <20230804123546.25293-1-tony@atomide.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED 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 After fixing the serial core port device to use port->port_id instead of port->line, unloading a hardware specific 8250 port driver started producing an error for "sysfs: cannot create duplicate filename". This is happening as we are wrongly initializing port->port_id to zero when adding back serial8250_isa_devs instances, and the serial8250:0.0 sysfs entry may already exist. For serial8250 devices, we typically have multiple devices mapped to a single driver instance. For the serial8250_isa_devs instances, the port->port_id is the same as port->line. Let's fix the issue by re-initializing port_id when adding back the serial8250_isa_devs instances in serial8250_unregister_port(). Fixes: d962de6ae51f ("serial: core: Fix serial core port id to not use port->line") Signed-off-by: Tony Lindgren --- drivers/tty/serial/8250/8250_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c @@ -1204,6 +1204,7 @@ void serial8250_unregister_port(int line) uart->port.flags &= ~UPF_BOOT_AUTOCONF; uart->port.type = PORT_UNKNOWN; uart->port.dev = &serial8250_isa_devs->dev; + uart->port.port_id = line; uart->capabilities = 0; serial8250_init_port(uart); serial8250_apply_quirks(uart); -- 2.41.0