From patchwork Wed May 4 06:02:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 9010491 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 77F559F1C1 for ; Wed, 4 May 2016 06:08:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 61CF1202EC for ; Wed, 4 May 2016 06:08:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7092B2027D for ; Wed, 4 May 2016 06:08:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757292AbcEDGHw (ORCPT ); Wed, 4 May 2016 02:07:52 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:36152 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751378AbcEDGDQ (ORCPT ); Wed, 4 May 2016 02:03:16 -0400 Received: by mail-pa0-f52.google.com with SMTP id bt5so19915350pac.3; Tue, 03 May 2016 23:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JGNUQ7GqGHAT1W+SK0tKIk/0Ol4DwewrRBqat5YK0FA=; b=QuxGKPT7pqOhv/zPg+bYJUJrbzPE6WMZ3J/8EjwHDWdsFYSjbTSpeg3d1dlUq2KPy2 CIfsjXsIgU2uKJ2LXBnmknCqiJX67ihmaZWpdR0kWbCZBoeSPof/CagkjrU2WffDSypX tJHYHwD4FH7/M49QqS5I/3e7CytRy98dJS33HDLd6XaItXugNkYvsI5QKH4sc2wN8tox swGBUqphtZc8pn3Rp9/lUSQGYMmT4TT0t/uIf0hL8bi8bSif+Cm08l2Y66lmDZSWHzaI 4SUWTDkWHbWxBb7YaPp83ekdr39HpsPhg9SStstxEs68o+EBTwiWwcTsMXPlXVH6GMfF /oTA== 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=JGNUQ7GqGHAT1W+SK0tKIk/0Ol4DwewrRBqat5YK0FA=; b=gmythMg6Zdp9FSTEb89YUFSZcJ5LG2IVO/WkT7p/IbRVEVHkHNdXG+WazM2EsEsBHb kIrHhGxxFSoWx3FKJaS3sXF0+tJupQOY3CC9hsXog9cz4QieaSOSkeAryMoDLlx6m1Yr B3E2XVtBfUYMAgr6Q2LwrUWpFg9xA0w4GPXpB9dLjZ5NIDjvLsGSUkafP5MpIjBvuzH+ oSuH+dGHaThAmpfxAA9OlTdxQpbR5Iz4SsjRf60B0puzV7kqma//1FpunEaAAYoB75yW Vrq8oZ6vZEdJuAASVe9t6krzJrsWXOckJ+BQfCZSgZ33LDgA/xosA1ELBAnlFXJFPWW8 bN7g== X-Gm-Message-State: AOPr4FXtbVZt6zhXFd5N2wQFK6W5yFQhYAKtUs94BJP8/xg9/QXLfjCxXJfclx9Y1w+Dww== X-Received: by 10.66.55.101 with SMTP id r5mr9660328pap.146.1462341795997; Tue, 03 May 2016 23:03:15 -0700 (PDT) Received: from localhost ([2601:647:4203:c8e0:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id u2sm2649742pfi.26.2016.05.03.23.03.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 May 2016 23:03:15 -0700 (PDT) From: Eduardo Valentin To: Rui Zhang Cc: Linux PM , LKML , Eduardo Valentin Subject: [PATCH 15/31] thermal: core: split available_policies_show() Date: Tue, 3 May 2016 23:02:29 -0700 Message-Id: <1462341765-13268-16-git-send-email-edubezval@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1462341765-13268-1-git-send-email-edubezval@gmail.com> References: <1462341765-13268-1-git-send-email-edubezval@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch creates a helper to build a list of available governors. Cc: Zhang Rui Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin --- drivers/thermal/thermal_core.c | 35 ++++++++++++++++++++--------------- drivers/thermal/thermal_core.h | 1 + 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index b4772e7..93da7d9 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -721,6 +721,25 @@ exit: return ret; } +int thermal_build_list_of_policies(char *buf) +{ + struct thermal_governor *pos; + ssize_t count = 0; + ssize_t size = PAGE_SIZE; + + mutex_lock(&thermal_governor_lock); + + list_for_each_entry(pos, &thermal_governor_list, governor_list) { + size = PAGE_SIZE - count; + count += scnprintf(buf + count, size, "%s ", pos->name); + } + count += scnprintf(buf + count, size, "\n"); + + mutex_unlock(&thermal_governor_lock); + + return count; +} + /* sys I/F for thermal zone */ #define to_thermal_zone(_dev) \ @@ -974,21 +993,7 @@ static ssize_t available_policies_show(struct device *dev, struct device_attribute *devattr, char *buf) { - struct thermal_governor *pos; - ssize_t count = 0; - ssize_t size = PAGE_SIZE; - - mutex_lock(&thermal_governor_lock); - - list_for_each_entry(pos, &thermal_governor_list, governor_list) { - size = PAGE_SIZE - count; - count += scnprintf(buf + count, size, "%s ", pos->name); - } - count += scnprintf(buf + count, size, "\n"); - - mutex_unlock(&thermal_governor_lock); - - return count; + return thermal_build_list_of_policies(buf); } static ssize_t diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 5bb5101..b80847c 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -58,6 +58,7 @@ int thermal_register_governor(struct thermal_governor *); void thermal_unregister_governor(struct thermal_governor *); void thermal_zone_device_passive_update(struct thermal_zone_device *, int); int thermal_zone_device_set_policy(struct thermal_zone_device *, char *); +int thermal_build_list_of_policies(char *buf); #ifdef CONFIG_THERMAL_GOV_STEP_WISE int thermal_gov_step_wise_register(void);