From patchwork Mon Dec 21 12:30:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1419011 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CzzNB2cV1z9sVk for ; Mon, 21 Dec 2020 23:31:06 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C2AAF828A9; Mon, 21 Dec 2020 13:30:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id EDF708289E; Mon, 21 Dec 2020 13:30:19 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 19AFC8283D for ; Mon, 21 Dec 2020 13:30:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=andriy.shevchenko@linux.intel.com IronPort-SDR: erWs2HpLYJRTaf9dAKVFibvdEkHb4/lw1ggiAHHEc1uGkNTzBBe2CPXjYO9B2GusdqyuJFDA5x oVl7KCxO+BdA== X-IronPort-AV: E=McAfee;i="6000,8403,9841"; a="260447084" X-IronPort-AV: E=Sophos;i="5.78,436,1599548400"; d="scan'208";a="260447084" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Dec 2020 04:30:13 -0800 IronPort-SDR: UiZWfIxrmwdClajWWdULaUlRPgz1NyLOdrOABWQxKB8LEuVuc812gk+TSe/pNuUQXL+pHn3J7r xVWVZLuxH/8Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,436,1599548400"; d="scan'208";a="337441983" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 21 Dec 2020 04:30:12 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id D88D16B9; Mon, 21 Dec 2020 14:30:09 +0200 (EET) From: Andy Shevchenko To: Tom Rini , U-Boot Mailing List Cc: Andy Shevchenko , Simon Glass Subject: [PATCH v3 9/9] IOMUX: Stop dropped consoles Date: Mon, 21 Dec 2020 14:30:08 +0200 Message-Id: <20201221123008.9930-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201221123008.9930-1-andriy.shevchenko@linux.intel.com> References: <20201221123008.9930-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean When at some point environment shrinks we need to stop dropped devices. Signed-off-by: Andy Shevchenko Reviewed-by: Simon Glass --- v3: added tag common/iomux.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/common/iomux.c b/common/iomux.c index 126d92ce850f..15bf53388559 100644 --- a/common/iomux.c +++ b/common/iomux.c @@ -27,8 +27,8 @@ int iomux_doenv(const int console, const char *arg) { char *console_args, *temp, **start; int i, j, k, io_flag, cs_idx, repeat; + struct stdio_dev **cons_set, **old_set; struct stdio_dev *dev; - struct stdio_dev **cons_set; console_args = strdup(arg); if (console_args == NULL) @@ -128,10 +128,23 @@ int iomux_doenv(const int console, const char *arg) return 1; } - /* Works even if console_devices[console] is NULL. */ - free(console_devices[console]); + old_set = console_devices[console]; + repeat = cd_count[console]; + console_devices[console] = cons_set; cd_count[console] = cs_idx; + + /* Stop dropped consoles */ + for (i = 0; i < repeat; i++) { + for (j = 0; j < cs_idx; j++) { + if (old_set[i] == cons_set[j]) + break; + } + if (j == cs_idx) + console_stop(console, old_set[i]); + } + + free(old_set); return 0; } #endif /* CONSOLE_MUX */