aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorDaniel Mack <daniel@caiaq.de>2010-05-31 03:35:13 -0400
committerDavid S. Miller <davem@davemloft.net>2010-05-31 03:35:13 -0400
commit0da529a7d996f100569040857ddf4d63a1b24e82 (patch)
treedd713c147fa3ba466f2875bc5524f9d47ab3131b /drivers/net
parent38117d1495e587fbb10d6e55733139a27893cef5 (diff)
drivers/net/arcnet/capmode.c: clean up code
- shuffle around functions to get rid of forward declarations - fix some CodingStyle and indentation issues - last but not least, get rid of the following CONFIG_MODULE=n warning: drivers/net/arcnet/capmode.c:52: warning: ‘capmode_proto’ defined but not used Signed-off-by: Daniel Mack <daniel@caiaq.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/arcnet/capmode.c177
1 files changed, 78 insertions, 99 deletions
diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c
index 355797f70048..42fce91b71fc 100644
--- a/drivers/net/arcnet/capmode.c
+++ b/drivers/net/arcnet/capmode.c
@@ -37,69 +37,6 @@
37 37
38#define VERSION "arcnet: cap mode (`c') encapsulation support loaded.\n" 38#define VERSION "arcnet: cap mode (`c') encapsulation support loaded.\n"
39 39
40
41static void rx(struct net_device *dev, int bufnum,
42 struct archdr *pkthdr, int length);
43static int build_header(struct sk_buff *skb,
44 struct net_device *dev,
45 unsigned short type,
46 uint8_t daddr);
47static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
48 int bufnum);
49static int ack_tx(struct net_device *dev, int acked);
50
51
52static struct ArcProto capmode_proto =
53{
54 'r',
55 XMTU,
56 0,
57 rx,
58 build_header,
59 prepare_tx,
60 NULL,
61 ack_tx
62};
63
64
65static void arcnet_cap_init(void)
66{
67 int count;
68
69 for (count = 1; count <= 8; count++)
70 if (arc_proto_map[count] == arc_proto_default)
71 arc_proto_map[count] = &capmode_proto;
72
73 /* for cap mode, we only set the bcast proto if there's no better one */
74 if (arc_bcast_proto == arc_proto_default)
75 arc_bcast_proto = &capmode_proto;
76
77 arc_proto_default = &capmode_proto;
78 arc_raw_proto = &capmode_proto;
79}
80
81
82#ifdef MODULE
83
84static int __init capmode_module_init(void)
85{
86 printk(VERSION);
87 arcnet_cap_init();
88 return 0;
89}
90
91static void __exit capmode_module_exit(void)
92{
93 arcnet_unregister_proto(&capmode_proto);
94}
95module_init(capmode_module_init);
96module_exit(capmode_module_exit);
97
98MODULE_LICENSE("GPL");
99#endif /* MODULE */
100
101
102
103/* packet receiver */ 40/* packet receiver */
104static void rx(struct net_device *dev, int bufnum, 41static void rx(struct net_device *dev, int bufnum,
105 struct archdr *pkthdr, int length) 42 struct archdr *pkthdr, int length)
@@ -231,65 +168,107 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
231 BUGMSG(D_DURING, "prepare_tx: length=%d ofs=%d\n", 168 BUGMSG(D_DURING, "prepare_tx: length=%d ofs=%d\n",
232 length,ofs); 169 length,ofs);
233 170
234 // Copy the arcnet-header + the protocol byte down: 171 /* Copy the arcnet-header + the protocol byte down: */
235 lp->hw.copy_to_card(dev, bufnum, 0, hard, ARC_HDR_SIZE); 172 lp->hw.copy_to_card(dev, bufnum, 0, hard, ARC_HDR_SIZE);
236 lp->hw.copy_to_card(dev, bufnum, ofs, &pkt->soft.cap.proto, 173 lp->hw.copy_to_card(dev, bufnum, ofs, &pkt->soft.cap.proto,
237 sizeof(pkt->soft.cap.proto)); 174 sizeof(pkt->soft.cap.proto));
238 175
239 // Skip the extra integer we have written into it as a cookie 176 /* Skip the extra integer we have written into it as a cookie
240 // but write the rest of the message: 177 but write the rest of the message: */
241 lp->hw.copy_to_card(dev, bufnum, ofs+1, 178 lp->hw.copy_to_card(dev, bufnum, ofs+1,
242 ((unsigned char*)&pkt->soft.cap.mes),length-1); 179 ((unsigned char*)&pkt->soft.cap.mes),length-1);
243 180
244 lp->lastload_dest = hard->dest; 181 lp->lastload_dest = hard->dest;
245 182
246 return 1; /* done */ 183 return 1; /* done */
247} 184}
248 185
249
250static int ack_tx(struct net_device *dev, int acked) 186static int ack_tx(struct net_device *dev, int acked)
251{ 187{
252 struct arcnet_local *lp = netdev_priv(dev); 188 struct arcnet_local *lp = netdev_priv(dev);
253 struct sk_buff *ackskb; 189 struct sk_buff *ackskb;
254 struct archdr *ackpkt; 190 struct archdr *ackpkt;
255 int length=sizeof(struct arc_cap); 191 int length=sizeof(struct arc_cap);
256 192
257 BUGMSG(D_DURING, "capmode: ack_tx: protocol: %x: result: %d\n", 193 BUGMSG(D_DURING, "capmode: ack_tx: protocol: %x: result: %d\n",
258 lp->outgoing.skb->protocol, acked); 194 lp->outgoing.skb->protocol, acked);
259 195
260 BUGLVL(D_SKB) arcnet_dump_skb(dev, lp->outgoing.skb, "ack_tx"); 196 BUGLVL(D_SKB) arcnet_dump_skb(dev, lp->outgoing.skb, "ack_tx");
261 197
262 /* Now alloc a skb to send back up through the layers: */ 198 /* Now alloc a skb to send back up through the layers: */
263 ackskb = alloc_skb(length + ARC_HDR_SIZE , GFP_ATOMIC); 199 ackskb = alloc_skb(length + ARC_HDR_SIZE , GFP_ATOMIC);
264 if (ackskb == NULL) { 200 if (ackskb == NULL) {
265 BUGMSG(D_NORMAL, "Memory squeeze, can't acknowledge.\n"); 201 BUGMSG(D_NORMAL, "Memory squeeze, can't acknowledge.\n");
266 goto free_outskb; 202 goto free_outskb;
267 } 203 }
204
205 skb_put(ackskb, length + ARC_HDR_SIZE );
206 ackskb->dev = dev;
207
208 skb_reset_mac_header(ackskb);
209 ackpkt = (struct archdr *)skb_mac_header(ackskb);
210 /* skb_pull(ackskb, ARC_HDR_SIZE); */
268 211
269 skb_put(ackskb, length + ARC_HDR_SIZE ); 212 skb_copy_from_linear_data(lp->outgoing.skb, ackpkt,
270 ackskb->dev = dev; 213 ARC_HDR_SIZE + sizeof(struct arc_cap));
214 ackpkt->soft.cap.proto = 0; /* using protocol 0 for acknowledge */
215 ackpkt->soft.cap.mes.ack=acked;
271 216
272 skb_reset_mac_header(ackskb); 217 BUGMSG(D_PROTO, "Ackknowledge for cap packet %x.\n",
273 ackpkt = (struct archdr *)skb_mac_header(ackskb); 218 *((int*)&ackpkt->soft.cap.cookie[0]));
274 /* skb_pull(ackskb, ARC_HDR_SIZE); */
275 219
220 ackskb->protocol = cpu_to_be16(ETH_P_ARCNET);
276 221
277 skb_copy_from_linear_data(lp->outgoing.skb, ackpkt, 222 BUGLVL(D_SKB) arcnet_dump_skb(dev, ackskb, "ack_tx_recv");
278 ARC_HDR_SIZE + sizeof(struct arc_cap)); 223 netif_rx(ackskb);
279 ackpkt->soft.cap.proto=0; /* using protocol 0 for acknowledge */
280 ackpkt->soft.cap.mes.ack=acked;
281 224
282 BUGMSG(D_PROTO, "Ackknowledge for cap packet %x.\n", 225free_outskb:
283 *((int*)&ackpkt->soft.cap.cookie[0])); 226 dev_kfree_skb_irq(lp->outgoing.skb);
227 lp->outgoing.proto = NULL; /* We are always finished when in this protocol */
284 228
285 ackskb->protocol = cpu_to_be16(ETH_P_ARCNET); 229 return 0;
230}
286 231
287 BUGLVL(D_SKB) arcnet_dump_skb(dev, ackskb, "ack_tx_recv"); 232static struct ArcProto capmode_proto =
288 netif_rx(ackskb); 233{
234 'r',
235 XMTU,
236 0,
237 rx,
238 build_header,
239 prepare_tx,
240 NULL,
241 ack_tx
242};
289 243
290 free_outskb: 244static void arcnet_cap_init(void)
291 dev_kfree_skb_irq(lp->outgoing.skb); 245{
292 lp->outgoing.proto = NULL; /* We are always finished when in this protocol */ 246 int count;
293 247
294 return 0; 248 for (count = 1; count <= 8; count++)
249 if (arc_proto_map[count] == arc_proto_default)
250 arc_proto_map[count] = &capmode_proto;
251
252 /* for cap mode, we only set the bcast proto if there's no better one */
253 if (arc_bcast_proto == arc_proto_default)
254 arc_bcast_proto = &capmode_proto;
255
256 arc_proto_default = &capmode_proto;
257 arc_raw_proto = &capmode_proto;
295} 258}
259
260static int __init capmode_module_init(void)
261{
262 printk(VERSION);
263 arcnet_cap_init();
264 return 0;
265}
266
267static void __exit capmode_module_exit(void)
268{
269 arcnet_unregister_proto(&capmode_proto);
270}
271module_init(capmode_module_init);
272module_exit(capmode_module_exit);
273
274MODULE_LICENSE("GPL");