From patchwork Thu Mar 3 05:40:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 63436 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2760691lbc; Wed, 2 Mar 2016 21:40:21 -0800 (PST) X-Received: by 10.66.250.163 with SMTP id zd3mr1088979pac.119.1456983621216; Wed, 02 Mar 2016 21:40:21 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id os6si24299068pab.214.2016.03.02.21.40.20; Wed, 02 Mar 2016 21:40:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751180AbcCCFkT (ORCPT + 11 others); Thu, 3 Mar 2016 00:40:19 -0500 Received: from mail-pa0-f42.google.com ([209.85.220.42]:35523 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750986AbcCCFkS (ORCPT ); Thu, 3 Mar 2016 00:40:18 -0500 Received: by mail-pa0-f42.google.com with SMTP id bj10so8274009pad.2 for ; Wed, 02 Mar 2016 21:40:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2POTF8eIzytqKoaUizIAmrm7u0QAA32lfhYzbLTJ0MA=; b=J05MWd2EfXZGp0Bjd5Oq4tF4HfsY0UhpMQzUir6WUjjFBoOIBq7Y7kgzOi7Nkouh5u /qSCka8RpxmmxrXa5EiDCNjFZvYN0mBUT0Ma+KUdyUn6yfHmCrnQtb6F7brIbOcTkJ5L RI3WbiQKmNvQUaFYYX6EQ4Dw0pDtEDdV6/Ehs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2POTF8eIzytqKoaUizIAmrm7u0QAA32lfhYzbLTJ0MA=; b=gRBKYqoW0Z4OUwGf147WpCxkzM97Hq7CWE0S+/6IkVcPQMB23TLMbaaY+gulYWDlge hfIHUim2b3VGJqZB+NEcVOowhsStopWOeALBonm+xuHa0oYYO9oFWm+9RAEnq0yMbiol jy1t5q8G2UBPb5ntJuRVi3aSPa5kHTIeZhE0yh89i1Z+fQVDSLxXmGlTmLKwVGg7w8pi OqDxpRyBkHKF0GL8HQM/eOp8VnnCJTjLMQORTZN7Zsp3rEzfjR554KCbBP8H0D6BKgXg 6Bw9JTLFcqVPpqmNro2UdeVUKNLOPB0zl1TFIXb1LSXo7nKIMbNQ7RsRzrARCOXhiE+5 vFvA== X-Gm-Message-State: AD7BkJIWK0i6DQRDWu0g1BAFmKv9YeKql3B8pMTmKEHCiqqrUrsPOqNmOxBT4X5mEdFvqmmy X-Received: by 10.66.97.101 with SMTP id dz5mr1105044pab.61.1456983618177; Wed, 02 Mar 2016 21:40:18 -0800 (PST) Received: from localhost ([122.171.118.240]) by smtp.gmail.com with ESMTPSA id w12sm56941950pfa.79.2016.03.02.21.40.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Mar 2016 21:40:17 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , srinivas.pandruvada@linux.intel.com, Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] cpufreq: acpi: Allow new dynamics attributes to be added to acpi_cpufreq_attr Date: Thu, 3 Mar 2016 11:10:05 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: <1456945994-5616-1-git-send-email-srinivas.pandruvada@linux.intel.com> References: <1456945994-5616-1-git-send-email-srinivas.pandruvada@linux.intel.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org acpi_cpufreq_attr contains at least one dynamically populated (removed) attribute today, cpb. But the code isn't friendly enough for new attributes to be populated in a similar way. Make some changes to allow new attributes to be easily added to the struct. Signed-off-by: Viresh Kumar --- Srinivas, This should make it easy for you to add another dynamic entry into the acpi_cpufreq_attr structure. drivers/cpufreq/acpi-cpufreq.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) -- 2.7.1.410.g6faf27b -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 59a7b380fbe2..c37617ddcc9e 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c @@ -866,7 +866,7 @@ static struct freq_attr *acpi_cpufreq_attr[] = { &cpufreq_freq_attr_scaling_available_freqs, &freqdomain_cpus, #ifdef CONFIG_X86_ACPI_CPUFREQ_CPB - &cpb, + NULL, /* Extra space for cpb if required */ #endif NULL, }; @@ -917,6 +917,7 @@ static void acpi_cpufreq_boost_exit(void) static int __init acpi_cpufreq_init(void) { + struct freq_attr **attr; int ret; if (acpi_disabled) @@ -932,6 +933,10 @@ static int __init acpi_cpufreq_init(void) if (ret) return ret; + /* Find first empty entry */ + for (attr = acpi_cpufreq_attr; *attr; attr++) + ; + #ifdef CONFIG_X86_ACPI_CPUFREQ_CPB /* this is a sysfs file with a strange name and an even stranger * semantic - per CPU instantiation, but system global effect. @@ -939,17 +944,11 @@ static int __init acpi_cpufreq_init(void) * only if configured. This is considered legacy code, which * will probably be removed at some point in the future. */ - if (!check_amd_hwpstate_cpu(0)) { - struct freq_attr **attr; - + if (check_amd_hwpstate_cpu(0)) + *attr++ = &cpb; + else pr_debug("CPB unsupported, do not expose it\n"); - for (attr = acpi_cpufreq_attr; *attr; attr++) - if (*attr == &cpb) { - *attr = NULL; - break; - } - } #endif acpi_cpufreq_boost_init();