diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2010-08-12 01:04:12 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2010-08-11 09:34:13 -0400 |
commit | 9bbb9e5a33109b2832e2e63dcc7a132924ab374b (patch) | |
tree | 87270ed3a61d0d0e654a61c8d44504cdef330192 /drivers | |
parent | a14fe249a8f74269c9e636bcbaa78f5bdb354ce3 (diff) |
param: use ops in struct kernel_param, rather than get and set fns directly
This is more kernel-ish, saves some space, and also allows us to
expand the ops without breaking all the callers who are happy for the
new members to be NULL.
The few places which defined their own param types are changed to the
new scheme (more which crept in recently fixed in following patches).
Since we're touching them anyway, we change get() and set() to take a
const struct kernel_param (which they really are). This causes some
harmless warnings until we fix them (in following patches).
To reduce churn, module_param_call creates the ops struct so the callers
don't have to change (and casts the functions to reduce warnings).
The modern version which takes an ops struct is called module_param_cb.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Tested-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Ville Syrjala <syrjala@sci.fi>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Alessandro Rubini <rubini@ipvvis.unipv.it>
Cc: Michal Januszewski <spock@gentoo.org>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Neil Brown <neilb@suse.de>
Cc: linux-kernel@vger.kernel.org
Cc: linux-input@vger.kernel.org
Cc: linux-fbdev-devel@lists.sourceforge.net
Cc: linux-nfs@vger.kernel.org
Cc: netdev@vger.kernel.org
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/input/misc/ati_remote2.c | 26 | ||||
-rw-r--r-- | drivers/input/mouse/psmouse-base.c | 14 | ||||
-rw-r--r-- | drivers/video/uvesafb.c | 7 |
3 files changed, 29 insertions, 18 deletions
diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c index e148749b5851..23257652b8e8 100644 --- a/drivers/input/misc/ati_remote2.c +++ b/drivers/input/misc/ati_remote2.c | |||
@@ -38,7 +38,8 @@ enum { | |||
38 | }; | 38 | }; |
39 | 39 | ||
40 | static int ati_remote2_set_mask(const char *val, | 40 | static int ati_remote2_set_mask(const char *val, |
41 | struct kernel_param *kp, unsigned int max) | 41 | const struct kernel_param *kp, |
42 | unsigned int max) | ||
42 | { | 43 | { |
43 | unsigned long mask; | 44 | unsigned long mask; |
44 | int ret; | 45 | int ret; |
@@ -59,28 +60,31 @@ static int ati_remote2_set_mask(const char *val, | |||
59 | } | 60 | } |
60 | 61 | ||
61 | static int ati_remote2_set_channel_mask(const char *val, | 62 | static int ati_remote2_set_channel_mask(const char *val, |
62 | struct kernel_param *kp) | 63 | const struct kernel_param *kp) |
63 | { | 64 | { |
64 | pr_debug("%s()\n", __func__); | 65 | pr_debug("%s()\n", __func__); |
65 | 66 | ||
66 | return ati_remote2_set_mask(val, kp, ATI_REMOTE2_MAX_CHANNEL_MASK); | 67 | return ati_remote2_set_mask(val, kp, ATI_REMOTE2_MAX_CHANNEL_MASK); |
67 | } | 68 | } |
68 | 69 | ||
69 | static int ati_remote2_get_channel_mask(char *buffer, struct kernel_param *kp) | 70 | static int ati_remote2_get_channel_mask(char *buffer, |
71 | const struct kernel_param *kp) | ||
70 | { | 72 | { |
71 | pr_debug("%s()\n", __func__); | 73 | pr_debug("%s()\n", __func__); |
72 | 74 | ||
73 | return sprintf(buffer, "0x%04x", *(unsigned int *)kp->arg); | 75 | return sprintf(buffer, "0x%04x", *(unsigned int *)kp->arg); |
74 | } | 76 | } |
75 | 77 | ||
76 | static int ati_remote2_set_mode_mask(const char *val, struct kernel_param *kp) | 78 | static int ati_remote2_set_mode_mask(const char *val, |
79 | const struct kernel_param *kp) | ||
77 | { | 80 | { |
78 | pr_debug("%s()\n", __func__); | 81 | pr_debug("%s()\n", __func__); |
79 | 82 | ||
80 | return ati_remote2_set_mask(val, kp, ATI_REMOTE2_MAX_MODE_MASK); | 83 | return ati_remote2_set_mask(val, kp, ATI_REMOTE2_MAX_MODE_MASK); |
81 | } | 84 | } |
82 | 85 | ||
83 | static int ati_remote2_get_mode_mask(char *buffer, struct kernel_param *kp) | 86 | static int ati_remote2_get_mode_mask(char *buffer, |
87 | const struct kernel_param *kp) | ||
84 | { | 88 | { |
85 | pr_debug("%s()\n", __func__); | 89 | pr_debug("%s()\n", __func__); |
86 | 90 | ||
@@ -89,15 +93,19 @@ static int ati_remote2_get_mode_mask(char *buffer, struct kernel_param *kp) | |||
89 | 93 | ||
90 | static unsigned int channel_mask = ATI_REMOTE2_MAX_CHANNEL_MASK; | 94 | static unsigned int channel_mask = ATI_REMOTE2_MAX_CHANNEL_MASK; |
91 | #define param_check_channel_mask(name, p) __param_check(name, p, unsigned int) | 95 | #define param_check_channel_mask(name, p) __param_check(name, p, unsigned int) |
92 | #define param_set_channel_mask ati_remote2_set_channel_mask | 96 | static struct kernel_param_ops param_ops_channel_mask = { |
93 | #define param_get_channel_mask ati_remote2_get_channel_mask | 97 | .set = ati_remote2_set_channel_mask, |
98 | .get = ati_remote2_get_channel_mask, | ||
99 | }; | ||
94 | module_param(channel_mask, channel_mask, 0644); | 100 | module_param(channel_mask, channel_mask, 0644); |
95 | MODULE_PARM_DESC(channel_mask, "Bitmask of channels to accept <15:Channel16>...<1:Channel2><0:Channel1>"); | 101 | MODULE_PARM_DESC(channel_mask, "Bitmask of channels to accept <15:Channel16>...<1:Channel2><0:Channel1>"); |
96 | 102 | ||
97 | static unsigned int mode_mask = ATI_REMOTE2_MAX_MODE_MASK; | 103 | static unsigned int mode_mask = ATI_REMOTE2_MAX_MODE_MASK; |
98 | #define param_check_mode_mask(name, p) __param_check(name, p, unsigned int) | 104 | #define param_check_mode_mask(name, p) __param_check(name, p, unsigned int) |
99 | #define param_set_mode_mask ati_remote2_set_mode_mask | 105 | static struct kernel_param_ops param_ops_mode_mask = { |
100 | #define param_get_mode_mask ati_remote2_get_mode_mask | 106 | .set = ati_remote2_set_mode_mask, |
107 | .get = ati_remote2_get_mode_mask, | ||
108 | }; | ||
101 | module_param(mode_mask, mode_mask, 0644); | 109 | module_param(mode_mask, mode_mask, 0644); |
102 | MODULE_PARM_DESC(mode_mask, "Bitmask of modes to accept <4:PC><3:AUX4><2:AUX3><1:AUX2><0:AUX1>"); | 110 | MODULE_PARM_DESC(mode_mask, "Bitmask of modes to accept <4:PC><3:AUX4><2:AUX3><1:AUX2><0:AUX1>"); |
103 | 111 | ||
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 979c50215282..73a7af2542a8 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c | |||
@@ -39,11 +39,13 @@ MODULE_DESCRIPTION(DRIVER_DESC); | |||
39 | MODULE_LICENSE("GPL"); | 39 | MODULE_LICENSE("GPL"); |
40 | 40 | ||
41 | static unsigned int psmouse_max_proto = PSMOUSE_AUTO; | 41 | static unsigned int psmouse_max_proto = PSMOUSE_AUTO; |
42 | static int psmouse_set_maxproto(const char *val, struct kernel_param *kp); | 42 | static int psmouse_set_maxproto(const char *val, const struct kernel_param *); |
43 | static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp); | 43 | static int psmouse_get_maxproto(char *buffer, const struct kernel_param *kp); |
44 | static struct kernel_param_ops param_ops_proto_abbrev = { | ||
45 | .set = psmouse_set_maxproto, | ||
46 | .get = psmouse_get_maxproto, | ||
47 | }; | ||
44 | #define param_check_proto_abbrev(name, p) __param_check(name, p, unsigned int) | 48 | #define param_check_proto_abbrev(name, p) __param_check(name, p, unsigned int) |
45 | #define param_set_proto_abbrev psmouse_set_maxproto | ||
46 | #define param_get_proto_abbrev psmouse_get_maxproto | ||
47 | module_param_named(proto, psmouse_max_proto, proto_abbrev, 0644); | 49 | module_param_named(proto, psmouse_max_proto, proto_abbrev, 0644); |
48 | MODULE_PARM_DESC(proto, "Highest protocol extension to probe (bare, imps, exps, any). Useful for KVM switches."); | 50 | MODULE_PARM_DESC(proto, "Highest protocol extension to probe (bare, imps, exps, any). Useful for KVM switches."); |
49 | 51 | ||
@@ -1679,7 +1681,7 @@ static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, | |||
1679 | } | 1681 | } |
1680 | 1682 | ||
1681 | 1683 | ||
1682 | static int psmouse_set_maxproto(const char *val, struct kernel_param *kp) | 1684 | static int psmouse_set_maxproto(const char *val, const struct kernel_param *kp) |
1683 | { | 1685 | { |
1684 | const struct psmouse_protocol *proto; | 1686 | const struct psmouse_protocol *proto; |
1685 | 1687 | ||
@@ -1696,7 +1698,7 @@ static int psmouse_set_maxproto(const char *val, struct kernel_param *kp) | |||
1696 | return 0; | 1698 | return 0; |
1697 | } | 1699 | } |
1698 | 1700 | ||
1699 | static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp) | 1701 | static int psmouse_get_maxproto(char *buffer, const struct kernel_param *kp) |
1700 | { | 1702 | { |
1701 | int type = *((unsigned int *)kp->arg); | 1703 | int type = *((unsigned int *)kp->arg); |
1702 | 1704 | ||
diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c index 7b8839ebf3c4..52ec0959d462 100644 --- a/drivers/video/uvesafb.c +++ b/drivers/video/uvesafb.c | |||
@@ -1977,8 +1977,7 @@ static void __devexit uvesafb_exit(void) | |||
1977 | 1977 | ||
1978 | module_exit(uvesafb_exit); | 1978 | module_exit(uvesafb_exit); |
1979 | 1979 | ||
1980 | #define param_get_scroll NULL | 1980 | static int param_set_scroll(const char *val, const struct kernel_param *kp) |
1981 | static int param_set_scroll(const char *val, struct kernel_param *kp) | ||
1982 | { | 1981 | { |
1983 | ypan = 0; | 1982 | ypan = 0; |
1984 | 1983 | ||
@@ -1993,7 +1992,9 @@ static int param_set_scroll(const char *val, struct kernel_param *kp) | |||
1993 | 1992 | ||
1994 | return 0; | 1993 | return 0; |
1995 | } | 1994 | } |
1996 | 1995 | static struct kernel_param_ops param_ops_scroll = { | |
1996 | .set = param_set_scroll, | ||
1997 | }; | ||
1997 | #define param_check_scroll(name, p) __param_check(name, p, void) | 1998 | #define param_check_scroll(name, p) __param_check(name, p, void) |
1998 | 1999 | ||
1999 | module_param_named(scroll, ypan, scroll, 0); | 2000 | module_param_named(scroll, ypan, scroll, 0); |