mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 03:10:12 +00:00
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>
This commit is contained in:
parent
38117d1495
commit
0da529a7d9
1 changed files with 79 additions and 100 deletions
|
@ -37,69 +37,6 @@
|
||||||
|
|
||||||
#define VERSION "arcnet: cap mode (`c') encapsulation support loaded.\n"
|
#define VERSION "arcnet: cap mode (`c') encapsulation support loaded.\n"
|
||||||
|
|
||||||
|
|
||||||
static void rx(struct net_device *dev, int bufnum,
|
|
||||||
struct archdr *pkthdr, int length);
|
|
||||||
static int build_header(struct sk_buff *skb,
|
|
||||||
struct net_device *dev,
|
|
||||||
unsigned short type,
|
|
||||||
uint8_t daddr);
|
|
||||||
static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
|
|
||||||
int bufnum);
|
|
||||||
static int ack_tx(struct net_device *dev, int acked);
|
|
||||||
|
|
||||||
|
|
||||||
static struct ArcProto capmode_proto =
|
|
||||||
{
|
|
||||||
'r',
|
|
||||||
XMTU,
|
|
||||||
0,
|
|
||||||
rx,
|
|
||||||
build_header,
|
|
||||||
prepare_tx,
|
|
||||||
NULL,
|
|
||||||
ack_tx
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static void arcnet_cap_init(void)
|
|
||||||
{
|
|
||||||
int count;
|
|
||||||
|
|
||||||
for (count = 1; count <= 8; count++)
|
|
||||||
if (arc_proto_map[count] == arc_proto_default)
|
|
||||||
arc_proto_map[count] = &capmode_proto;
|
|
||||||
|
|
||||||
/* for cap mode, we only set the bcast proto if there's no better one */
|
|
||||||
if (arc_bcast_proto == arc_proto_default)
|
|
||||||
arc_bcast_proto = &capmode_proto;
|
|
||||||
|
|
||||||
arc_proto_default = &capmode_proto;
|
|
||||||
arc_raw_proto = &capmode_proto;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
static int __init capmode_module_init(void)
|
|
||||||
{
|
|
||||||
printk(VERSION);
|
|
||||||
arcnet_cap_init();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void __exit capmode_module_exit(void)
|
|
||||||
{
|
|
||||||
arcnet_unregister_proto(&capmode_proto);
|
|
||||||
}
|
|
||||||
module_init(capmode_module_init);
|
|
||||||
module_exit(capmode_module_exit);
|
|
||||||
|
|
||||||
MODULE_LICENSE("GPL");
|
|
||||||
#endif /* MODULE */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* packet receiver */
|
/* packet receiver */
|
||||||
static void rx(struct net_device *dev, int bufnum,
|
static void rx(struct net_device *dev, int bufnum,
|
||||||
struct archdr *pkthdr, int length)
|
struct archdr *pkthdr, int length)
|
||||||
|
@ -231,13 +168,13 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
|
||||||
BUGMSG(D_DURING, "prepare_tx: length=%d ofs=%d\n",
|
BUGMSG(D_DURING, "prepare_tx: length=%d ofs=%d\n",
|
||||||
length,ofs);
|
length,ofs);
|
||||||
|
|
||||||
// Copy the arcnet-header + the protocol byte down:
|
/* Copy the arcnet-header + the protocol byte down: */
|
||||||
lp->hw.copy_to_card(dev, bufnum, 0, hard, ARC_HDR_SIZE);
|
lp->hw.copy_to_card(dev, bufnum, 0, hard, ARC_HDR_SIZE);
|
||||||
lp->hw.copy_to_card(dev, bufnum, ofs, &pkt->soft.cap.proto,
|
lp->hw.copy_to_card(dev, bufnum, ofs, &pkt->soft.cap.proto,
|
||||||
sizeof(pkt->soft.cap.proto));
|
sizeof(pkt->soft.cap.proto));
|
||||||
|
|
||||||
// Skip the extra integer we have written into it as a cookie
|
/* Skip the extra integer we have written into it as a cookie
|
||||||
// but write the rest of the message:
|
but write the rest of the message: */
|
||||||
lp->hw.copy_to_card(dev, bufnum, ofs+1,
|
lp->hw.copy_to_card(dev, bufnum, ofs+1,
|
||||||
((unsigned char*)&pkt->soft.cap.mes),length-1);
|
((unsigned char*)&pkt->soft.cap.mes),length-1);
|
||||||
|
|
||||||
|
@ -246,7 +183,6 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
|
||||||
return 1; /* done */
|
return 1; /* done */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ack_tx(struct net_device *dev, int acked)
|
static int ack_tx(struct net_device *dev, int acked)
|
||||||
{
|
{
|
||||||
struct arcnet_local *lp = netdev_priv(dev);
|
struct arcnet_local *lp = netdev_priv(dev);
|
||||||
|
@ -273,10 +209,9 @@ static int ack_tx(struct net_device *dev, int acked)
|
||||||
ackpkt = (struct archdr *)skb_mac_header(ackskb);
|
ackpkt = (struct archdr *)skb_mac_header(ackskb);
|
||||||
/* skb_pull(ackskb, ARC_HDR_SIZE); */
|
/* skb_pull(ackskb, ARC_HDR_SIZE); */
|
||||||
|
|
||||||
|
|
||||||
skb_copy_from_linear_data(lp->outgoing.skb, ackpkt,
|
skb_copy_from_linear_data(lp->outgoing.skb, ackpkt,
|
||||||
ARC_HDR_SIZE + sizeof(struct arc_cap));
|
ARC_HDR_SIZE + sizeof(struct arc_cap));
|
||||||
ackpkt->soft.cap.proto=0; /* using protocol 0 for acknowledge */
|
ackpkt->soft.cap.proto = 0; /* using protocol 0 for acknowledge */
|
||||||
ackpkt->soft.cap.mes.ack=acked;
|
ackpkt->soft.cap.mes.ack=acked;
|
||||||
|
|
||||||
BUGMSG(D_PROTO, "Ackknowledge for cap packet %x.\n",
|
BUGMSG(D_PROTO, "Ackknowledge for cap packet %x.\n",
|
||||||
|
@ -287,9 +222,53 @@ static int ack_tx(struct net_device *dev, int acked)
|
||||||
BUGLVL(D_SKB) arcnet_dump_skb(dev, ackskb, "ack_tx_recv");
|
BUGLVL(D_SKB) arcnet_dump_skb(dev, ackskb, "ack_tx_recv");
|
||||||
netif_rx(ackskb);
|
netif_rx(ackskb);
|
||||||
|
|
||||||
free_outskb:
|
free_outskb:
|
||||||
dev_kfree_skb_irq(lp->outgoing.skb);
|
dev_kfree_skb_irq(lp->outgoing.skb);
|
||||||
lp->outgoing.proto = NULL; /* We are always finished when in this protocol */
|
lp->outgoing.proto = NULL; /* We are always finished when in this protocol */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct ArcProto capmode_proto =
|
||||||
|
{
|
||||||
|
'r',
|
||||||
|
XMTU,
|
||||||
|
0,
|
||||||
|
rx,
|
||||||
|
build_header,
|
||||||
|
prepare_tx,
|
||||||
|
NULL,
|
||||||
|
ack_tx
|
||||||
|
};
|
||||||
|
|
||||||
|
static void arcnet_cap_init(void)
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
|
||||||
|
for (count = 1; count <= 8; count++)
|
||||||
|
if (arc_proto_map[count] == arc_proto_default)
|
||||||
|
arc_proto_map[count] = &capmode_proto;
|
||||||
|
|
||||||
|
/* for cap mode, we only set the bcast proto if there's no better one */
|
||||||
|
if (arc_bcast_proto == arc_proto_default)
|
||||||
|
arc_bcast_proto = &capmode_proto;
|
||||||
|
|
||||||
|
arc_proto_default = &capmode_proto;
|
||||||
|
arc_raw_proto = &capmode_proto;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int __init capmode_module_init(void)
|
||||||
|
{
|
||||||
|
printk(VERSION);
|
||||||
|
arcnet_cap_init();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __exit capmode_module_exit(void)
|
||||||
|
{
|
||||||
|
arcnet_unregister_proto(&capmode_proto);
|
||||||
|
}
|
||||||
|
module_init(capmode_module_init);
|
||||||
|
module_exit(capmode_module_exit);
|
||||||
|
|
||||||
|
MODULE_LICENSE("GPL");
|
||||||
|
|
Loading…
Reference in a new issue