From patchwork Tue Nov 22 17:42:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 9441733 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B77706075D for ; Tue, 22 Nov 2016 17:45:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE56B27DA4 for ; Tue, 22 Nov 2016 17:45:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A356E2859F; Tue, 22 Nov 2016 17:45:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2ACE128593 for ; Tue, 22 Nov 2016 17:45:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756225AbcKVRpC (ORCPT ); Tue, 22 Nov 2016 12:45:02 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:60384 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755568AbcKVRpA (ORCPT ); Tue, 22 Nov 2016 12:45:00 -0500 Received: from localhost ([127.0.0.1] helo=[127.0.1.1]) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1c9F51-0000Fm-Na; Tue, 22 Nov 2016 18:42:03 +0100 Message-Id: <20161122173731.680477115@linutronix.de> User-Agent: quilt/0.63-1 Date: Tue, 22 Nov 2016 17:42:03 -0000 From: Thomas Gleixner To: LKML Cc: Fenghua Yu , Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, Sebastian Siewior , Peter Zijlstra , x86@kernel.org Subject: [patch 3/6] hwmon/coretemp: Avoid redundant lookups References: <20161122173622.771252945@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline; filename=hwmon-coretemp--Avoid-redundant-lookups.patch Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP No point in looking up the same thing over and over. Signed-off-by: Thomas Gleixner --- drivers/hwmon/coretemp.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c @@ -533,21 +533,14 @@ static int create_core_data(struct platf return err; } -static void coretemp_add_core(unsigned int cpu, int pkg_flag) +static void +coretemp_add_core(struct platform_device *pdev, unsigned int cpu, int pkg_flag) { - struct platform_device *pdev = coretemp_get_pdev(cpu); - int err; - - if (!pdev) - return; - - err = create_core_data(pdev, cpu, pkg_flag); - if (err) + if (create_core_data(pdev, cpu, pkg_flag)) dev_err(&pdev->dev, "Adding Core %u failed\n", cpu); } -static void coretemp_remove_core(struct platform_data *pdata, - int indx) +static void coretemp_remove_core(struct platform_data *pdata, int indx) { struct temp_data *tdata = pdata->core_data[indx]; @@ -692,7 +685,7 @@ static void get_core_online(unsigned int * If so, add interfaces for pkgtemp. */ if (cpu_has(c, X86_FEATURE_PTS)) - coretemp_add_core(cpu, 1); + coretemp_add_core(pdev, cpu, 1); } pdata = platform_get_drvdata(pdev); @@ -701,7 +694,7 @@ static void get_core_online(unsigned int * interface for this CPU core. */ if (!cpumask_intersects(&pdata->cpumask, topology_sibling_cpumask(cpu))) - coretemp_add_core(cpu, 0); + coretemp_add_core(pdev, cpu, 0); cpumask_set_cpu(cpu, &pdata->cpumask); }