From patchwork Fri Oct 23 08:52:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kovalivskyi X-Patchwork-Id: 1386601 X-Patchwork-Delegate: lukma@denx.de 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=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=globallogic.com header.i=@globallogic.com header.a=rsa-sha256 header.s=google header.b=N5o068VD; dkim-atps=neutral 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHdKd4SMvz9sT6 for ; Fri, 23 Oct 2020 19:52:53 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 61EAB82495; Fri, 23 Oct 2020 10:52:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.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=globallogic.com header.i=@globallogic.com header.b="N5o068VD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 81E2182483; Fri, 23 Oct 2020 10:52:41 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) (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 6469782456 for ; Fri, 23 Oct 2020 10:52:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=roman.kovalivskyi@globallogic.com Received: by mail-lj1-x235.google.com with SMTP id m20so736066ljj.5 for ; Fri, 23 Oct 2020 01:52:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=globallogic.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=HkvUySe+iCRfdnNXa33nZSOcvUAQrVd3W3lZ4uwNQBE=; b=N5o068VDrzJ5hqxn1hL4gfXDqmAkdKtKfQgQWhcd3YjToeL7FP3ocAMR3dIO2W82Jh CejABT6TK4oFDlBpJ24AFZFRAuPnBNwNT4gGMQuobZjLU9sAEfwOchhjPI94TMmfsB3t c8hQQnZhURw9EnizWT1RsjuUzxRMFW2Pjgm6D8Ucuwg7BmCjle8frXuJN3cPvGDEYYMS utU+4svxvvYuFvTYnrv2De3/9hdjlhv6OjsKdMAo73vOY4BzWm8iaiJifsfHbg653Vr7 O+T7UUv+9rt3Oi0zP5c3qm0TEggsu5PFKVKNuVfn1+EI2cHZKj6fYlvNyj3pO0+nagjO 4qkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=HkvUySe+iCRfdnNXa33nZSOcvUAQrVd3W3lZ4uwNQBE=; b=qZr/8X6MtxUZV/W+eEiEZf4w7WRv4aV2FqYG0ySi/KYhwOyV6A11bAP7dedrOj4kag DBSUKl6r5yWKHAGxlzeWuvI5RoCZuxt53ZJfq5zBjq35gCIWPZoC3osRW7mEwTCY3ZNC zNMOKxOyPST054XZ+lXSlF3es/fMTcn4RNVeAUwfY1qWQmBDkKrwM1hqasMx2K/TIjGN mJlwKruYhfn+i76SdCSbv5BU6nqB2s+G0M96jTi3dIfNm4skRpkEvS++/QEZG6Ljp8YB 4VNanCworJRm4DU6+g1Iyh1HhDmb8CiycRE6kIx6hYbREZXfspP5OB2yyl5PrxTv58uI H8iw== X-Gm-Message-State: AOAM532kmg2Hmlg6QTU12EvlcMVsSG9AIHRJqOmUJKlnlo1XfIB+b/Me kBySoUGPkJYzGoykdnTaNpfZQ2z8v4v62Q== X-Google-Smtp-Source: ABdhPJy5l/KvtymgezSP5r1+UreiNRa9O/WW6niXYqB0hDSyvOaV6EMZwKDbJ7nE0cWcYRBn8qOlJw== X-Received: by 2002:a05:651c:112c:: with SMTP id e12mr493543ljo.42.1603443157551; Fri, 23 Oct 2020 01:52:37 -0700 (PDT) Received: from user-HP-ZBook-14u-G4.synapse.com ([159.224.5.60]) by smtp.googlemail.com with ESMTPSA id f184sm74564lfd.253.2020.10.23.01.52.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 01:52:37 -0700 (PDT) From: Roman Kovalivskyi To: u-boot@lists.denx.de Cc: Roman Stratiienko , Joe Hershberger , Roman Kovalivskyi , Simon Glass , Marek Vasut , Lukasz Majewski , Eugeniu Rosca , Alex Kiernan , Sam Protsenko , Neil Armstrong , Philipp Tomsich , Kever Yang , Paul Kocialkowski , Lokesh Vutla , Jagan Teki , Miquel Raynal , Boris Brezillon , Tom Rini , Igor Opaniuk , Aleksandr Bulyshchenko Subject: [RESEND 1/7] cmd: bcb: Extract '__bcb_load' from 'do_bcb_load' for internal needs Date: Fri, 23 Oct 2020 11:52:19 +0300 Message-Id: <267a7467167c43abb1e72c08df7a0c07cd20b6fa.1603442753.git.roman.kovalivskyi@globallogic.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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 From: Eugeniu Rosca Enriching the functionality of U-Boot 'bcb' may assume using the existing sub-commands as building blocks for the next ones. A clean way to achive the above is to expose a number of static routines, each mapped to an existing user command (e.g. load/set/store), with a user/caller-friendly prototype (i.e. do not force the caller to wrap an integer into a string). This first patch makes '__bcb_load' available for internal needs. No functional change, except for a tiny update in error handling. Signed-off-by: Eugeniu Rosca Signed-off-by: Roman Kovalivskyi --- cmd/bcb.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/cmd/bcb.c b/cmd/bcb.c index e03218066bf2..2ed8b801a3e2 100644 --- a/cmd/bcb.c +++ b/cmd/bcb.c @@ -110,8 +110,7 @@ static int bcb_field_get(char *name, char **fieldp, int *sizep) return 0; } -static int do_bcb_load(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]) +static int __bcb_load(int devnum, const char *partp) { struct blk_desc *desc; struct disk_partition info; @@ -119,17 +118,19 @@ static int do_bcb_load(struct cmd_tbl *cmdtp, int flag, int argc, char *endp; int part, ret; - ret = blk_get_device_by_str("mmc", argv[1], &desc); - if (ret < 0) + desc = blk_get_devnum_by_type(IF_TYPE_MMC, devnum); + if (!desc) { + ret = -ENODEV; goto err_read_fail; + } - part = simple_strtoul(argv[2], &endp, 0); + part = simple_strtoul(partp, &endp, 0); if (*endp == '\0') { ret = part_get_info(desc, part, &info); if (ret) goto err_read_fail; } else { - part = part_get_info_by_name(desc, argv[2], &info); + part = part_get_info_by_name(desc, partp, &info); if (part < 0) { ret = part; goto err_read_fail; @@ -151,10 +152,10 @@ static int do_bcb_load(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_SUCCESS; err_read_fail: - printf("Error: mmc %s:%s read failed (%d)\n", argv[1], argv[2], ret); + printf("Error: mmc %d:%s read failed (%d)\n", devnum, partp, ret); goto err; err_too_small: - printf("Error: mmc %s:%s too small!", argv[1], argv[2]); + printf("Error: mmc %d:%s too small!", devnum, partp); goto err; err: bcb_dev = -1; @@ -163,6 +164,20 @@ err: return CMD_RET_FAILURE; } +static int do_bcb_load(struct cmd_tbl *cmdtp, int flag, int argc, + char * const argv[]) +{ + char *endp; + int devnum = simple_strtoul(argv[1], &endp, 0); + + if (*endp != '\0') { + printf("Error: Device id '%s' not a number\n", argv[1]); + return CMD_RET_FAILURE; + } + + return __bcb_load(devnum, argv[2]); +} + static int do_bcb_set(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { From patchwork Fri Oct 23 08:52:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kovalivskyi X-Patchwork-Id: 1386602 X-Patchwork-Delegate: lukma@denx.de 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=globallogic.com header.i=@globallogic.com header.a=rsa-sha256 header.s=google header.b=Wfnd39z+; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHdKr0GLkz9sT6 for ; Fri, 23 Oct 2020 19:53:03 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3097D824A5; Fri, 23 Oct 2020 10:52:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.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=globallogic.com header.i=@globallogic.com header.b="Wfnd39z+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E5E7082495; Fri, 23 Oct 2020 10:52:43 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) (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 A196C8245F for ; Fri, 23 Oct 2020 10:52:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=roman.kovalivskyi@globallogic.com Received: by mail-lf1-x142.google.com with SMTP id 77so1169123lfl.2 for ; Fri, 23 Oct 2020 01:52:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=globallogic.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=WUudbUgqZTxFfi9mrdvNvTJcZ8u4SLL6h6HtxkUa4Co=; b=Wfnd39z+pYQ8Aoo6irDSN3Fi2zGr7SqXQz2E4uiyckuLRbSVy4TmRB1Cly2tv15OZO b4cldw5tvLnVtflMgFX+Ts2k89ejiokN8l61sC+Bx386ZdXL1k4lucgtnfUmc9fiMCdU GrGNmDilW6HPIwizZ+CpWFjp0+u8wyt6vetyh9m+5QiaLJeO56q2k/ViCpXpyHbHmxZy 7TfJuenM2+d22QB7vxBMSbC8+ecIjVOLAa/O0S5qrV72F/6NlyJjBnVW4SYY1VM9fnbk 0q/Nx9Hml5+UMW6pysmyt3PIFreUsJvoWEmu0UBbe131WrE8a5+fyKGIe6mvbwzl3lRJ jsRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=WUudbUgqZTxFfi9mrdvNvTJcZ8u4SLL6h6HtxkUa4Co=; b=fQlb/efmP6ouHoxRcGZP/zNSsWfEl00KP659fm2BtiMEuY/UT9SXkxT2Ykq3yG80lm GyXzVQUq78pjO+Qrbo0RI4U+dkLVPiW0WilwxTiEATGs4Eqcv4uvUKFLjx1rc1AkSmri 31tN2Sfippi0nnfIJjyj7IwYbfmx9KXsjVx1xB2rYniuE0vRC66BTvLKgh1iu+WehVuh ROyPD+nBZ03LMqCu27xNcZhu3ERVLajx7OyrzyrBxxxIPDe3nAlB2VSZdBQHGAPkmaBw 9hbTW30q39OkqiJ1CT9ZAuxcHy8TRgcg0He+Hh44jgoqNxXzac/QINuKNp0O2QcIpoAP D7sg== X-Gm-Message-State: AOAM530imwZ6evW8erYb1aLIQpbMk36KxVCwfxez2QvLGHSl2B/1g+v+ eDEAQ8iCpfn35TCR8B8/49QdnHxQ6tfS2g== X-Google-Smtp-Source: ABdhPJxIlVnsmZ520t2v/FTzONCVMCgiIeX8xTRk/Stl0YaW5cvFN7wTfBhpr7Bo2nu6ddlR+LxwCA== X-Received: by 2002:ac2:521a:: with SMTP id a26mr394118lfl.10.1603443159651; Fri, 23 Oct 2020 01:52:39 -0700 (PDT) Received: from user-HP-ZBook-14u-G4.synapse.com ([159.224.5.60]) by smtp.googlemail.com with ESMTPSA id f184sm74564lfd.253.2020.10.23.01.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 01:52:39 -0700 (PDT) From: Roman Kovalivskyi To: u-boot@lists.denx.de Cc: Roman Stratiienko , Joe Hershberger , Roman Kovalivskyi , Simon Glass , Marek Vasut , Lukasz Majewski , Eugeniu Rosca , Alex Kiernan , Sam Protsenko , Neil Armstrong , Philipp Tomsich , Kever Yang , Paul Kocialkowski , Lokesh Vutla , Jagan Teki , Miquel Raynal , Boris Brezillon , Tom Rini , Igor Opaniuk , Aleksandr Bulyshchenko Subject: [RESEND 2/7] cmd: bcb: Extract '__bcb_set' from 'do_bcb_set' for internal needs Date: Fri, 23 Oct 2020 11:52:20 +0300 Message-Id: <849dd7dfb983184258d179d03d11cdfd99015c7d.1603442753.git.roman.kovalivskyi@globallogic.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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 From: Eugeniu Rosca Enriching the functionality of U-Boot 'bcb' may assume using the existing sub-commands as building blocks for the next ones. A clean way to achive the above is to expose a number of static routines, each mapped to an existing user command (e.g. load/set/store), with a user/caller-friendly prototype (i.e. do not force the caller to wrap an integer into a string). This second patch makes '__bcb_set' available for internal needs. No functional change intended. Signed-off-by: Eugeniu Rosca Signed-off-by: Roman Kovalivskyi --- cmd/bcb.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cmd/bcb.c b/cmd/bcb.c index 2ed8b801a3e2..113f04ffe6b2 100644 --- a/cmd/bcb.c +++ b/cmd/bcb.c @@ -178,22 +178,21 @@ static int do_bcb_load(struct cmd_tbl *cmdtp, int flag, int argc, return __bcb_load(devnum, argv[2]); } -static int do_bcb_set(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]) +static int __bcb_set(char *fieldp, char *valp) { int size, len; char *field, *str, *found; - if (bcb_field_get(argv[1], &field, &size)) + if (bcb_field_get(fieldp, &field, &size)) return CMD_RET_FAILURE; - len = strlen(argv[2]); + len = strlen(valp); if (len >= size) { printf("Error: sizeof('%s') = %d >= %d = sizeof(bcb.%s)\n", - argv[2], len, size, argv[1]); + valp, len, size, fieldp); return CMD_RET_FAILURE; } - str = argv[2]; + str = valp; field[0] = '\0'; while ((found = strsep(&str, ":"))) { @@ -205,6 +204,12 @@ static int do_bcb_set(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_SUCCESS; } +static int do_bcb_set(struct cmd_tbl *cmdtp, int flag, int argc, + char * const argv[]) +{ + return __bcb_set(argv[1], argv[2]); +} + static int do_bcb_clear(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { From patchwork Fri Oct 23 08:52:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kovalivskyi X-Patchwork-Id: 1386603 X-Patchwork-Delegate: lukma@denx.de 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=globallogic.com header.i=@globallogic.com header.a=rsa-sha256 header.s=google header.b=S6oHIo2Z; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHdL35KRJz9sT6 for ; Fri, 23 Oct 2020 19:53:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ABAF28249C; Fri, 23 Oct 2020 10:52:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.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=globallogic.com header.i=@globallogic.com header.b="S6oHIo2Z"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 928E8824AE; Fri, 23 Oct 2020 10:52:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) (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 8911982473 for ; Fri, 23 Oct 2020 10:52:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=roman.kovalivskyi@globallogic.com Received: by mail-lf1-x143.google.com with SMTP id z2so1169571lfr.1 for ; Fri, 23 Oct 2020 01:52:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=globallogic.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=hxiltvW1+erURMOEpsPIng5+Fm2aTx8YH+2o9Q0wB3c=; b=S6oHIo2ZRz66aeWc8mGJ0gXtyxzTP7fUr3XnBibVQW6bvDcjxrrFEWRL4raLZosTiL icQmcHYqYFC68An7xJr0nDNcnh1GK8Nj8lXijOYlVKeAywaPa9pscIHWHk80BpqcUo5a N2i/uMRzbRaL7VOnEhVbqiNtUh+sSwxBw2pFpzWmbsm+3wXHglNJ81nCG/Y5d3luDeGC Trac1NWnULd/TeXBsLcbCwCJNqvxm5IobkTix1Ji1fHdLlMD6nIhU7xTJpg/DZ+uTcYI odBWPOnR1N0q3+xJqkBnVWTl9OzJJcBo2HSkfFSyWac8O1qZ2hK+bTmRmZNm8Lyoqc4P gYyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=hxiltvW1+erURMOEpsPIng5+Fm2aTx8YH+2o9Q0wB3c=; b=YoV+Ru6ANp54ZOG96aAATMx3U8ObIxBvEOYeWbnEVU1MSWuO6y60FGEdiRYJDF9us/ cR161wiD8q7tyAVjn8/rnlPFp1aYM0cBW5nJ08kwKVrrFquClpfCJwKzBDbKWHjdscdV 1tyWumw8CeN5W2ah0O/9/pu0/LvzVgOMNNYhDH+tkKoQDxiZTIrcI+HqBzwZ5R6YOsrA +P1g3mDACxs9+Wf3Wko/ycRcTDXhsr4g4APqeM2YPsrPslqebKxTk0vt2nI1+PwDkok4 PeWu61lUbDQVo084f90afMrWwM7tM+F0rWAgB2Nrq/Tycx/GLorwHAAR7z1NY7ZNI1JC gVVg== X-Gm-Message-State: AOAM530FB2lORNzylp4F01c7Ary37TpQV7nzJov1++txNh4gQvJJyf+u XYDNEbl1WB953q/GwDQSZuff4YnvjjO0LQ== X-Google-Smtp-Source: ABdhPJx+Am91SIggO+TPt69RiV1zft7wXlhdmPMJyQmD+bEVfyXrokvENiX0GYTWeRTzM4kyc46r6w== X-Received: by 2002:ac2:50c1:: with SMTP id h1mr385447lfm.333.1603443161593; Fri, 23 Oct 2020 01:52:41 -0700 (PDT) Received: from user-HP-ZBook-14u-G4.synapse.com ([159.224.5.60]) by smtp.googlemail.com with ESMTPSA id f184sm74564lfd.253.2020.10.23.01.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 01:52:41 -0700 (PDT) From: Roman Kovalivskyi To: u-boot@lists.denx.de Cc: Roman Stratiienko , Joe Hershberger , Roman Kovalivskyi , Simon Glass , Marek Vasut , Lukasz Majewski , Eugeniu Rosca , Alex Kiernan , Sam Protsenko , Neil Armstrong , Philipp Tomsich , Kever Yang , Paul Kocialkowski , Lokesh Vutla , Jagan Teki , Miquel Raynal , Boris Brezillon , Tom Rini , Igor Opaniuk , Aleksandr Bulyshchenko Subject: [RESEND 3/7] cmd: bcb: Extract '__bcb_store' from 'do_bcb_store' for internal needs Date: Fri, 23 Oct 2020 11:52:21 +0300 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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 From: Eugeniu Rosca Enriching the functionality of U-Boot 'bcb' may assume using the existing sub-commands as building blocks for the next ones. A clean way to achive the above is to expose a number of static routines, each mapped to an existing user command (e.g. load/set/store), with a user/caller-friendly prototype (i.e. do not force the caller to wrap an integer into a string). This third patch makes '__bcb_store' available for internal needs. No functional change intended. Signed-off-by: Eugeniu Rosca Signed-off-by: Roman Kovalivskyi --- cmd/bcb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/bcb.c b/cmd/bcb.c index 113f04ffe6b2..b9cd20ea3d56 100644 --- a/cmd/bcb.c +++ b/cmd/bcb.c @@ -270,8 +270,7 @@ static int do_bcb_dump(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_SUCCESS; } -static int do_bcb_store(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]) +static int __bcb_store(void) { struct blk_desc *desc; struct disk_partition info; @@ -302,6 +301,12 @@ err: return CMD_RET_FAILURE; } +static int do_bcb_store(struct cmd_tbl *cmdtp, int flag, int argc, + char * const argv[]) +{ + return __bcb_store(); +} + static struct cmd_tbl cmd_bcb_sub[] = { U_BOOT_CMD_MKENT(load, CONFIG_SYS_MAXARGS, 1, do_bcb_load, "", ""), U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 1, do_bcb_set, "", ""), From patchwork Fri Oct 23 08:52:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kovalivskyi X-Patchwork-Id: 1386604 X-Patchwork-Delegate: lukma@denx.de 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=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=globallogic.com header.i=@globallogic.com header.a=rsa-sha256 header.s=google header.b=KcWJ6NqJ; dkim-atps=neutral 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHdLJ597Vz9sT6 for ; Fri, 23 Oct 2020 19:53:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2681E824B5; Fri, 23 Oct 2020 10:52:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.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=globallogic.com header.i=@globallogic.com header.b="KcWJ6NqJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DB6AD824A7; Fri, 23 Oct 2020 10:52:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) (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 85A15824A5 for ; Fri, 23 Oct 2020 10:52:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=roman.kovalivskyi@globallogic.com Received: by mail-lf1-x141.google.com with SMTP id v6so1121793lfa.13 for ; Fri, 23 Oct 2020 01:52:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=globallogic.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=ajnNwgE6hVjzxy+z8ViYKl0ox3M5pbe0SbqpSY95SSU=; b=KcWJ6NqJZTa6ukFx4WQIFABYPWBRzDR8raJTfG74sh5I0MwHBzr1kF7m10qZZ+Dowi o7wTI2sMR7mBqzCXwSZvVdCM5DoKN9JJBuS1h5SOLYqn/BClOCoFUbWCNHwn+W+Sj8Ad 5Rk3eBSb/V8RRvMqgrXEyVaV2/ah1EuDJejemSlUEONEmKEkHUYjpPy7b8YV8BFMPNdb WWHA/mFR1Vm1tbqNqEBonJhdrJ09xiaq0dkCGa5plIttR+9SCPJBDes49agpRpRBHDcr MIZSVjLUOmJyaz3Z5VMAE0UUAGAvSaWChfGyjhvG9Gw7rBFTwex8o+g8nGiEbg2JaSpO HxlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=ajnNwgE6hVjzxy+z8ViYKl0ox3M5pbe0SbqpSY95SSU=; b=c00S9Iv4JFD8qgWYfLjuOs8fGRmn33wKgt2FMTbI8HzvIAL62x9bnIdUi4DCSDy6wo klRog3cIYRD9G5b34fKWB5p6VS44GRqIGZ5nE2ZMHNb0h0Qxxv7Q/ay1Pedotgo+FDat zCh6x+FbPvorh+vb07RkGwFd8wpdmoFBGUyBc+E0xrJ44pwJAmkkEJZTL8FdtsmGcWHA 1wysGcPdZvN1T62Wfooig+PS95XecsdRdQFoDg3G2jtSDMLfTDODIsx7SNYvsM31zorP 3jLL8I39jWv4MsoD32FE7dSQWZAQaj9haqOi1I0cXf2NYNFkn8zSQJjNDbZQhwzTHFLe 7THw== X-Gm-Message-State: AOAM530KZbi2RIecS0F5dagFwmTuuYvzVzrxsrw2YLW1A9M0LoOEA9g5 K89VJwosQlC6eHBcoxQdts0XrSB7w6LTCA== X-Google-Smtp-Source: ABdhPJwCcDavQZJkwvOmAlrcdpGLgGfkrzsMRLaE/MsXUvnOfrJd/LtYRb2aax6qaBO6tvdZ3TxDOQ== X-Received: by 2002:ac2:46f3:: with SMTP id q19mr454715lfo.271.1603443163625; Fri, 23 Oct 2020 01:52:43 -0700 (PDT) Received: from user-HP-ZBook-14u-G4.synapse.com ([159.224.5.60]) by smtp.googlemail.com with ESMTPSA id f184sm74564lfd.253.2020.10.23.01.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 01:52:43 -0700 (PDT) From: Roman Kovalivskyi To: u-boot@lists.denx.de Cc: Roman Stratiienko , Joe Hershberger , Roman Kovalivskyi , Simon Glass , Marek Vasut , Lukasz Majewski , Eugeniu Rosca , Alex Kiernan , Sam Protsenko , Neil Armstrong , Philipp Tomsich , Kever Yang , Paul Kocialkowski , Lokesh Vutla , Jagan Teki , Miquel Raynal , Boris Brezillon , Tom Rini , Igor Opaniuk , Aleksandr Bulyshchenko Subject: [RESEND 4/7] cmd: bcb: Expose 'bcb_write_reboot_reason' to external callers Date: Fri, 23 Oct 2020 11:52:22 +0300 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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 From: Eugeniu Rosca Fastboot is evolving and beginning with commit [1], the upstream implementation expects bootloaders to offer support for: - reboot-recovery - reboot-fastboot The most natural way to achieve the above is through a set of pre-defined "reboot reason" strings, written into / read from the BCB "command" field, e.g.: - bootonce-bootloader [2] - boot-fastboot [3] - boot-recovery [4] Expose the first 'bcb' API meant to be called by e.g. fastboot stack, to allow updating the BCB reboot reason via the BCB 'command' field. [1] https://android.googlesource.com/platform/system/core/+/dea91b4b5354af2 ("Add fastbootd.") [2] https://android.googlesource.com/platform/bootable/recovery/+/cba7fa88d8b9 ("Add 'reboot bootloader' to bootloader_message.") [3] https://android.googlesource.com/platform/bootable/recovery/+/eee4e260f9f6 ("recovery: Add "boot-fastboot" command to BCB.") [4] https://android.googlesource.com/platform/system/core/+/5e98b633a748695f ("init: Write the reason in BCB on "reboot recovery"") Signed-off-by: Eugeniu Rosca Signed-off-by: Roman Kovalivskyi --- cmd/bcb.c | 20 ++++++++++++++++++++ include/bcb.h | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 include/bcb.h diff --git a/cmd/bcb.c b/cmd/bcb.c index b9cd20ea3d56..5da3526142ad 100644 --- a/cmd/bcb.c +++ b/cmd/bcb.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -307,6 +308,25 @@ static int do_bcb_store(struct cmd_tbl *cmdtp, int flag, int argc, return __bcb_store(); } +int bcb_write_reboot_reason(int devnum, char *partp, char *reasonp) +{ + int ret; + + ret = __bcb_load(devnum, partp); + if (ret != CMD_RET_SUCCESS) + return ret; + + ret = __bcb_set("command", reasonp); + if (ret != CMD_RET_SUCCESS) + return ret; + + ret = __bcb_store(); + if (ret != CMD_RET_SUCCESS) + return ret; + + return 0; +} + static struct cmd_tbl cmd_bcb_sub[] = { U_BOOT_CMD_MKENT(load, CONFIG_SYS_MAXARGS, 1, do_bcb_load, "", ""), U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 1, do_bcb_set, "", ""), diff --git a/include/bcb.h b/include/bcb.h new file mode 100644 index 000000000000..9b662d1203a6 --- /dev/null +++ b/include/bcb.h @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2020 Eugeniu Rosca + * + * Android Bootloader Control Block Header + */ + +#ifndef __BCB_H__ +#define __BCB_H__ + +#if CONFIG_IS_ENABLED(CMD_BCB) +int bcb_write_reboot_reason(int devnum, char *partp, char *reasonp); +#else +static inline int bcb_write_reboot_reason(int devnum, char *partp, char *reasonp) +{ + return -EOPNOTSUPP; +} +#endif + +#endif /* __BCB_H__ */ From patchwork Fri Oct 23 08:52:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kovalivskyi X-Patchwork-Id: 1386605 X-Patchwork-Delegate: lukma@denx.de 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=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=globallogic.com header.i=@globallogic.com header.a=rsa-sha256 header.s=google header.b=exueNGXH; dkim-atps=neutral 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHdLb0C7nz9sTL for ; Fri, 23 Oct 2020 19:53:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7D2AE824C3; Fri, 23 Oct 2020 10:53:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.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=globallogic.com header.i=@globallogic.com header.b="exueNGXH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2572C8249C; Fri, 23 Oct 2020 10:52:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) (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 6743C824A9 for ; Fri, 23 Oct 2020 10:52:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=roman.kovalivskyi@globallogic.com Received: by mail-lf1-x142.google.com with SMTP id j30so1158910lfp.4 for ; Fri, 23 Oct 2020 01:52:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=globallogic.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=7n2nTAYuUVdM5hAGGUOVYoeb3GrTca79TNgAwBXZ0eM=; b=exueNGXH79Ibsd824fyRlIoYJgo4zOWPpcnpE3dT22Xs1yafYvkVALgbxjR3ay4Utf 56RhePtUH3JpRFVpKQ9E0JGbOZl8fk4vCPSXjVUWiQMdO62EsCxfYZYvO2GJIeDPWtOM 3im0U9cu3ofpUw2rP+kA5W01voK8e4uLpUsj43Ee7gSOW6VemJCi5chwi2jHH7mHkTHm Equ28CvBHINqUn2QDAduSgdOBWiLDzRUrBME0TiB1KXcJWD7vshfGBpviiALkdmN0QYP yOGlmACeV+prmNOQVtUwaJIK+dRn/3nznrQkDk1Fe8V0tn8ANSP2JqPcDjO2iTeZkpv2 A5+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=7n2nTAYuUVdM5hAGGUOVYoeb3GrTca79TNgAwBXZ0eM=; b=SYFEr+5csTxpBE1RCs0hoPx+YR9cUAMDhIbtid04SEI5dOrDxb++WqRUkzNCebBI4y PV1ltBi5Yfk1NPCfcOOnlqJzEokY3ibHVrWSY1yHsDBsxN+a8W1Ee0xYuGZGrTZUWNPf jl98E/QS3QJtjxwmz0hyFPDKY/H7Tf8/IuITChD1YDJSp5ekRxdYgkcyltImZxcX0lv2 K5IZkLZmEHpYaiLLXagze10ffDiFETNcJn478b0yv7WZvzC2Hp0klhUSmCc1wL7ogUol r9YGMkwhRlOtMJuYbXjNAOyv20DHH7mGKty/7ybCQCtrfMWrt+v5IEM49Q3Q7mAUyjAs 8KQg== X-Gm-Message-State: AOAM533TVNVvduh13ButXH/HKp2j/0gjEoGdDTNsxG2rnlYCquLA3Gdf Q+qlMtVl/oV0sVAK3jZxQt31/0iPbroBdg== X-Google-Smtp-Source: ABdhPJz9+1pZvWDkROUT+blE0I+CrvRl7GW6qVO57Rr4ihaI4LmccEJFgugnHoA+vqaLLhFWIRof4Q== X-Received: by 2002:ac2:5506:: with SMTP id j6mr386837lfk.290.1603443165558; Fri, 23 Oct 2020 01:52:45 -0700 (PDT) Received: from user-HP-ZBook-14u-G4.synapse.com ([159.224.5.60]) by smtp.googlemail.com with ESMTPSA id f184sm74564lfd.253.2020.10.23.01.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 01:52:45 -0700 (PDT) From: Roman Kovalivskyi To: u-boot@lists.denx.de Cc: Roman Stratiienko , Joe Hershberger , Roman Kovalivskyi , Simon Glass , Marek Vasut , Lukasz Majewski , Eugeniu Rosca , Alex Kiernan , Sam Protsenko , Neil Armstrong , Philipp Tomsich , Kever Yang , Paul Kocialkowski , Lokesh Vutla , Jagan Teki , Miquel Raynal , Boris Brezillon , Tom Rini , Igor Opaniuk , Aleksandr Bulyshchenko Subject: [RESEND 5/7] cmd: bcb: Add support for processing const string literals in bcb_set() Date: Fri, 23 Oct 2020 11:52:23 +0300 Message-Id: <08150c4e849814274b42ef69049d78a1cfadb777.1603442753.git.roman.kovalivskyi@globallogic.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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 From: Eugeniu Rosca On request/suggestion from Simon Glass back in May 22 2019 [1], the 'strsep' mechanism implemented in bcb_set() was set to work directly with user-provided argv strings, to avoid duplicating memory and for the sake of simpler implementation. However, since we recently exposed bcb_write_reboot_reason() API to be called by U-Boot fastboot, the idea is to be able to pass const string literals to this new BCB API, carrying the reboot reason. Since 'strsep' (just like its older/superseded sibling 'strtok') modifies the input string passed as parameter, BCB command in its current state would attempt to perform in-place modifications in a readonly string, which might lead to unexpected results. Fix the above with the cost of one dynamic memory allocation ('strdup'). This will also ensure no compiler warnings when passing string literals to bcb_write_reboot_reason(). [1] http://u-boot.10912.n7.nabble.com/PATCH-v2-0-2-Add-bcb-command-to-read-modify-write-Android-BCB-td369934i20.html#a370456 Cc: Simon Glass Signed-off-by: Eugeniu Rosca Signed-off-by: Roman Kovalivskyi --- cmd/bcb.c | 17 ++++++++++++----- include/bcb.h | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cmd/bcb.c b/cmd/bcb.c index 5da3526142ad..6b6f1e9a2f10 100644 --- a/cmd/bcb.c +++ b/cmd/bcb.c @@ -11,6 +11,7 @@ #include #include #include +#include enum bcb_cmd { BCB_CMD_LOAD, @@ -179,10 +180,10 @@ static int do_bcb_load(struct cmd_tbl *cmdtp, int flag, int argc, return __bcb_load(devnum, argv[2]); } -static int __bcb_set(char *fieldp, char *valp) +static int __bcb_set(char *fieldp, const char *valp) { int size, len; - char *field, *str, *found; + char *field, *str, *found, *tmp; if (bcb_field_get(fieldp, &field, &size)) return CMD_RET_FAILURE; @@ -193,14 +194,20 @@ static int __bcb_set(char *fieldp, char *valp) valp, len, size, fieldp); return CMD_RET_FAILURE; } - str = valp; + str = strdup(valp); + if (!str) { + printf("Error: Out of memory while strdup\n"); + return CMD_RET_FAILURE; + } + tmp = str; field[0] = '\0'; - while ((found = strsep(&str, ":"))) { + while ((found = strsep(&tmp, ":"))) { if (field[0] != '\0') strcat(field, "\n"); strcat(field, found); } + free(str); return CMD_RET_SUCCESS; } @@ -308,7 +315,7 @@ static int do_bcb_store(struct cmd_tbl *cmdtp, int flag, int argc, return __bcb_store(); } -int bcb_write_reboot_reason(int devnum, char *partp, char *reasonp) +int bcb_write_reboot_reason(int devnum, char *partp, const char *reasonp) { int ret; diff --git a/include/bcb.h b/include/bcb.h index 9b662d1203a6..9ef4928642ca 100644 --- a/include/bcb.h +++ b/include/bcb.h @@ -9,9 +9,9 @@ #define __BCB_H__ #if CONFIG_IS_ENABLED(CMD_BCB) -int bcb_write_reboot_reason(int devnum, char *partp, char *reasonp); +int bcb_write_reboot_reason(int devnum, char *partp, const char *reasonp); #else -static inline int bcb_write_reboot_reason(int devnum, char *partp, char *reasonp) +static inline int bcb_write_reboot_reason(int devnum, char *partp, const char *reasonp) { return -EOPNOTSUPP; } From patchwork Fri Oct 23 08:52:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kovalivskyi X-Patchwork-Id: 1386606 X-Patchwork-Delegate: lukma@denx.de 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=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=globallogic.com header.i=@globallogic.com header.a=rsa-sha256 header.s=google header.b=cFTe/V1J; dkim-atps=neutral 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHdLs4KJrz9sT6 for ; Fri, 23 Oct 2020 19:53:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0BBBE824CD; Fri, 23 Oct 2020 10:53:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.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=globallogic.com header.i=@globallogic.com header.b="cFTe/V1J"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 53E90824A9; Fri, 23 Oct 2020 10:52:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) (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 C91C882494 for ; Fri, 23 Oct 2020 10:52:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=roman.kovalivskyi@globallogic.com Received: by mail-lf1-x143.google.com with SMTP id z2so1169868lfr.1 for ; Fri, 23 Oct 2020 01:52:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=globallogic.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=IgC1K/x6jCNX5cB9+RyRFuPxa99sx7mS80LYraeNOZ8=; b=cFTe/V1Jr2SkJ6qJ9+gX+FlZNLbdmYFvoboCNXRZRIKE2hRVXWYxqr98YeSUhX5n/2 +M903TfIpA9/2Sk/PraFbndRNp7qZOgFCKUpxaIB8ZP2jMfw2S2uI8cqdiXT8qOeKHkn 4zqOlQ1pXpSj8lzpAoSpClr2dk9VZ6uOX0MyEkRNIun5U/GSu+eTDj9bI0DyMbVheIAB 3p9QFxY27AOMqhihE0/9ghWIyMpcIztZhqLdAfvaZRRxaiG2ReT3E9AuYnvD86kHVduk 0R+0eV4Oedv5yLUQsNcmgDymOOXEZ/Zw1JyuVIByt9f2j6ZhoQhbTaTjZ3QwF4u72U+L Z2Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=IgC1K/x6jCNX5cB9+RyRFuPxa99sx7mS80LYraeNOZ8=; b=nAAmvkHWmIJ0rgVftx7K7ayrG6q8sv4r1Uo1yAw/ji3CA1IzATyO8G9SjjVeRpok8W 2mLC3erCcD2SWamzM/DnK/Di5baMWStK2nARHuA+3b4iTdZofxSyGcO1A221JG/JJcUJ +/sxfmIxVY0Edg9xGiIHU/Ts3UOUSfMsYs/1/G+fRxHcrQzC7Y3NHwNuNIVyxaqjBZcr R6FuCbiRm3E5DajJy3o4I1PlcMHSLh5b8jF7EooaD/8diO4SrKb+PTmRbKG0BPTXhPoL udpYiOq2kpcAgbXBRRC+jMa/zLF/YYX0BM0Z6/l8fmNKs8kdYbkqYOgJ8P0IAoNXsHlH 5LOg== X-Gm-Message-State: AOAM531N8z2VgrIy2a0vDKN1BgqxnWOIXXZl2QG8Q7eV6DY6ZaZYYOBx Yu5oZYcD8xMmK5VSyjIsu6v66bBFgm7roA== X-Google-Smtp-Source: ABdhPJyLlvoL4nfCzV/KCy3htBfFoqnQzBA4emWAUokwUcpsO+MNSru9V+KPl6I9e6FAQEljAbFGew== X-Received: by 2002:a19:83c1:: with SMTP id f184mr374041lfd.97.1603443167684; Fri, 23 Oct 2020 01:52:47 -0700 (PDT) Received: from user-HP-ZBook-14u-G4.synapse.com ([159.224.5.60]) by smtp.googlemail.com with ESMTPSA id f184sm74564lfd.253.2020.10.23.01.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 01:52:47 -0700 (PDT) From: Roman Kovalivskyi To: u-boot@lists.denx.de Cc: Roman Stratiienko , Joe Hershberger , Roman Kovalivskyi , Simon Glass , Marek Vasut , Lukasz Majewski , Eugeniu Rosca , Alex Kiernan , Sam Protsenko , Neil Armstrong , Philipp Tomsich , Kever Yang , Paul Kocialkowski , Lokesh Vutla , Jagan Teki , Miquel Raynal , Boris Brezillon , Tom Rini , Igor Opaniuk , Aleksandr Bulyshchenko Subject: [RESEND 6/7] Revert "fastboot: Add default fastboot_set_reboot_flag implementation" Date: Fri, 23 Oct 2020 11:52:24 +0300 Message-Id: <3165953c704d49a53e933fa5b7a52c2bce6be802.1603442753.git.roman.kovalivskyi@globallogic.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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 This reverts commit 0ebf9842e56c5b8cb7cb1f990bb452cc14af6225. Current generic implementation of fastboot_set_reboot_flag is somewhat messy and requires some additional configuration option to be enabled besides CMD_BCB, so it reverts that implementtion in order to bring a new cleaner one. Next commit introduces new generic implementation of fastboot_set_reboot_flag. Signed-off-by: Roman Kovalivskyi --- drivers/fastboot/Kconfig | 12 ---------- drivers/fastboot/Makefile | 1 - drivers/fastboot/fb_bcb_impl.c | 43 ---------------------------------- include/fastboot.h | 9 ------- 4 files changed, 65 deletions(-) delete mode 100644 drivers/fastboot/fb_bcb_impl.c diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index 4352ba67a713..d4436dfc9173 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -165,18 +165,6 @@ config FASTBOOT_CMD_OEM_FORMAT relies on the env variable partitions to contain the list of partitions as required by the gpt command. -config FASTBOOT_USE_BCB_SET_REBOOT_FLAG - bool "Use BCB by fastboot to set boot reason" - depends on CMD_BCB && !ARCH_MESON && !ARCH_ROCKCHIP && !TARGET_KC1 && \ - !TARGET_SNIPER && !TARGET_AM57XX_EVM && !TARGET_DRA7XX_EVM - default y - help - Fastboot could implement setting of reboot reason in a generic fashion - via BCB commands. BCB commands are able to write reboot reason into - command field of boot control block. In general case it is sufficient - implementation if your platform supports BCB commands and doesn't - require any specific reboot reason handling. - endif # FASTBOOT endmenu diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile index 2b2c390fe4de..048af5aa8234 100644 --- a/drivers/fastboot/Makefile +++ b/drivers/fastboot/Makefile @@ -5,4 +5,3 @@ obj-y += fb_getvar.o obj-y += fb_command.o obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fb_mmc.o obj-$(CONFIG_FASTBOOT_FLASH_NAND) += fb_nand.o -obj-$(CONFIG_FASTBOOT_USE_BCB_SET_REBOOT_FLAG) += fb_bcb_impl.o diff --git a/drivers/fastboot/fb_bcb_impl.c b/drivers/fastboot/fb_bcb_impl.c deleted file mode 100644 index 89ec3601b6f6..000000000000 --- a/drivers/fastboot/fb_bcb_impl.c +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright 2020 GlobalLogic. - * Roman Kovalivskyi - */ - -#include -#include - -/** - * fastboot_set_reboot_flag() - Set flag to indicate reboot-bootloader - * - * Set flag which indicates that we should reboot into the bootloader - * following the reboot that fastboot executes after this function. - * - * This function should be overridden in your board file with one - * which sets whatever flag your board specific Android bootloader flow - * requires in order to re-enter the bootloader. - */ -int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason) -{ - char cmd[64]; - - if (reason >= FASTBOOT_REBOOT_REASONS_COUNT) - return -EINVAL; - - snprintf(cmd, sizeof(cmd), "bcb load %d misc", - CONFIG_FASTBOOT_FLASH_MMC_DEV); - - if (run_command(cmd, 0)) - return -ENODEV; - - snprintf(cmd, sizeof(cmd), "bcb set command %s", - fastboot_boot_cmds[reason]); - - if (run_command(cmd, 0)) - return -ENOEXEC; - - if (run_command("bcb store", 0)) - return -EIO; - - return 0; -} diff --git a/include/fastboot.h b/include/fastboot.h index 8e9ee80907df..b86b508e69fd 100644 --- a/include/fastboot.h +++ b/include/fastboot.h @@ -52,15 +52,6 @@ enum fastboot_reboot_reason { FASTBOOT_REBOOT_REASONS_COUNT }; -/** - * BCB boot commands - */ -static const char * const fastboot_boot_cmds[] = { - [FASTBOOT_REBOOT_REASON_BOOTLOADER] = "bootonce-bootloader", - [FASTBOOT_REBOOT_REASON_FASTBOOTD] = "boot-fastboot", - [FASTBOOT_REBOOT_REASON_RECOVERY] = "boot-recovery" -}; - /** * fastboot_response() - Writes a response of the form "$tag$reason". * From patchwork Fri Oct 23 08:52:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kovalivskyi X-Patchwork-Id: 1386607 X-Patchwork-Delegate: lukma@denx.de 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=globallogic.com header.i=@globallogic.com header.a=rsa-sha256 header.s=google header.b=jDKjDsVx; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHdM75jFbz9sT6 for ; Fri, 23 Oct 2020 19:54:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CD91E824DE; Fri, 23 Oct 2020 10:53:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.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=globallogic.com header.i=@globallogic.com header.b="jDKjDsVx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C7BEE824C2; Fri, 23 Oct 2020 10:52:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) (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 A14F5824A7 for ; Fri, 23 Oct 2020 10:52:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=roman.kovalivskyi@globallogic.com Received: by mail-lf1-x144.google.com with SMTP id d24so1142865lfa.8 for ; Fri, 23 Oct 2020 01:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=globallogic.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=peqSysT7oSF80qa5aHdugzVXAEIynmMmW1B98YJrJsM=; b=jDKjDsVx/UmbsycdXoK31xBfBtsBeDWI/yQWaIntyEDqw7sMD8Fjc+BTVWPqg3jzR+ sPwuTuGR+5BQX4eif+vaYkvh9ijNVuu4gKLVru5j72GaJbLuzMkQkimUMMU1d6w96g84 sjCzJnnpMcjnm4BmWz2kW38ut8SQOGTeltHxQrDgKBeqIG/H75IUtOo57hpJs0nP4nMW xJnjJMriYuUm68oHGoXpt01iSOurU28hrIIae0QGqxB31bCsWffCuvidoD+MxzZDKcaY YNbv39imxmtEysSVB42myiAvHsgvETORdMF9ig8oP0H5RqkbE70hG0IjnfC+LWxAsZno hCAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=peqSysT7oSF80qa5aHdugzVXAEIynmMmW1B98YJrJsM=; b=bCQAWJcsvd2lQeUGxwkgfHSHQBzJAeru6jzSnJlAVmCDzN/f2zP0/nos07IcXs/uU2 kiwXtXn5RvA7f1cLVoxWqV5rGFVzX0KQQtcQRuiVnFN30h9y9oz0F59dQzzsy4utSibI yTw8Xjbg0No2A5Q7QFkLno/XbIDsqUZw5OHOGkmvyAfuMXd7I/dOc0vZx6FX6FgrS85m S+VjNvic58iiMLrp/YJFonaJNYeJVhUY4sOOcNQsLBW+pispnngF8HAa4CUfxk6/CMbk St8HZifZ9oo1Q8pGSlKmz26kQwfl/mkAVOzt+5hIA7f4rLara5Gl7DA+8aQeT+sMsmF3 7GbQ== X-Gm-Message-State: AOAM530mG2yJhspulck6xCZPBS0xytQSluI/klnoPxk5991sNL9hG7Gf TdD8M6s+AP4lLus6jGMMYE30/k8zAso8hg== X-Google-Smtp-Source: ABdhPJwJQDgSj+TIkvXF61+hfn015mz3pg5Kr+73rs5D/gIrAXpHhbDqqw7bGE4QtsIztkV2E/1amA== X-Received: by 2002:ac2:4465:: with SMTP id y5mr386312lfl.437.1603443169693; Fri, 23 Oct 2020 01:52:49 -0700 (PDT) Received: from user-HP-ZBook-14u-G4.synapse.com ([159.224.5.60]) by smtp.googlemail.com with ESMTPSA id f184sm74564lfd.253.2020.10.23.01.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 01:52:49 -0700 (PDT) From: Roman Kovalivskyi To: u-boot@lists.denx.de Cc: Roman Stratiienko , Joe Hershberger , Roman Kovalivskyi , Simon Glass , Marek Vasut , Lukasz Majewski , Eugeniu Rosca , Alex Kiernan , Sam Protsenko , Neil Armstrong , Philipp Tomsich , Kever Yang , Paul Kocialkowski , Lokesh Vutla , Jagan Teki , Miquel Raynal , Boris Brezillon , Tom Rini , Igor Opaniuk , Aleksandr Bulyshchenko Subject: [RESEND 7/7] fastboot: Implement generic fastboot_set_reboot_flag Date: Fri, 23 Oct 2020 11:52:25 +0300 Message-Id: <56991dc2a425578649ae5dcbc02901cba800294d.1603442753.git.roman.kovalivskyi@globallogic.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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 It is possible to implement fastboot_set_reboot_flag in a generic way if BCB commands are turned on for a target. Using bcb_set_reboot_reason allows to do this by simply passing string with correct reboot reason that should be handled during next boot process. If BCB are turned off, then bcb_set_reboot_reason would simply return error, so it won't introduce any new behaviour for such targets. Signed-off-by: Roman Kovalivskyi --- drivers/fastboot/fb_common.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c index 736ce1cd024f..005dccf3c967 100644 --- a/drivers/fastboot/fb_common.c +++ b/drivers/fastboot/fb_common.c @@ -10,6 +10,7 @@ * Rob Herring */ +#include #include #include #include @@ -90,7 +91,16 @@ void fastboot_okay(const char *reason, char *response) */ int __weak fastboot_set_reboot_flag(enum fastboot_reboot_reason reason) { - return -ENOSYS; + static const char * const boot_cmds[] = { + [FASTBOOT_REBOOT_REASON_BOOTLOADER] = "bootonce-bootloader", + [FASTBOOT_REBOOT_REASON_FASTBOOTD] = "boot-fastboot", + [FASTBOOT_REBOOT_REASON_RECOVERY] = "boot-recovery" + }; + + if (reason >= FASTBOOT_REBOOT_REASONS_COUNT) + return -EINVAL; + + return bcb_write_reboot_reason(CONFIG_FASTBOOT_FLASH_MMC_DEV, "misc", boot_cmds[reason]); } /**