From: Chanwoo Choi <cw00.choi@samsung.com>
To: myungjoo.ham@samsung.com, kyungmin.park@samsung.com
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
Chanwoo Choi <cw00.choi@samsung.com>
Subject: [PATCH 3/6] PM / devfreq: Add show_one macro to delete the duplicate code
Date: Thu, 19 Nov 2015 17:17:47 +0900 [thread overview]
Message-ID: <1447921070-6045-4-git-send-email-cw00.choi@samsung.com> (raw)
In-Reply-To: <1447921070-6045-1-git-send-email-cw00.choi@samsung.com>
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
next prev parent reply other threads:[~2015-11-19 8:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 1/6] PM / devfreq: event: Remove the error log of devfreq_event_get_edev_by_phandle() Chanwoo Choi
2015-11-19 8:17 ` [PATCH 2/6] PM / devfreq: event: Fix the error and warning from script/checkpatch.pl Chanwoo Choi
2015-11-19 8:17 ` Chanwoo Choi [this message]
2015-11-19 8:17 ` [PATCH 4/6] PM / devfreq: Set the freq_table of devfreq device Chanwoo Choi
2015-11-19 8:17 ` [PATCH 5/6] PM / devfreq: Modify the indentation of trans_stat sysfs for readability Chanwoo Choi
2015-11-19 8:17 ` [PATCH 6/6] PM / devfreq: Set the min_freq and max_freq of devfreq device Chanwoo Choi
-- strict thread matches above, loose matches on Subject: below --
2015-11-23 6:33 [PATCH 3/6] PM / devfreq: Add show_one macro to delete the duplicate code MyungJoo Ham
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1447921070-6045-4-git-send-email-cw00.choi@samsung.com \
--to=cw00.choi@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox