From patchwork Tue Mar 5 06:44:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 1908029 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TpmNM3PWVz23fC for ; Tue, 5 Mar 2024 17:48:03 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rhOad-0001F3-2h; Tue, 05 Mar 2024 06:47:51 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rhOZl-0000zy-49 for kernel-team@lists.ubuntu.com; Tue, 05 Mar 2024 06:46:57 +0000 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id F3B653F0F8 for ; Tue, 5 Mar 2024 06:46:56 +0000 (UTC) Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5679f32e6b5so60783a12.3 for ; Mon, 04 Mar 2024 22:46:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709621216; x=1710226016; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RxQu7gOni6/QMdrnzEyl8MvcHgH/eLauzOWKF3xqWKM=; b=YFLvEsvuz+Pu5kYnqyu99RJ1Y6CL0/m77r5v0vjaZnvCB6My/0kNujBxahRKt+C6Aa FPtTbrYRf4xCJgg9xj+2Wbs3mVnqUTjGFqKntend5kMsVMgUqZTeUHTJQY7E0P9nPXV6 uuRlZgUDG/Z+6y7oZtO9s53SPal7Rk8NWrPow5Uf8KQbk2o2r9T+Os6zqGeRm8C+O3jz MnsT2pBnR81IBimJQr/+fHUrB4RXxYiHZGyPfMEqL9K8gNr8uYpHGgFejdya+E9RmsJ4 XY1hpkggPWoifKL555XvqFA8FAgAlQm9BzSqUn/7nN41UCxGNsw83y81G1d6MaKsq9SZ coSA== X-Gm-Message-State: AOJu0YyDnf2hHUgT+rwKxArMP9p9rjvLEcIwQAvRGZVQqPCHOORMFe/3 ulGTjpmRShl9UXXy3FZovZBpG3yK1JtXJUOlPtCzuMJu4jaguZ106Eep04GEoB2sWPELGu0ibNc gvmAF4rkYdsb95WJEFW46Phh0wga5Qg21s/X2Dw02jw57vRicDiyowJnv9q/RkGhF7J/xhLoiFn GTiLPsB0LJfA== X-Received: by 2002:aa7:d597:0:b0:566:76e4:bafd with SMTP id r23-20020aa7d597000000b0056676e4bafdmr7882675edq.39.1709621216669; Mon, 04 Mar 2024 22:46:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEB5/q0LWUMkBu3Fmt4IVFrQBX9FmNp2e/eoTDqAXO40T55xIK/s77xH1cVnTVOTNn5ZsXwNw== X-Received: by 2002:aa7:d597:0:b0:566:76e4:bafd with SMTP id r23-20020aa7d597000000b0056676e4bafdmr7882667edq.39.1709621216384; Mon, 04 Mar 2024 22:46:56 -0800 (PST) Received: from localhost.localdomain (host-95-252-40-65.retail.telecomitalia.it. [95.252.40.65]) by smtp.gmail.com with ESMTPSA id i17-20020aa7c9d1000000b00567566227a5sm1784439edt.18.2024.03.04.22.46.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 22:46:56 -0800 (PST) From: Andrea Righi To: kernel-team@lists.ubuntu.com Subject: [N/U][PATCH 4/8] hwmon: (coretemp) Remove redundant pdata->cpu_map[] Date: Tue, 5 Mar 2024 07:44:08 +0100 Message-ID: <20240305064644.251754-5-andrea.righi@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240305064644.251754-1-andrea.righi@canonical.com> References: <20240305064644.251754-1-andrea.righi@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Zhang Rui BugLink: https://bugs.launchpad.net/bugs/2056126 pdata->cpu_map[] saves the mapping between cpu core id and the index in pdata->core_data[]. This is used to find the temp_data structure using cpu_core_id, by traversing the pdata->cpu_map[] array. But the same goal can be achieved by traversing the pdata->core_temp[] array directly. Remove redundant pdata->cpu_map[]. No functional change. Signed-off-by: Zhang Rui Link: https://lore.kernel.org/r/20240202092144.71180-8-rui.zhang@intel.com Signed-off-by: Guenter Roeck (cherry picked from commit 87eb801925a0a391dce0d7519eb1d45a9d7e0953 linux-next) Signed-off-by: Andrea Righi --- drivers/hwmon/coretemp.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index cdd1e069d5c1..29ee8e0c0fe9 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c @@ -96,7 +96,6 @@ struct temp_data { struct platform_data { struct device *hwmon_dev; u16 pkg_id; - u16 cpu_map[NUM_REAL_CORES]; struct ida ida; struct cpumask cpumask; struct temp_data *core_data[MAX_CORE_DATA]; @@ -517,7 +516,6 @@ static int create_core_data(struct platform_device *pdev, unsigned int cpu, if (index < 0) return index; - pdata->cpu_map[index] = topology_core_id(cpu); index += BASE_SYSFS_ATTR_NO; } @@ -696,7 +694,7 @@ static int coretemp_cpu_offline(unsigned int cpu) struct platform_device *pdev = coretemp_get_pdev(cpu); struct platform_data *pd; struct temp_data *tdata; - int i, indx = -1, target; + int i, target; /* No need to tear down any interfaces for suspend */ if (cpuhp_tasks_frozen) @@ -707,18 +705,16 @@ static int coretemp_cpu_offline(unsigned int cpu) if (!pd->hwmon_dev) return 0; - for (i = 0; i < NUM_REAL_CORES; i++) { - if (pd->cpu_map[i] == topology_core_id(cpu)) { - indx = i + BASE_SYSFS_ATTR_NO; + for (i = BASE_SYSFS_ATTR_NO; i < MAX_CORE_DATA; i++) { + if (pd->core_data[i] && pd->core_data[i]->cpu_core_id == topology_core_id(cpu)) break; - } } /* Too many cores and this core is not populated, just return */ - if (indx < 0) + if (i == MAX_CORE_DATA) return 0; - tdata = pd->core_data[indx]; + tdata = pd->core_data[i]; cpumask_clear_cpu(cpu, &pd->cpumask); @@ -729,7 +725,7 @@ static int coretemp_cpu_offline(unsigned int cpu) */ target = cpumask_any_and(&pd->cpumask, topology_sibling_cpumask(cpu)); if (target >= nr_cpu_ids) { - coretemp_remove_core(pd, indx); + coretemp_remove_core(pd, i); } else if (tdata && tdata->cpu == cpu) { mutex_lock(&tdata->update_lock); tdata->cpu = target;