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 0A34DC433F5 for ; Mon, 9 May 2022 05:30:13 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C45A883E59; Mon, 9 May 2022 07:29:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.b="es1Lb+PM"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="aSTrQHmE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DB99B83F34; Mon, 9 May 2022 07:29:46 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 469A583DFE for ; Mon, 9 May 2022 07:29:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 803DE5C00DD; Mon, 9 May 2022 01:29:40 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 09 May 2022 01:29:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1652074180; x=1652160580; bh=XO ZOxLl+BMKoZtVH88eQ9UzMwTbd4+1FjutYfgzkgzI=; b=es1Lb+PM629QbOBwKK BGkHsjz2gyve4W9tREJ3WXFeqhgWNSessLpAjhvVrCmZXhs9+LQWOXHDrt9Ukpz/ aiqGa0pR2EUCSsFM2lZrO1x7fFIxBO21V0fr4FrcUbyM80dEDD5OAzgyPQZe+Apv dofyhgfddV0eB3EUhegZChtZZWpQIKvRhgMmnlO6ElMfPQNhcmimgZSBPOy+wd+I 2zRVKbfIf/SDNzuFDuplru+RylcBt+JJhMLohQi/HkZD983NE2UzQ0h7ARcJ85k7 oHaqkCOCD6/KmHjUrdGPfsl1LNByDbnblNLpfXdqlz5ob5IEclb30vgGVu+Pel0S Cxyw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1652074180; x=1652160580; bh=XOZOxLl+BMKoZtVH88eQ9UzMwTbd4+1Fjut YfgzkgzI=; b=aSTrQHmEbl0LUgGyNp9Kgz31YkbZdI4kepPjmyFypW0uoXAgIrY NQpeV/Ztg1KrNqmDYSeG0Ie4iKE+WdZafWSkqcdO8nq+G4y2fQ3rcSOguRGwGh0Q 3x0FQTEu5fTfw4AsyaZ7CnXpT6APOEliEhu4/UP6mpb6TdUXfky96ZT78l17mZ+1 HhSBUZr0RWeSxotXpB7OZDeJTSE1k6HGruxjb2Xo19L2v3p/1Ql9vur/2kUx4iyU cR3WV3XWCVkNDn0+8gYn4UfZZEoCOv//+867aJcvMuhQ5pxdaHU3y0/KoBJ4YrcO 1pAI1LLZkk17mnWEGj8/uvHb4zYkS+Qv4Qw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeekgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 9 May 2022 01:29:39 -0400 (EDT) From: Samuel Holland To: u-boot@lists.denx.de, Jagan Teki , Andre Przywara , Lukasz Majewski , Sean Anderson Cc: Samuel Holland , Bin Meng , Heinrich Schuchardt , Maxime Ripard Subject: [PATCH 1/7] clk: sunxi: Store the array sizes in the CCU descriptor Date: Mon, 9 May 2022 00:29:31 -0500 Message-Id: <20220509052937.42283-2-samuel@sholland.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220509052937.42283-1-samuel@sholland.org> References: <20220509052937.42283-1-samuel@sholland.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.5 at phobos.denx.de X-Virus-Status: Clean The reset array size is currently used for bounds checking in the reset driver. The same bounds check should really be done in the clock driver. Currently, the array size is provided to the reset driver separately from the CCU descriptor, which is a bit strange. Let's do this the usual way, with the array sizes next to the arrays themselves. Signed-off-by: Samuel Holland --- drivers/clk/sunxi/clk_a10.c | 2 ++ drivers/clk/sunxi/clk_a10s.c | 2 ++ drivers/clk/sunxi/clk_a23.c | 2 ++ drivers/clk/sunxi/clk_a31.c | 2 ++ drivers/clk/sunxi/clk_a31_r.c | 2 ++ drivers/clk/sunxi/clk_a64.c | 2 ++ drivers/clk/sunxi/clk_a80.c | 4 ++++ drivers/clk/sunxi/clk_a83t.c | 2 ++ drivers/clk/sunxi/clk_h3.c | 2 ++ drivers/clk/sunxi/clk_h6.c | 2 ++ drivers/clk/sunxi/clk_h616.c | 2 ++ drivers/clk/sunxi/clk_h6_r.c | 2 ++ drivers/clk/sunxi/clk_r40.c | 2 ++ drivers/clk/sunxi/clk_v3s.c | 2 ++ include/clk/sunxi.h | 2 ++ 15 files changed, 32 insertions(+) diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c index 90b929d3d3..6b58cffc8a 100644 --- a/drivers/clk/sunxi/clk_a10.c +++ b/drivers/clk/sunxi/clk_a10.c @@ -65,6 +65,8 @@ static struct ccu_reset a10_resets[] = { static const struct ccu_desc a10_ccu_desc = { .gates = a10_gates, .resets = a10_resets, + .num_gates = ARRAY_SIZE(a10_gates), + .num_resets = ARRAY_SIZE(a10_resets), }; static int a10_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c index addf4f4d5c..81b146ce1e 100644 --- a/drivers/clk/sunxi/clk_a10s.c +++ b/drivers/clk/sunxi/clk_a10s.c @@ -50,6 +50,8 @@ static struct ccu_reset a10s_resets[] = { static const struct ccu_desc a10s_ccu_desc = { .gates = a10s_gates, .resets = a10s_resets, + .num_gates = ARRAY_SIZE(a10s_gates), + .num_resets = ARRAY_SIZE(a10s_resets), }; static int a10s_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c index c45d2c3529..c7c78bc7d8 100644 --- a/drivers/clk/sunxi/clk_a23.c +++ b/drivers/clk/sunxi/clk_a23.c @@ -69,6 +69,8 @@ static struct ccu_reset a23_resets[] = { static const struct ccu_desc a23_ccu_desc = { .gates = a23_gates, .resets = a23_resets, + .num_gates = ARRAY_SIZE(a23_gates), + .num_resets = ARRAY_SIZE(a23_resets), }; static int a23_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c index 251fc3b705..c8c7f4ecf5 100644 --- a/drivers/clk/sunxi/clk_a31.c +++ b/drivers/clk/sunxi/clk_a31.c @@ -90,6 +90,8 @@ static struct ccu_reset a31_resets[] = { static const struct ccu_desc a31_ccu_desc = { .gates = a31_gates, .resets = a31_resets, + .num_gates = ARRAY_SIZE(a31_gates), + .num_resets = ARRAY_SIZE(a31_resets), }; static int a31_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a31_r.c b/drivers/clk/sunxi/clk_a31_r.c index 1f08ea956f..7bf1c4578c 100644 --- a/drivers/clk/sunxi/clk_a31_r.c +++ b/drivers/clk/sunxi/clk_a31_r.c @@ -31,6 +31,8 @@ static struct ccu_reset a31_r_resets[] = { static const struct ccu_desc a31_r_ccu_desc = { .gates = a31_r_gates, .resets = a31_r_resets, + .num_gates = ARRAY_SIZE(a31_r_gates), + .num_resets = ARRAY_SIZE(a31_r_resets), }; static int a31_r_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c index 1004a79503..6da861ddc1 100644 --- a/drivers/clk/sunxi/clk_a64.c +++ b/drivers/clk/sunxi/clk_a64.c @@ -76,6 +76,8 @@ static const struct ccu_reset a64_resets[] = { static const struct ccu_desc a64_ccu_desc = { .gates = a64_gates, .resets = a64_resets, + .num_gates = ARRAY_SIZE(a64_gates), + .num_resets = ARRAY_SIZE(a64_resets), }; static int a64_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a80.c b/drivers/clk/sunxi/clk_a80.c index 8a0834d83a..7025d3cbe6 100644 --- a/drivers/clk/sunxi/clk_a80.c +++ b/drivers/clk/sunxi/clk_a80.c @@ -75,11 +75,15 @@ static const struct ccu_reset a80_mmc_resets[] = { static const struct ccu_desc a80_ccu_desc = { .gates = a80_gates, .resets = a80_resets, + .num_gates = ARRAY_SIZE(a80_gates), + .num_resets = ARRAY_SIZE(a80_resets), }; static const struct ccu_desc a80_mmc_clk_desc = { .gates = a80_mmc_gates, .resets = a80_mmc_resets, + .num_gates = ARRAY_SIZE(a80_mmc_gates), + .num_resets = ARRAY_SIZE(a80_mmc_resets), }; static int a80_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c index 8c6043f51e..c50d253f84 100644 --- a/drivers/clk/sunxi/clk_a83t.c +++ b/drivers/clk/sunxi/clk_a83t.c @@ -73,6 +73,8 @@ static struct ccu_reset a83t_resets[] = { static const struct ccu_desc a83t_ccu_desc = { .gates = a83t_gates, .resets = a83t_resets, + .num_gates = ARRAY_SIZE(a83t_gates), + .num_resets = ARRAY_SIZE(a83t_resets), }; static int a83t_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c index 59afba53ee..22c2b236a8 100644 --- a/drivers/clk/sunxi/clk_h3.c +++ b/drivers/clk/sunxi/clk_h3.c @@ -89,6 +89,8 @@ static struct ccu_reset h3_resets[] = { static const struct ccu_desc h3_ccu_desc = { .gates = h3_gates, .resets = h3_resets, + .num_gates = ARRAY_SIZE(h3_gates), + .num_resets = ARRAY_SIZE(h3_resets), }; static int h3_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_h6.c b/drivers/clk/sunxi/clk_h6.c index 4a53788352..6521811215 100644 --- a/drivers/clk/sunxi/clk_h6.c +++ b/drivers/clk/sunxi/clk_h6.c @@ -90,6 +90,8 @@ static struct ccu_reset h6_resets[] = { static const struct ccu_desc h6_ccu_desc = { .gates = h6_gates, .resets = h6_resets, + .num_gates = ARRAY_SIZE(h6_gates), + .num_resets = ARRAY_SIZE(h6_resets), }; static int h6_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_h616.c b/drivers/clk/sunxi/clk_h616.c index af97d3bb9f..26f74c0fa0 100644 --- a/drivers/clk/sunxi/clk_h616.c +++ b/drivers/clk/sunxi/clk_h616.c @@ -108,6 +108,8 @@ static struct ccu_reset h616_resets[] = { static const struct ccu_desc h616_ccu_desc = { .gates = h616_gates, .resets = h616_resets, + .num_gates = ARRAY_SIZE(h616_gates), + .num_resets = ARRAY_SIZE(h616_resets), }; static int h616_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_h6_r.c b/drivers/clk/sunxi/clk_h6_r.c index b9e527e16a..fee9604551 100644 --- a/drivers/clk/sunxi/clk_h6_r.c +++ b/drivers/clk/sunxi/clk_h6_r.c @@ -35,6 +35,8 @@ static struct ccu_reset h6_r_resets[] = { static const struct ccu_desc h6_r_ccu_desc = { .gates = h6_r_gates, .resets = h6_r_resets, + .num_gates = ARRAY_SIZE(h6_r_gates), + .num_resets = ARRAY_SIZE(h6_r_resets), }; static int h6_r_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c index 4d5b69a976..456a38a159 100644 --- a/drivers/clk/sunxi/clk_r40.c +++ b/drivers/clk/sunxi/clk_r40.c @@ -100,6 +100,8 @@ static struct ccu_reset r40_resets[] = { static const struct ccu_desc r40_ccu_desc = { .gates = r40_gates, .resets = r40_resets, + .num_gates = ARRAY_SIZE(r40_gates), + .num_resets = ARRAY_SIZE(r40_resets), }; static int r40_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c index cce5c658ca..ab21cd791b 100644 --- a/drivers/clk/sunxi/clk_v3s.c +++ b/drivers/clk/sunxi/clk_v3s.c @@ -50,6 +50,8 @@ static struct ccu_reset v3s_resets[] = { static const struct ccu_desc v3s_ccu_desc = { .gates = v3s_gates, .resets = v3s_resets, + .num_gates = ARRAY_SIZE(v3s_gates), + .num_resets = ARRAY_SIZE(v3s_resets), }; static int v3s_clk_bind(struct udevice *dev) diff --git a/include/clk/sunxi.h b/include/clk/sunxi.h index a2239b990b..5471b9c831 100644 --- a/include/clk/sunxi.h +++ b/include/clk/sunxi.h @@ -65,6 +65,8 @@ struct ccu_reset { struct ccu_desc { const struct ccu_clk_gate *gates; const struct ccu_reset *resets; + u8 num_gates; + u8 num_resets; }; /** -- 2.35.1