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 46D42C001B0 for ; Sun, 6 Aug 2023 17:53:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 92F8F8684C; Sun, 6 Aug 2023 19:52:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="JBIVZt0t"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5C5DB86835; Sun, 6 Aug 2023 19:52:53 +0200 (CEST) Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) (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 6643C8682B for ; Sun, 6 Aug 2023 19:52:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=clamor95@gmail.com Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-99c1f6f3884so556289066b.0 for ; Sun, 06 Aug 2023 10:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691344371; x=1691949171; 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=133KeprTV/vR0eagW5kUqY7IWB39BGwuNCAQ+zim7o4=; b=JBIVZt0tWNWEb6A6VCxx0cPpR33BJhRu5w5E/6sr/o6zps8Zhq+t8kjZEJujQhZS/E zfsOKOGY6SxkMeqRMnB1SV5lIsYyzfbidRLkRyqedw3ifVsW4v3hKjAjIbvX665CbCQX uL7IRs+ZcP057SNTxPFuAc6JsbkRgJcNv13PolBSTLh0hSU+O4udkgk34RLM1Lsl6rMn aymNu4TuHMQeO3TgQyKbwRMdAKH/epyBJH1kI3zdyhX0tQD6fZntZ+j8XIMfpZ5Vo5ly VjOVLiT12arrEkdEI1/uG491Jq5CArdpSsOhzp94LuhDUqMA4Opr4Ef5BYYKDjZXd0fO OTvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691344371; x=1691949171; 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=133KeprTV/vR0eagW5kUqY7IWB39BGwuNCAQ+zim7o4=; b=OxfnF+ZZet/2AeqGAef7urHKUuEPJ0EK987BOzO5M9hZNcVegDWE1H0SBK/wBYIQsI E5UTNSF/+CGBbiFEwIiVBIt91obEkfa7vmesINLYtPuJ1U8BvXpLglm8bCEC+s146DHo raLF+CqpqjwpDJV7pTSJLLXxfvpP2l55nzobHwWg4D3kJ9lixG7Hi7m2eSq2B78U1OIx Egg4JCGf543gnGurBTSwLqSoFZx5a5eCQuZydmJb2Zt+UEqqSsTNGzrF83tA9Dd8oDrJ od7tS/j7N1aZIKntEX9JYONu/ZxkZCcO20MHbfX8Ph1t9k9ZrdxuXuWIxlKHnGI0dFi0 1IIw== X-Gm-Message-State: AOJu0YyRZfELbqwXYWNMuKVXXMAd2RFYwkDGlyqa3AwsoRrpcaSu8pK8 ISqXIyNtvokiWQIiKtQ60as= X-Google-Smtp-Source: AGHT+IHOURngl8kdqAVGw2z7gO8YSXErsjJ8ZEZzRx7bB3su7uOnC0KfVEF6K+0pI9W4LMFrThLbNA== X-Received: by 2002:a17:906:3193:b0:99b:c2b2:e4ac with SMTP id 19-20020a170906319300b0099bc2b2e4acmr6809242ejy.33.1691344370948; Sun, 06 Aug 2023 10:52:50 -0700 (PDT) Received: from xeon.. ([188.163.112.48]) by smtp.gmail.com with ESMTPSA id la4-20020a170906ad8400b0099bd682f317sm4066454ejb.206.2023.08.06.10.52.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Aug 2023 10:52:50 -0700 (PDT) From: Svyatoslav Ryhel To: Jaehoon Chung , Simon Glass , Jonas Karlman , Svyatoslav Ryhel , Eugen Hristev , Patrice Chotard , John Keeping Cc: u-boot@lists.denx.de Subject: [PATCH v3 2/4] test: dm: regulator: test counter in set_enable_if_allowed test Date: Sun, 6 Aug 2023 20:52:22 +0300 Message-Id: <20230806175224.103002-3-clamor95@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230806175224.103002-1-clamor95@gmail.com> References: <20230806175224.103002-1-clamor95@gmail.com> 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.8 at phobos.denx.de X-Virus-Status: Clean Emulate use of the regulator by a few consumers with balanced on/off calls. Signed-off-by: Svyatoslav Ryhel --- test/dm/regulator.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/dm/regulator.c b/test/dm/regulator.c index 86f4862d9d..33115daaf5 100644 --- a/test/dm/regulator.c +++ b/test/dm/regulator.c @@ -194,6 +194,24 @@ int dm_test_power_regulator_set_enable_if_allowed(struct unit_test_state *uts) ut_assertok(regulator_set_enable_if_allowed(dev, val_set)); ut_asserteq(regulator_get_enable(dev), !val_set); + /* Set the Enable of LDO1 - default is disabled */ + platname = regulator_names[LDO1][PLATNAME]; + ut_assertok(regulator_get_by_platname(platname, &dev)); + ut_assertok(regulator_set_enable_if_allowed(dev, true)); + + /* Get the Enable state of LDO1 and compare it with the requested one */ + ut_asserteq(regulator_get_enable(dev), true); + + /* Emulate second consumer */ + ut_assertok(regulator_set_enable_if_allowed(dev, true)); + ut_asserteq(regulator_get_enable(dev), true); + + /* Emulate one of counsumers disable call */ + ut_assertok(regulator_set_enable_if_allowed(dev, false)); + + /* Regulator should still be on since counter indicates one consumer active */ + ut_asserteq(regulator_get_enable(dev), true); + return 0; } DM_TEST(dm_test_power_regulator_set_enable_if_allowed, UT_TESTF_SCAN_FDT); -- 2.39.2