public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/6] PM / devfreq: Add show_one macro to delete the duplicate code
  2015-11-19  8:17 [PATCH 0/6] PM / devfreq: Clean code and add set the freq_table array Chanwoo Choi
@ 2015-11-19  8:17 ` Chanwoo Choi
  0 siblings, 0 replies; 2+ messages in thread
From: Chanwoo Choi @ 2015-11-19  8:17 UTC (permalink / raw)
  To: myungjoo.ham, kyungmin.park; +Cc: linux-kernel, linux-pm, Chanwoo Choi

This patch adds the 'show_one' macro to simplify the duplicate code
of both max_freq_show() and min_freq_show().

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
---
 drivers/devfreq/devfreq.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index ca848cc6a8fd..49fc7dcf664c 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -921,12 +921,6 @@ unlock:
 	return ret;
 }
 
-static ssize_t min_freq_show(struct device *dev, struct device_attribute *attr,
-			     char *buf)
-{
-	return sprintf(buf, "%lu\n", to_devfreq(dev)->min_freq);
-}
-
 static ssize_t max_freq_store(struct device *dev, struct device_attribute *attr,
 			      const char *buf, size_t count)
 {
@@ -953,13 +947,17 @@ unlock:
 	mutex_unlock(&df->lock);
 	return ret;
 }
-static DEVICE_ATTR_RW(min_freq);
 
-static ssize_t max_freq_show(struct device *dev, struct device_attribute *attr,
-			     char *buf)
-{
-	return sprintf(buf, "%lu\n", to_devfreq(dev)->max_freq);
+#define show_one(name)						\
+static ssize_t name##_show					\
+(struct device *dev, struct device_attribute *attr, char *buf)	\
+{								\
+	return sprintf(buf, "%lu\n", to_devfreq(dev)->name);	\
 }
+show_one(min_freq);
+show_one(max_freq);
+
+static DEVICE_ATTR_RW(min_freq);
 static DEVICE_ATTR_RW(max_freq);
 
 static ssize_t available_frequencies_show(struct device *d,
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 3/6] PM / devfreq: Add show_one macro to delete the duplicate code
@ 2015-11-23  6:33 MyungJoo Ham
  0 siblings, 0 replies; 2+ messages in thread
From: MyungJoo Ham @ 2015-11-23  6:33 UTC (permalink / raw)
  To: 최찬우, 박경민
  Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org

>   
>  This patch adds the 'show_one' macro to simplify the duplicate code
> of both max_freq_show() and min_freq_show().
> 
> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

Applied.

Thanks.

> ---
>  drivers/devfreq/devfreq.c | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-23  6:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-23  6:33 [PATCH 3/6] PM / devfreq: Add show_one macro to delete the duplicate code MyungJoo Ham
  -- strict thread matches above, loose matches on Subject: below --
2015-11-19  8:17 [PATCH 0/6] PM / devfreq: Clean code and add set the freq_table array Chanwoo Choi
2015-11-19  8:17 ` [PATCH 3/6] PM / devfreq: Add show_one macro to delete the duplicate code Chanwoo Choi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox