From patchwork Thu Apr 6 20:07:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1766360 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::33f; helo=mail-wm1-x33f.google.com; envelope-from=swupdate+bncbcxploxj6ikrba6nxsqqmgqehtb2dqq@googlegroups.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20221208 header.b=p7F19/9Q; dkim-atps=neutral Received: from mail-wm1-x33f.google.com (mail-wm1-x33f.google.com [IPv6:2a00:1450:4864:20::33f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Pssx91jmbz1yZm for ; Fri, 7 Apr 2023 06:07:39 +1000 (AEST) Received: by mail-wm1-x33f.google.com with SMTP id bh19-20020a05600c3d1300b003ee93fac4a9sf20246102wmb.2 for ; Thu, 06 Apr 2023 13:07:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1680811652; cv=pass; d=google.com; s=arc-20160816; b=lkPnuDTlqnyCpznJI47RSyVI3Ln7h1fhjEp6hPh91QKxDM3p5yARf1iRdzQuT1AFvY Rjt93TLGQ1FBybHeFPrH97oFe5ZsfA7XUEu75nhwevBfJ+EhSPypGtVrb7ei4TPs9gOd H2sPLuQeUFzoSoUPYZXP73WWx9vbc+rFwxjKocWZqZnTfFftBtjUc+xqsFOyd3vG6vv8 R60Qj6uLUm/ZKKtLSucw0HRJlsgbKLg4nxFjR7Mxms+MvWuIlw7Uj2t18Xs8bFJCtR7u W/KhhACrCtEq5PH0DWEJ76WGuzZetxbamvcn/J4rJRbA6RC0ucDIrCqMORVc/55xmy9W Aakw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=2Lo6Lr2FSXoVjmUTj3U+BLMhTtT6MsHsJC6Nwo4ewDY=; b=h4Zs8VNYT0OJ8AtflW1Oq341IgIQf46cGEGHBLBrV7bkjmccvY+1GyPBBmp8NJNzAo 1o9UuPqpR+mgbh9ywk4C6Dx2CT8FgF5X/ABfTJTgzgT314uq71xdpMlxXWORAibyFgJj syDse92MRVfzGrUJObPC0OwVtS75td2D9WA+nv1NWj1a/mjk1mfDFE0DzYGxBZuDCiSO eIU3wCBTViYo81/DSEN/Qw+4BULk6T/X7/P4DisOwy/F+Y/IRU4Rn5gtwn8gl3e/+WIt pHDnipjjNBEmNjO4xVmcsNUZommI10A70pBX037Rz5LByc1hgczL0TMLhVsdXEbZR6Nb Xdug== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1680811652; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :sender:from:to:cc:subject:date:message-id:reply-to; bh=2Lo6Lr2FSXoVjmUTj3U+BLMhTtT6MsHsJC6Nwo4ewDY=; b=p7F19/9QNfjZkK+g4do3qrRcuuDagkU46AGLQqW9+EogVNPy9sYTIqvOoyogAeoc1E 9Sq/Wbjyt6PsSFOBfmuo9DzaxcErYlFHY6vkECk3xHCYRTM4DhnFc60taO4BXRFbGMgJ 9F2a6jAcnr523ASnUaavYcS6BbU9JjhW1GovWtwLMgAoc0I2kJKUF8rCibjUwLO68dxn tiY+eoO7ajrl4ZP3t2n2tbLRe0kwWq1NlN+AHVbdEUZAwchExRzD9BaSIV2WLNRaYyld mu1/aPtg2TDPIioRlrjQ64qrZ7N2U/lwI1OljUr7CIrtp3oIuEC+Uqm5ueYpxnTOaIPb ZHRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680811652; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=2Lo6Lr2FSXoVjmUTj3U+BLMhTtT6MsHsJC6Nwo4ewDY=; b=lLMif1x5re7vBAYZxLrd7yjcrWDolRoiVtt00A9F/juOTMElCMRBKwqV3/TzHC3mJb G0ppHbzyk4AkzkkEi6BLZr2efWcjhblKOykxMcRthPOkQfpQYOfWW4jgdlRspSVsbhOw i6XfRSPMWk2wCIY2bGGGq9zAARCuDjQQiIZ5QJkDpbG0CP0GcTj7my9IXpz6c7fIObr5 Da6wXQJjdiZjMTVj8FIAAGarEvbskADqGXtQ84R6NBz0iPzeTEdPHvfsg+c/jENXTZmt 4X3TfZqJAfvD46EEYqYy9/qDv+i466S/BWNXr7IL6pS21Y+eYPqOK6AMGmZfRCINV3Aj qajQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AAQBX9fqadRtMHSKoi6OSJFVBF/wiFRzcVIGK3+Xthed/1+ZLYWBn17S 9AyjFxBBdk0qk150jJ8Jyhk= X-Google-Smtp-Source: AKy350Y1rReTNDmJzzqWUVlqWcn6mn5YiMUzBXvWxqgZs0ydcRIqKk1VuC0J/qfcMGuMuPX19Zb0qA== X-Received: by 2002:a5d:5273:0:b0:2d2:4920:8019 with SMTP id l19-20020a5d5273000000b002d249208019mr2059950wrc.0.1680811652106; Thu, 06 Apr 2023 13:07:32 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:358f:b0:3ef:df3:1695 with SMTP id p15-20020a05600c358f00b003ef0df31695ls12701915wmq.1.-pod-canary-gmail; Thu, 06 Apr 2023 13:07:30 -0700 (PDT) X-Received: by 2002:a1c:f013:0:b0:3ed:29d9:56ae with SMTP id a19-20020a1cf013000000b003ed29d956aemr7847746wmb.6.1680811650775; Thu, 06 Apr 2023 13:07:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680811650; cv=none; d=google.com; s=arc-20160816; b=m64ixxX+BDeJ1mWi65qXLg2f1wgea9sL5MUXnLilPZegRNEVh2joHRZSTecEEMxS7g zTCz+5+08Xc26q7r+F7ludn7hvKlBJRUpufP9EqUyIyQTzQp5wSfvLOy5wXwCv4ANgOq fpqiIrZ2hT/ILeWYLW+mR/W+VxFuxCw2IEkQUYWnZ535qSiZEZ+azIn0316ELMREsTsz jGQAsLLZ8OJyN5ylhgCxHr+TZpLfiALp5zd85gHPISr1DVhiVW2TffqKtJ7CecHEoAaT 90+O9plX+MmJJBIK2+fnsZo6UbyBa+UVu5cM7RsKu8et04mEsvvTeqNVgOQz+5NN7ni+ s5nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=ttal6TbhfFYsSmmEXqaHJWeY4ms1VTZUYAWUNzBc+oM=; b=K0242rbFanDJlGvYX1aWKnrhD19HdZYV9/DjNa+xA9dDic9AX/sCVGmmIVNNpeDWnO DBCGU1bUZa/URaboVO4Tq/adsSBnlEGjdKw8f/vxRddk5UbiQKDBJdu85c/zQKLdh2QO /IBAOes+dvwEVF7ayi4UGCBncFuD8zRAveysIazdh1YruR+LOcte2C7zaW3G+3jyrHoP fHce97UCI8+BBN3Gb7pAjgJInSklsM3OqOS4KyyZVln4xAmevFte0EEu0l+Dm7nn01Cq bApjyvKmgiOITfqLga0Ve+VwC7DRYsJozjSfAvCydTbVAodJhZpdwYqnbPXv99vX7CWh kH2w== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id p25-20020a05600c1d9900b003ede00b425fsi402646wms.1.2023.04.06.13.07.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Apr 2023 13:07:30 -0700 (PDT) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=2001:a60:0:28:0:1:25:1; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Psswy2JSMz1sB7H; Thu, 6 Apr 2023 22:07:30 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Psswy1jvQz1qqlS; Thu, 6 Apr 2023 22:07:30 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id v_gxHXECGrpG; Thu, 6 Apr 2023 22:07:29 +0200 (CEST) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Thu, 6 Apr 2023 22:07:29 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 2D37E4540BAA; Thu, 6 Apr 2023 22:07:29 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id lo4FewTKEzAv; Thu, 6 Apr 2023 22:07:25 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id C72594540792; Thu, 6 Apr 2023 22:07:25 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 1/3] progress: add function to increase number of steps Date: Thu, 6 Apr 2023 22:07:22 +0200 Message-Id: <20230406200724.1192395-1-sbabic@denx.de> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , It is not always possible to know the number of steps before updating. There are some cases where a handler can split the update in multiple single steps, calling a chained handler. A chained handler will update the progress as ususal, but this means that a single step is multiplied causing a total progress > 100%. Add a funtion to increase during the update the number of steps. Signed-off-by: Stefano Babic --- core/progress_thread.c | 7 +++++++ include/progress.h | 1 + 2 files changed, 8 insertions(+) diff --git a/core/progress_thread.c b/core/progress_thread.c index b8aa3ad..e7794e4 100644 --- a/core/progress_thread.c +++ b/core/progress_thread.c @@ -119,6 +119,13 @@ void swupdate_progress_init(unsigned int nsteps) { pthread_mutex_unlock(&pprog->lock); } +void swupdate_progress_addstep(void) { + struct swupdate_progress *pprog = &progress; + pthread_mutex_lock(&pprog->lock); + pprog->msg.nsteps++; + pthread_mutex_unlock(&pprog->lock); +} + void swupdate_progress_update(unsigned int perc) { struct swupdate_progress *pprog = &progress; diff --git a/include/progress.h b/include/progress.h index aa99ec8..11f1496 100644 --- a/include/progress.h +++ b/include/progress.h @@ -17,6 +17,7 @@ * as well as external use are defined in progress_ipc.h */ void swupdate_progress_init(unsigned int nsteps); +void swupdate_progress_addstep(void); void swupdate_progress_update(unsigned int perc); void swupdate_progress_inc_step(const char *image, const char *handler_name); void swupdate_progress_step_completed(void);