Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C2D19C433F5 for ; Mon, 4 Apr 2022 15:51:53 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 21FE783639; Mon, 4 Apr 2022 17:51:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=softathome.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=softathome1.onmicrosoft.com header.i=@softathome1.onmicrosoft.com header.b="EVzXC+Mp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 521EA836B4; Mon, 4 Apr 2022 17:51:18 +0200 (CEST) Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-pr2fra01on0608.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e18::608]) (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 339FB83531 for ; Mon, 4 Apr 2022 17:51:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=softathome.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=alexandre.besnard@softathome.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f0W4uXqKWxjkCTXoAOgcOdbRYZOgFLbbCET+rFULJzAUoRnTGVShKmDfA49AncbBPD2l3/ITRi3djM6HAqF+BHpnShZX/iNGZm+P6F7t1pox/u5V9x1sQukvaKGL/II4JqNxjQoZ0idcL47GZ29DRxSOriosaSqMImqnVm7Rq/CyT84s7auwnRo+AEmt65VXh1HRH+x51/Agzi7fQUEdPdhAqwhw2KjWLOjUnQ2NGWI/Q453GjVd6YIvWapZUEiw2DvQcIzg/Zz7wQkvJVhWG/lYEekCaZpzq5I5a8iBPOGJB5n4wqywM7NMuFHpS6jwGeMG2K4vPkzHC59ZG5SUIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sY6Nb0cv6uS5ei7oCwO16nHJUc7pqQAGsxEmVHq0UxU=; b=BXAWTNa5ty5139ZMh8isW1oxFWHHSD3U167XJN+0FCGA/9J1yS7YP5ITUCusC411ejEmi/MdcJPR1wv7LN47e+vLlhNLuPNxsSwqiXUKN2UAylAwbq+9Ba3lMMpIHh8q8bp2JmgKZD/AmSvsaQr4EjvCDGu5gaDdnxy0RBFzBfkl+AU6iKsRyBw30hK90FKTFx8d/gnn5qHnBtb+IZMT3VSIYBz5fqh15mutGnDT/2zfErMTgFFRUq1BH5bHW+lp2HaMXDubcWVRtj4E1cvoPnVXgR2q/gH2BHUmWwbEQjAsSYGG5Mea0AD/+aXF2IO1tzc47qKMIN++c9cT1uTXpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.6.166.170) smtp.rcpttodomain=lists.denx.de smtp.mailfrom=softathome.com; dmarc=bestguesspass action=none header.from=softathome.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=softathome1.onmicrosoft.com; s=selector1-softathome1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sY6Nb0cv6uS5ei7oCwO16nHJUc7pqQAGsxEmVHq0UxU=; b=EVzXC+MpXG8U8RXzgEt94u/fl7LpGb6wDEZeD+dv/3RhUoz2/BMk8lw71niSHITM9xRiNabPWRSS9OSaAgivG3DH1h4qq+WAgeq9aqbmP1+wSopS785GBAJhWPdV9/k9XTEjV20vWpwgZ1XD/X9mYAfswJ4WxncMhHHi9AyHHw9JOWgooKWmxhsvfoFT78v7CNj6LIK5eFkviNODoG1UcdpvZhI44DeK1oSsn37XXX3rUeAHAb/+9b2ved+t9GJ/mxLjiTuLEwJIgLxTxtN5yvmwlrB9tB8OQr2zOB/9kMnhS4VkC7aHuR805dB6euxZjvk4pkcJZXff3lBsclW+mA== Received: from MR2P264CA0037.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500::25) by MR1P264MB2322.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:33::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.31; Mon, 4 Apr 2022 15:51:12 +0000 Received: from MR2FRA01FT003.eop-fra01.prod.protection.outlook.com (2603:10a6:500:0:cafe::78) by MR2P264CA0037.outlook.office365.com (2603:10a6:500::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.31 via Frontend Transport; Mon, 4 Apr 2022 15:51:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.6.166.170) smtp.mailfrom=softathome.com; dkim=none (message not signed) header.d=none;dmarc=bestguesspass action=none header.from=softathome.com; Received-SPF: Pass (protection.outlook.com: domain of softathome.com designates 149.6.166.170 as permitted sender) receiver=protection.outlook.com; client-ip=149.6.166.170; helo=proxy.softathome.com; Received: from proxy.softathome.com (149.6.166.170) by MR2FRA01FT003.mail.protection.outlook.com (10.152.50.177) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Mon, 4 Apr 2022 15:51:12 +0000 Received: from sah1lpt441.softathome.com (unknown [192.168.66.200]) by proxy.softathome.com (Postfix) with ESMTPSA id 28FEE2000B; Mon, 4 Apr 2022 17:51:11 +0200 (CEST) From: Alexandre Besnard To: u-boot@lists.denx.de Cc: Alexandre Besnard Subject: [PATCH] cmd: ubi.c: skip part command if right partition is already attached Date: Mon, 4 Apr 2022 17:50:14 +0200 Message-Id: <20220404155014.1338880-1-alexandre.besnard@softathome.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 431c50f9-6453-4ef4-fb7e-08da1652f1b4 X-MS-TrafficTypeDiagnostic: MR1P264MB2322:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TNQ62ejUzAqOo49fUXCxbOOzf3OVUSpsM2XCqOSZxsffA1O6MI5V71jRRvljiatmS3kNrB9Ee3/0BJ/DZ/JcPMZiagZxdo6EpmWmmXcPuJR2+E2RivAEbO8lF6vLI1uhHNs3NS2m8duU8GA+R/qSLMAncIqPzmbmT2hLmgSJKrpy3yiKv4V5Ag7DAdh9N1/mMA9EnjXWDqTlaOteXkkRHUT+USHOkLCnuqRiw37ch/Mt6b5KnudxoW7/iD/ciOfMhhFdXsWZXqer5XXMyo1I95bSYl81xItnPxMYaCX9nw4aCRcaeEsXyiOXRyFPMm3Es9o8cLsHoEGlW8fVXNtNuhNmx7vycNlKbGMFe3OJ2WFNq6T2wV4vwIu++ssUwskRRvk1/IFQnRJWPj+UQG6cDPsOK1Vp5UbzOtxqISOEpPMWBADja48c8F95RjVxLmaAmgCJmr4LOjgNMsAyKMvcQzD0WkHWzRrcwfCJXfq2jVHejlhR+wa8GR0fnWu8IissuQfjspTvjLIPWGRIrZf5tECNlJFP7r1jxhFjGdqdEWZb942fj9XgV0fw62UBi2Uf+4QsHHdbrT0KqQ3dYKYOrrssp4UbuWJeWVMWNWEGb4jtTkYu4X9p2gzx+w4oSNiIKjoyITkdRDuFpcaWlDdeUqVL30XXPqxjwydKBMPjIu68YDENEsevfAQ9G9Q5XxTJTwSrYzYGE1ljWgMg78y8sg== X-Forefront-Antispam-Report: CIP:149.6.166.170; CTRY:FR; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:proxy.softathome.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(5660300002)(8936002)(508600001)(426003)(6916009)(44832011)(186003)(6266002)(26005)(2616005)(36756003)(107886003)(316002)(1076003)(4744005)(6966003)(336012)(70206006)(81166007)(70586007)(86362001)(47076005)(82310400004)(40460700003)(7696005)(2906002)(36860700001)(8676002)(4326008)(82960400001)(356005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: softathome.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2022 15:51:12.3864 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 431c50f9-6453-4ef4-fb7e-08da1652f1b4 X-MS-Exchange-CrossTenant-Id: aa10e044-e405-4c10-8353-36b4d0cce511 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=aa10e044-e405-4c10-8353-36b4d0cce511; Ip=[149.6.166.170]; Helo=[proxy.softathome.com] X-MS-Exchange-CrossTenant-AuthSource: MR2FRA01FT003.eop-fra01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MR1P264MB2322 X-Mailman-Approved-At: Mon, 04 Apr 2022 17:51:48 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean Attaching a UBI partition may take a while, since scanning the memory is required. It thus makes sense to avoid a detach/scan/attach cycle when the right partition is already attached, and let the calling process call 'detach' beforehand if it needs it. This commit checks for the currently attached UBI partition, and skips reattaching if not needed, showing an information. Signed-off-by: Alexandre Besnard --- cmd/ubi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/ubi.c b/cmd/ubi.c index fe8ac58bac..fccbfdf48d 100644 --- a/cmd/ubi.c +++ b/cmd/ubi.c @@ -511,6 +511,11 @@ int ubi_part(char *part_name, const char *vid_header_offset) struct mtd_info *mtd; int err = 0; + if (ubi && ubi->mtd && !strcmp(ubi->mtd->name, part_name)) { + printf("UBI partition '%s' already selected\n", part_name); + return 0; + } + ubi_detach(); mtd_probe_devices(); -- 2.35.1