Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1090719pxu; Wed, 2 Dec 2020 10:45:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBl1cE1grxoMdgtAr376gzLyR+Oo0V98zP666H5LJIzNjKqx/0O2Imk/R7bFsUMIFpDDIk X-Received: by 2002:aa7:ca41:: with SMTP id j1mr1306658edt.295.1606934750211; Wed, 02 Dec 2020 10:45:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606934750; cv=none; d=google.com; s=arc-20160816; b=gA6X/z8Iaoq5+GHf94/SQc+a0eMVTNgT8TCLJG8YkSoxWzKrdrxHXzm10K+3RUsvB+ ohEEryifGKetbuzmYM5h86vxZg8rVCp7aCmL7m7SNZAxOE/ZlT9+eEXxbC8Tw+cahig1 J26Zqesb+vJsDHiLtQ9JDay4AR/JtFt8hHpPP1BufJAjr7tHHEaKj8ZsNfGnWP1kT+K7 EVfzfu+rKL3K2S2sE/0f5N8sJQR1W9gTVMWH+fxxDE1DcIUKMSoyiXCISmz1OZ4CuxEq DthKiH107PUhRmaBOXeZBZfsde3EGzFwBjFLy1AS3nKGf12jB47bVCGd3UeJKMJFKLPq t+Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cK6AK8VTndq2WNu92SDcRQLBfLwMiV+V214MHUEgg2w=; b=hpjzEPwdzOUaPvebD0ER5vLUegR97DeCI7UOUTOmTyW9jnYj7pwKMNsm+wM2nnUtfW tiBj+qWAu0+no88VqPOc+x8eJUN0yi5fJ2Ki3IXVouslfEkTaNHX5QbpuseIEefXHO9C PMG2fxtU57DNT2ppmHjlsA3bZi9sIsJGT9HOuSZruSL5Rgkd+K3X2dAQahT+wJKntzDP 0fTAfSOZLjOCY2sOYB7I5cH3sdzHkKsU18pG1JsBqwAoqUpTcUs5LcQAGTK2QiTwKV7b UW6wuh6kD+iZd1xTIaNNt0CbGgEtVrjSo1sQ63EEGxgorjmNkRMlBZ5mRQZiSiusfi2h 0Xng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Xf/f5iL7"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m1si481467eja.95.2020.12.02.10.45.27; Wed, 02 Dec 2020 10:45:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Xf/f5iL7"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729000AbgLBSmw (ORCPT + 99 others); Wed, 2 Dec 2020 13:42:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731006AbgLBSmv (ORCPT ); Wed, 2 Dec 2020 13:42:51 -0500 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7813C061A4B for ; Wed, 2 Dec 2020 10:41:39 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id k14so5174731wrn.1 for ; Wed, 02 Dec 2020 10:41:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cK6AK8VTndq2WNu92SDcRQLBfLwMiV+V214MHUEgg2w=; b=Xf/f5iL7f+U7uWYo68hnex0nqviSfyrK8iju0quGui/JaXe3jHIb4ayRSem4PO/dq2 lJGlb+3oWwRKdmbaF5MTjSBGA1a/nZ3DnuYAFU0VXkg3XJeK83UY1px90mjbi3yXR1Mb iM4vVVqC7wOJlGnKkNBM4fXDzNbk9nKHDjGpETmTOggyBJ43ISHXgf96DSwHeZ+e19Zg qzN5AGHZoq4l2bC1PF4CKHiN+laTlUEI/0jdRvB/GCkrYMSfiNf9DuMdmu6iUyf28J74 kWyZuBuapoYx8SF7rQXnFicabHz3K+IUHtgj2IDCOGeZb28eFFDsBHNzY2NUKlGXgXVv XqJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cK6AK8VTndq2WNu92SDcRQLBfLwMiV+V214MHUEgg2w=; b=tb9qBzBd+LCdP/fWHxi8jYH50276oiYAPpv50MiYDHIKuRQ+7/GkwdiKDc2YDysz22 R1ZNlBWR1JaNHjyQh3f+QRew1edvRbcQoTdlLvHRYgWsuemxpztYtEkffXIwqMxaXkV+ GfXVHNsH1fUiAckuEJScgXCwPBu0dn1UGVYsiWC5stSLb2cDtJd80evbKJEQaQRwSph+ hjuLGX3JIhaH+lHFHkS4gw9MNGAltRqjOpt12W7Nq4GBO1p8EpEHlEB3J2DxikZIi0kV K3u/2YaCB7G7ynJP+eTcRx2CKJZqpaKd1kRFlt14XEcFN1vOPj7kev5UZFN0enQzEKsg RGqA== X-Gm-Message-State: AOAM5312AejZJVqFmxmX2sR1CUB0MKN/M8mtvbG6D+Hql0ONKWLQ2nyB Rd8p4KPKRA4vuIxkWcEpEazoZA== X-Received: by 2002:adf:dd81:: with SMTP id x1mr5122600wrl.163.1606934498348; Wed, 02 Dec 2020 10:41:38 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:5ddd:b7c5:e3c9:e87a]) by smtp.gmail.com with ESMTPSA id z21sm2967184wmk.20.2020.12.02.10.41.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Dec 2020 10:41:37 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Cc: Jonathan Corbet , Catalin Marinas , Will Deacon , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Dennis Zhou , Tejun Heo , Christoph Lameter , Mark Rutland , Lorenzo Pieralisi , Sudeep Holla , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, David Brazdil Subject: [PATCH v4 05/26] psci: Replace psci_function_id array with a struct Date: Wed, 2 Dec 2020 18:41:01 +0000 Message-Id: <20201202184122.26046-6-dbrazdil@google.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201202184122.26046-1-dbrazdil@google.com> References: <20201202184122.26046-1-dbrazdil@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Small refactor that replaces array of v0.1 function IDs indexed by an enum of function-name constants with a struct of function IDs "indexed" by field names. This is done in preparation for exposing the IDs to other parts of the kernel. Exposing a struct avoids the need for bounds checking. Signed-off-by: David Brazdil --- drivers/firmware/psci/psci.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 13b9ed71b446..593fdd0e09a2 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -58,15 +58,14 @@ typedef unsigned long (psci_fn)(unsigned long, unsigned long, unsigned long, unsigned long); static psci_fn *invoke_psci_fn; -enum psci_function { - PSCI_FN_CPU_SUSPEND, - PSCI_FN_CPU_ON, - PSCI_FN_CPU_OFF, - PSCI_FN_MIGRATE, - PSCI_FN_MAX, +struct psci_0_1_function_ids { + u32 cpu_suspend; + u32 cpu_on; + u32 cpu_off; + u32 migrate; }; -static u32 psci_function_id[PSCI_FN_MAX]; +static struct psci_0_1_function_ids psci_0_1_function_ids; #define PSCI_0_2_POWER_STATE_MASK \ (PSCI_0_2_POWER_STATE_ID_MASK | \ @@ -178,7 +177,7 @@ static int __psci_cpu_suspend(u32 fn, u32 state, unsigned long entry_point) static int psci_0_1_cpu_suspend(u32 state, unsigned long entry_point) { - return __psci_cpu_suspend(psci_function_id[PSCI_FN_CPU_SUSPEND], + return __psci_cpu_suspend(psci_0_1_function_ids.cpu_suspend, state, entry_point); } @@ -198,7 +197,7 @@ static int __psci_cpu_off(u32 fn, u32 state) static int psci_0_1_cpu_off(u32 state) { - return __psci_cpu_off(psci_function_id[PSCI_FN_CPU_OFF], state); + return __psci_cpu_off(psci_0_1_function_ids.cpu_off, state); } static int psci_0_2_cpu_off(u32 state) @@ -216,7 +215,7 @@ static int __psci_cpu_on(u32 fn, unsigned long cpuid, unsigned long entry_point) static int psci_0_1_cpu_on(unsigned long cpuid, unsigned long entry_point) { - return __psci_cpu_on(psci_function_id[PSCI_FN_CPU_ON], cpuid, entry_point); + return __psci_cpu_on(psci_0_1_function_ids.cpu_on, cpuid, entry_point); } static int psci_0_2_cpu_on(unsigned long cpuid, unsigned long entry_point) @@ -234,7 +233,7 @@ static int __psci_migrate(u32 fn, unsigned long cpuid) static int psci_0_1_migrate(unsigned long cpuid) { - return __psci_migrate(psci_function_id[PSCI_FN_MIGRATE], cpuid); + return __psci_migrate(psci_0_1_function_ids.migrate, cpuid); } static int psci_0_2_migrate(unsigned long cpuid) @@ -548,22 +547,22 @@ static int __init psci_0_1_init(struct device_node *np) psci_ops.get_version = psci_0_1_get_version; if (!of_property_read_u32(np, "cpu_suspend", &id)) { - psci_function_id[PSCI_FN_CPU_SUSPEND] = id; + psci_0_1_function_ids.cpu_suspend = id; psci_ops.cpu_suspend = psci_0_1_cpu_suspend; } if (!of_property_read_u32(np, "cpu_off", &id)) { - psci_function_id[PSCI_FN_CPU_OFF] = id; + psci_0_1_function_ids.cpu_off = id; psci_ops.cpu_off = psci_0_1_cpu_off; } if (!of_property_read_u32(np, "cpu_on", &id)) { - psci_function_id[PSCI_FN_CPU_ON] = id; + psci_0_1_function_ids.cpu_on = id; psci_ops.cpu_on = psci_0_1_cpu_on; } if (!of_property_read_u32(np, "migrate", &id)) { - psci_function_id[PSCI_FN_MIGRATE] = id; + psci_0_1_function_ids.migrate = id; psci_ops.migrate = psci_0_1_migrate; } -- 2.29.2.454.gaff20da3a2-goog