From patchwork Sat Feb 24 20:20:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 205932 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1308743dyb; Sat, 24 Feb 2024 12:26:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWs8sRaXMNldQJHtdub2mTWCjCk9QkGCFGWgn+EL45f8Vkv/UK18FZtfOoto1TINvQLTYP1E7zpAXxfVax8GWsAKmg40g== X-Google-Smtp-Source: AGHT+IGMo5cjYley1AuP2Ygycc1BzRYtUXZoOa4SYwKDo0KmfTFmeGiMy5S4Y9d1FWevUZ3ZKt1Z X-Received: by 2002:a17:902:f7c1:b0:1db:edb8:35d8 with SMTP id h1-20020a170902f7c100b001dbedb835d8mr2859377plw.34.1708806417014; Sat, 24 Feb 2024 12:26:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708806416; cv=pass; d=google.com; s=arc-20160816; b=SacN7qEcEsN/mNRzqsnr7NBZJrjQJaWno0slsZcFHk0huj62gNXzk3a8Vx8hYz6yxQ K0NVf4BT8h5yTJtZHZBJKI/yY1nuKgFXnG2s+7CGbmMzV/32kuS3wunVuUBF6QKCzzKg ztJoZrrtnfW1JuAxr1D3wc2rPk0BV8otXAiLfst0TiRHLFgFh4bHIk6/IjNUxvp3IP1z C94oNMRhqUDKHzMOR0S6wPleZ3mZGq/ignxtqrxvMloPYxPM6lLee5qI5ZhC/2bAwOuy BuZtruLQLq0GDC3RjpDkuR5Pd8wd+1cbz0JMK8iAZnL00h3wsv/FydPx0RuJb+J5LSjk 5VRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=S7KoDUleWCo5UKlQBGeeXR+YMlhweLkGTgyZVq03PTg=; fh=q8Iw2eL4XhEBnYDYnhxjCp0oYhjW7UIJh1rxTfw6QQo=; b=HpCxi/Tx8diumsxy7+Mx/KLTHVE6JKDmUJ12B20fOQfxwHgxiuJea/McUeVBzSJf/E 6auWk1xCP9XsbbhbkrpEc3dNqjw+sTRdvAXC9F7DsBq3p909WMq3bAi7sZTUD5uTD4mA WLcV7pnjqu5ghIe6++KjO4LVhqJHxt+GEK34YXKD8zE5zM9Uukf8SvcpnGuomGxbBu+H SKhnz/XXF5FiKtBs1R+pcu/awIXa8Y3NJtZOfkpphVyQu7ktWAmjQMNBszej+euycxpv 8lLlKdmllq3L2Jv48Bvl+DMldb7F7k3PzRbWVkoJldNGidUQENjUtrrGOzyrV/dgdHAU x4dQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qk5FAEkj; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-79842-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79842-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id u6-20020a170902e80600b001dbf6a7e767si1241175plg.59.2024.02.24.12.26.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 12:26:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79842-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qk5FAEkj; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-79842-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79842-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4E953B22815 for ; Sat, 24 Feb 2024 20:24:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5093254BE7; Sat, 24 Feb 2024 20:21:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Qk5FAEkj" Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1469D4EB5E for ; Sat, 24 Feb 2024 20:21:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708806064; cv=none; b=E5QIGfJ07KwPDn0YAfqiVoF1gk2jaoiO9QR5ZfPIHguCE1GW/J9MUeTpPk6+Nh97m88IPMFrAOOyjCGycA3fA/38+jmO97cW5dJe0PF+0ZscbOHkjiyrUybz+kp9iNvaFYb/jgUzrKuMHJ68+S6ULudfm4Gr51oS4P35I5xorv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708806064; c=relaxed/simple; bh=1ImW2IACKGUhYJ7/rOYdyKajWLj0N3ZFaS5Yy40Yw9Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o1ttbse0fLmiTiJ56KrxQCyyznrzB7EGhKsfLRAMALUsVj8OOb+f4AmLeXuNeloZljg2OUgGESS029i88nIbd/LFjRDzwN43ZzlZ4TXD6VB4rmSor4vIjhbiaZ02/o5JlSNiAmKlyMC8uBahJRTek4XuKRVyKPEiYx4ExQ+dm2A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Qk5FAEkj; arc=none smtp.client-ip=209.85.167.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-f169.google.com with SMTP id 5614622812f47-3c15b7b36bbso701630b6e.1 for ; Sat, 24 Feb 2024 12:21:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708806061; x=1709410861; darn=vger.kernel.org; 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=S7KoDUleWCo5UKlQBGeeXR+YMlhweLkGTgyZVq03PTg=; b=Qk5FAEkjrBHH8HlHdVAu9FwzTs1OZcvOlRjeq5hHbGEDMWbAVC0Rp+UsrP/uA1dkIO hNDPTPu3Nzi1ochSmYgkPuibYyOwknfrwgAWLo+GcMkIJ3ww52EaRN7zW10zBvJOXnLw 6sn4JAKxYdgsYWqLbV66W8cAfNaxHcdHl9KhMK3UluqNeTAGSZjPQsy+u5WToBiCn1Kl A+4sAwb0uJeKLVQrpskgly/cLXxMFvASYGOc1UsownmtMX0iFQQ1CWyDwvN/Ih7psvJb Iab/NmG4IVxl/FYoOz4Jsc2xKwkSzGO+2VXMxnMb+6pyage8G8KKFKJG+s4RP9LcVEtr bZLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708806061; x=1709410861; 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=S7KoDUleWCo5UKlQBGeeXR+YMlhweLkGTgyZVq03PTg=; b=gU+ljraBFH8KRDPbvBp2esETHEVO3wQ26ysdAacjhLVaWqklfuSWVUzHszQGnEFwd+ P0ZlXtlfD52e8r3Kutwi2p2ByR6HmL9u8NcLKFDSRjl+Vemjg/vbkaM9zUH/UYkoUQXf bqNHs4LKXDF4E0UskN2l2h715jwMKjPpjXb0Pyz50aEuYQDTSe0jJssuWJgOnWw2x8Vm qbOdTS7oy7x/G+qIDsFWpLk5DgAB/II0f1QZPjB+8ZO/cg7cHNIMXXiPinf+n6fvD5X6 QWsK265bjj0OyOR2jSgu6wNP7kMvs6G91sgOfl9map3hDEH85sGwJO60DfEFAG0tbtih v5vg== X-Forwarded-Encrypted: i=1; AJvYcCWn95CvaCiHpQNl+2XaP0b2ghBdAZKshLsmfAvNMPb4wijEIjJX+9MUhZTCL/0x/G270RYN/GwopDgQZE06USz4NTyZx5ORHN7GoONU X-Gm-Message-State: AOJu0Yzk4nqjOo/7pjn0zk20vpXmQbvZR4C9ptXSKwbIoTFBvCgyid+j 7Rt/pO+MmLxbvE0UPjaKiuxg7SwUbBQIE/6iRkryuvy9xkecoaAR6awhviq9Wg0= X-Received: by 2002:a05:6808:f88:b0:3c1:9c5b:74a7 with SMTP id o8-20020a0568080f8800b003c19c5b74a7mr119158oiw.17.1708806061101; Sat, 24 Feb 2024 12:21:01 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 22-20020aca0916000000b003c150705429sm382420oij.12.2024.02.24.12.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 12:21:00 -0800 (PST) From: Sam Protsenko To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley , Tomasz Figa , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 09/15] clk: samsung: Keep CPU clock chip specific data in a dedicated struct Date: Sat, 24 Feb 2024 14:20:47 -0600 Message-Id: <20240224202053.25313-10-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240224202053.25313-1-semen.protsenko@linaro.org> References: <20240224202053.25313-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791813397412940517 X-GMAIL-MSGID: 1791813397412940517 Keep chip specific data in the data structure, don't mix it with code. It makes it easier to add more chip specific data further. Having all chip specific data in the table eliminates possible code bloat when adding more rate handlers for new chips, and also makes it possible to keep some other chip related data in that array. No functional change. Signed-off-by: Sam Protsenko --- Changes in v3: - none Changes in v2: - Improved the commit message: explained why it's beneficial for new chips to keep chip-specific data in one table drivers/clk/samsung/clk-cpu.c | 40 +++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c index 635ab8cc54a2..eb2b67d08f89 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -43,6 +43,16 @@ struct exynos_cpuclk; typedef int (*exynos_rate_change_fn_t)(struct clk_notifier_data *ndata, struct exynos_cpuclk *cpuclk); +/** + * struct exynos_cpuclk_chip - Chip specific data for CPU clock + * @pre_rate_cb: callback to run before CPU clock rate change + * @post_rate_cb: callback to run after CPU clock rate change + */ +struct exynos_cpuclk_chip { + exynos_rate_change_fn_t pre_rate_cb; + exynos_rate_change_fn_t post_rate_cb; +}; + /** * struct exynos_cpuclk - information about clock supplied to a CPU core * @hw: handle between CCF and CPU clock @@ -55,8 +65,7 @@ typedef int (*exynos_rate_change_fn_t)(struct clk_notifier_data *ndata, * @clk_nb: clock notifier registered for changes in clock speed of the * primary parent clock * @flags: configuration flags for the CPU clock - * @pre_rate_cb: callback to run before CPU clock rate change - * @post_rate_cb: callback to run after CPU clock rate change + * @chip: chip-specific data for the CPU clock * * This structure holds information required for programming the CPU clock for * various clock speeds. @@ -70,9 +79,7 @@ struct exynos_cpuclk { const unsigned long num_cfgs; struct notifier_block clk_nb; unsigned long flags; - - exynos_rate_change_fn_t pre_rate_cb; - exynos_rate_change_fn_t post_rate_cb; + const struct exynos_cpuclk_chip *chip; }; /* ---- Common code --------------------------------------------------------- */ @@ -420,13 +427,24 @@ static int exynos_cpuclk_notifier_cb(struct notifier_block *nb, cpuclk = container_of(nb, struct exynos_cpuclk, clk_nb); if (event == PRE_RATE_CHANGE) - err = cpuclk->pre_rate_cb(ndata, cpuclk); + err = cpuclk->chip->pre_rate_cb(ndata, cpuclk); else if (event == POST_RATE_CHANGE) - err = cpuclk->post_rate_cb(ndata, cpuclk); + err = cpuclk->chip->post_rate_cb(ndata, cpuclk); return notifier_from_errno(err); } +static const struct exynos_cpuclk_chip exynos_clkcpu_chips[] = { + [CPUCLK_LAYOUT_E4210] = { + .pre_rate_cb = exynos_cpuclk_pre_rate_change, + .post_rate_cb = exynos_cpuclk_post_rate_change, + }, + [CPUCLK_LAYOUT_E5433] = { + .pre_rate_cb = exynos5433_cpuclk_pre_rate_change, + .post_rate_cb = exynos5433_cpuclk_post_rate_change, + }, +}; + /* helper function to register a CPU clock */ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx, const struct samsung_cpu_clock *clk_data) @@ -465,13 +483,7 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx, cpuclk->lock = &ctx->lock; cpuclk->flags = clk_data->flags; cpuclk->clk_nb.notifier_call = exynos_cpuclk_notifier_cb; - if (clk_data->reg_layout == CPUCLK_LAYOUT_E5433) { - cpuclk->pre_rate_cb = exynos5433_cpuclk_pre_rate_change; - cpuclk->post_rate_cb = exynos5433_cpuclk_post_rate_change; - } else { - cpuclk->pre_rate_cb = exynos_cpuclk_pre_rate_change; - cpuclk->post_rate_cb = exynos_cpuclk_post_rate_change; - } + cpuclk->chip = &exynos_clkcpu_chips[clk_data->reg_layout]; ret = clk_notifier_register(parent->clk, &cpuclk->clk_nb); if (ret) {