From patchwork Fri Aug 17 18:20:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajagopal Venkat X-Patchwork-Id: 1339281 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A293F3FC81 for ; Fri, 17 Aug 2012 18:23:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758773Ab2HQSXg (ORCPT ); Fri, 17 Aug 2012 14:23:36 -0400 Received: from mail-gg0-f174.google.com ([209.85.161.174]:42130 "EHLO mail-gg0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758764Ab2HQSXf (ORCPT ); Fri, 17 Aug 2012 14:23:35 -0400 Received: by ggdk6 with SMTP id k6so4262410ggd.19 for ; Fri, 17 Aug 2012 11:23:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=he6K2p6OYbZ1YpyvJu+MSH9vb4ZQfBT53H18im4RDGY=; b=WdNFVu8e8t3RyCFKJFsay/Bb5s1NL1I5xDqg/ZxWXzEqZ3rs+6vgp0q2lKGoa1H4/Y 2AgbgHfT1MpzXXv8O/8s/UWWlAyrdGWXgQnC7rJKhQx/UubA5/zG4nTRSoOY+9znKyyq igpv4W1BE+6TbRzFhI/UNQhOHlLI1eFyyDXFDvtDagFuyFT2FDCuitIqVJx9bu30pblZ 6+gkpK6ttLdqinAvFW8/QkDnT4Z9G44po0xRfwWfGjqWn6PhlSaU0vaMCyRdS7r3rCgR 8tCsIiDvZZjorhy+oOS+ZHBj92N+LP3kYb6Zy7bRK7qCO/OjpsYR1tAQr2G6P9X9Mk9y zpXQ== Received: by 10.66.75.97 with SMTP id b1mr11459918paw.15.1345227813733; Fri, 17 Aug 2012 11:23:33 -0700 (PDT) Received: from localhost.localdomain ([115.241.125.74]) by mx.google.com with ESMTPS id uy3sm4739046pbc.29.2012.08.17.11.23.29 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 17 Aug 2012 11:23:33 -0700 (PDT) From: Rajagopal Venkat To: mturquette@linaro.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, rjw@sisk.pl Cc: patches@linaro.org, linaro-dev@lists.linaro.org, linux-pm@vger.kernel.org, Rajagopal Venkat Subject: [PATCH 3/3][RFC] devfreq: Add current freq callback in device profile Date: Fri, 17 Aug 2012 23:50:45 +0530 Message-Id: <1345227645-20703-4-git-send-email-rajagopal.venkat@linaro.org> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1345227645-20703-1-git-send-email-rajagopal.venkat@linaro.org> References: <1345227645-20703-1-git-send-email-rajagopal.venkat@linaro.org> X-Gm-Message-State: ALoCoQmvXXqGJ2My7KeW3Z30+6DcuvXhd3zyfCBgiXNNqY5jkgFLQVKOU/xlJKIoTQbmCoFiF/ew Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Devfreq returns governor predicted frequency as current frequency via sysfs interface. But device may not support all frequencies that governor predicts. As per the design its driver responsibility to maintain current frequency at which device is operating. So add a callback in device profile to fix this. Signed-off-by: Rajagopal Venkat --- drivers/devfreq/devfreq.c | 14 ++++++++++++-- include/linux/devfreq.h | 6 +++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 375b5aa1..798e8ca 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -176,7 +176,6 @@ struct devfreq *devfreq_add_device(struct device *dev, devfreq->dev.release = devfreq_dev_release; devfreq->profile = profile; devfreq->governor = governor; - devfreq->previous_freq = profile->initial_freq; devfreq->governor_data = data; devfreq->nb.notifier_call = devfreq_notifier_call; devfreq->min_freq = profile->min_freq; @@ -272,7 +271,18 @@ static ssize_t show_governor(struct device *dev, static ssize_t show_freq(struct device *dev, struct device_attribute *attr, char *buf) { - return sprintf(buf, "%lu\n", to_devfreq(dev)->previous_freq); + int ret; + unsigned long freq; + struct devfreq *devfreq = to_devfreq(dev); + + if (devfreq->profile->get_cur_freq) { + ret = devfreq->profile->get_cur_freq(devfreq->dev.parent, + &freq); + if (!ret) + return sprintf(buf, "%lu\n", freq); + } + + return sprintf(buf, ""); } static ssize_t store_min_freq(struct device *dev, struct device_attribute *attr, diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index 7c6517f..43f111f 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -76,6 +76,8 @@ struct devfreq_dev_status { * explained above with "DEVFREQ_FLAG_*" macros. * @get_dev_status The device should provide the current performance * status to devfreq, which is used by governors. + * @get_cur_freq The device should provide the current frequency + * at which it is operating. * @exit An optional callback that is called when devfreq * is removing the devfreq object due to error or * from devfreq_remove_device() call. If the user @@ -91,6 +93,7 @@ struct devfreq_dev_profile { int (*target)(struct device *dev, unsigned long *freq, u32 flags); int (*get_dev_status)(struct device *dev, struct devfreq_dev_status *stat); + int (*get_cur_freq)(struct device *dev, unsigned long *freq); void (*exit)(struct device *dev); }; @@ -119,7 +122,6 @@ struct devfreq_governor { * @nb notifier block used to notify devfreq object that it should * reevaluate operable frequencies. Devfreq users may use * devfreq.nb to the corresponding register notifier call chain. - * @previous_freq previously configured frequency value. * @governor_data Private data of the governor. The devfreq framework * does not touch this. * @min_freq Limit minimum frequency requested by user (0: none) @@ -142,8 +144,6 @@ struct devfreq { const struct devfreq_governor *governor; struct notifier_block nb; - unsigned long previous_freq; - void *governor_data; /* private data for governors */ unsigned long min_freq;