]>
Commit | Line | Data |
---|---|---|
b5a39c4d JR |
1 | lets try this again. for now there are two owner pointers, the original |
2 | in atmdev_ops and another in the struct shared between the common code | |
3 | and the lane code. the shared one pointers to the private owner. | |
4 | would that be the 'right' way or should i just ignore the owner field | |
5 | in atmdev_ops. | |
6 | ||
7 | Index: linux/net/atm/lec.h | |
8 | =================================================================== | |
9 | RCS file: /home/chas/CVSROOT/linux/net/atm/lec.h,v | |
10 | retrieving revision 1.3 | |
11 | retrieving revision 1.4 | |
12 | diff -u -r1.3 -r1.4 | |
13 | --- linux/net/atm/lec.h 24 Feb 2003 13:24:46 -0000 1.3 | |
14 | +++ linux/net/atm/lec.h 26 Feb 2003 15:52:44 -0000 1.4 | |
15 | @@ -65,6 +65,7 @@ | |
16 | int (*mcast_attach)(struct atm_vcc *vcc, int arg); | |
17 | int (*vcc_attach)(struct atm_vcc *vcc, void *arg); | |
18 | struct net_device **(*get_lecs)(void); | |
19 | + struct module *owner; | |
20 | }; | |
21 | ||
22 | /* | |
23 | Index: linux/net/atm/proc.c | |
24 | =================================================================== | |
25 | RCS file: /home/chas/CVSROOT/linux/net/atm/proc.c,v | |
26 | retrieving revision 1.1 | |
27 | retrieving revision 1.2 | |
28 | diff -u -r1.1 -r1.2 | |
29 | --- linux/net/atm/proc.c 20 Feb 2003 13:46:30 -0000 1.1 | |
30 | +++ linux/net/atm/proc.c 26 Feb 2003 15:52:44 -0000 1.2 | |
31 | @@ -444,8 +444,11 @@ | |
32 | } | |
33 | if (atm_lane_ops.get_lecs == NULL) | |
34 | return 0; /* the lane module is not there yet */ | |
35 | - else | |
36 | - dev_lec = atm_lane_ops.get_lecs(); | |
37 | + | |
38 | + if (!try_module_get(atm_lane_ops.owner)) | |
39 | + return 0; | |
40 | + | |
41 | + dev_lec = atm_lane_ops.get_lecs(); | |
42 | ||
43 | count = pos; | |
44 | for(d=0;d<MAX_LEC_ITF;d++) { | |
45 | @@ -458,6 +461,7 @@ | |
46 | e=sprintf(buf,"%s ", | |
47 | dev_lec[d]->name); | |
48 | lec_info(entry,buf+e); | |
49 | + module_put(atm_lane_ops.owner); | |
50 | return strlen(buf); | |
51 | } | |
52 | } | |
53 | @@ -466,6 +470,7 @@ | |
54 | if (--count) continue; | |
55 | e=sprintf(buf,"%s ",dev_lec[d]->name); | |
56 | lec_info(entry, buf+e); | |
57 | + module_put(atm_lane_ops.owner); | |
58 | return strlen(buf); | |
59 | } | |
60 | for(entry=priv->lec_no_forward; entry; | |
61 | @@ -473,6 +478,7 @@ | |
62 | if (--count) continue; | |
63 | e=sprintf(buf,"%s ",dev_lec[d]->name); | |
64 | lec_info(entry, buf+e); | |
65 | + module_put(atm_lane_ops.owner); | |
66 | return strlen(buf); | |
67 | } | |
68 | for(entry=priv->mcast_fwds; entry; | |
69 | @@ -480,9 +486,11 @@ | |
70 | if (--count) continue; | |
71 | e=sprintf(buf,"%s ",dev_lec[d]->name); | |
72 | lec_info(entry, buf+e); | |
73 | + module_put(atm_lane_ops.owner); | |
74 | return strlen(buf); | |
75 | } | |
76 | } | |
77 | + module_put(atm_lane_ops.owner); | |
78 | return 0; | |
79 | } | |
80 | #endif | |
81 | Index: linux/net/atm/common.c | |
82 | =================================================================== | |
83 | RCS file: /home/chas/CVSROOT/linux/net/atm/common.c,v | |
84 | retrieving revision 1.4 | |
85 | retrieving revision 1.5 | |
86 | diff -u -r1.4 -r1.5 | |
87 | --- linux/net/atm/common.c 25 Feb 2003 20:06:54 -0000 1.4 | |
88 | +++ linux/net/atm/common.c 26 Feb 2003 15:52:44 -0000 1.5 | |
89 | @@ -685,12 +685,15 @@ | |
90 | } | |
91 | if (atm_lane_ops.lecd_attach == NULL) | |
92 | atm_lane_init(); | |
93 | - if (atm_lane_ops.lecd_attach == NULL) { /* try again */ | |
94 | + if (!try_module_get(atm_lane_ops.owner)) { /* try again */ | |
95 | ret_val = -ENOSYS; | |
96 | goto done; | |
97 | } | |
98 | error = atm_lane_ops.lecd_attach(vcc, (int)arg); | |
99 | - if (error >= 0) sock->state = SS_CONNECTED; | |
100 | + if (error >= 0) | |
101 | + sock->state = SS_CONNECTED; | |
102 | + else | |
103 | + module_put(atm_lane_ops.owner); | |
104 | ret_val = error; | |
105 | goto done; | |
106 | case ATMLEC_MCAST: | |
107 | Index: linux/net/atm/lec.c | |
108 | =================================================================== | |
109 | RCS file: /home/chas/CVSROOT/linux/net/atm/lec.c,v | |
110 | retrieving revision 1.8 | |
111 | retrieving revision 1.10 | |
112 | diff -u -r1.8 -r1.10 | |
113 | --- linux/net/atm/lec.c 25 Feb 2003 11:59:08 -0000 1.8 | |
114 | +++ linux/net/atm/lec.c 26 Feb 2003 15:52:44 -0000 1.10 | |
115 | @@ -543,12 +543,12 @@ | |
116 | } | |
117 | ||
118 | printk("%s: Shut down!\n", dev->name); | |
119 | - MOD_DEC_USE_COUNT; | |
120 | } | |
121 | ||
122 | static struct atmdev_ops lecdev_ops = { | |
123 | close: lec_atm_close, | |
124 | - send: lec_atm_send | |
125 | + send: lec_atm_send, | |
126 | + owner: THIS_MODULE | |
127 | }; | |
128 | ||
129 | static struct atm_dev lecatm_dev = { | |
130 | @@ -824,7 +824,6 @@ | |
131 | if (dev_lec[i]->flags & IFF_UP) { | |
132 | netif_start_queue(dev_lec[i]); | |
133 | } | |
134 | - MOD_INC_USE_COUNT; | |
135 | return i; | |
136 | } | |
137 | ||
138 | @@ -834,6 +833,7 @@ | |
139 | ops->mcast_attach = lec_mcast_attach; | |
140 | ops->vcc_attach = lec_vcc_attach; | |
141 | ops->get_lecs = get_dev_lec; | |
142 | + ops->owner = lecdev_ops.owner; | |
143 | ||
144 | printk("lec.c: " __DATE__ " " __TIME__ " initialized\n"); | |
145 | ||
146 | @@ -859,6 +859,7 @@ | |
147 | atm_lane_ops.mcast_attach = NULL; | |
148 | atm_lane_ops.vcc_attach = NULL; | |
149 | atm_lane_ops.get_lecs = NULL; | |
150 | + atm_lane_ops.owner = NULL; | |
151 | ||
152 | for (i = 0; i < MAX_LEC_ITF; i++) { | |
153 | if (dev_lec[i] != NULL) { | |
154 | - | |
155 | To unsubscribe from this list: send the line "unsubscribe linux-kernel" in | |
156 | the body of a message to majordomo@vger.kernel.org | |
157 | More majordomo info at http://vger.kernel.org/majordomo-info.html | |
158 | Please read the FAQ at http://www.tux.org/lkml/ |