lkml.org 
[lkml]   [2007]   [May]   [8]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
DateMon, 07 May 2007 23:30:10 -0700
FromJeremy Fitzhardinge <>
SubjectRe: [patch 25/29] xen: Add the Xen virtual network device driver.
Rusty Russell wrote:
> Looks good, you can slightly improve it to be the model use of new
> module_param types by calling your functions param_set_rx_mode and
> param_get_rx_mode, then simply using "module_param(rx_mode, rx_mode,
> 0400)"
> 

Cute.  I tried it out, but it doesn't yield an obvious improvement:

diff -r 83d67449bff4 drivers/net/xen-netfront.c
--- a/drivers/net/xen-netfront.c	Mon May 07 18:44:11 2007 -0700
+++ b/drivers/net/xen-netfront.c	Mon May 07 22:58:36 2007 -0700
@@ -67,13 +67,16 @@ struct netfront_cb {
  * For fully-virtualised guests there is no option - copying must be used.
  * For paravirtualised guests, flipping is the default.
  */
-static enum rx_mode {
+typedef enum rx_mode {
 	RX_COPY = 0,
 	RX_FLIP = 1,
-} rx_mode = RX_FLIP;
-MODULE_PARM_DESC(rx_mode, "How to get packets from card: \"copy\" or \"flip\"");
-
-static int set_rx_mode(const char *val, struct kernel_param *kp)
+} rx_mode_t;
+
+static enum rx_mode rx_mode = RX_FLIP;
+
+#define param_check_rx_mode_t(name, p) __param_check(name, p, rx_mode_t)
+
+static int param_set_rx_mode_t(const char *val, struct kernel_param *kp)
 {
 	enum rx_mode *rxmp = kp->arg;
 	int ret = 0;
@@ -88,14 +91,15 @@ static int set_rx_mode(const char *val, 
 	return ret;
 }
 
-static int get_rx_mode(char *buffer, struct kernel_param *kp)
+static int param_get_rx_mode_t(char *buffer, struct kernel_param *kp)
 {
 	enum rx_mode *rxmp = kp->arg;
 
 	return sprintf(buffer, "%s", *rxmp == RX_COPY ? "copy" : "flip");
 }
 
-module_param_call(rx_mode, set_rx_mode, get_rx_mode, &rx_mode, 0400);
+MODULE_PARM_DESC(rx_mode, "How to get packets from card: \"copy\" or \"flip\"");
+module_param(rx_mode, rx_mode_t, 0400);
 
 #define RX_COPY_THRESHOLD 256
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-05-08 08:43    [from the cache]
©2003-2008