Commit fb0466c3ae7f1c73f70072af8fd27ac166908a2f

Authored by Eric Van Hensbergen
Committed by Eric Van Hensbergen
1 parent 50fd801067

9p: fix bad kconfig cross-dependency

This patch moves transport dynamic registration and matching to the net
module to prevent a bad Kconfig dependency between the net and fs 9p modules.

Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>

Showing 5 changed files with 67 additions and 46 deletions Side-by-side Diff

... ... @@ -37,47 +37,6 @@
37 37 #include "v9fs_vfs.h"
38 38  
39 39 /*
40   - * Dynamic Transport Registration Routines
41   - *
42   - */
43   -
44   -static LIST_HEAD(v9fs_trans_list);
45   -static struct p9_trans_module *v9fs_default_trans;
46   -
47   -/**
48   - * v9fs_register_trans - register a new transport with 9p
49   - * @m - structure describing the transport module and entry points
50   - *
51   - */
52   -void v9fs_register_trans(struct p9_trans_module *m)
53   -{
54   - list_add_tail(&m->list, &v9fs_trans_list);
55   - if (m->def)
56   - v9fs_default_trans = m;
57   -}
58   -EXPORT_SYMBOL(v9fs_register_trans);
59   -
60   -/**
61   - * v9fs_match_trans - match transport versus registered transports
62   - * @arg: string identifying transport
63   - *
64   - */
65   -static struct p9_trans_module *v9fs_match_trans(const substring_t *name)
66   -{
67   - struct list_head *p;
68   - struct p9_trans_module *t = NULL;
69   -
70   - list_for_each(p, &v9fs_trans_list) {
71   - t = list_entry(p, struct p9_trans_module, list);
72   - if (strncmp(t->name, name->from, name->to-name->from) == 0) {
73   - P9_DPRINTK(P9_DEBUG_TRANS, "trans=%s\n", t->name);
74   - break;
75   - }
76   - }
77   - return t;
78   -}
79   -
80   -/*
81 40 * Option Parsing (code inspired by NFS code)
82 41 * NOTE: each transport will parse its own options
83 42 */
... ... @@ -135,7 +94,7 @@
135 94 v9ses->afid = ~0;
136 95 v9ses->debug = 0;
137 96 v9ses->cache = 0;
138   - v9ses->trans = v9fs_default_trans;
  97 + v9ses->trans = v9fs_default_trans();
139 98  
140 99 if (!options)
141 100 return;
... ... @@ -244,10 +203,6 @@
244 203 v9ses->dfltgid = V9FS_DEFGID;
245 204 v9ses->options = kstrdup(data, GFP_KERNEL);
246 205 v9fs_parse_options(v9ses);
247   -
248   - if ((v9ses->trans == NULL) && !list_empty(&v9fs_trans_list))
249   - v9ses->trans = list_first_entry(&v9fs_trans_list,
250   - struct p9_trans_module, list);
251 206  
252 207 if (v9ses->trans == NULL) {
253 208 retval = -EPROTONOSUPPORT;
include/net/9p/transport.h
... ... @@ -50,6 +50,8 @@
50 50 };
51 51  
52 52 void v9fs_register_trans(struct p9_trans_module *m);
  53 +struct p9_trans_module *v9fs_match_trans(const substring_t *name);
  54 +struct p9_trans_module *v9fs_default_trans(void);
53 55  
54 56 #endif /* NET_9P_TRANSPORT_H */
... ... @@ -30,6 +30,7 @@
30 30 #include <linux/sched.h>
31 31 #include <linux/uaccess.h>
32 32 #include <net/9p/9p.h>
  33 +#include <linux/parser.h>
33 34 #include <net/9p/transport.h>
34 35 #include <net/9p/conn.h>
35 36 #include <net/9p/client.h>
... ... @@ -27,6 +27,10 @@
27 27 #include <linux/module.h>
28 28 #include <linux/moduleparam.h>
29 29 #include <net/9p/9p.h>
  30 +#include <linux/fs.h>
  31 +#include <linux/parser.h>
  32 +#include <net/9p/transport.h>
  33 +#include <linux/list.h>
30 34  
31 35 #ifdef CONFIG_NET_9P_DEBUG
32 36 unsigned int p9_debug_level = 0; /* feature-rific global debug level */
... ... @@ -39,6 +43,64 @@
39 43 extern void p9_mux_global_exit(void);
40 44 extern int p9_sysctl_register(void);
41 45 extern void p9_sysctl_unregister(void);
  46 +
  47 +/*
  48 + * Dynamic Transport Registration Routines
  49 + *
  50 + */
  51 +
  52 +static LIST_HEAD(v9fs_trans_list);
  53 +static struct p9_trans_module *v9fs_default_transport;
  54 +
  55 +/**
  56 + * v9fs_register_trans - register a new transport with 9p
  57 + * @m - structure describing the transport module and entry points
  58 + *
  59 + */
  60 +void v9fs_register_trans(struct p9_trans_module *m)
  61 +{
  62 + list_add_tail(&m->list, &v9fs_trans_list);
  63 + if (m->def)
  64 + v9fs_default_transport = m;
  65 +}
  66 +EXPORT_SYMBOL(v9fs_register_trans);
  67 +
  68 +/**
  69 + * v9fs_match_trans - match transport versus registered transports
  70 + * @arg: string identifying transport
  71 + *
  72 + */
  73 +struct p9_trans_module *v9fs_match_trans(const substring_t *name)
  74 +{
  75 + struct list_head *p;
  76 + struct p9_trans_module *t = NULL;
  77 +
  78 + list_for_each(p, &v9fs_trans_list) {
  79 + t = list_entry(p, struct p9_trans_module, list);
  80 + if (strncmp(t->name, name->from, name->to-name->from) == 0)
  81 + break;
  82 + }
  83 + return t;
  84 +}
  85 +EXPORT_SYMBOL(v9fs_match_trans);
  86 +
  87 +/**
  88 + * v9fs_default_trans - returns pointer to default transport
  89 + *
  90 + */
  91 +
  92 +struct p9_trans_module *v9fs_default_trans(void)
  93 +{
  94 + if (v9fs_default_transport)
  95 + return v9fs_default_transport;
  96 + else if (!list_empty(&v9fs_trans_list))
  97 + return list_first_entry(&v9fs_trans_list,
  98 + struct p9_trans_module, list);
  99 + else
  100 + return NULL;
  101 +}
  102 +EXPORT_SYMBOL(v9fs_default_trans);
  103 +
42 104  
43 105 /**
44 106 * v9fs_init - Initialize module
... ... @@ -31,6 +31,7 @@
31 31 #include <linux/idr.h>
32 32 #include <linux/mutex.h>
33 33 #include <net/9p/9p.h>
  34 +#include <linux/parser.h>
34 35 #include <net/9p/transport.h>
35 36 #include <net/9p/conn.h>
36 37