From: Sudeep Holla <sudeep.holla@arm.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Sudeep Holla <sudeep.holla@arm.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
Lorenzo Pieralisi <Lorenzo.Pieralisi@arm.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH v5 02/11] topology: replace custom attribute macros with standard DEVICE_ATTR*
Date: Tue, 30 Sep 2014 14:48:23 +0100 [thread overview]
Message-ID: <1412084912-2767-3-git-send-email-sudeep.holla@arm.com> (raw)
In-Reply-To: <1412084912-2767-1-git-send-email-sudeep.holla@arm.com>
Currently couple of custom macros are defined to declare the
device attributes. However there are already standard macros
defined in device.h that suffice the need and these custom
macros can be removed.
This patch replaces custom attribute macros with standard
DEVICE_ATTR_RO attribute
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/base/topology.c | 53 ++++++++++++++++++++++---------------------------
1 file changed, 24 insertions(+), 29 deletions(-)
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index f7c353843ddf..6491f45200a7 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -29,57 +29,52 @@
#include <linux/hardirq.h>
#include <linux/topology.h>
-#define define_one_ro_named(_name, _func) \
- static DEVICE_ATTR(_name, 0444, _func, NULL)
-
-#define define_one_ro(_name) \
- static DEVICE_ATTR(_name, 0444, show_##_name, NULL)
-
#define define_id_show_func(name) \
-static ssize_t show_##name(struct device *dev, \
+static ssize_t name##_show(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
return sprintf(buf, "%d\n", topology_##name(dev->id)); \
}
-#define define_siblings_show_map(name) \
-static ssize_t show_##name(struct device *dev, \
+#define define_siblings_show_map(name, mask) \
+static ssize_t name##_show(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
- return cpumap_print_to_pagebuf(false, buf, topology_##name(dev->id));\
+ return cpumap_print_to_pagebuf(false, buf, topology_##mask(dev->id));\
}
-#define define_siblings_show_list(name) \
-static ssize_t show_##name##_list(struct device *dev, \
- struct device_attribute *attr, \
- char *buf) \
+#define define_siblings_show_list(name, mask) \
+static ssize_t name##_list_show(struct device *dev, \
+ struct device_attribute *attr, \
+ char *buf) \
{ \
- return cpumap_print_to_pagebuf(true, buf, topology_##name(dev->id));\
+ return cpumap_print_to_pagebuf(true, buf, topology_##mask(dev->id));\
}
-#define define_siblings_show_func(name) \
- define_siblings_show_map(name); define_siblings_show_list(name)
+#define define_siblings_show_func(name, mask) \
+ define_siblings_show_map(name, mask); \
+ define_siblings_show_list(name, mask)
define_id_show_func(physical_package_id);
-define_one_ro(physical_package_id);
+static DEVICE_ATTR_RO(physical_package_id);
define_id_show_func(core_id);
-define_one_ro(core_id);
+static DEVICE_ATTR_RO(core_id);
-define_siblings_show_func(thread_cpumask);
-define_one_ro_named(thread_siblings, show_thread_cpumask);
-define_one_ro_named(thread_siblings_list, show_thread_cpumask_list);
+define_siblings_show_func(thread_siblings, thread_cpumask);
+static DEVICE_ATTR_RO(thread_siblings);
+static DEVICE_ATTR_RO(thread_siblings_list);
-define_siblings_show_func(core_cpumask);
-define_one_ro_named(core_siblings, show_core_cpumask);
-define_one_ro_named(core_siblings_list, show_core_cpumask_list);
+define_siblings_show_func(core_siblings, core_cpumask);
+static DEVICE_ATTR_RO(core_siblings);
+static DEVICE_ATTR_RO(core_siblings_list);
#ifdef CONFIG_SCHED_BOOK
define_id_show_func(book_id);
-define_one_ro(book_id);
-define_siblings_show_func(book_cpumask);
-define_one_ro_named(book_siblings, show_book_cpumask);
-define_one_ro_named(book_siblings_list, show_book_cpumask_list);
+static DEVICE_ATTR_RO(book_id);
+define_siblings_show_func(book_siblings, book_cpumask);
+static DEVICE_ATTR_RO(book_siblings);
+static DEVICE_ATTR_RO(book_siblings_list);
#endif
static struct attribute *default_attrs[] = {
--
1.9.1
next prev parent reply other threads:[~2014-09-30 13:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-30 13:48 [PATCH v5 00/11] drivers: cacheinfo support Sudeep Holla
2014-09-30 13:48 ` [PATCH v5 01/11] cpumask: factor out show_cpumap into separate helper function Sudeep Holla
2014-09-30 13:48 ` Sudeep Holla [this message]
2014-09-30 13:48 ` [PATCH v5 03/11] drivers: base: add cpu_device_create to support per-cpu devices Sudeep Holla
2014-11-07 19:22 ` Greg Kroah-Hartman
2014-09-30 13:48 ` [PATCH v5 04/11] drivers: base: support cpu cache information interface to userspace via sysfs Sudeep Holla
2014-09-30 13:48 ` [PATCH v5 05/11] ia64: move cacheinfo sysfs to generic cacheinfo infrastructure Sudeep Holla
2014-09-30 13:48 ` [PATCH v5 06/11] s390: " Sudeep Holla
2014-09-30 13:48 ` [PATCH v5 07/11] x86: " Sudeep Holla
2014-09-30 13:48 ` [PATCH v5 08/11] powerpc: " Sudeep Holla
2014-09-30 13:48 ` [PATCH v5 09/11] ARM64: kernel: add support for cpu cache information Sudeep Holla
2014-09-30 13:48 ` [PATCH v5 10/11] ARM: " Sudeep Holla
2014-09-30 13:48 ` [PATCH v5 11/11] ARM: kernel: add outer cache support for cacheinfo implementation Sudeep Holla
2014-10-20 18:46 ` [PATCH v5 00/11] drivers: cacheinfo support Sudeep Holla
2014-10-20 18:49 ` Greg Kroah-Hartman
2014-10-21 9:26 ` Sudeep Holla
2014-11-07 19:23 ` Greg Kroah-Hartman
2014-11-07 19:40 ` Sudeep Holla
2014-11-07 19:45 ` Greg Kroah-Hartman
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=1412084912-2767-3-git-send-email-sudeep.holla@arm.com \
--to=sudeep.holla@arm.com \
--cc=Lorenzo.Pieralisi@arm.com \
--cc=gregkh@linuxfoundation.org \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®