diff options
author | Eliad Peller <eliad@wizery.com> | 2010-10-27 08:58:29 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-11-15 13:24:48 -0500 |
commit | 07caf9d6c9135ae25a760867f37aab90c1008380 (patch) | |
tree | 528409cde06c5927a311d453a4e59206fca0beb5 /net/mac80211/debugfs_key.c | |
parent | 6a6733f256f18cbcf4875e13f59eedb593b755a8 (diff) |
mac80211: refactor debugfs function generation code
refactor mac80211 debugfs code by using a format© function, instead of
duplicating the code for each generated function.
this change reduces about 600B from mac80211.ko
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/debugfs_key.c')
-rw-r--r-- | net/mac80211/debugfs_key.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/net/mac80211/debugfs_key.c b/net/mac80211/debugfs_key.c index 1243d1db5c59..5822a6ce7671 100644 --- a/net/mac80211/debugfs_key.c +++ b/net/mac80211/debugfs_key.c | |||
@@ -15,18 +15,17 @@ | |||
15 | #include "debugfs.h" | 15 | #include "debugfs.h" |
16 | #include "debugfs_key.h" | 16 | #include "debugfs_key.h" |
17 | 17 | ||
18 | #define KEY_READ(name, prop, buflen, format_string) \ | 18 | #define KEY_READ(name, prop, format_string) \ |
19 | static ssize_t key_##name##_read(struct file *file, \ | 19 | static ssize_t key_##name##_read(struct file *file, \ |
20 | char __user *userbuf, \ | 20 | char __user *userbuf, \ |
21 | size_t count, loff_t *ppos) \ | 21 | size_t count, loff_t *ppos) \ |
22 | { \ | 22 | { \ |
23 | char buf[buflen]; \ | ||
24 | struct ieee80211_key *key = file->private_data; \ | 23 | struct ieee80211_key *key = file->private_data; \ |
25 | int res = scnprintf(buf, buflen, format_string, key->prop); \ | 24 | return mac80211_format_buffer(userbuf, count, ppos, \ |
26 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); \ | 25 | format_string, key->prop); \ |
27 | } | 26 | } |
28 | #define KEY_READ_D(name) KEY_READ(name, name, 20, "%d\n") | 27 | #define KEY_READ_D(name) KEY_READ(name, name, "%d\n") |
29 | #define KEY_READ_X(name) KEY_READ(name, name, 20, "0x%x\n") | 28 | #define KEY_READ_X(name) KEY_READ(name, name, "0x%x\n") |
30 | 29 | ||
31 | #define KEY_OPS(name) \ | 30 | #define KEY_OPS(name) \ |
32 | static const struct file_operations key_ ##name## _ops = { \ | 31 | static const struct file_operations key_ ##name## _ops = { \ |
@@ -39,9 +38,9 @@ static const struct file_operations key_ ##name## _ops = { \ | |||
39 | KEY_READ_##format(name) \ | 38 | KEY_READ_##format(name) \ |
40 | KEY_OPS(name) | 39 | KEY_OPS(name) |
41 | 40 | ||
42 | #define KEY_CONF_READ(name, buflen, format_string) \ | 41 | #define KEY_CONF_READ(name, format_string) \ |
43 | KEY_READ(conf_##name, conf.name, buflen, format_string) | 42 | KEY_READ(conf_##name, conf.name, format_string) |
44 | #define KEY_CONF_READ_D(name) KEY_CONF_READ(name, 20, "%d\n") | 43 | #define KEY_CONF_READ_D(name) KEY_CONF_READ(name, "%d\n") |
45 | 44 | ||
46 | #define KEY_CONF_OPS(name) \ | 45 | #define KEY_CONF_OPS(name) \ |
47 | static const struct file_operations key_ ##name## _ops = { \ | 46 | static const struct file_operations key_ ##name## _ops = { \ |
@@ -59,7 +58,7 @@ KEY_CONF_FILE(keyidx, D); | |||
59 | KEY_CONF_FILE(hw_key_idx, D); | 58 | KEY_CONF_FILE(hw_key_idx, D); |
60 | KEY_FILE(flags, X); | 59 | KEY_FILE(flags, X); |
61 | KEY_FILE(tx_rx_count, D); | 60 | KEY_FILE(tx_rx_count, D); |
62 | KEY_READ(ifindex, sdata->name, IFNAMSIZ + 2, "%s\n"); | 61 | KEY_READ(ifindex, sdata->name, "%s\n"); |
63 | KEY_OPS(ifindex); | 62 | KEY_OPS(ifindex); |
64 | 63 | ||
65 | static ssize_t key_algorithm_read(struct file *file, | 64 | static ssize_t key_algorithm_read(struct file *file, |