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@linaro.org X-Patchwork-Id: 10792 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 30D0023E29 for ; Fri, 17 Aug 2012 18:23:36 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id D8998A18043 for ; Fri, 17 Aug 2012 18:23:35 +0000 (UTC) Received: by yhpp61 with SMTP id p61so4490211yhp.11 for ; Fri, 17 Aug 2012 11:23:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=he6K2p6OYbZ1YpyvJu+MSH9vb4ZQfBT53H18im4RDGY=; b=EjybPriCJgy4kQoslpvEeSvJPM5n7onvE8M3sg3xxT9hnfvBWOuty/okJ8jKGHYBlT GHZq7d0v6jPBZv2nmmLUn2jXXL55IDp4NEVfcZ6FjDobk5H+CxdAEwE0EF6BMLgNSFf/ I5EHQy/ZZYB+rByQ8OVKwkl4IYHQvhd048HLKEn6HTC/fb0/+lGY9BP1pAEDNRsP+8MG E2gCN6bP2tGW89jJ5j9ken0L5xC1ihX59Deu1JYLrAgwm16PhFSpPmHuLkk6aZmWNNA1 wkeppa1peS8hk0lO/BZows1F7JaJufToiM+SRL55R859zChTEKOX+wdLrXN4Vfe0MZZz TdXA== Received: by 10.50.10.201 with SMTP id k9mr2922312igb.28.1345227815186; Fri, 17 Aug 2012 11:23:35 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp123298igc; Fri, 17 Aug 2012 11:23:34 -0700 (PDT) Received: by 10.68.129.38 with SMTP id nt6mr13719274pbb.76.1345227814083; Fri, 17 Aug 2012 11:23:34 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id pp2si1745540pbc.46.2012.08.17.11.23.33 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 17 Aug 2012 11:23:34 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) smtp.mail=rajagopal.venkat@linaro.org Received: by mail-pb0-f50.google.com with SMTP id md12so4190900pbc.37 for ; Fri, 17 Aug 2012 11:23:33 -0700 (PDT) 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: ALoCoQmem7YcnC9jddyd6VSlnS34Z4E0sBVGjROTpEVcQXRPIj0vTriUV71fJZhXWZcE7SsZbQjo 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;