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 15F01C46467 for ; Sun, 8 Jan 2023 03:02:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5B39585691; Sun, 8 Jan 2023 03:57:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ALh11FVj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3986F85629; Sun, 8 Jan 2023 03:56:26 +0100 (CET) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5274585695 for ; Sun, 8 Jan 2023 03:51:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12e.google.com with SMTP id a9so2670386ilp.6 for ; Sat, 07 Jan 2023 18:51:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eEnHdESXNqePX4Rs8+GG1D6Pkea217yOJGhj6cvcIWQ=; b=ALh11FVjr9dbDxjDr3kE1JmggIMOcNB2RbzzkGIAK7lBR4ROnUHuDmz/KPrlf1Q7SV tdraxNb8gejAAzpjnpvC38rNgfg9dnJe5lvn5mUePAs5i7zYlsPKM8G6BCb2XXbq+AJy oMDa6tgugYhA7yaOsquY+gmCLkohAaeDCEjPI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eEnHdESXNqePX4Rs8+GG1D6Pkea217yOJGhj6cvcIWQ=; b=C6S+wK863bk6OHIM6felQE2BjMz3dbyVt7EeEge+yPlaPBnZ3sXvE4FxBdOPhhcDJ9 vB1/t1s0iN/VfIyhO7BVs0mDyAXdgKK155KYWrN38G6tN2zLIzrvogSZhv7riHmT/9rM JeuOttMcvgmEqtjwvRRH1Pt49pSaF6dU7qs0+lTxNxX8KYqXSHFWUJsDZg06UrArPVe/ 9ky8qsTFveUHtqJrKTOQBvf8+a9kODht6qjI+OMJNm6E2NLE+vDUtfP2j2lxcyoMrkHj naTwHNS5CLvkptc8nWXUiwXSEXKEqDf7FIyP4wXTl3w6zJx2mfTVkrrJh0rN4DnKJd6N 9aEQ== X-Gm-Message-State: AFqh2kq2r9k9bmBc7X8KL5S1HFnaKNQG5zRMAkyHoqeWO6vEHWciiDlg Oq4ZHzUshG85/Oe7kJV+JM2VhHe4ouF0Af01 X-Google-Smtp-Source: AMrXdXsWjR6GNKdN7QsV807yEghcyBwQ9eauahGEZfp0g96Bu3CK+d+OPOM8jHaCfc5eNR9s8WgS1g== X-Received: by 2002:a05:6e02:4a3:b0:30d:8f90:7ac4 with SMTP id e3-20020a056e0204a300b0030d8f907ac4mr4874185ils.1.1673146298861; Sat, 07 Jan 2023 18:51:38 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-71-56-217-229.hsd1.co.comcast.net. [71.56.217.229]) by smtp.gmail.com with ESMTPSA id c17-20020a92bd11000000b00302a00aaefasm1622174ile.26.2023.01.07.18.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Jan 2023 18:51:38 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH v2 63/71] extension: Refactor to allow non-command usage Date: Sat, 7 Jan 2023 19:50:39 -0700 Message-Id: <20230108025047.522240-64-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230108025047.522240-1-sjg@chromium.org> References: <20230108025047.522240-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.6 at phobos.denx.de X-Virus-Status: Clean The current extension code is designed to be used from commands. We want to add a boot driver which uses it. To help with this, split the code into the command processing and a function which actually does the scan. Really the extension code should be in common/ or use driver model, but this is a start. Signed-off-by: Simon Glass --- (no changes since v1) cmd/extension_board.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd/extension_board.c b/cmd/extension_board.c index f94abd612d5..f7685d47b8b 100644 --- a/cmd/extension_board.c +++ b/cmd/extension_board.c @@ -80,8 +80,7 @@ static int do_extension_list(struct cmd_tbl *cmdtp, int flag, return CMD_RET_SUCCESS; } -static int do_extension_scan(struct cmd_tbl *cmdtp, int flag, - int argc, char *const argv[]) +static int extension_scan(bool show) { struct extension *extension, *next; int extension_num; @@ -91,12 +90,23 @@ static int do_extension_scan(struct cmd_tbl *cmdtp, int flag, free(extension); } extension_num = extension_board_scan(&extension_list); + if (show && extension_num >= 0) + printf("Found %d extension board(s).\n", extension_num); + + /* either the number of extensions, or -ve for error */ + return extension_num; +} + +static int do_extension_scan(struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) +{ + int extension_num; + + extension_num = extension_scan(true); if (extension_num < 0) return CMD_RET_FAILURE; - printf("Found %d extension board(s).\n", extension_num); - return CMD_RET_SUCCESS; } -- 2.39.0.314.g84b9a713c41-goog