From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Andi Kleen <andi@firstfloor.org>, Andi Kleen <ak@linux.intel.com>,
Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 07/62] sysdev: Convert cpu driver sysdev class attributes
Date: Tue, 2 Mar 2010 15:28:06 -0800 [thread overview]
Message-ID: <1267572541-410-7-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20100302230933.GA32287@kroah.com>
From: Andi Kleen <andi@firstfloor.org>
Using the new attribute argument convert the cpu driver class attributes
to carry the node state. Then use a shared function to do what a lot of
individual functions did before.
This eliminates an ugly macro.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/cpu.c | 37 +++++++++++++++++++++----------------
1 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index fd1b2f9..b04ecfc 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -141,27 +141,32 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
/*
* Print cpu online, possible, present, and system maps
*/
-static ssize_t print_cpus_map(char *buf, const struct cpumask *map)
+
+struct cpu_attr {
+ struct sysdev_class_attribute attr;
+ const struct cpumask *const * const map;
+};
+
+static ssize_t show_cpus_attr(struct sysdev_class *class,
+ struct sysdev_class_attribute *attr,
+ char *buf)
{
- int n = cpulist_scnprintf(buf, PAGE_SIZE-2, map);
+ struct cpu_attr *ca = container_of(attr, struct cpu_attr, attr);
+ int n = cpulist_scnprintf(buf, PAGE_SIZE-2, *(ca->map));
buf[n++] = '\n';
buf[n] = '\0';
return n;
}
-#define print_cpus_func(type) \
-static ssize_t print_cpus_##type(struct sysdev_class *class, \
- struct sysdev_class_attribute *attr, char *buf) \
-{ \
- return print_cpus_map(buf, cpu_##type##_mask); \
-} \
-static struct sysdev_class_attribute attr_##type##_map = \
- _SYSDEV_CLASS_ATTR(type, 0444, print_cpus_##type, NULL)
+#define _CPU_ATTR(name, map) \
+ { _SYSDEV_CLASS_ATTR(name, 0444, show_cpus_attr, NULL), map }
-print_cpus_func(online);
-print_cpus_func(possible);
-print_cpus_func(present);
+static struct cpu_attr cpu_attrs[] = {
+ _CPU_ATTR(online, &cpu_online_mask),
+ _CPU_ATTR(possible, &cpu_possible_mask),
+ _CPU_ATTR(present, &cpu_present_mask),
+};
/*
* Print values for NR_CPUS and offlined cpus
@@ -208,9 +213,9 @@ static ssize_t print_cpus_offline(struct sysdev_class *class,
static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL);
static struct sysdev_class_attribute *cpu_state_attr[] = {
- &attr_online_map,
- &attr_possible_map,
- &attr_present_map,
+ &cpu_attrs[0].attr,
+ &cpu_attrs[1].attr,
+ &cpu_attrs[2].attr,
&attr_kernel_max,
&attr_offline,
};
--
1.7.0.1
next prev parent reply other threads:[~2010-03-02 23:29 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-02 23:09 [GIT PATCH] driver core patches for 2.6.33-git Greg KH
2010-03-02 23:28 ` [PATCH 01/62] kobject-example: Spelling fixes Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 02/62] kset-example: " Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 03/62] Driver core: add platform_create_bundle() helper Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 04/62] driver core: make platform_device_id table const Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 05/62] sysdev: Pass attribute in sysdev_class attributes show/store Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 06/62] sysdev: Convert node driver class attributes to be data driven Greg Kroah-Hartman
2010-03-02 23:28 ` Greg Kroah-Hartman [this message]
2010-03-02 23:28 ` [PATCH 08/62] sysfs: Add sysfs_add/remove_files utility functions Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 09/62] sysfs: Add attribute array to sysdev classes Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 10/62] sysdev: Convert node driver Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 11/62] sysdev: Use sysdev_class attribute arrays in " Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 12/62] sysdev: Add sysdev_create/remove_files Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 13/62] sysdev: Fix type of sysdev class attribute in memory driver Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 14/62] sysdev: fix missing s390 conversion Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 15/62] driver-core: Add attribute argument to class_attribute show/store Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 16/62] driver core: Add class_attr_string for simple read-only string Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 17/62] driver core: Convert some drivers to CLASS_ATTR_STRING Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 18/62] Driver-Core: devtmpfs - reset inode permissions before unlinking Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 19/62] Driver-Core: devtmpfs - remove EXPERIMENTAL and enable it by default Greg Kroah-Hartman
2010-03-03 4:38 ` Eric W. Biederman
2010-03-03 16:46 ` Linus Torvalds
2010-03-03 20:03 ` Kay Sievers
2010-03-03 20:21 ` Eric W. Biederman
2010-03-03 22:01 ` Kay Sievers
2010-03-03 21:22 ` Greg KH
2010-03-03 21:48 ` Linus Torvalds
2010-03-03 22:04 ` Greg KH
2010-03-04 0:04 ` Linus Torvalds
2010-03-02 23:28 ` [PATCH 20/62] Driver-Core: disable /sbin/hotplug " Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 21/62] Driver-Core: require valid action string in uevent trigger Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 22/62] sysfs: Cache the last sysfs_dirent to improve readdir scalability v2 Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 23/62] driver-core: firmware_class: remove base.h header inclusion Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 24/62] kobject: Constify struct kset_uevent_ops Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 25/62] HOWTO: Updates on subsystem trees, patchwork, -next (vs. -mm) Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 26/62] sysdev: fix up the probe/release attributes Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 27/62] Driver core: Constify struct sysfs_ops in struct kobj_type Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 28/62] Driver core: make struct platform_driver.id_table const Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 29/62] platform-drivers: move probe to .devinit.text in arch/arm Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 30/62] platform-drivers: move probe to .devinit.text in drivers/scsi Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 32/62] x86: move hp-wmi's probe function to .devinit.text Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 33/62] i2c: move i2c_omap's " Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 34/62] w1: move omap_hdq's " Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 35/62] media: move omap24xxcam's " Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 36/62] auxdisplay: move cfag12864bfb's " Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 37/62] net: move am79c961's " Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 38/62] UIO: Add a driver for Hilscher netX-based fieldbus cards Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 39/62] UIO: minor Kconfig fixes Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 40/62] UIO: Remove SMX Cryptengine driver Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 41/62] Driver core: Fix first line of kernel-doc for a few functions Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 42/62] sysfs: Remove sysfs_get/put_active_two Greg Kroah-Hartman
2010-03-03 1:34 ` Tejun Heo
2010-03-02 23:28 ` [PATCH 43/62] sysfs: Only take active references on attributes Greg Kroah-Hartman
2010-03-03 1:36 ` Tejun Heo
2010-03-02 23:28 ` [PATCH 44/62] sysfs: Use one lockdep class per sysfs attribute Greg Kroah-Hartman
2010-03-03 1:41 ` Tejun Heo
2010-03-02 23:28 ` [PATCH 45/62] sysfs: Use sysfs_attr_init and sysfs_bin_attr_init on dynamic attributes Greg Kroah-Hartman
2010-03-03 1:41 ` Tejun Heo
2010-03-02 23:28 ` [PATCH 46/62] sysfs: Document sysfs_attr_init and sysfs_bin_attr_init Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 47/62] sysfs: Use sysfs_attr_init and sysfs_bin_attr_init on module dynamic attributes Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 48/62] sysfs: windfarm: init sysfs attributes Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 49/62] sysfs: Serialize updates to the vfs inode Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 50/62] sysfs: Pack sysfs_dirent more tightly Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 51/62] sysfs: Implement sysfs_rename_link Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 52/62] driver core: Use sysfs_rename_link in device_rename Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 53/62] sysfs: Pass super_block to sysfs_get_inode Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 54/62] sysfs: Kill unused sysfs_sb variable Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 56/62] msi-laptop: Support standard ec 66/62 command on MSI notebook and nebook Greg Kroah-Hartman
2010-03-02 23:42 ` Matthew Garrett
2010-03-02 23:58 ` Greg KH
2010-03-03 13:47 ` Matthew Garrett
2010-03-02 23:28 ` [PATCH 57/62] msi-laptop: Add threeg sysfs file for support query 3G state by standard 66/62 ec command Greg Kroah-Hartman
2010-03-02 23:36 ` Matthew Garrett
2010-03-02 23:47 ` Greg KH
2010-03-03 13:46 ` Matthew Garrett
2010-03-02 23:28 ` [PATCH 58/62] msi-laptop: Support some MSI 3G netbook that is need load SCM Greg Kroah-Hartman
2010-03-02 23:39 ` Matthew Garrett
2010-03-02 23:46 ` Greg KH
2010-03-02 23:28 ` [PATCH 59/62] msi-laptop: Add resume method for set the SCM load again Greg Kroah-Hartman
2010-03-02 23:28 ` [PATCH 60/62] msi-laptop: Detect 3G device exists by standard ec command Greg Kroah-Hartman
2010-03-02 23:29 ` [PATCH 61/62] msi-laptop: depends on RFKILL Greg Kroah-Hartman
2010-03-03 6:09 ` Dmitry Torokhov
2010-03-03 21:23 ` Greg KH
2010-03-02 23:29 ` [PATCH 62/62] sysfs: fix for thinko with sysfs_bin_attr_init() Greg Kroah-Hartman
2010-03-08 14:12 ` [GIT PATCH] driver core patches for 2.6.33-git Greg KH
2010-03-08 17:28 ` Linus Torvalds
2010-03-08 17:33 ` Greg KH
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=1267572541-410-7-git-send-email-gregkh@suse.de \
--to=gregkh@suse.de \
--cc=ak@linux.intel.com \
--cc=andi@firstfloor.org \
--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
Powered by JetHome