From patchwork Thu Apr 25 10:29:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1090674 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44qYSX5smDz9s3q for ; Thu, 25 Apr 2019 20:33:48 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 7998DC21E0D; Thu, 25 Apr 2019 10:32:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C3FC0C21E18; Thu, 25 Apr 2019 10:31:08 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 27F89C21C50; Thu, 25 Apr 2019 10:30:39 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by lists.denx.de (Postfix) with ESMTPS id 085ECC21E15 for ; Thu, 25 Apr 2019 10:30:38 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 44qYNs5yCWz1rJh3; Thu, 25 Apr 2019 12:30:37 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 44qYNs4NzMz1qyC7; Thu, 25 Apr 2019 12:30:37 +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 jP0ddnZf801L; Thu, 25 Apr 2019 12:30:36 +0200 (CEST) X-Auth-Info: e9p6QbnXKfSiXKNGkvtPgy8bvAH5cq4mYUqQXp0g+fE= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 25 Apr 2019 12:30:36 +0200 (CEST) From: Lukasz Majewski To: Stefano Babic , Fabio Estevam , Marek Vasut , Simon Glass , Tom Rini , u-boot@lists.denx.de, Jagan Teki , Peng Fan , Marcel Ziswiler , Adam Ford Date: Thu, 25 Apr 2019 12:29:51 +0200 Message-Id: <20190425102953.5348-10-lukma@denx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190425102953.5348-1-lukma@denx.de> References: <20190425102953.5348-1-lukma@denx.de> Subject: [U-Boot] [PATCH v3 09/11] clk: test: Provide unit test for clk_get_by_id() method X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This commit provides sandbox unit test for clk_get_by_id() method. To test it default test clocks setup had to be adjusted to emulate structure similar to clocks in the Common Clock Framework [CCF] (for iMX devices). The clk_get_by_id() relies on dev->driver_data having the pointer to struct clk. Signed-off-by: Lukasz Majewski --- Changes in v3: - New patch arch/sandbox/include/asm/clk.h | 8 ++++++++ drivers/clk/clk_sandbox_test.c | 23 +++++++++++++++++++++++ test/dm/clk.c | 3 ++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/arch/sandbox/include/asm/clk.h b/arch/sandbox/include/asm/clk.h index 2b1c49f783..90f925109f 100644 --- a/arch/sandbox/include/asm/clk.h +++ b/arch/sandbox/include/asm/clk.h @@ -63,6 +63,14 @@ int sandbox_clk_query_enable(struct udevice *dev, int id); */ int sandbox_clk_test_get(struct udevice *dev); /** + * sandbox_clk_test_get_by_id - Ask the sandbox clock test device to request its + * clocks by using clock id. + * + * @dev: The sandbox clock test (client) devivce. + * @return: 0 if OK, or a negative error code. + */ +int sandbox_clk_test_get_by_id(struct udevice *dev); +/** * sandbox_clk_test_get_bulk - Ask the sandbox clock test device to request its * clocks with the bulk clk API. * diff --git a/drivers/clk/clk_sandbox_test.c b/drivers/clk/clk_sandbox_test.c index e8465dbfad..4d276f55b9 100644 --- a/drivers/clk/clk_sandbox_test.c +++ b/drivers/clk/clk_sandbox_test.c @@ -34,6 +34,29 @@ int sandbox_clk_test_get(struct udevice *dev) return 0; } +int sandbox_clk_test_get_by_id(struct udevice *dev) +{ + struct sandbox_clk_test *sbct = dev_get_priv(dev); + struct clk *clkp, *i2c_clk; + ulong driver_data_bkp; + const int id = 24; + int ret, id_bkp; + + i2c_clk = &sbct->clks[SANDBOX_CLK_TEST_ID_I2C]; + + id_bkp = i2c_clk->id; + i2c_clk->id = id; + driver_data_bkp = i2c_clk->dev->driver_data; + i2c_clk->dev->driver_data = (ulong)i2c_clk; + + ret = clk_get_by_id(id, &clkp); + + i2c_clk->id = id_bkp; + i2c_clk->dev->driver_data = driver_data_bkp; + + return ret; +} + int sandbox_clk_test_get_bulk(struct udevice *dev) { struct sandbox_clk_test *sbct = dev_get_priv(dev); diff --git a/test/dm/clk.c b/test/dm/clk.c index 112d5cbbc9..8b858cee01 100644 --- a/test/dm/clk.c +++ b/test/dm/clk.c @@ -99,8 +99,9 @@ static int dm_test_clk(struct unit_test_state *uts) ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_SPI)); ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_I2C)); - ut_assertok(sandbox_clk_test_free(dev_test)); + ut_asserteq(0, sandbox_clk_test_get_by_id(dev_test)); + ut_assertok(sandbox_clk_test_free(dev_test)); return 0; } DM_TEST(dm_test_clk, DM_TESTF_SCAN_FDT);