Commit f3da3d88 authored by Linus Torvalds's avatar Linus Torvalds

Import 2.3.36pre5

parent eab2ce74
......@@ -7878,22 +7878,26 @@ CONFIG_USB_UHCI
The Universal Host Controller Interface is a standard by Intel for
accessing the USB hardware in the PC (which is also called the USB
host controller). If your USB host controller conforms to this
standard, say Y. All recent boards with Intel PCI chipsets conform
to this standard. If unsure, say Y.
standard, say Y. All recent boards with Intel PCI chipsets (like
intel 430TX, 440FX, 440LX, 440BX, i810, i820) conform to this standard.
Also all VIA PCI chipsets (like VIA VP2, VP3, MVP3, Apollo Pro, Apollo
Pro II or Apollo Pro 133).
If unsure, say Y.
This code is also available as a module ( = code which can be
inserted in and removed from the running kernel whenever you want).
The module will be called usb-uhci.o. If you want to compile it as a
module, say M here and read Documentation/modules.txt.
OHCI-HCD (Compaq, iMacs, OPTi, SiS, and others) support?
OHCI-HCD (Compaq, iMacs, OPTi, SiS, ALi, and others) support?
CONFIG_USB_OHCI_HCD
The Open Host Controller Interface is a standard by
Compaq/Microsoft/National for accessing the USB PC hardware (also
called USB host controller). If your USB host controller conforms
to this standard, say Y. The USB host controllers on most
non-Intel architectures and on several x86 compatibles with
non-Intel chipsets conform to this standard.
non-Intel architectures and on several x86 compatibles with non-Intel
chipsets - like SiS (aktual 610, 610 and so on) or ALi (ALi IV, ALi V,
Aladin Pro..) - conform to this standard.
You may want to read the file drivers/usb/README.ohci_hcd.
......
......@@ -23,6 +23,7 @@
*
* **********************
*/
#include <linux/module.h>
#include <linux/config.h> /* for CONFIG_INET */
#include <linux/init.h>
......@@ -43,7 +44,8 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
int bufnum);
struct ArcProto rawmode_proto = {
struct ArcProto rawmode_proto =
{
'r',
XMTU,
rx,
......@@ -90,7 +92,7 @@ void cleanup_module(void)
static void rx(struct net_device *dev, int bufnum,
struct archdr *pkthdr, int length)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
struct sk_buff *skb;
struct archdr *pkt = pkthdr;
int ofs;
......@@ -103,17 +105,15 @@ static void rx(struct net_device *dev, int bufnum,
ofs = 256 - length;
skb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
if (skb == NULL)
{
if (skb == NULL) {
BUGMSG(D_NORMAL, "Memory squeeze, dropping packet.\n");
lp->stats.rx_dropped++;
return;
}
skb_put(skb, length + ARC_HDR_SIZE);
skb->dev = dev;
pkt = (struct archdr *)skb->data;
pkt = (struct archdr *) skb->data;
skb->mac.raw = skb->data;
skb_pull(skb, ARC_HDR_SIZE);
......@@ -141,7 +141,7 @@ static int build_header(struct sk_buff *skb, unsigned short type,
{
struct net_device *dev = skb->dev;
int hdr_size = ARC_HDR_SIZE;
struct archdr *pkt = (struct archdr *)skb_push(skb, hdr_size);
struct archdr *pkt = (struct archdr *) skb_push(skb, hdr_size);
/*
* Set the source hardware address.
......@@ -154,8 +154,7 @@ static int build_header(struct sk_buff *skb, unsigned short type,
/* see linux/net/ethernet/eth.c to see where I got the following */
if (dev->flags & (IFF_LOOPBACK|IFF_NOARP))
{
if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) {
/*
* FIXME: fill in the last byte of the dest ipaddr here to better
* comply with RFC1051 in "noarp" mode.
......@@ -163,7 +162,6 @@ static int build_header(struct sk_buff *skb, unsigned short type,
pkt->hard.dest = 0;
return hdr_size;
}
/* otherwise, just fill it in and go! */
pkt->hard.dest = daddr;
......@@ -174,7 +172,7 @@ static int build_header(struct sk_buff *skb, unsigned short type,
static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
int bufnum)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
struct arc_hardware *hard = &pkt->hard;
int ofs;
......@@ -183,25 +181,19 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
length -= ARC_HDR_SIZE; /* hard header is not included in packet length */
if (length > XMTU)
{
if (length > XMTU) {
/* should never happen! other people already check for this. */
BUGMSG(D_NORMAL, "Bug! prepare_tx with size %d (> %d)\n",
length, XMTU);
length = XMTU;
}
if (length > MinTU)
{
if (length > MinTU) {
hard->offset[0] = 0;
hard->offset[1] = ofs = 512 - length;
}
else if (length > MTU)
{
} else if (length > MTU) {
hard->offset[0] = 0;
hard->offset[1] = ofs = 512 - length - 3;
}
else
} else
hard->offset[0] = ofs = 256 - length;
lp->hw.copy_to_card(dev, bufnum, 0, hard, ARC_HDR_SIZE);
......
......@@ -43,12 +43,12 @@
static int arcrimi_probe(struct net_device *dev);
static int arcrimi_found(struct net_device *dev);
static void arcrimi_command (struct net_device *dev, int command);
static int arcrimi_status (struct net_device *dev);
static void arcrimi_setmask (struct net_device *dev, int mask);
static int arcrimi_reset (struct net_device *dev, int really_reset);
static void arcrimi_command(struct net_device *dev, int command);
static int arcrimi_status(struct net_device *dev);
static void arcrimi_setmask(struct net_device *dev, int mask);
static int arcrimi_reset(struct net_device *dev, int really_reset);
static void arcrimi_openclose(struct net_device *dev, bool open);
static void arcrimi_copy_to_card (struct net_device *dev, int bufnum, int offset,
static void arcrimi_copy_to_card(struct net_device *dev, int bufnum, int offset,
void *buf, int count);
static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int offset,
void *buf, int count);
......@@ -97,18 +97,15 @@ static int __init arcrimi_probe(struct net_device *dev)
"must specify the shmem and irq!\n");
return -ENODEV;
}
if (check_mem_region(dev->mem_start, BUFFER_SIZE)) {
BUGMSG(D_NORMAL, "Card memory already allocated\n");
return -ENODEV;
}
if (dev->dev_addr[0] == 0) {
BUGMSG(D_NORMAL, "You need to specify your card's station "
"ID!\n");
return -ENODEV;
}
return arcrimi_found(dev);
}
......@@ -178,7 +175,6 @@ static int __init arcrimi_found(struct net_device *dev)
BUGMSG(D_NORMAL, "Can't remap device memory!\n");
goto err_free_dev_priv;
}
/* Fill in the fields of the device structure with generic
* values.
*/
......@@ -198,9 +194,9 @@ static int __init arcrimi_found(struct net_device *dev)
return 0;
err_free_dev_priv:
err_free_dev_priv:
kfree(dev->priv);
err_free_irq:
err_free_irq:
free_irq(dev->irq, dev);
return -EIO;
}
......@@ -222,10 +218,9 @@ static int arcrimi_reset(struct net_device *dev, int really_reset)
BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n", dev->name, ASTATUS());
if (really_reset) {
writeb(TESTvalue, ioaddr-0x800); /* fake reset */
writeb(TESTvalue, ioaddr - 0x800); /* fake reset */
return 0;
}
ACOMMAND(CFLAGScmd | RESETclear); /* clear flags & end reset */
ACOMMAND(CFLAGScmd | CONFIGclear);
......@@ -273,7 +268,7 @@ static void arcrimi_copy_to_card(struct net_device *dev, int bufnum, int offset,
void *buf, int count)
{
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
void *memaddr = lp->mem_start + 0x800 + bufnum*512 + offset;
void *memaddr = lp->mem_start + 0x800 + bufnum * 512 + offset;
TIME("memcpy_toio", count, memcpy_toio(memaddr, buf, count));
}
......@@ -282,7 +277,7 @@ static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int offse
void *buf, int count)
{
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
void *memaddr = lp->mem_start + 0x800 + bufnum*512 + offset;
void *memaddr = lp->mem_start + 0x800 + bufnum * 512 + offset;
TIME("memcpy_fromio", count, memcpy_fromio(buf, memaddr, count));
}
......@@ -360,7 +355,7 @@ static int __init arcrimi_setup(char *s)
return 1;
dev = alloc_bootmem(sizeof(struct net_device) + 10);
memset(dev, 0, sizeof(struct net_device) + 10);
dev->name = (char *)(dev+1);
dev->name = (char *) (dev + 1);
dev->init = arcrimi_probe;
switch (ints[0]) {
......
......@@ -70,7 +70,8 @@ static int null_prepare_tx(struct net_device *dev, struct archdr *pkt,
*/
struct ArcProto *arc_proto_map[256], *arc_proto_default, *arc_bcast_proto;
struct ArcProto arc_proto_null = {
struct ArcProto arc_proto_null =
{
'?',
XMTU,
null_rx,
......@@ -113,8 +114,7 @@ void __init arcnet_init(void)
printk(VERSION);
#ifdef ALPHA_WARNING
BUGLVL(D_EXTRA)
{
BUGLVL(D_EXTRA) {
printk("arcnet: ***\n"
"arcnet: * Read arcnet.txt for important release notes!\n"
"arcnet: *\n"
......@@ -191,8 +191,7 @@ void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc)
save_flags(flags);
cli();
printk(KERN_DEBUG "%6s: skb dump (%s) follows:", dev->name, desc);
for (i = 0; i < skb->len; i++)
{
for (i = 0; i < skb->len; i++) {
if (i % 16 == 0)
printk("\n" KERN_DEBUG "[%04X] ", i);
printk("%02X ", ((u_char *) skb->data)[i]);
......@@ -211,7 +210,7 @@ EXPORT_SYMBOL(arcnet_dump_skb);
#if (ARCNET_DEBUG_MAX & (D_RX | D_TX))
void arcnet_dump_packet(struct net_device *dev, int bufnum, char *desc)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
int i, length;
long flags;
static uint8_t buf[512];
......@@ -225,8 +224,7 @@ void arcnet_dump_packet(struct net_device *dev, int bufnum, char *desc)
length = (buf[2] ? 256 : 512);
printk(KERN_DEBUG "%6s: packet dump (%s) follows:", dev->name, desc);
for (i = 0; i < length; i++)
{
for (i = 0; i < length; i++) {
if (i % 16 == 0)
printk("\n" KERN_DEBUG "[%04X] ", i);
printk("%02X ", buf[i]);
......@@ -254,8 +252,7 @@ void arcnet_unregister_proto(struct ArcProto *proto)
if (arc_bcast_proto == proto)
arc_bcast_proto = arc_proto_default;
for (count = 0; count < 256; count++)
{
for (count = 0; count < 256; count++) {
if (arc_proto_map[count] == proto)
arc_proto_map[count] = arc_proto_default;
}
......@@ -271,14 +268,13 @@ void arcnet_unregister_proto(struct ArcProto *proto)
*/
static void release_arcbuf(struct net_device *dev, int bufnum)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
int i;
lp->buf_queue[lp->first_free_buf++] = bufnum;
lp->first_free_buf %= 5;
BUGLVL(D_DURING)
{
BUGLVL(D_DURING) {
BUGMSG(D_DURING, "release_arcbuf: freed #%d; buffer queue is now: ",
bufnum);
for (i = lp->next_buf; i != lp->first_free_buf; i = ++i % 5)
......@@ -294,28 +290,25 @@ static void release_arcbuf(struct net_device *dev, int bufnum)
*/
static int get_arcbuf(struct net_device *dev)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
int buf = -1, i;
if (!atomic_dec_and_test(&lp->buf_lock)) /* already in this function */
BUGMSG(D_NORMAL, "get_arcbuf: overlap (%d)!\n", lp->buf_lock.counter);
else /* we can continue */
{
else { /* we can continue */
if (lp->next_buf >= 5)
lp->next_buf -= 5;
if (lp->next_buf == lp->first_free_buf)
BUGMSG(D_NORMAL, "get_arcbuf: BUG: no buffers are available??\n");
else
{
else {
buf = lp->buf_queue[lp->next_buf++];
lp->next_buf %= 5;
}
}
BUGLVL(D_DURING)
{
BUGLVL(D_DURING) {
BUGMSG(D_DURING, "get_arcbuf: got #%d; buffer queue is now: ", buf);
for (i = lp->next_buf; i != lp->first_free_buf; i = ++i % 5)
BUGMSG2(D_DURING, "#%d ", lp->buf_queue[i]);
......@@ -332,11 +325,9 @@ static int choose_mtu(void)
int count, mtu = 65535;
/* choose the smallest MTU of all available encaps */
for (count = 0; count < 256; count++)
{
for (count = 0; count < 256; count++) {
if (arc_proto_map[count] != &arc_proto_null
&& arc_proto_map[count]->mtu < mtu)
{
&& arc_proto_map[count]->mtu < mtu) {
mtu = arc_proto_map[count]->mtu;
}
}
......@@ -384,11 +375,10 @@ void arcdev_setup(struct net_device *dev)
*/
static int arcnet_open(struct net_device *dev)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
int count, newmtu;
BUGLVL(D_PROTO)
{
BUGLVL(D_PROTO) {
int count;
BUGMSG(D_PROTO, "protocol map (default is '%c'): ",
arc_proto_default->suffix);
......@@ -418,10 +408,8 @@ static int arcnet_open(struct net_device *dev)
memset(lp->default_proto, 0, sizeof(lp->default_proto));
/* the broadcast address is special - use the 'bcast' protocol */
for (count = 0; count < 256; count++)
{
if (arc_proto_map[count] == arc_bcast_proto)
{
for (count = 0; count < 256; count++) {
if (arc_proto_map[count] == arc_bcast_proto) {
lp->default_proto[0] = count;
break;
}
......@@ -471,7 +459,7 @@ static int arcnet_open(struct net_device *dev)
/* The inverse routine to arcnet_open - shuts down the card. */
static int arcnet_close(struct net_device *dev)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
/* flush TX and disable RX */
AINTMASK(0);
......@@ -494,14 +482,14 @@ static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
unsigned short type, void *daddr, void *saddr,
unsigned len)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
uint8_t _daddr, proto_num;
struct ArcProto *proto;
BUGMSG(D_DURING,
"create header from %d to %d; protocol %d (%Xh); size %u.\n",
saddr ? *(uint8_t *)saddr : -1,
daddr ? *(uint8_t *)daddr : -1,
saddr ? *(uint8_t *) saddr : -1,
daddr ? *(uint8_t *) daddr : -1,
type, type, len);
if (len != skb->len)
......@@ -513,23 +501,20 @@ static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
* Store the packet type (eg. ETH_P_IP) for now, and we'll push on a
* real header when we do rebuild_header.
*/
if (!daddr)
{
*(uint16_t *)skb_push(skb, 2) = type;
if (!daddr) {
*(uint16_t *) skb_push(skb, 2) = type;
if (skb->nh.raw - skb->mac.raw != 2)
BUGMSG(D_NORMAL, "arcnet_header: Yikes! diff (%d) is not 2!\n",
skb->nh.raw - skb->mac.raw);
return -2; /* return error -- can't transmit yet! */
}
/* otherwise, we can just add the header as usual. */
_daddr = *(uint8_t *)daddr;
_daddr = *(uint8_t *) daddr;
proto_num = lp->default_proto[_daddr];
proto = arc_proto_map[proto_num];
BUGMSG(D_DURING, "building header for %02Xh using protocol '%c'\n",
proto_num, proto->suffix);
if (proto == &arc_proto_null && arc_bcast_proto != proto)
{
if (proto == &arc_proto_null && arc_bcast_proto != proto) {
BUGMSG(D_DURING, "actually, let's use '%c' instead.\n",
arc_bcast_proto->suffix);
proto = arc_bcast_proto;
......@@ -546,32 +531,27 @@ static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
static int arcnet_rebuild_header(struct sk_buff *skb)
{
struct net_device *dev = skb->dev;
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
int status = 0; /* default is failure */
unsigned short type;
uint8_t daddr;
if (skb->nh.raw - skb->mac.raw != 2)
{
if (skb->nh.raw - skb->mac.raw != 2) {
BUGMSG(D_NORMAL,
"rebuild_header: shouldn't be here! (hdrsize=%d)\n",
skb->nh.raw - skb->mac.raw);
return 0;
}
type = *(uint16_t *) skb_pull(skb, 2);
type = *(uint16_t *)skb_pull(skb, 2);
if (type == ETH_P_IP)
{
if (type == ETH_P_IP) {
#ifdef CONFIG_INET
BUGMSG(D_DURING, "rebuild header for ethernet protocol %Xh\n", type);
status = arp_find(&daddr, skb) ? 1 : 0;
BUGMSG(D_DURING, " rebuilt: dest is %d; protocol %Xh\n",
daddr, type);
#endif
}
else
{
} else {
BUGMSG(D_NORMAL,
"I don't understand ethernet protocol %Xh addresses!\n", type);
lp->stats.tx_errors++;
......@@ -593,7 +573,7 @@ static int arcnet_rebuild_header(struct sk_buff *skb)
/* Called by the kernel in order to transmit a packet. */
static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
struct archdr *pkt;
struct arc_rfc1201 *soft;
struct ArcProto *proto;
......@@ -603,8 +583,7 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev)
"transmit requested (status=%Xh, txbufs=%d/%d, len=%d)\n",
ASTATUS(), lp->cur_tx, lp->next_tx, skb->len);
if (dev->tbusy)
{
if (dev->tbusy) {
/*
* If we get here, some higher level has decided we are broken.
* There should really be a "kick me" function call instead.
......@@ -612,24 +591,19 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev)
unsigned long flags;
int tickssofar = jiffies - dev->trans_start, status = ASTATUS();
if (tickssofar < TX_TIMEOUT)
{
if (tickssofar < TX_TIMEOUT) {
BUGMSG(D_DURING, "premature kickme! (status=%Xh ticks=%d)\n",
status, tickssofar);
return 1; /* means "try again" */
}
save_flags(flags);
cli();
if (status & TXFREEflag) /* transmit _DID_ finish */
{
if (status & TXFREEflag) { /* transmit _DID_ finish */
BUGMSG(D_NORMAL, "tx timeout - missed IRQ? (status=%Xh, ticks=%d, mask=%Xh, dest=%02Xh)\n",
status, tickssofar, lp->intmask, lp->lasttrans_dest);
lp->stats.tx_errors++;
}
else
{
} else {
BUGMSG(D_EXTRA, "tx timed out (status=%Xh, tickssofar=%d, intmask=%Xh, dest=%02Xh)\n",
status, tickssofar, lp->intmask, lp->lasttrans_dest);
lp->stats.tx_errors++;
......@@ -651,27 +625,23 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev)
restore_flags(flags);
return 1;
}
pkt = (struct archdr *)skb->data;
pkt = (struct archdr *) skb->data;
soft = &pkt->soft.rfc1201;
proto = arc_proto_map[soft->proto];
BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "tx");
/* fits in one packet? */
if (skb->len - ARC_HDR_SIZE > XMTU && !proto->continue_tx)
{
if (skb->len - ARC_HDR_SIZE > XMTU && !proto->continue_tx) {
BUGMSG(D_NORMAL, "fixme: packet too large: compensating badly!\n");
dev_kfree_skb(skb);
return 0; /* don't try again */
}
/*
* Block a timer-based transmit from overlapping. This could better be
* done with atomic_swap(1, dev->tbusy), but set_bit() works as well.
*/
if (test_and_set_bit(0, (int *)&dev->tbusy))
{
if (test_and_set_bit(0, (int *) &dev->tbusy)) {
BUGMSG(D_NORMAL, "transmitter called with busy bit set! "
"(status=%Xh, tickssofar=%ld)\n",
ASTATUS(), jiffies - dev->trans_start);
......@@ -679,20 +649,15 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev)
lp->stats.tx_fifo_errors++;
return 0; /* don't try again */
}
AINTMASK(0);
txbuf = get_arcbuf(dev);
if (txbuf != -1)
{
if (proto->prepare_tx(dev, pkt, skb->len, txbuf))
{
if (txbuf != -1) {
if (proto->prepare_tx(dev, pkt, skb->len, txbuf)) {
/* done right away */
lp->stats.tx_bytes += skb->len;
dev_kfree_skb(skb);
}
else
{
} else {
/* do it the 'split' way */
lp->outgoing.proto = proto;
lp->outgoing.skb = skb;
......@@ -700,8 +665,7 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev)
if (!proto->continue_tx)
BUGMSG(D_NORMAL, "bug! prep_tx==0, but no continue_tx!\n");
else if (proto->continue_tx(dev, txbuf))
{
else if (proto->continue_tx(dev, txbuf)) {
BUGMSG(D_NORMAL,
"bug! continue_tx finished the first time! "
"(proto='%c')\n", proto->suffix);
......@@ -709,8 +673,7 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev)
}
lp->next_tx = txbuf;
}
else
} else
dev_kfree_skb(skb);
/* make sure we didn't ignore a TX IRQ while we were in here */
......@@ -728,7 +691,7 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev)
*/
static int go_tx(struct net_device *dev)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
BUGMSG(D_DURING, "go_tx: status=%Xh, intmask=%Xh, next_tx=%d, cur_tx=%d\n",
ASTATUS(), lp->intmask, lp->next_tx, lp->cur_tx);
......@@ -767,48 +730,38 @@ void arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
BUGMSG(D_DURING, "\n");
if (dev == NULL)
{
if (dev == NULL) {
BUGMSG(D_DURING, "arcnet: irq %d for unknown device.\n", irq);
return;
}
BUGMSG(D_DURING, "in arcnet_interrupt\n");
lp = (struct arcnet_local *)dev->priv;
if (!lp)
{
lp = (struct arcnet_local *) dev->priv;
if (!lp) {
BUGMSG(D_DURING, "arcnet: irq ignored due to missing lp.\n");
return;
}
/*
* RESET flag was enabled - if !dev->start, we must clear it right
* away (but nothing else).
*/
if (!dev->start)
{
if (!dev->start) {
if (ASTATUS() & RESETflag)
ACOMMAND(CFLAGScmd | RESETclear);
AINTMASK(0);
return;
}
if (dev->interrupt)
{
if (dev->interrupt) {
BUGMSG(D_NORMAL, "DRIVER PROBLEM! Nested arcnet interrupts!\n");
return; /* don't even try. */
}
dev->interrupt = 1;
BUGMSG(D_DURING, "in arcnet_inthandler (status=%Xh, intmask=%Xh)\n",
ASTATUS(), lp->intmask);
boguscount = 3;
do
{
do {
status = ASTATUS();
didsomething = 0;
......@@ -818,8 +771,7 @@ void arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
*
* The card is in an undefined state. Clear it out and start over.
*/
if (status & RESETflag)
{
if (status & RESETflag) {
BUGMSG(D_NORMAL, "spurious reset (status=%Xh)\n", status);
arcnet_close(dev);
arcnet_open(dev);
......@@ -827,8 +779,6 @@ void arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
/* get out of the interrupt handler! */
break;
}
/*
* RX is inhibited - we must have received something. Prepare to
* receive into the next buffer.
......@@ -839,50 +789,39 @@ void arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
* of interrupts at once.
*/
recbuf = -1;
if (status & lp->intmask & NORXflag)
{
if (status & lp->intmask & NORXflag) {
recbuf = lp->cur_rx;
BUGMSG(D_DURING, "Buffer #%d: receive irq (status=%Xh)\n",
recbuf, status);
lp->cur_rx = get_arcbuf(dev);
if (lp->cur_rx != -1)
{
if (lp->cur_rx != -1) {
BUGMSG(D_DURING, "enabling receive to buffer #%d\n",
lp->cur_rx);
ACOMMAND(RXcmd | (lp->cur_rx << 3) | RXbcasts);
}
didsomething++;
}
/* a transmit finished, and we're interested in it. */
if (status & lp->intmask & TXFREEflag)
{
if (status & lp->intmask & TXFREEflag) {
lp->intmask &= ~TXFREEflag;
BUGMSG(D_DURING, "TX IRQ (stat=%Xh)\n", status);
if (lp->cur_tx != -1 && !(status & TXACKflag))
{
if (lp->lasttrans_dest != 0)
{
if (lp->cur_tx != -1 && !(status & TXACKflag)) {
if (lp->lasttrans_dest != 0) {
BUGMSG(D_EXTRA, "transmit was not acknowledged! "
"(status=%Xh, dest=%02Xh)\n",
status, lp->lasttrans_dest);
lp->stats.tx_errors++;
lp->stats.tx_carrier_errors++;
}
else
{
} else {
BUGMSG(D_DURING,
"broadcast was not acknowledged; that's normal "
"(status=%Xh, dest=%02Xh)\n",
status, lp->lasttrans_dest);
}
}
if (lp->cur_tx != -1)
release_arcbuf(dev, lp->cur_tx);
......@@ -893,34 +832,26 @@ void arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
go_tx(dev);
/* continue a split packet, if any */
if (lp->outgoing.proto && lp->outgoing.proto->continue_tx)
{
if (lp->outgoing.proto && lp->outgoing.proto->continue_tx) {
int txbuf = get_arcbuf(dev);
if (txbuf != -1)
{
if (lp->outgoing.proto->continue_tx(dev, txbuf))
{
if (txbuf != -1) {
if (lp->outgoing.proto->continue_tx(dev, txbuf)) {
/* that was the last segment */
lp->stats.tx_bytes += lp->outgoing.skb->len;
dev_kfree_skb(lp->outgoing.skb);
lp->outgoing.proto = NULL;
}
lp->next_tx = txbuf;
}
}
/* inform upper layers of idleness, if necessary */
if (lp->cur_tx == -1)
{
if (lp->cur_tx == -1) {
dev->tbusy = 0;
mark_bh(NET_BH);
}
}
/* now process the received packet, if any */
if (recbuf != -1)
{
if (recbuf != -1) {
BUGLVL(D_RX) arcnet_dump_packet(dev, recbuf, "rx irq");
arcnet_rx(dev, recbuf);
......@@ -928,9 +859,7 @@ void arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
didsomething++;
}
if (status & lp->intmask & RECONflag)
{
if (status & lp->intmask & RECONflag) {
ACOMMAND(CFLAGScmd | CONFIGclear);
lp->stats.tx_carrier_errors++;
......@@ -939,17 +868,14 @@ void arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
/* is the RECON info empty or old? */
if (!lp->first_recon || !lp->last_recon ||
jiffies - lp->last_recon > HZ * 10)
{
jiffies - lp->last_recon > HZ * 10) {
if (lp->network_down)
BUGMSG(D_NORMAL, "reconfiguration detected: cabling restored?\n");
lp->first_recon = lp->last_recon = jiffies;
lp->num_recons = lp->network_down = 0;
BUGMSG(D_DURING, "recon: clearing counters.\n");
}
else
{ /* add to current RECON counter */
} else { /* add to current RECON counter */
lp->last_recon = jiffies;
lp->num_recons++;
......@@ -966,22 +892,17 @@ void arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
*/
if (!lp->network_down
&& (lp->last_recon - lp->first_recon) <= HZ * 60
&& lp->num_recons >= RECON_THRESHOLD)
{
&& lp->num_recons >= RECON_THRESHOLD) {
lp->network_down = 1;
BUGMSG(D_NORMAL, "many reconfigurations detected: cabling problem?\n");
}
else if (!lp->network_down
&& lp->last_recon - lp->first_recon > HZ * 60)
{
} else if (!lp->network_down
&& lp->last_recon - lp->first_recon > HZ * 60) {
/* reset counters if we've gone for over a minute. */
lp->first_recon = lp->last_recon;
lp->num_recons = 1;
}
}
}
else if (lp->network_down && jiffies - lp->last_recon > HZ * 10)
{
} else if (lp->network_down && jiffies - lp->last_recon > HZ * 10) {
if (lp->network_down)
BUGMSG(D_NORMAL, "cabling restored?\n");
lp->first_recon = lp->last_recon = 0;
......@@ -1011,7 +932,7 @@ void arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
*/
void arcnet_rx(struct net_device *dev, int bufnum)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
struct archdr pkt;
struct arc_rfc1201 *soft;
int length, ofs;
......@@ -1019,13 +940,10 @@ void arcnet_rx(struct net_device *dev, int bufnum)
soft = &pkt.soft.rfc1201;
lp->hw.copy_from_card(dev, bufnum, 0, &pkt, sizeof(ARC_HDR_SIZE));
if (pkt.hard.offset[0])
{
if (pkt.hard.offset[0]) {
ofs = pkt.hard.offset[0];
length = 256 - ofs;
}
else
{
} else {
ofs = pkt.hard.offset[1];
length = 512 - ofs;
}
......@@ -1033,8 +951,7 @@ void arcnet_rx(struct net_device *dev, int bufnum)
/* get the full header, if possible */
if (sizeof(pkt.soft) < length)
lp->hw.copy_from_card(dev, bufnum, ofs, soft, sizeof(pkt.soft));
else
{
else {
memset(&pkt.soft, 0, sizeof(pkt.soft));
lp->hw.copy_from_card(dev, bufnum, ofs, soft, length);
}
......@@ -1047,16 +964,13 @@ void arcnet_rx(struct net_device *dev, int bufnum)
lp->stats.rx_bytes += length + ARC_HDR_SIZE;
/* call the right receiver for the protocol */
if (arc_proto_map[soft->proto] != &arc_proto_null)
{
BUGLVL(D_PROTO)
{
if (arc_proto_map[soft->proto] != &arc_proto_null) {
BUGLVL(D_PROTO) {
struct ArcProto
*oldp = arc_proto_map[lp->default_proto[pkt.hard.source]],
*newp = arc_proto_map[soft->proto];
if (oldp != newp)
{
if (oldp != newp) {
BUGMSG(D_PROTO,
"got protocol %02Xh; encap for host %02Xh is now '%c'"
" (was '%c')\n", soft->proto, pkt.hard.source,
......@@ -1070,7 +984,6 @@ void arcnet_rx(struct net_device *dev, int bufnum)
/* in striking contrast, the following isn't a hack. */
lp->default_proto[pkt.hard.source] = soft->proto;
}
/* call the protocol-specific receiver. */
arc_proto_map[soft->proto]->rx(dev, bufnum, &pkt, length);
......@@ -1106,7 +1019,7 @@ static int null_build_header(struct sk_buff *skb, unsigned short type,
uint8_t daddr)
{
struct net_device *dev = skb->dev;
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
BUGMSG(D_PROTO,
"tx: can't build header for encap %02Xh; load a protocol driver.\n",
......@@ -1121,7 +1034,7 @@ static int null_build_header(struct sk_buff *skb, unsigned short type,
static int null_prepare_tx(struct net_device *dev, struct archdr *pkt,
int length, int bufnum)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
struct arc_hardware newpkt;
BUGMSG(D_PROTO, "tx: no encap for this host; load a protocol driver.\n");
......
......@@ -60,31 +60,24 @@ static int __init com20020isa_probe(struct net_device *dev)
BUGLVL(D_NORMAL) printk(VERSION);
ioaddr = dev->base_addr;
if (!ioaddr)
{
if (!ioaddr) {
BUGMSG(D_NORMAL, "No autoprobe (yet) for IO mapped cards; you "
"must specify the base address!\n");
return -ENODEV;
}
if (check_region(ioaddr, ARCNET_TOTAL_SIZE))
{
if (check_region(ioaddr, ARCNET_TOTAL_SIZE)) {
BUGMSG(D_NORMAL, "IO region %xh-%xh already allocated.\n",
ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
return -ENXIO;
}
if (ASTATUS() == 0xFF)
{
if (ASTATUS() == 0xFF) {
BUGMSG(D_NORMAL, "IO address %x empty\n", ioaddr);
return -ENODEV;
}
if (com20020_check(dev))
return -ENODEV;
if (!dev->irq)
{
if (!dev->irq) {
/* if we do this, we're sure to get an IRQ since the
* card has just reset and the NORXflag is on until
* we tell it to start receiving.
......@@ -97,22 +90,19 @@ static int __init com20020isa_probe(struct net_device *dev)
outb(0, _INTMASK);
dev->irq = probe_irq_off(airqmask);
if (dev->irq <= 0)
{
if (dev->irq <= 0) {
BUGMSG(D_INIT_REASONS, "Autoprobe IRQ failed first time\n");
airqmask = probe_irq_on();
outb(NORXflag, _INTMASK);
udelay(5);
outb(0, _INTMASK);
dev->irq = probe_irq_off(airqmask);
if (dev->irq <= 0)
{
if (dev->irq <= 0) {
BUGMSG(D_NORMAL, "Autoprobe IRQ failed.\n");
return -ENODEV;
}
}
}
return com20020_found(dev, 0);
}
......@@ -209,8 +199,8 @@ static int __init com20020isa_setup(char *s)
return 1;
dev = alloc_bootmem(sizeof(struct net_device) + sizeof(struct arcnet_local) + 10);
memset(dev, 0, sizeof(struct net_device) + sizeof(struct arcnet_local) + 10);
lp = dev->priv = (struct arcnet_local *)(dev+1);
dev->name = (char *)(lp+1);
lp = dev->priv = (struct arcnet_local *) (dev + 1);
dev->name = (char *) (lp + 1);
dev->init = com20020isa_probe;
switch (ints[0]) {
......
......@@ -43,7 +43,8 @@
#define VERSION "arcnet: COM20020 PCI support\n"
#ifdef MODULE
static struct net_device *cards[16];
#define MAX_CARDS 16
static struct net_device *cards[MAX_CARDS];
static int numcards;
#endif
......@@ -68,8 +69,7 @@ static int __init com20020pci_probe(char *name_template, int node, int backplane
BUGLVL(D_NORMAL) printk(VERSION);
while ((pdev = pci_find_device(0x1571, 0xa004, pdev)))
{
while ((pdev = pci_find_device(0x1571, 0xa004, pdev))) {
if (pci_enable_device(pdev))
continue;
dev = dev_alloc(name_template ? : "arc%d", &err);
......@@ -92,26 +92,24 @@ static int __init com20020pci_probe(char *name_template, int node, int backplane
BUGMSG(D_INIT, "PCI BIOS reports a device at %Xh, IRQ %d\n",
ioaddr, dev->irq);
if (check_region(ioaddr, ARCNET_TOTAL_SIZE))
{
if (check_region(ioaddr, ARCNET_TOTAL_SIZE)) {
BUGMSG(D_INIT, "IO region %xh-%xh already allocated.\n",
ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
continue;
}
if (ASTATUS() == 0xFF)
{
if (ASTATUS() == 0xFF) {
BUGMSG(D_NORMAL, "IO address %Xh was reported by PCI BIOS, "
"but seems empty!\n", ioaddr);
continue;
}
if (com20020_check(dev))
continue;
if (!com20020_found(dev, SA_SHIRQ))
{
if (!com20020_found(dev, SA_SHIRQ)) {
#ifdef MODULE
if(numcards==MAX_CARDS)
printk(KERN_WARNING "com20020pci: Too many cards. Ignoring.\n");
else
cards[numcards++] = dev;
#endif
gotone++;
......@@ -148,8 +146,7 @@ void cleanup_module(void)
struct net_device *dev;
int count;
for (count = 0; count < numcards; count++)
{
for (count = 0; count < numcards; count++) {
dev = cards[count];
if (dev->start)
......
......@@ -46,12 +46,12 @@ static char *clockrates[] =
"156.25 Kb/s", "Reserved", "Reserved",
"Reserved"};
static void com20020_command (struct net_device *dev, int command);
static int com20020_status (struct net_device *dev);
static void com20020_setmask (struct net_device *dev, int mask);
static int com20020_reset (struct net_device *dev, int really_reset);
static void com20020_command(struct net_device *dev, int command);
static int com20020_status(struct net_device *dev);
static void com20020_setmask(struct net_device *dev, int mask);
static int com20020_reset(struct net_device *dev, int really_reset);
static void com20020_openclose(struct net_device *dev, bool open);
static void com20020_copy_to_card (struct net_device *dev, int bufnum,
static void com20020_copy_to_card(struct net_device *dev, int bufnum,
int offset, void *buf, int count);
static void com20020_copy_from_card(struct net_device *dev, int bufnum,
int offset, void *buf, int count);
......@@ -108,12 +108,10 @@ int __init com20020_check(struct net_device *dev)
status = ASTATUS();
if ((status & 0x99) != (NORXflag | TXFREEflag | RESETflag))
{
if ((status & 0x99) != (NORXflag | TXFREEflag | RESETflag)) {
BUGMSG(D_NORMAL, "status invalid (%Xh).\n", status);
return -ENODEV;
}
BUGMSG(D_INIT_REASONS, "status after reset: %X\n", status);
/* Enable TX */
......@@ -130,13 +128,11 @@ int __init com20020_check(struct net_device *dev)
outb(0 | RDDATAflag | AUTOINCflag, _ADDR_HI);
outb(0, _ADDR_LO);
if ((status = inb(_MEMDATA)) != TESTvalue)
{
if ((status = inb(_MEMDATA)) != TESTvalue) {
BUGMSG(D_NORMAL, "Signature byte not found (%02Xh != D1h).\n",
status);
return -ENODEV;
}
return 0;
}
......@@ -150,7 +146,7 @@ int __init com20020_found(struct net_device *dev, int shared)
/* Initialize the rest of the device structure. */
lp = (struct arcnet_local *)dev->priv;
lp = (struct arcnet_local *) dev->priv;
lp->hw.command = com20020_command;
lp->hw.status = com20020_status;
......@@ -183,12 +179,10 @@ int __init com20020_found(struct net_device *dev, int shared)
/* reserve the irq */
if (request_irq(dev->irq, &arcnet_interrupt, shared,
"arcnet (COM20020)", dev))
{
"arcnet (COM20020)", dev)) {
BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", dev->irq);
return -ENODEV;
}
/* reserve the I/O region - guaranteed to work by check_region */
request_region(ioaddr, ARCNET_TOTAL_SIZE, "arcnet (COM20020)");
dev->base_addr = ioaddr;
......@@ -201,19 +195,15 @@ int __init com20020_found(struct net_device *dev, int shared)
if (lp->timeout != 3)
BUGMSG(D_NORMAL, "Using extended timeout value of %d.\n", lp->timeout);
if (lp->setup)
{
if (lp->setup) {
BUGMSG(D_NORMAL, "Using CKP %d - data rate %s.\n",
lp->setup >> 1, clockrates[lp->setup >> 1]);
}
if (!dev->init && register_netdev(dev))
{
if (!dev->init && register_netdev(dev)) {
free_irq(dev->irq, dev);
release_region(ioaddr, ARCNET_TOTAL_SIZE);
return -EIO;
}
return 0;
}
......@@ -228,7 +218,7 @@ int __init com20020_found(struct net_device *dev, int shared)
*/
static int com20020_reset(struct net_device *dev, int really_reset)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
short ioaddr = dev->base_addr;
u_char inbyte;
......@@ -239,25 +229,21 @@ static int com20020_reset(struct net_device *dev, int really_reset)
/* power-up defaults */
SETCONF(lp->config);
if (really_reset)
{
if (really_reset) {
/* reset the card */
ARCRESET;
mdelay(RESETtime * 2); /* COM20020 seems to be slower sometimes */
}
/* clear flags & end reset */
ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
/* verify that the ARCnet signature byte is present */
com20020_copy_from_card(dev, 0, 0, &inbyte, 1);
if (inbyte != TESTvalue)
{
if (inbyte != TESTvalue) {
BUGMSG(D_NORMAL, "reset failed: TESTvalue not present.\n");
return 1;
}
/* enable extended (512-byte) packets */
ACOMMAND(CONFIGcmd | EXTconf);
......@@ -289,13 +275,12 @@ static int com20020_status(struct net_device *dev)
static void com20020_openclose(struct net_device *dev, bool open)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
int ioaddr = dev->base_addr;
if (open)
MOD_INC_USE_COUNT;
else
{
else {
/* disable transmitter */
lp->config &= ~TXENcfg;
SETCONF(lp->config);
......@@ -317,16 +302,14 @@ static void com20020_set_mc_list(struct net_device *dev)
struct arcnet_local *lp = dev->priv;
int ioaddr = dev->base_addr;
if ((dev->flags & IFF_PROMISC) && (dev->flags & IFF_UP))
{ /* Enable promiscuous mode */
if ((dev->flags & IFF_PROMISC) && (dev->flags & IFF_UP)) { /* Enable promiscuous mode */
if (!(lp->setup & PROMISCset))
BUGMSG(D_NORMAL, "Setting promiscuous flag...\n");
REGSETUP;
SETCONF(lp->config);
lp->setup |= PROMISCset;
outb(lp->setup, _SETUP);
}
else
} else
/* Disable promiscuous mode, use normal mode */
{
if ((lp->setup & PROMISCset))
......@@ -348,7 +331,7 @@ static void com20020_set_mc_list(struct net_device *dev)
SETCONF(lp->config);
BUGMSG(D_EXTRA, "New NextID detected: %X\n", inb(ioaddr + 7));
}
*/
*/
#ifdef MODULE
......
......@@ -43,12 +43,12 @@
/* Internal function declarations */
static int com90io_found(struct net_device *dev);
static void com90io_command (struct net_device *dev, int command);
static int com90io_status (struct net_device *dev);
static void com90io_setmask (struct net_device *dev, int mask);
static int com90io_reset (struct net_device *dev, int really_reset);
static void com90io_command(struct net_device *dev, int command);
static int com90io_status(struct net_device *dev);
static void com90io_setmask(struct net_device *dev, int mask);
static int com90io_reset(struct net_device *dev, int really_reset);
static void com90io_openclose(struct net_device *dev, bool open);
static void com90io_copy_to_card (struct net_device *dev, int bufnum, int offset,
static void com90io_copy_to_card(struct net_device *dev, int bufnum, int offset,
void *buf, int count);
static void com90io_copy_from_card(struct net_device *dev, int bufnum, int offset,
void *buf, int count);
......@@ -108,6 +108,7 @@ static void put_buffer_byte(struct net_device *dev, unsigned offset, u_char datu
outb(datum, _MEMDATA);
}
#endif
......@@ -162,18 +163,15 @@ static int __init com90io_probe(struct net_device *dev)
"must specify the base address!\n");
return -ENODEV;
}
if (check_region(ioaddr, ARCNET_TOTAL_SIZE)) {
BUGMSG(D_INIT_REASONS, "IO check_region %x-%x failed.\n",
ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
return -ENXIO;
}
if (ASTATUS() == 0xFF) {
BUGMSG(D_INIT_REASONS, "IO address %x empty\n", ioaddr);
return -ENODEV;
}
inb(_RESET);
mdelay(RESETtime);
......@@ -183,7 +181,6 @@ static int __init com90io_probe(struct net_device *dev)
BUGMSG(D_INIT_REASONS, "Status invalid (%Xh).\n", status);
return -ENODEV;
}
BUGMSG(D_INIT_REASONS, "Status after reset: %X\n", status);
ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
......@@ -196,7 +193,6 @@ static int __init com90io_probe(struct net_device *dev)
BUGMSG(D_INIT_REASONS, "Eternal reset (status=%Xh)\n", status);
return -ENODEV;
}
outb((0x16 | IOMAPflag) & ~ENABLE16flag, _CONFIG);
/* Read first loc'n of memory */
......@@ -209,7 +205,6 @@ static int __init com90io_probe(struct net_device *dev)
" (%Xh instead).\n", status);
return -ENODEV;
}
if (!dev->irq) {
/*
* if we do this, we're sure to get an IRQ since the
......@@ -228,7 +223,6 @@ static int __init com90io_probe(struct net_device *dev)
return -ENODEV;
}
}
return com90io_found(dev);
}
......@@ -246,7 +240,6 @@ static int __init com90io_found(struct net_device *dev)
BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", dev->irq);
return -ENODEV;
}
/* Reserve the I/O region - guaranteed to work by check_region */
request_region(dev->base_addr, ARCNET_TOTAL_SIZE, "arcnet (COM90xx-IO)");
......@@ -308,7 +301,6 @@ static int com90io_reset(struct net_device *dev, int really_reset)
inb(_RESET);
mdelay(RESETtime);
}
/* Set the thing to IO-mapped, 8-bit mode */
lp->config = (0x1C | IOMAPflag) & ~ENABLE16flag;
SETCONF();
......@@ -321,7 +313,6 @@ static int com90io_reset(struct net_device *dev, int really_reset)
BUGMSG(D_NORMAL, "reset failed: TESTvalue not present.\n");
return 1;
}
/* enable extended (512-byte) packets */
ACOMMAND(CONFIGcmd | EXTconf);
......@@ -364,14 +355,14 @@ static void com90io_openclose(struct net_device *dev, int open)
static void com90io_copy_to_card(struct net_device *dev, int bufnum, int offset,
void *buf, int count)
{
TIME("put_whole_buffer", count, put_whole_buffer(dev, bufnum*512 + offset, count, buf));
TIME("put_whole_buffer", count, put_whole_buffer(dev, bufnum * 512 + offset, count, buf));
}
static void com90io_copy_from_card(struct net_device *dev, int bufnum, int offset,
void *buf, int count)
{
TIME("get_whole_buffer", count, get_whole_buffer(dev, bufnum*512 + offset, count, buf));
TIME("get_whole_buffer", count, get_whole_buffer(dev, bufnum * 512 + offset, count, buf));
}
......@@ -445,7 +436,7 @@ static int __init com90io_setup(char *s)
return 1;
dev = alloc_bootmem(sizeof(struct net_device) + 10);
memset(dev, 0, sizeof(struct net_device) + 10);
dev->name = (char *)(dev+1);
dev->name = (char *) (dev + 1);
dev->init = com90io_probe;
switch (ints[0]) {
......
......@@ -55,12 +55,12 @@
/* Internal function declarations */
static int com90xx_found(struct net_device *dev, int ioaddr, int airq,
u_long shmem);
static void com90xx_command (struct net_device *dev, int command);
static int com90xx_status (struct net_device *dev);
static void com90xx_setmask (struct net_device *dev, int mask);
static int com90xx_reset (struct net_device *dev, int really_reset);
static void com90xx_command(struct net_device *dev, int command);
static int com90xx_status(struct net_device *dev);
static void com90xx_setmask(struct net_device *dev, int mask);
static int com90xx_reset(struct net_device *dev, int really_reset);
static void com90xx_openclose(struct net_device *dev, bool open);
static void com90xx_copy_to_card (struct net_device *dev, int bufnum, int offset,
static void com90xx_copy_to_card(struct net_device *dev, int bufnum, int offset,
void *buf, int count);
static void com90xx_copy_from_card(struct net_device *dev, int bufnum, int offset,
void *buf, int count);
......@@ -102,10 +102,13 @@ static int com90xx_skip_probe __initdata = 0;
int __init com90xx_probe(struct net_device *dev)
{
int count, status, ioaddr, numprint, airq, retval = -ENODEV, openparen = 0;
int count, status, ioaddr, numprint, airq, retval = -ENODEV,
openparen = 0;
unsigned long airqmask;
int ports[(0x3f0 - 0x200) / 16 + 1] = { 0 };
u_long shmems[(0xFF800 - 0xA0000) / 2048 + 1] = { 0 };
int ports[(0x3f0 - 0x200) / 16 + 1] =
{0};
u_long shmems[(0xFF800 - 0xA0000) / 2048 + 1] =
{0};
int numports, numshmems, *port;
u_long *shmem;
......@@ -135,12 +138,10 @@ int __init com90xx_probe(struct net_device *dev)
* (empty), and reset any others by reading the reset port.
*/
numprint = -1;
for (port = &ports[0]; port - ports < numports; port++)
{
for (port = &ports[0]; port - ports < numports; port++) {
numprint++;
numprint %= 8;
if (!numprint)
{
if (!numprint) {
BUGMSG2(D_INIT, "\n");
BUGMSG(D_INIT, "S1: ");
}
......@@ -148,8 +149,7 @@ int __init com90xx_probe(struct net_device *dev)
ioaddr = *port;
if (check_region(*port, ARCNET_TOTAL_SIZE))
{
if (check_region(*port, ARCNET_TOTAL_SIZE)) {
BUGMSG2(D_INIT_REASONS, "(check_region)\n");
BUGMSG(D_INIT_REASONS, "S1: ");
BUGLVL(D_INIT_REASONS) numprint = 0;
......@@ -158,8 +158,7 @@ int __init com90xx_probe(struct net_device *dev)
port--;
continue;
}
if (ASTATUS() == 0xFF)
{
if (ASTATUS() == 0xFF) {
BUGMSG2(D_INIT_REASONS, "(empty)\n");
BUGMSG(D_INIT_REASONS, "S1: ");
BUGLVL(D_INIT_REASONS) numprint = 0;
......@@ -168,7 +167,6 @@ int __init com90xx_probe(struct net_device *dev)
port--;
continue;
}
inb(_RESET); /* begin resetting card */
BUGMSG2(D_INIT_REASONS, "\n");
......@@ -177,23 +175,19 @@ int __init com90xx_probe(struct net_device *dev)
}
BUGMSG2(D_INIT, "\n");
if (!numports)
{
if (!numports) {
BUGMSG(D_NORMAL, "S1: No ARCnet cards found.\n");
return -ENODEV;
}
/* Stage 2: we have now reset any possible ARCnet cards, so we can't
* do anything until they finish. If D_INIT, print the list of
* cards that are left.
*/
numprint = -1;
for (port = &ports[0]; port - ports < numports; port++)
{
for (port = &ports[0]; port - ports < numports; port++) {
numprint++;
numprint %= 8;
if (!numprint)
{
if (!numprint) {
BUGMSG2(D_INIT, "\n");
BUGMSG(D_INIT, "S2: ");
}
......@@ -206,21 +200,18 @@ int __init com90xx_probe(struct net_device *dev)
* 0xD1 byte in the right place, or are read-only.
*/
numprint = -1;
for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++)
{
for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) {
u_long ptr = *shmem;
numprint++;
numprint %= 8;
if (!numprint)
{
if (!numprint) {
BUGMSG2(D_INIT, "\n");
BUGMSG(D_INIT, "S3: ");
}
BUGMSG2(D_INIT, "%lXh ", *shmem);
if (check_mem_region(*shmem, BUFFER_SIZE))
{
if (check_mem_region(*shmem, BUFFER_SIZE)) {
BUGMSG2(D_INIT_REASONS, "(check_mem_region)\n");
BUGMSG(D_INIT_REASONS, "Stage 3: ");
BUGLVL(D_INIT_REASONS) numprint = 0;
......@@ -229,9 +220,7 @@ int __init com90xx_probe(struct net_device *dev)
shmem--;
continue;
}
if (isa_readb(ptr) != TESTvalue)
{
if (isa_readb(ptr) != TESTvalue) {
BUGMSG2(D_INIT_REASONS, "(%02Xh != %02Xh)\n",
isa_readb(ptr), TESTvalue);
BUGMSG(D_INIT_REASONS, "S3: ");
......@@ -247,8 +236,7 @@ int __init com90xx_probe(struct net_device *dev)
* because *cptr != TESTvalue.
*/
isa_writeb(0x42, ptr);
if (isa_readb(ptr) != 0x42)
{
if (isa_readb(ptr) != 0x42) {
BUGMSG2(D_INIT_REASONS, "(read only)\n");
BUGMSG(D_INIT_REASONS, "S3: ");
*shmem = shmems[numshmems - 1];
......@@ -262,22 +250,18 @@ int __init com90xx_probe(struct net_device *dev)
}
BUGMSG2(D_INIT, "\n");
if (!numshmems)
{
if (!numshmems) {
BUGMSG(D_NORMAL, "S3: No ARCnet cards found.\n");
return -ENODEV;
}
/* Stage 4: something of a dummy, to report the shmems that are
* still possible after stage 3.
*/
numprint = -1;
for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++)
{
for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) {
numprint++;
numprint %= 8;
if (!numprint)
{
if (!numprint) {
BUGMSG2(D_INIT, "\n");
BUGMSG(D_INIT, "S4: ");
}
......@@ -293,12 +277,10 @@ int __init com90xx_probe(struct net_device *dev)
* after the first one is found.
*/
numprint = -1;
for (port = &ports[0]; port - ports < numports; port++)
{
for (port = &ports[0]; port - ports < numports; port++) {
numprint++;
numprint %= 8;
if (!numprint)
{
if (!numprint) {
BUGMSG2(D_INIT, "\n");
BUGMSG(D_INIT, "S5: ");
}
......@@ -308,8 +290,7 @@ int __init com90xx_probe(struct net_device *dev)
status = ASTATUS();
if ((status & 0x9D)
!= (NORXflag | RECONflag | TXFREEflag | RESETflag))
{
!= (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
BUGMSG2(D_INIT_REASONS, "(status=%Xh)\n", status);
BUGMSG(D_INIT_REASONS, "S5: ");
BUGLVL(D_INIT_REASONS) numprint = 0;
......@@ -318,11 +299,9 @@ int __init com90xx_probe(struct net_device *dev)
port--;
continue;
}
ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
status = ASTATUS();
if (status & RESETflag)
{
if (status & RESETflag) {
BUGMSG2(D_INIT_REASONS, " (eternal reset, status=%Xh)\n",
status);
BUGMSG(D_INIT_REASONS, "S5: ");
......@@ -335,8 +314,7 @@ int __init com90xx_probe(struct net_device *dev)
/* skip this completely if an IRQ was given, because maybe
* we're on a machine that locks during autoirq!
*/
if (!dev || !dev->irq)
{
if (!dev || !dev->irq) {
/* if we do this, we're sure to get an IRQ since the
* card has just reset and the NORXflag is on until
* we tell it to start receiving.
......@@ -347,8 +325,7 @@ int __init com90xx_probe(struct net_device *dev)
AINTMASK(0);
airq = probe_irq_off(airqmask);
if (airq <= 0)
{
if (airq <= 0) {
BUGMSG2(D_INIT_REASONS, "(airq=%d)\n", airq);
BUGMSG(D_INIT_REASONS, "S5: ");
BUGLVL(D_INIT_REASONS) numprint = 0;
......@@ -357,9 +334,7 @@ int __init com90xx_probe(struct net_device *dev)
port--;
continue;
}
}
else
{
} else {
airq = dev->irq;
}
......@@ -373,13 +348,10 @@ int __init com90xx_probe(struct net_device *dev)
* multiple shmems still in the list.
*/
#ifdef FAST_PROBE
if (numports > 1 || numshmems > 1)
{
if (numports > 1 || numshmems > 1) {
inb(_RESET);
mdelay(RESETtime);
}
else
{
} else {
/* just one shmem and port, assume they match */
isa_writeb(TESTvalue, shmems[0]);
}
......@@ -388,12 +360,10 @@ int __init com90xx_probe(struct net_device *dev)
mdelay(RESETtime);
#endif
for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++)
{
for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) {
u_long ptr = *shmem;
if (isa_readb(ptr) == TESTvalue)
{ /* found one */
if (isa_readb(ptr) == TESTvalue) { /* found one */
BUGMSG2(D_INIT, "%lXh)\n", *shmem);
openparen = 0;
......@@ -406,15 +376,12 @@ int __init com90xx_probe(struct net_device *dev)
numshmems--;
break; /* go to the next I/O port */
}
else
{
} else {
BUGMSG2(D_INIT_REASONS, "%Xh-", isa_readb(ptr));
}
}
if (openparen)
{
if (openparen) {
BUGLVL(D_INIT) printk("no matching shmem)\n");
BUGLVL(D_INIT_REASONS) printk("S5: ");
BUGLVL(D_INIT_REASONS) numprint = 0;
......@@ -448,18 +415,15 @@ static int __init com90xx_found(struct net_device *dev0, int ioaddr, int airq,
int mirror_size, err;
/* allocate struct net_device if we don't have one yet */
if (!dev && !(dev = dev_alloc("arc%d", &err)))
{
if (!dev && !(dev = dev_alloc("arc%d", &err))) {
BUGMSG(D_NORMAL, "Can't allocate device!\n");
return err;
}
lp = dev->priv = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL);
if (!lp)
{
if (!lp) {
BUGMSG(D_NORMAL, "Can't allocate device data!\n");
goto err_free_dev;
}
/* find the real shared memory start/end points, including mirrors */
/* guess the actual size of one "memory mirror" - the number of
......@@ -496,12 +460,10 @@ static int __init com90xx_found(struct net_device *dev0, int ioaddr, int airq,
lp->hw.copy_to_card = com90xx_copy_to_card;
lp->hw.copy_from_card = com90xx_copy_from_card;
lp->mem_start = ioremap(dev->mem_start, dev->mem_end - dev->mem_start + 1);
if (!lp->mem_start)
{
if (!lp->mem_start) {
BUGMSG(D_NORMAL, "Can't remap device memory!\n");
goto err_free_dev_priv;
}
/* Fill in the fields of the device structure with generic values. */
arcdev_setup(dev);
......@@ -509,8 +471,7 @@ static int __init com90xx_found(struct net_device *dev0, int ioaddr, int airq,
dev->dev_addr[0] = readb(lp->mem_start + 1);
/* reserve the irq */
if (request_irq(airq, &arcnet_interrupt, 0, "arcnet (90xx)", dev))
{
if (request_irq(airq, &arcnet_interrupt, 0, "arcnet (90xx)", dev)) {
BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", airq);
goto err_unmap;
}
......@@ -533,15 +494,15 @@ static int __init com90xx_found(struct net_device *dev0, int ioaddr, int airq,
cards[numcards++] = dev;
return 0;
err_release:
err_release:
free_irq(dev->irq, dev);
release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1);
err_unmap:
err_unmap:
iounmap(lp->mem_start);
err_free_dev_priv:
err_free_dev_priv:
kfree(dev->priv);
err_free_dev:
err_free_dev:
if (!dev0)
kfree(dev);
return -EIO;
......@@ -588,13 +549,11 @@ int com90xx_reset(struct net_device *dev, int really_reset)
BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n",
dev->name, ASTATUS());
if (really_reset)
{
if (really_reset) {
/* reset the card */
inb(_RESET);
mdelay(RESETtime);
}
ACOMMAND(CFLAGScmd | RESETclear); /* clear flags & end reset */
ACOMMAND(CFLAGScmd | CONFIGclear);
......@@ -602,12 +561,10 @@ int com90xx_reset(struct net_device *dev, int really_reset)
/* outb(inb(_CONFIG) | ENABLE16flag, _CONFIG); */
/* verify that the ARCnet signature byte is present */
if (readb(lp->mem_start) != TESTvalue)
{
if (readb(lp->mem_start) != TESTvalue) {
BUGMSG(D_NORMAL, "reset failed: TESTvalue not present.\n");
return 1;
}
/* enable extended (512-byte) packets */
ACOMMAND(CONFIGcmd | EXTconf);
......@@ -633,7 +590,7 @@ static void com90xx_copy_to_card(struct net_device *dev, int bufnum, int offset,
void *buf, int count)
{
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
void *memaddr = lp->mem_start + bufnum*512 + offset;
void *memaddr = lp->mem_start + bufnum * 512 + offset;
TIME("memcpy_toio", count, memcpy_toio(memaddr, buf, count));
}
......@@ -642,7 +599,7 @@ static void com90xx_copy_from_card(struct net_device *dev, int bufnum, int offse
void *buf, int count)
{
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
void *memaddr = lp->mem_start + bufnum*512 + offset;
void *memaddr = lp->mem_start + bufnum * 512 + offset;
TIME("memcpy_fromio", count, memcpy_fromio(buf, memaddr, count));
}
......@@ -667,8 +624,7 @@ int init_module(void)
struct net_device *dev;
int err;
if (io || irq || shmem || device)
{
if (io || irq || shmem || device) {
dev = dev_alloc(device ? : "arc%d", &err);
if (!dev)
return err;
......@@ -678,8 +634,8 @@ int init_module(void)
dev->irq = 9;
dev->mem_start = shmem;
com90xx_probe(dev);
}
else com90xx_probe(NULL);
} else
com90xx_probe(NULL);
if (!numcards)
return -EIO;
......@@ -693,8 +649,7 @@ void cleanup_module(void)
struct arcnet_local *lp;
int count;
for (count = 0; count < numcards; count++)
{
for (count = 0; count < numcards; count++) {
dev = cards[count];
lp = (struct arcnet_local *) dev->priv;
......@@ -724,10 +679,9 @@ static int __init com90xx_setup(char *s)
printk("com90xx: Disabled.\n");
return 1;
}
dev = alloc_bootmem(sizeof(struct net_device) + 10);
memset(dev, 0, sizeof(struct net_device) + 10);
dev->name = (char *)(dev+1);
dev->name = (char *) (dev + 1);
dev->init = com90xx_probe;
switch (ints[0]) {
......
......@@ -44,7 +44,8 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
int bufnum);
struct ArcProto rfc1051_proto = {
struct ArcProto rfc1051_proto =
{
's',
XMTU - RFC1051_HDR_SIZE,
rx,
......@@ -90,8 +91,8 @@ void cleanup_module(void)
*/
static unsigned short type_trans(struct sk_buff *skb, struct net_device *dev)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct archdr *pkt = (struct archdr *)skb->data;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
struct archdr *pkt = (struct archdr *) skb->data;
struct arc_rfc1051 *soft = &pkt->soft.rfc1051;
int hdr_size = ARC_HDR_SIZE + RFC1051_HDR_SIZE;
......@@ -101,16 +102,13 @@ static unsigned short type_trans(struct sk_buff *skb, struct net_device *dev)
if (pkt->hard.dest == 0)
skb->pkt_type = PACKET_BROADCAST;
else if (dev->flags & IFF_PROMISC)
{
else if (dev->flags & IFF_PROMISC) {
/* if we're not sending to ourselves :) */
if (pkt->hard.dest != dev->dev_addr[0])
skb->pkt_type = PACKET_OTHERHOST;
}
/* now return the protocol number */
switch (soft->proto)
{
switch (soft->proto) {
case ARC_P_IP_RFC1051:
return htons(ETH_P_IP);
case ARC_P_ARP_RFC1051:
......@@ -130,7 +128,7 @@ static unsigned short type_trans(struct sk_buff *skb, struct net_device *dev)
static void rx(struct net_device *dev, int bufnum,
struct archdr *pkthdr, int length)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
struct sk_buff *skb;
struct archdr *pkt = pkthdr;
int ofs;
......@@ -143,17 +141,15 @@ static void rx(struct net_device *dev, int bufnum,
ofs = 256 - length;
skb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
if (skb == NULL)
{
if (skb == NULL) {
BUGMSG(D_NORMAL, "Memory squeeze, dropping packet.\n");
lp->stats.rx_dropped++;
return;
}
skb_put(skb, length + ARC_HDR_SIZE);
skb->dev = dev;
pkt = (struct archdr *)skb->data;
pkt = (struct archdr *) skb->data;
/* up to sizeof(pkt->soft) has already been copied from the card */
memcpy(pkt, pkthdr, sizeof(struct archdr));
......@@ -176,14 +172,13 @@ static int build_header(struct sk_buff *skb, unsigned short type,
uint8_t daddr)
{
struct net_device *dev = skb->dev;
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
int hdr_size = ARC_HDR_SIZE + RFC1051_HDR_SIZE;
struct archdr *pkt = (struct archdr *)skb_push(skb, hdr_size);
struct archdr *pkt = (struct archdr *) skb_push(skb, hdr_size);
struct arc_rfc1051 *soft = &pkt->soft.rfc1051;
/* set the protocol ID according to RFC1051 */
switch (type)
{
switch (type) {
case ETH_P_IP:
soft->proto = ARC_P_IP_RFC1051;
break;
......@@ -210,8 +205,7 @@ static int build_header(struct sk_buff *skb, unsigned short type,
/* see linux/net/ethernet/eth.c to see where I got the following */
if (dev->flags & (IFF_LOOPBACK|IFF_NOARP))
{
if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) {
/*
* FIXME: fill in the last byte of the dest ipaddr here to better
* comply with RFC1051 in "noarp" mode.
......@@ -219,7 +213,6 @@ static int build_header(struct sk_buff *skb, unsigned short type,
pkt->hard.dest = 0;
return hdr_size;
}
/* otherwise, just fill it in and go! */
pkt->hard.dest = daddr;
......@@ -230,7 +223,7 @@ static int build_header(struct sk_buff *skb, unsigned short type,
static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
int bufnum)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
struct arc_hardware *hard = &pkt->hard;
int ofs;
......@@ -239,25 +232,19 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
length -= ARC_HDR_SIZE; /* hard header is not included in packet length */
if (length > XMTU)
{
if (length > XMTU) {
/* should never happen! other people already check for this. */
BUGMSG(D_NORMAL, "Bug! prepare_tx with size %d (> %d)\n",
length, XMTU);
length = XMTU;
}
if (length > MinTU)
{
if (length > MinTU) {
hard->offset[0] = 0;
hard->offset[1] = ofs = 512 - length;
}
else if (length > MTU)
{
} else if (length > MTU) {
hard->offset[0] = 0;
hard->offset[1] = ofs = 512 - length - 3;
}
else
} else
hard->offset[0] = ofs = 256 - length;
lp->hw.copy_to_card(dev, bufnum, 0, hard, ARC_HDR_SIZE);
......
......@@ -43,7 +43,8 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
int bufnum);
static int continue_tx(struct net_device *dev, int bufnum);
struct ArcProto rfc1201_proto = {
struct ArcProto rfc1201_proto =
{
'a',
1500, /* could be more, but some receivers can't handle it... */
rx,
......@@ -92,9 +93,9 @@ void cleanup_module(void)
*/
static unsigned short type_trans(struct sk_buff *skb, struct net_device *dev)
{
struct archdr *pkt = (struct archdr *)skb->data;
struct archdr *pkt = (struct archdr *) skb->data;
struct arc_rfc1201 *soft = &pkt->soft.rfc1201;
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
int hdr_size = ARC_HDR_SIZE + RFC1201_HDR_SIZE;
/* Pull off the arcnet header. */
......@@ -103,16 +104,13 @@ static unsigned short type_trans(struct sk_buff *skb, struct net_device *dev)
if (pkt->hard.dest == 0)
skb->pkt_type = PACKET_BROADCAST;
else if (dev->flags & IFF_PROMISC)
{
else if (dev->flags & IFF_PROMISC) {
/* if we're not sending to ourselves :) */
if (pkt->hard.dest != dev->dev_addr[0])
skb->pkt_type = PACKET_OTHERHOST;
}
/* now return the protocol number */
switch (soft->proto)
{
switch (soft->proto) {
case ARC_P_IP:
return htons(ETH_P_IP);
case ARC_P_ARP:
......@@ -137,7 +135,7 @@ static unsigned short type_trans(struct sk_buff *skb, struct net_device *dev)
static void rx(struct net_device *dev, int bufnum,
struct archdr *pkthdr, int length)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
struct sk_buff *skb;
struct archdr *pkt = pkthdr;
struct arc_rfc1201 *soft = &pkthdr->soft.rfc1201;
......@@ -151,12 +149,10 @@ static void rx(struct net_device *dev, int bufnum,
else
ofs = 256 - length;
if (soft->split_flag == 0xFF) /* Exception Packet */
{
if (soft->split_flag == 0xFF) { /* Exception Packet */
if (length >= 4 + RFC1201_HDR_SIZE)
BUGMSG(D_DURING, "compensating for exception packet\n");
else
{
else {
BUGMSG(D_EXTRA, "short RFC1201 exception packet from %02Xh",
saddr);
return;
......@@ -168,14 +164,11 @@ static void rx(struct net_device *dev, int bufnum,
lp->hw.copy_from_card(dev, bufnum, 512 - length,
soft, sizeof(pkt->soft));
}
if (!soft->split_flag) /* not split */
{
if (!soft->split_flag) { /* not split */
BUGMSG(D_RX, "incoming is not split (splitflag=%d)\n",
soft->split_flag);
if (in->skb) /* already assembling one! */
{
if (in->skb) { /* already assembling one! */
BUGMSG(D_EXTRA, "aborting assembly (seq=%d) for unsplit packet (splitflag=%d, seq=%d)\n",
in->sequence, soft->split_flag, soft->sequence);
lp->rfc1201.aborted_seq = soft->sequence;
......@@ -184,21 +177,18 @@ static void rx(struct net_device *dev, int bufnum,
lp->stats.rx_missed_errors++;
in->skb = NULL;
}
in->sequence = soft->sequence;
skb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
if (skb == NULL)
{
if (skb == NULL) {
BUGMSG(D_NORMAL, "Memory squeeze, dropping packet.\n");
lp->stats.rx_dropped++;
return;
}
skb_put(skb, length + ARC_HDR_SIZE);
skb->dev = dev;
pkt = (struct archdr *)skb->data;
pkt = (struct archdr *) skb->data;
soft = &pkt->soft.rfc1201;
/* up to sizeof(pkt->soft) has already been copied from the card */
......@@ -213,45 +203,35 @@ static void rx(struct net_device *dev, int bufnum,
* source address is always 0! So we take the hardware source addr
* (which is impossible to fumble) and insert it ourselves.
*/
if (soft->proto == ARC_P_ARP)
{
struct arphdr *arp = (struct arphdr *)soft->payload;
if (soft->proto == ARC_P_ARP) {
struct arphdr *arp = (struct arphdr *) soft->payload;
/* make sure addresses are the right length */
if (arp->ar_hln == 1 && arp->ar_pln == 4)
{
uint8_t *cptr = (uint8_t *)arp + sizeof(struct arphdr);
if (arp->ar_hln == 1 && arp->ar_pln == 4) {
uint8_t *cptr = (uint8_t *) arp + sizeof(struct arphdr);
if (!*cptr) /* is saddr = 00? */
{
if (!*cptr) { /* is saddr = 00? */
BUGMSG(D_EXTRA,
"ARP source address was 00h, set to %02Xh.\n",
saddr);
lp->stats.rx_crc_errors++;
*cptr = saddr;
}
else
{
} else {
BUGMSG(D_DURING, "ARP source address (%Xh) is fine.\n",
*cptr);
}
}
else
{
} else {
BUGMSG(D_NORMAL, "funny-shaped ARP packet. (%Xh, %Xh)\n",
arp->ar_hln, arp->ar_pln);
lp->stats.rx_errors++;
lp->stats.rx_crc_errors++;
}
}
BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx");
skb->protocol = type_trans(skb, dev);
netif_rx(skb);
}
else /* split packet */
{
} else { /* split packet */
/*
* NOTE: MSDOS ARP packet correction should only need to apply to
* unsplit packets, since ARP packets are so short.
......@@ -272,8 +252,7 @@ static void rx(struct net_device *dev, int bufnum,
BUGMSG(D_RX, "packet is split (splitflag=%d, seq=%d)\n",
soft->split_flag, in->sequence);
if (in->skb && in->sequence != soft->sequence)
{
if (in->skb && in->sequence != soft->sequence) {
BUGMSG(D_EXTRA, "wrong seq number (saddr=%d, expected=%d, seq=%d, splitflag=%d)\n",
saddr, in->sequence, soft->sequence,
soft->split_flag);
......@@ -283,13 +262,10 @@ static void rx(struct net_device *dev, int bufnum,
lp->stats.rx_missed_errors++;
in->lastpacket = in->numpackets = 0;
}
if (soft->split_flag & 1) /* first packet in split */
{
if (soft->split_flag & 1) { /* first packet in split */
BUGMSG(D_RX, "brand new splitpacket (splitflag=%d)\n",
soft->split_flag);
if (in->skb) /* already assembling one! */
{
if (in->skb) { /* already assembling one! */
BUGMSG(D_EXTRA, "aborting previous (seq=%d) assembly "
"(splitflag=%d, seq=%d)\n",
in->sequence, soft->split_flag,
......@@ -298,50 +274,41 @@ static void rx(struct net_device *dev, int bufnum,
lp->stats.rx_missed_errors++;
kfree_skb(in->skb);
}
in->sequence = soft->sequence;
in->numpackets = ((unsigned)soft->split_flag >> 1) + 2;
in->numpackets = ((unsigned) soft->split_flag >> 1) + 2;
in->lastpacket = 1;
if (in->numpackets > 16)
{
if (in->numpackets > 16) {
BUGMSG(D_EXTRA, "incoming packet more than 16 segments; dropping. (splitflag=%d)\n",
soft->split_flag);
lp->stats.rx_errors++;
lp->stats.rx_length_errors++;
return;
}
in->skb = skb = alloc_skb(508 * in->numpackets + ARC_HDR_SIZE,
GFP_ATOMIC);
if (skb == NULL)
{
if (skb == NULL) {
BUGMSG(D_NORMAL, "(split) memory squeeze, dropping packet.\n");
lp->stats.rx_dropped++;
return;
}
skb->dev = dev;
pkt = (struct archdr *)skb->data;
pkt = (struct archdr *) skb->data;
soft = &pkt->soft.rfc1201;
memcpy(pkt, pkthdr, ARC_HDR_SIZE + RFC1201_HDR_SIZE);
skb_put(skb, ARC_HDR_SIZE + RFC1201_HDR_SIZE);
soft->split_flag = 0; /* end result won't be split */
}
else /* not first packet */
{
int packetnum = ((unsigned)soft->split_flag >> 1) + 1;
} else { /* not first packet */
int packetnum = ((unsigned) soft->split_flag >> 1) + 1;
/*
* if we're not assembling, there's no point trying to
* continue.
*/
if (!in->skb)
{
if (lp->rfc1201.aborted_seq != soft->sequence)
{
if (!in->skb) {
if (lp->rfc1201.aborted_seq != soft->sequence) {
BUGMSG(D_EXTRA, "can't continue split without starting "
"first! (splitflag=%d, seq=%d, aborted=%d)\n",
soft->split_flag, soft->sequence,
......@@ -351,20 +318,16 @@ static void rx(struct net_device *dev, int bufnum,
}
return;
}
in->lastpacket++;
if (packetnum != in->lastpacket) /* not the right flag! */
{
if (packetnum != in->lastpacket) { /* not the right flag! */
/* harmless duplicate? ignore. */
if (packetnum <= in->lastpacket - 1)
{
if (packetnum <= in->lastpacket - 1) {
BUGMSG(D_EXTRA, "duplicate splitpacket ignored! (splitflag=%d)\n",
soft->split_flag);
lp->stats.rx_errors++;
lp->stats.rx_frame_errors++;
return;
}
/* "bad" duplicate, kill reassembly */
BUGMSG(D_EXTRA, "out-of-order splitpacket, reassembly "
"(seq=%d) aborted (splitflag=%d, seq=%d)\n",
......@@ -377,8 +340,7 @@ static void rx(struct net_device *dev, int bufnum,
in->lastpacket = in->numpackets = 0;
return;
}
pkt = (struct archdr *)in->skb->data;
pkt = (struct archdr *) in->skb->data;
soft = &pkt->soft.rfc1201;
}
......@@ -390,8 +352,7 @@ static void rx(struct net_device *dev, int bufnum,
skb_put(skb, length - RFC1201_HDR_SIZE);
/* are we done? */
if (in->lastpacket == in->numpackets)
{
if (in->lastpacket == in->numpackets) {
in->skb = NULL;
in->lastpacket = in->numpackets = 0;
......@@ -409,14 +370,13 @@ static int build_header(struct sk_buff *skb, unsigned short type,
uint8_t daddr)
{
struct net_device *dev = skb->dev;
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
int hdr_size = ARC_HDR_SIZE + RFC1201_HDR_SIZE;
struct archdr *pkt = (struct archdr *)skb_push(skb, hdr_size);
struct archdr *pkt = (struct archdr *) skb_push(skb, hdr_size);
struct arc_rfc1201 *soft = &pkt->soft.rfc1201;
/* set the protocol ID according to RFC1201 */
switch (type)
{
switch (type) {
case ETH_P_IP:
soft->proto = ARC_P_IP;
break;
......@@ -456,8 +416,7 @@ static int build_header(struct sk_buff *skb, unsigned short type,
/* see linux/net/ethernet/eth.c to see where I got the following */
if (dev->flags & (IFF_LOOPBACK|IFF_NOARP))
{
if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) {
/*
* FIXME: fill in the last byte of the dest ipaddr here to better
* comply with RFC1051 in "noarp" mode. For now, always broadcasting
......@@ -466,7 +425,6 @@ static int build_header(struct sk_buff *skb, unsigned short type,
pkt->hard.dest = 0;
return hdr_size;
}
/* otherwise, drop in the dest address */
pkt->hard.dest = daddr;
return hdr_size;
......@@ -476,27 +434,24 @@ static int build_header(struct sk_buff *skb, unsigned short type,
static void load_pkt(struct net_device *dev, struct arc_hardware *hard,
struct arc_rfc1201 *soft, int softlen, int bufnum)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
int ofs;
/* assume length <= XMTU: someone should have handled that by now. */
if (softlen > MinTU)
{
if (softlen > MinTU) {
hard->offset[0] = 0;
hard->offset[1] = ofs = 512 - softlen;
}
else if (softlen > MTU) /* exception packet - add an extra header */
{
struct arc_rfc1201 excsoft = { soft->proto, 0xFF, 0xFFFF };
} else if (softlen > MTU) { /* exception packet - add an extra header */
struct arc_rfc1201 excsoft =
{soft->proto, 0xFF, 0xFFFF};
hard->offset[0] = 0;
ofs = 512 - softlen;
hard->offset[1] = ofs - RFC1201_HDR_SIZE;
lp->hw.copy_to_card(dev, bufnum, ofs - RFC1201_HDR_SIZE,
&excsoft, RFC1201_HDR_SIZE);
}
else
} else
hard->offset[0] = ofs = 256 - softlen;
lp->hw.copy_to_card(dev, bufnum, 0, hard, ARC_HDR_SIZE);
......@@ -509,7 +464,7 @@ static void load_pkt(struct net_device *dev, struct arc_hardware *hard,
static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
int bufnum)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
const int maxsegsize = XMTU - RFC1201_HDR_SIZE;
struct Outgoing *out;
......@@ -521,8 +476,7 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
pkt->soft.rfc1201.split_flag = 0;
/* need to do a split packet? */
if (length > XMTU)
{
if (length > XMTU) {
out = &lp->outgoing;
out->length = length - RFC1201_HDR_SIZE;
......@@ -536,7 +490,6 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
return 0; /* not done */
}
/* just load the packet into the buffers and send it off */
load_pkt(dev, &pkt->hard, &pkt->soft.rfc1201, length, bufnum);
......@@ -546,7 +499,7 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
static int continue_tx(struct net_device *dev, int bufnum)
{
struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
struct Outgoing *out = &lp->outgoing;
struct arc_hardware *hard = &out->pkt->hard;
struct arc_rfc1201 *soft = &out->pkt->soft.rfc1201, *newsoft;
......@@ -563,8 +516,7 @@ static int continue_tx(struct net_device *dev, int bufnum)
if (!out->segnum) /* first packet; newsoft == soft */
newsoft->split_flag = ((out->numsegs - 2) << 1) | 1;
else
{
else {
newsoft->split_flag = out->segnum << 1;
newsoft->proto = soft->proto;
newsoft->sequence = soft->sequence;
......
......@@ -672,7 +672,7 @@ struct pci_dev * __init pci_scan_slot(struct pci_dev *temp)
first_dev = dev;
}
DBG("PCI: %02x:%02x [%04x/%04x] %06x %02x\n", bus->number, dev->devfn, dev->vendor, dev->device, class, hdr_type);
DBG("PCI: %02x:%02x [%04x/%04x] %06x %02x\n", bus->number, dev->devfn, dev->vendor, dev->device, dev->class, hdr_type);
/*
* Put it into the global PCI device chain. It's used to
......
......@@ -185,8 +185,8 @@ int cb_setup_cis_mem(socket_info_t *s, int space)
/* Not configured? Then set up temporary map */
br = (space == 7) ? CB_ROM_BASE : CB_BAR(space-1);
pci_writel(s->cap.cardbus, 0, br, 0xffffffff);
pci_readl(s->cap.cardbus, 0, br, &sz);
pci_writel(s->cap.cb_dev->subordinate->number, 0, br, 0xffffffff);
pci_readl(s->cap.cb_dev->subordinate->number, 0, br, &sz);
sz &= PCI_BASE_ADDRESS_MEM_MASK;
sz = FIND_FIRST_BIT(sz);
if (sz < PAGE_SIZE) sz = PAGE_SIZE;
......@@ -199,8 +199,8 @@ int cb_setup_cis_mem(socket_info_t *s, int space)
s->cb_cis_virt = ioremap(base, sz);
DEBUG(1, " phys 0x%08lx-0x%08lx, virt 0x%08lx\n",
base, base+sz-1, (u_long)s->cb_cis_virt);
pci_writel(s->cap.cardbus, 0, br, base | 1);
pci_writeb(s->cap.cardbus, 0, PCI_COMMAND, PCI_COMMAND_MEMORY);
pci_writel(s->cap.cb_dev->subordinate->number, 0, br, base | 1);
pci_writeb(s->cap.cb_dev->subordinate->number, 0, PCI_COMMAND, PCI_COMMAND_MEMORY);
m->map = 0; m->flags = MAP_ACTIVE;
m->start = base; m->stop = base+sz-1;
s->ss_entry->set_bridge(s->sock, m);
......@@ -228,8 +228,8 @@ void cb_release_cis_mem(socket_info_t *s)
CB_ROM_BASE : CB_BAR(s->cb_cis_space-1);
m->map = 0; m->flags = 0;
s->ss_entry->set_bridge(s->sock, m);
pci_writeb(s->cap.cardbus, 0, PCI_COMMAND, 0);
pci_writel(s->cap.cardbus, 0, br, 0);
pci_writeb(s->cap.cb_dev->subordinate->number, 0, PCI_COMMAND, 0);
pci_writel(s->cap.cb_dev->subordinate->number, 0, br, 0);
release_mem_region(m->start, m->stop - m->start + 1);
m->start = 0;
}
......@@ -249,7 +249,7 @@ void read_cb_mem(socket_info_t *s, u_char fn, int space,
if (space == 0) {
if (addr+len > 0x100) goto fail;
for (; len; addr++, ptr++, len--)
pci_readb(s->cap.cardbus, fn, addr, (u_char *)ptr);
pci_readb(s->cap.cb_dev->subordinate->number, fn, addr, (u_char *)ptr);
} else {
if (cb_setup_cis_mem(s, space) != 0) goto fail;
if (space == 7) {
......@@ -278,57 +278,62 @@ void read_cb_mem(socket_info_t *s, u_char fn, int space,
int cb_alloc(socket_info_t *s)
{
struct pci_bus *bus;
struct pci_dev tmp;
u_short vend, v, dev;
u_char i, hdr, fn, bus = s->cap.cardbus;
u_char i, hdr, fn;
cb_config_t *c;
bus = s->cap.cb_dev->subordinate;
memset(&tmp, 0, sizeof(tmp));
tmp.bus = s->cap.cb_bus; tmp.devfn = 0;
tmp.bus = bus; tmp.devfn = 0;
printk("bus=%p, number=%d\n", bus, bus->number);
pci_read_config_word(&tmp, PCI_VENDOR_ID, &vend);
pci_read_config_word(&tmp, PCI_DEVICE_ID, &dev);
printk(KERN_INFO "cs: cb_alloc(bus %d): vendor 0x%04x, "
"device 0x%04x\n", bus, vend, dev);
"device 0x%04x\n", bus->number, vend, dev);
pci_read_config_byte(&tmp, PCI_HEADER_TYPE, &hdr);
fn = 1;
if (hdr & 0x80) {
/* Count functions */
for (fn = 0; fn < 8; fn++) {
do {
tmp.devfn = fn;
pci_read_config_word(&tmp, PCI_VENDOR_ID, &v);
if (v != vend) break;
fn++;
} while (fn < 8);
}
} else fn = 1;
s->functions = fn;
c = kmalloc(fn * sizeof(struct cb_config_t), GFP_ATOMIC);
if (!c) return CS_OUT_OF_RESOURCE;
memset(c, 0, fn * sizeof(struct cb_config_t));
s->cb_config = c;
for (i = 0; i < fn; i++) {
c[i].dev.bus = s->cap.cb_bus;
c[i].dev.devfn = i;
struct pci_dev *dev = &c[i].dev;
dev->bus = bus;
dev->devfn = i;
if (i < fn-1) {
c[i].dev.sibling = c[i].dev.next = &c[i+1].dev;
dev->sibling = dev->next = &c[i+1].dev;
}
dev->vendor = vend;
pci_read_config_word(dev, PCI_DEVICE_ID, &dev->device);
pci_read_config_dword(dev, PCI_CLASS_REVISION, &dev->class);
dev->class >>= 8;
dev->hdr_type = hdr;
#ifdef CONFIG_PROC_FS
pci_proc_attach_device(dev);
#endif
}
s->cap.cb_bus->devices = &c[0].dev;
/* Link into PCI device chain */
bus->devices = &c[0].dev;
c[fn-1].dev.next = pci_devices;
pci_devices = &c[0].dev;
for (i = 0; i < fn; i++) {
c[i].dev.vendor = vend;
pci_readw(bus, i, PCI_DEVICE_ID, &c[i].dev.device);
pci_readl(bus, i, PCI_CLASS_REVISION, &c[i].dev.class);
c[i].dev.class >>= 8;
c[i].dev.hdr_type = hdr;
#ifdef CONFIG_PROC_FS
pci_proc_attach_device(&c[i].dev);
#endif
}
s->cb_config = c;
return CS_SUCCESS;
}
......@@ -336,6 +341,7 @@ int cb_alloc(socket_info_t *s)
void cb_free(socket_info_t *s)
{
cb_config_t *c = s->cb_config;
struct pci_bus *bus = s->cap.cb_dev->subordinate;
if (c) {
struct pci_dev **p;
......@@ -343,7 +349,7 @@ void cb_free(socket_info_t *s)
p = &pci_devices;
while (*p) {
struct pci_dev * dev = *p;
if (dev->bus != s->cap.cb_bus) {
if (dev->bus != bus) {
p = &dev->next;
continue;
}
......@@ -352,10 +358,10 @@ void cb_free(socket_info_t *s)
pci_proc_detach_device(dev);
#endif
}
s->cap.cb_bus->devices = NULL;
bus->devices = NULL;
kfree(s->cb_config);
s->cb_config = NULL;
printk(KERN_INFO "cs: cb_free(bus %d)\n", s->cap.cardbus);
printk(KERN_INFO "cs: cb_free(bus %d)\n", s->cap.cb_dev->subordinate->number);
}
}
......@@ -375,11 +381,11 @@ int cb_config(socket_info_t *s)
{
cb_config_t *c = s->cb_config;
u_char fn = s->functions;
u_char i, j, bus = s->cap.cardbus, *name;
u_char i, j, bus = s->cap.cb_dev->subordinate->number, *name;
u_int sz, align, m, mask[3], num[3], base[3];
int irq, try, ret;
printk(KERN_INFO "cs: cb_config(bus %d)\n", s->cap.cardbus);
printk(KERN_INFO "cs: cb_config(bus %d)\n", s->cap.cb_dev->subordinate->number);
/* Determine IO and memory space needs */
num[B_IO] = num[B_M1] = num[B_M2] = 0;
......@@ -524,7 +530,7 @@ void cb_release(socket_info_t *s)
{
cb_config_t *c = s->cb_config;
DEBUG(0, "cs: cb_release(bus %d)\n", s->cap.cardbus);
DEBUG(0, "cs: cb_release(bus %d)\n", s->cap.cb_dev->subordinate->number);
if (s->win[0].size > 0)
release_mem_region(s->win[0].base, s->win[0].size);
......@@ -556,7 +562,7 @@ void cb_release(socket_info_t *s)
void cb_enable(socket_info_t *s)
{
u_char i, j, bus = s->cap.cardbus;
u_char i, j, bus = s->cap.cb_dev->subordinate->number;
cb_config_t *c = s->cb_config;
DEBUG(0, "cs: cb_enable(bus %d)\n", bus);
......@@ -630,7 +636,7 @@ void cb_disable(socket_info_t *s)
u_char i;
cb_bridge_map m = { 0, 0, 0, 0xffff };
DEBUG(0, "cs: cb_disable(bus %d)\n", s->cap.cardbus);
DEBUG(0, "cs: cb_disable(bus %d)\n", s->cap.cb_dev->subordinate->number);
/* Turn off bridge windows */
if (s->cb_cis_map.start)
......
......@@ -367,7 +367,7 @@ int pcmcia_get_first_tuple(client_handle_t handle, tuple_t *tuple)
#ifdef CONFIG_CARDBUS
if (s->state & SOCKET_CARDBUS) {
u_int ptr;
pcibios_read_config_dword(s->cap.cardbus, 0, 0x28, &ptr);
pcibios_read_config_dword(s->cap.cb_dev->subordinate->number, 0, 0x28, &ptr);
tuple->CISOffset = ptr & ~7;
SPACE(tuple->Flags) = (ptr & 7);
} else
......
......@@ -46,6 +46,7 @@
#include <linux/delay.h>
#include <linux/proc_fs.h>
#include <linux/compile.h>
#include <linux/pci.h>
#include <asm/system.h>
#include <asm/irq.h>
......@@ -994,7 +995,7 @@ int pcmcia_get_configuration_info(client_handle_t handle,
config->Function = fn;
config->Vcc = s->socket.Vcc;
config->Vpp1 = config->Vpp2 = s->socket.Vpp;
config->Option = s->cap.cardbus;
config->Option = s->cap.cb_dev->subordinate->number;
if (s->cb_config) {
config->Attributes = CONF_VALID_CLIENT;
config->IntType = INT_CARDBUS;
......
......@@ -1615,7 +1615,7 @@ static void __init add_cb_bridge(int type, struct pci_dev *dev0)
break;
}
request_mem_region(s->cb_phys, 0x1000, "i82365");
s->cap.cb_bus = dev->subordinate;
s->cap.cb_dev = dev;
add_socket(0, 0, type);
}
if (ns == 0) return;
......
......@@ -30,7 +30,7 @@
static struct pci_simple_probe_entry controller_list[] = {
{ PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1225, 0, 0, &yenta_operations },
{ 0x1180, 0x0475, 0, 0, &yenta_operations },
{ 0x1180, 0x0475, 0, 0, &ricoh_operations },
{ 0, 0, 0, 0, NULL }
};
......
......@@ -36,3 +36,5 @@ struct pci_socket_ops {
};
extern struct pci_socket_ops yenta_operations;
extern struct pci_socket_ops ricoh_operations;
......@@ -15,11 +15,59 @@
#include "yenta.h"
#include "i82365.h"
#include "ricoh.h"
/* Don't ask.. */
#define to_cycles(ns) ((ns)/120)
#define to_ns(cycles) ((cycles)*120)
/*
* Generate easy-to-use ways of reading a cardbus sockets
* regular memory space ("cb_xxx"), configuration space
* ("config_xxx") and compatibility space ("exca_xxxx")
*/
#define cb_readl(sock,reg) readl((sock)->base + (reg))
#define cb_writel(sock,reg,val) writel(val,(sock)->base + (reg))
static inline u8 config_readb(pci_socket_t *socket, unsigned offset)
{
u8 val;
pci_read_config_byte(socket->dev, offset, &val);
return val;
}
static inline u16 config_readw(pci_socket_t *socket, unsigned offset)
{
u16 val;
pci_read_config_word(socket->dev, offset, &val);
return val;
}
static inline u32 config_readl(pci_socket_t *socket, unsigned offset)
{
u32 val;
pci_read_config_dword(socket->dev, offset, &val);
return val;
}
#define config_writeb(s,off,val) pci_write_config_byte((s)->dev, (off), (val))
#define config_writew(s,off,val) pci_write_config_word((s)->dev, (off), (val))
#define config_writel(s,off,val) pci_write_config_dword((s)->dev, (off), (val))
#define exca_readb(sock,reg) readb((sock)->base + 0x800 + (reg))
#define exca_writeb(sock,reg,v) writeb((v), (sock)->base + 0x800 + (reg))
static u16 exca_readw(pci_socket_t *socket, unsigned reg)
{
return exca_readb(socket, reg) | (exca_readb(socket, reg+1) << 8);
}
static void exca_writew(pci_socket_t *socket, unsigned reg, u16 val)
{
exca_writeb(socket, reg, val);
exca_writeb(socket, reg+1, val >> 8);
}
static int yenta_inquire(pci_socket_t *socket, socket_cap_t *cap)
{
*cap = socket->cap;
......@@ -27,52 +75,55 @@ static int yenta_inquire(pci_socket_t *socket, socket_cap_t *cap)
}
/*
* Silly interface. We convert the cardbus status to a internal status,
* and we probably really should keep it in cardbus status form and
* only convert for old-style 16-bit PCMCIA cards..
* Ugh, mixed-mode cardbus and 16-bit pccard state: things depend
* on what kind of card is inserted..
*/
static int yenta_get_status(pci_socket_t *socket, unsigned int *value)
{
u32 state = cb_readl(socket, CB_SOCKET_STATE);
unsigned int val;
u32 state = cb_readl(socket, CB_SOCKET_STATE);
/* Convert from Yenta status to old-style status */
val = (state & CB_CARDSTS) ? SS_STSCHG : 0;
val |= (state & (CB_CDETECT1 | CB_CDETECT2)) ? 0 : SS_DETECT;
val |= (state & CB_PWRCYCLE) ? SS_POWERON | SS_READY : 0;
val |= (state & CB_CBCARD) ? SS_CARDBUS : 0;
val |= (state & CB_3VCARD) ? SS_3VCARD : 0;
val = (state & CB_3VCARD) ? SS_3VCARD : 0;
val |= (state & CB_XVCARD) ? SS_XVCARD : 0;
/* Get the old compatibility status too.. */
if (!(state & CB_CBCARD)) {
if (state & CB_CBCARD) {
val |= SS_CARDBUS;
val |= (state & CB_CARDSTS) ? SS_STSCHG : 0;
val |= (state & (CB_CDETECT1 | CB_CDETECT2)) ? 0 : SS_DETECT;
val |= (state & CB_PWRCYCLE) ? SS_POWERON | SS_READY : 0;
} else {
u8 status = exca_readb(socket, I365_STATUS);
val |= ((status & I365_CS_DETECT) == I365_CS_DETECT) ? SS_DETECT : 0;
if (exca_readb(socket, I365_INTCTL) & I365_PC_IOCARD) {
val |= (status & I365_CS_STSCHG) ? 0 : SS_STSCHG;
} else {
val |= (status & I365_CS_BVD1) ? 0 : SS_BATDEAD;
val |= (status & I365_CS_BVD2) ? 0 : SS_BATWARN;
}
val |= (status & I365_CS_WRPROT) ? SS_WRPROT : 0;
val |= (status & I365_CS_READY) ? SS_READY : 0;
val |= (status & I365_CS_POWERON) ? SS_POWERON : 0;
}
printk("yenta_get_status(%p)= %x\n", socket, val);
*value = val;
return 0;
}
static int yenta_Vcc_power(u32 control)
{
switch ((control >> CB_VCCCTRL) & CB_PWRBITS) {
case CB_PWR5V: return 50;
case CB_PWR3V: return 33;
switch (control & CB_SC_VCC_MASK) {
case CB_SC_VCC_5V: return 50;
case CB_SC_VCC_3V: return 33;
default: return 0;
}
}
static int yenta_Vpp_power(u32 control)
{
switch ((control >> CB_VPPCTRL) & CB_PWRBITS) {
case CB_PWR12V: return 120;
case CB_PWR5V: return 50;
case CB_PWR3V: return 33;
switch (control & CB_SC_VPP_MASK) {
case CB_SC_VPP_12V: return 120;
case CB_SC_VPP_5V: return 50;
case CB_SC_VPP_3V: return 33;
default: return 0;
}
}
......@@ -88,8 +139,8 @@ static int yenta_get_socket(pci_socket_t *socket, socket_state_t *state)
state->Vpp = yenta_Vpp_power(control);
state->io_irq = socket->io_irq;
if (cb_readb(socket, CB_SOCKET_STATE) & CB_CBCARD) {
u16 bridge = cb_readw(socket, CB_BRIDGE_CONTROL);
if (cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) {
u16 bridge = config_readw(socket, CB_BRIDGE_CONTROL);
if (bridge & CB_BRIDGE_CRST)
state->flags |= SS_RESET;
return 0;
......@@ -119,28 +170,42 @@ static int yenta_get_socket(pci_socket_t *socket, socket_state_t *state)
static void yenta_set_power(pci_socket_t *socket, socket_state_t *state)
{
u32 control = CB_STOPCLK;
u32 reg = 0; /* CB_SC_STPCLK? */
switch (state->Vcc) {
case 33:
control |= CB_PWR3V << CB_VCCCTRL;
break;
case 50:
control |= CB_PWR5V << CB_VCCCTRL;
break;
case 33: reg = CB_SC_VCC_3V; break;
case 50: reg = CB_SC_VCC_5V; break;
default: reg = 0; break;
}
switch (state->Vpp) {
case 33:
control |= CB_PWR3V << CB_VPPCTRL;
break;
case 50:
control |= CB_PWR5V << CB_VPPCTRL;
break;
case 120:
control |= CB_PWR12V << CB_VPPCTRL;
break;
case 33: reg |= CB_SC_VPP_3V; break;
case 50: reg |= CB_SC_VPP_5V; break;
case 120: reg |= CB_SC_VPP_12V; break;
}
cb_writel(socket, CB_SOCKET_CONTROL, control);
if (reg != cb_readl(socket, CB_SOCKET_CONTROL))
cb_writel(socket, CB_SOCKET_CONTROL, reg);
}
static void yenta_bridge_control(pci_socket_t *socket, u16 bridgectl)
{
struct pci_dev *dev = socket->dev;
/* MAGIC NUMBERS! Fixme */
config_writew(socket, CB_BRIDGE_CONTROL, bridgectl);
config_writel(socket, CB_LEGACY_MODE_BASE, 0);
config_writel(socket, PCI_BASE_ADDRESS_0, dev->resource[0].start);
config_writew(socket, PCI_COMMAND,
PCI_COMMAND_IO |
PCI_COMMAND_MEMORY |
PCI_COMMAND_MASTER |
PCI_COMMAND_WAIT);
config_writeb(socket, PCI_CACHE_LINE_SIZE, 32);
config_writeb(socket, PCI_LATENCY_TIMER, 168);
config_writeb(socket, PCI_SEC_LATENCY_TIMER, 176);
config_writeb(socket, PCI_PRIMARY_BUS, dev->bus->number);
config_writeb(socket, PCI_SECONDARY_BUS, dev->subordinate->number);
config_writeb(socket, PCI_SUBORDINATE_BUS, dev->subordinate->number);
config_writew(socket, CB_BRIDGE_CONTROL, bridgectl);
}
static int yenta_set_socket(pci_socket_t *socket, socket_state_t *state)
......@@ -151,7 +216,7 @@ static int yenta_set_socket(pci_socket_t *socket, socket_state_t *state)
bridge = config_readw(socket, CB_BRIDGE_CONTROL) & ~CB_BRIDGE_CRST;
if (cb_readb(socket, CB_SOCKET_STATE) & CB_CBCARD) {
if (cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) {
bridge |= (state->flags & SS_RESET) ? CB_BRIDGE_CRST : 0;
/* ISA interrupt control? */
......@@ -174,6 +239,7 @@ static int yenta_set_socket(pci_socket_t *socket, socket_state_t *state)
reg |= I365_PWR_NORESET;
if (state->flags & SS_PWR_AUTO) reg |= I365_PWR_AUTO;
if (state->flags & SS_OUTPUT_ENA) reg |= I365_PWR_OUT;
if (exca_readb(socket, I365_POWER) != reg)
exca_writeb(socket, I365_POWER, reg);
/* CSC interrupt: no ISA irq for CSC */
......@@ -188,7 +254,7 @@ static int yenta_set_socket(pci_socket_t *socket, socket_state_t *state)
exca_writeb(socket, I365_CSCINT, reg);
exca_readb(socket, I365_CSC);
}
config_writew(socket, CB_BRIDGE_CONTROL, bridge);
yenta_bridge_control(socket, bridge);
/* Socket event mask: get card insert/remove events.. */
cb_writel(socket, CB_SOCKET_EVENT, -1);
......@@ -271,9 +337,7 @@ static int yenta_get_mem_map(pci_socket_t *socket, struct pccard_mem_map *mem)
start = (start & 0x0fff) << 12;
stop = exca_readw(socket, I365_MEM(map) + I365_W_STOP);
mem->speed = (stop & I365_MEM_WS0) ? 1 : 0;
mem->speed += (stop & I365_MEM_WS1) ? 2 : 0;
mem->speed = to_ns(mem->speed);
mem->speed = to_ns(stop >> 14);
stop = ((stop & 0x0fff) << 12) + 0x0fff;
offset = exca_readw(socket, I365_MEM(map) + I365_W_OFF);
......@@ -301,7 +365,8 @@ static int yenta_set_mem_map(pci_socket_t *socket, struct pccard_mem_map *mem)
stop = mem->sys_stop;
card_start = mem->card_start;
if (map > 4 || start > stop || ((start ^ stop) >> 24) || (card_start >> 26) || mem->speed > 1000)
if (map > 4 || start > stop || ((start ^ stop) >> 24) ||
(card_start >> 26) || mem->speed > 1000)
return -EINVAL;
enable = I365_ENA_MEM(map);
......@@ -432,8 +497,6 @@ static void yenta_interrupt(int irq, void *dev_id, struct pt_regs *regs)
events |= (csc & I365_CSC_READY) ? SS_READY : 0;
}
printk("Socket interrupt event %08x (%08x %02x)\n", events, cb_event, csc);
if (events && socket->handler)
socket->handler(socket->info, events);
}
......@@ -470,23 +533,6 @@ static unsigned int yenta_probe_irq(pci_socket_t *socket)
return probe_irq_mask(val);
}
static void yenta_get_socket_capabilities(pci_socket_t *socket)
{
/* MAGIC NUMBERS! Fixme */
config_writeb(socket, PCI_LATENCY_TIMER, 168);
config_writeb(socket, PCI_SEC_LATENCY_TIMER, 176);
socket->cap.features |= SS_CAP_PAGE_REGS | SS_CAP_PCCARD | SS_CAP_CARDBUS;
socket->cap.map_size = 0x1000;
socket->cap.pci_irq = socket->cb_irq;
socket->cap.irq_mask = yenta_probe_irq(socket);
socket->cap.cardbus = config_readb(socket, PCI_CB_CARD_BUS);
socket->cap.cb_bus = socket->dev->subordinate;
socket->cap.bus = NULL;
printk("Yenta IRQ list %04x\n", socket->cap.irq_mask);
}
/* Called at resume and initialization events */
static int yenta_init(pci_socket_t *socket)
{
......@@ -496,7 +542,14 @@ static int yenta_init(pci_socket_t *socket)
pci_set_power_state(socket->dev, 0);
mem.sys_stop = 0x1000;
/* MAGIC NUMBERS! Fixme */
config_writeb(socket, PCI_LATENCY_TIMER, 168);
config_writeb(socket, PCI_SEC_LATENCY_TIMER, 176);
exca_writeb(socket, I365_GBLCTL, 0x00);
exca_writeb(socket, I365_GENCTL, 0x00);
mem.sys_stop = 0x0fff;
yenta_set_socket(socket, &dead_socket);
for (i = 0; i < 2; i++) {
io.map = i;
......@@ -509,6 +562,29 @@ static int yenta_init(pci_socket_t *socket)
return 0;
}
/*
* More of an example than anything else... The standard
* yenta init code works well enough - but this is how
* you'd do it if you wanted to have a special init sequence.
*/
static int ricoh_init(pci_socket_t *socket)
{
u16 misc = config_readw(socket, RL5C4XX_MISC);
u16 ctl = config_readw(socket, RL5C4XX_16BIT_CTL);
u16 io = config_readw(socket, RL5C4XX_16BIT_IO_0);
u16 mem = config_readw(socket, RL5C4XX_16BIT_MEM_0);
ctl = RL5C4XX_16CTL_IO_TIMING | RL5C4XX_16CTL_MEM_TIMING;
config_writew(socket, RL5C4XX_MISC, misc);
config_writew(socket, RL5C4XX_16BIT_CTL, ctl);
config_writew(socket, RL5C4XX_16BIT_IO_0, io);
config_writew(socket, RL5C4XX_16BIT_MEM_0, mem);
return yenta_init(socket);
}
static int yenta_suspend(pci_socket_t *socket)
{
yenta_set_socket(socket, &dead_socket);
......@@ -516,6 +592,21 @@ static int yenta_suspend(pci_socket_t *socket)
return 0;
}
/*
* Set static data that doesn't need re-initializing..
*/
static void yenta_get_socket_capabilities(pci_socket_t *socket)
{
socket->cap.features |= SS_CAP_PAGE_REGS | SS_CAP_PCCARD | SS_CAP_CARDBUS;
socket->cap.map_size = 0x1000;
socket->cap.pci_irq = socket->cb_irq;
socket->cap.irq_mask = yenta_probe_irq(socket);
socket->cap.cb_dev = socket->dev;
socket->cap.bus = NULL;
printk("Yenta IRQ list %04x\n", socket->cap.irq_mask);
}
/*
* Initialize a cardbus controller. Make sure we have a usable
* interrupt, and that we can map the cardbus area. Fill in the
......@@ -551,10 +642,10 @@ static int yenta_open(pci_socket_t *socket)
/* Figure out what the dang thing can do.. */
yenta_get_socket_capabilities(socket);
/* Enable all events */
writel(0x0f, socket->base + 4);
/* Disable all events */
cb_writel(socket, CB_SOCKET_MASK, 0x0);
printk("Socket status: %08x\n", readl(socket->base + 8));
printk("Socket status: %08x\n", cb_readl(socket, CB_SOCKET_STATE));
return 0;
}
......@@ -569,6 +660,9 @@ static void yenta_close(pci_socket_t *sock)
iounmap(sock->base);
}
/*
* Standard plain cardbus - no frills, no extensions
*/
struct pci_socket_ops yenta_operations = {
yenta_open,
yenta_close,
......@@ -586,3 +680,25 @@ struct pci_socket_ops yenta_operations = {
yenta_set_bridge,
yenta_proc_setup
};
/*
* Ricoh cardbus bridge: standard cardbus, except it needs
* some extra init code to set timings etc.
*/
struct pci_socket_ops ricoh_operations = {
yenta_open,
yenta_close,
ricoh_init,
yenta_suspend,
yenta_inquire,
yenta_get_status,
yenta_get_socket,
yenta_set_socket,
yenta_get_io_map,
yenta_set_io_map,
yenta_get_mem_map,
yenta_set_mem_map,
yenta_get_bridge,
yenta_set_bridge,
yenta_proc_setup
};
......@@ -4,35 +4,6 @@
#include <asm/io.h>
#include "pci_socket.h"
/*
* Generate easy-to-use ways of reading a cardbus sockets
* regular memory space ("cb_xxx"), configuration space
* ("config_xxx") and compatibility space ("exca_xxxx")
*/
#define cb_readb(sock,reg) readb((sock)->base + (reg))
#define cb_readw(sock,reg) readw((sock)->base + (reg))
#define cb_readl(sock,reg) readl((sock)->base + (reg))
#define cb_writeb(sock,reg,val) writeb((val), (sock)->base + (reg))
#define cb_writew(sock,reg,val) writew((val), (sock)->base + (reg))
#define cb_writel(sock,reg,val) writel((val), (sock)->base + (reg))
#define config_readb(sock,offset) ({ __u8 __val; pci_read_config_byte((sock)->dev, (offset), &__val); __val; })
#define config_readw(sock,offset) ({ __u16 __val; pci_read_config_word((sock)->dev, (offset), &__val); __val; })
#define config_readl(sock,offset) ({ __u32 __val; pci_read_config_dword((sock)->dev, (offset), &__val); __val; })
#define config_writeb(sock,offset,val) pci_write_config_byte((sock)->dev, (offset), (val))
#define config_writew(sock,offset,val) pci_write_config_word((sock)->dev, (offset), (val))
#define config_writel(sock,offset,val) pci_write_config_dword((sock)->dev, (offset), (val))
#define exca_readb(sock,reg) cb_readb((sock),(reg)+0x0800)
#define exca_readw(sock,reg) cb_readw((sock),(reg)+0x0800)
#define exca_readl(sock,reg) cb_readl((sock),(reg)+0x0800)
#define exca_writeb(sock,reg,val) cb_writeb((sock),(reg)+0x0800,(val))
#define exca_writew(sock,reg,val) cb_writew((sock),(reg)+0x0800,(val))
#define exca_writel(sock,reg,val) cb_writel((sock),(reg)+0x0800,(val))
#define CB_SOCKET_EVENT 0x00
#define CB_CSTSEVENT 0x00000001 /* Card status event */
#define CB_CD1EVENT 0x00000002 /* Card detect 1 change event */
......@@ -81,17 +52,20 @@
#define CB_CVSTEST 0x00004000 /* Card VS test */
#define CB_SOCKET_CONTROL 0x10
#define CB_VPPCTRL 0 /* Shift for Vpp */
#define CB_VCCCTRL 4 /* Shift for Vcc */
#define CB_STOPCLK 0x00000080 /* CLKRUN can slow CB clock when idle */
#define CB_PWRBITS 0x7
#define CB_PWROFF 0x0
#define CB_PWR12V 0x1 /* Only valid for Vpp */
#define CB_PWR5V 0x2
#define CB_PWR3V 0x3
#define CB_PWRXV 0x4
#define CB_PWRYV 0x5
#define CB_SC_VPP_MASK 0x00000007
#define CB_SC_VPP_OFF 0x00000000
#define CB_SC_VPP_12V 0x00000001
#define CB_SC_VPP_5V 0x00000002
#define CB_SC_VPP_3V 0x00000003
#define CB_SC_VPP_XV 0x00000004
#define CB_SC_VPP_YV 0x00000005
#define CB_SC_VCC_MASK 0x00000070
#define CB_SC_VCC_OFF 0x00000000
#define CB_SC_VCC_5V 0x00000020
#define CB_SC_VCC_3V 0x00000030
#define CB_SC_VCC_XV 0x00000040
#define CB_SC_VCC_YV 0x00000050
#define CB_SC_CCLK_STOP 0x00000080
#define CB_SOCKET_POWER 0x20
#define CB_SKTACCES 0x02000000 /* A PC card access has occurred (clear on read) */
......@@ -115,6 +89,7 @@
#define CB_BRIDGE_PREFETCH0 0x00000100
#define CB_BRIDGE_PREFETCH1 0x00000200
#define CB_BRIDGE_POSTEN 0x00000400
#define CB_LEGACY_MODE_BASE 0x44
/*
* ExCA area extensions in Yenta
......
......@@ -10,7 +10,7 @@ comment 'USB Controllers'
dep_tristate ' UHCI (Intel PIIX4, VIA, and others) support' CONFIG_USB_UHCI \
$CONFIG_USB
dep_tristate ' OHCI-HCD (Compaq, iMacs, OPTi, SiS, and others) support' \
dep_tristate ' OHCI-HCD (Compaq, iMacs, OPTi, SiS, ALi, and others) support' \
CONFIG_USB_OHCI_HCD $CONFIG_USB
comment 'Miscellaneous USB options'
......
#!/usr/bin/perl
# Reads /proc/bus/usb/devices and selectively lists and/or
# interprets it.
$DEVFILENAME = "/proc/bus/usb/devices";
$PROGNAME = $0;
$TAGS = $ARGV[0]; # save user TAGS
if (length ($TAGS) == 0)
{
print "usage: $PROGNAME tags\n";
print " where 'tags' can be any number of 'TDPCIE' or 'A(LL)'\n";
exit 1;
}
$ALL = ($TAGS =~ /all/i) || ($TAGS =~ /a/i);
# TBD: Check that $TAGS is valid.
if (! $ALL)
{
}
if (! open (DEVNUM, "<$DEVFILENAME"))
{
print "$PROGNAME: cannot open '$DEVFILENAME'\n";
exit 1;
}
while ($line = <DEVNUM>) # read a text line from DEVNUM
{
if (($ALL) || ($line =~ /^[$TAGS]:/i)) # any of TAGS at beg. of line?
{
print "$line"; # still has newline char on it
# TBD: add more/paging functionality.
}
} # end while DEVNUM
close (DEVNUM);
# END.
......@@ -17,6 +17,7 @@
#include <linux/smp_lock.h>
#include <linux/quotaops.h>
#include <linux/pagemap.h>
#include <linux/dcache.h>
#include <asm/uaccess.h>
#include <asm/unaligned.h>
......@@ -550,83 +551,6 @@ static inline int may_create(struct inode *dir, struct dentry *child) {
return permission(dir,MAY_WRITE | MAY_EXEC);
}
static inline struct dentry *get_parent(struct dentry *dentry)
{
return dget(dentry->d_parent);
}
static inline void unlock_dir(struct dentry *dir)
{
up(&dir->d_inode->i_sem);
dput(dir);
}
/*
* We need to do a check-parent every time
* after we have locked the parent - to verify
* that the parent is still our parent and
* that we are still hashed onto it..
*
* This is requied in case two processes race
* on removing (or moving) the same entry: the
* parent lock will serialize them, but the
* other process will be too late..
*/
#define check_parent(dir, dentry) \
((dir) == (dentry)->d_parent && !list_empty(&dentry->d_hash))
/*
* Locking the parent is needed to:
* - serialize directory operations
* - make sure the parent doesn't change from
* under us in the middle of an operation.
*
* NOTE! Right now we'd rather use a "struct inode"
* for this, but as I expect things to move toward
* using dentries instead for most things it is
* probably better to start with the conceptually
* better interface of relying on a path of dentries.
*/
static inline struct dentry *lock_parent(struct dentry *dentry)
{
struct dentry *dir = dget(dentry->d_parent);
down(&dir->d_inode->i_sem);
return dir;
}
/*
* Whee.. Deadlock country. Happily there are only two VFS
* operations that do this..
*/
static inline void double_lock(struct dentry *d1, struct dentry *d2)
{
struct semaphore *s1 = &d1->d_inode->i_sem;
struct semaphore *s2 = &d2->d_inode->i_sem;
if (s1 != s2) {
if ((unsigned long) s1 < (unsigned long) s2) {
struct semaphore *tmp = s2;
s2 = s1; s1 = tmp;
}
down(s1);
}
down(s2);
}
static inline void double_unlock(struct dentry *d1, struct dentry *d2)
{
struct semaphore *s1 = &d1->d_inode->i_sem;
struct semaphore *s2 = &d2->d_inode->i_sem;
up(s1);
if (s1 != s2)
up(s2);
dput(d1);
dput(d2);
}
/*
* Special case: O_CREAT|O_EXCL implies O_NOFOLLOW for security
* reasons.
......
......@@ -22,7 +22,7 @@
#ifdef __KERNEL__
#ifndef bool
# define bool int
#define bool int
#endif
......@@ -176,24 +176,22 @@ extern int arcnet_debug;
/* information needed to define an encapsulation driver */
struct ArcProto
{
struct ArcProto {
char suffix; /* a for RFC1201, e for ether-encap, etc. */
int mtu; /* largest possible packet */
void (*rx)(struct net_device *dev, int bufnum,
struct archdr *pkthdr, int length);
int (*build_header)(struct sk_buff *skb, unsigned short ethproto,
void (*rx) (struct net_device * dev, int bufnum,
struct archdr * pkthdr, int length);
int (*build_header) (struct sk_buff * skb, unsigned short ethproto,
uint8_t daddr);
/* these functions return '1' if the skb can now be freed */
int (*prepare_tx)(struct net_device *dev, struct archdr *pkt, int length,
int (*prepare_tx) (struct net_device * dev, struct archdr * pkt, int length,
int bufnum);
int (*continue_tx)(struct net_device *dev, int bufnum);
int (*continue_tx) (struct net_device * dev, int bufnum);
};
extern struct ArcProto *arc_proto_map[256],
*arc_proto_default, *arc_bcast_proto;
extern struct ArcProto *arc_proto_map[256], *arc_proto_default, *arc_bcast_proto;
extern struct ArcProto arc_proto_null;
......@@ -201,8 +199,7 @@ extern struct ArcProto arc_proto_null;
* "Incoming" is information needed for each address that could be sending
* to us. Mostly for partially-received split packets.
*/
struct Incoming
{
struct Incoming {
struct sk_buff *skb; /* packet data buffer */
uint16_t sequence; /* sequence number of assembly */
uint8_t lastpacket, /* number of last packet (from 1) */
......@@ -211,8 +208,7 @@ struct Incoming
/* only needed for RFC1201 */
struct Outgoing
{
struct Outgoing {
struct ArcProto *proto; /* protocol driver that owns this:
* if NULL, no packet is pending.
*/
......@@ -225,8 +221,7 @@ struct Outgoing
};
struct arcnet_local
{
struct arcnet_local {
struct net_device_stats stats;
uint8_t config, /* current value of CONFIG register */
......@@ -283,16 +278,16 @@ struct arcnet_local
/* hardware-specific functions */
struct {
void (*command) (struct net_device *dev, int cmd);
int (*status) (struct net_device *dev);
void (*intmask) (struct net_device *dev, int mask);
bool (*reset) (struct net_device *dev, bool really_reset);
void (*open_close)(struct net_device *dev, bool open);
void (*open_close_ll)(struct net_device *dev, bool open);
void (*copy_to_card)(struct net_device *dev, int bufnum, int offset,
void (*command) (struct net_device * dev, int cmd);
int (*status) (struct net_device * dev);
void (*intmask) (struct net_device * dev, int mask);
bool (*reset) (struct net_device * dev, bool really_reset);
void (*open_close) (struct net_device * dev, bool open);
void (*open_close_ll) (struct net_device * dev, bool open);
void (*copy_to_card) (struct net_device * dev, int bufnum, int offset,
void *buf, int count);
void (*copy_from_card)(struct net_device *dev, int bufnum, int offset,
void (*copy_from_card) (struct net_device * dev, int bufnum, int offset,
void *buf, int count);
} hw;
......@@ -311,13 +306,13 @@ struct arcnet_local
#if ARCNET_DEBUG_MAX & D_SKB
void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc);
#else
# define arcnet_dump_skb(dev,skb,desc) ;
#define arcnet_dump_skb(dev,skb,desc) ;
#endif
#if (ARCNET_DEBUG_MAX & D_RX) || (ARCNET_DEBUG_MAX & D_TX)
void arcnet_dump_packet(struct net_device *dev, int bufnum, char *desc);
#else
# define arcnet_dump_packet(dev, bufnum, desc) ;
#define arcnet_dump_packet(dev, bufnum, desc) ;
#endif
void arcnet_unregister_proto(struct ArcProto *proto);
......
......@@ -996,6 +996,91 @@ extern int generic_buffer_fdatasync(struct inode *inode, unsigned long start_idx
extern int inode_change_ok(struct inode *, struct iattr *);
extern void inode_setattr(struct inode *, struct iattr *);
/*
* Common dentry functions for inclusion in the VFS
* or in other stackable file systems. Some of these
* functions were in linux/fs/ C (VFS) files.
*
*/
/*
* We need to do a check-parent every time
* after we have locked the parent - to verify
* that the parent is still our parent and
* that we are still hashed onto it..
*
* This is required in case two processes race
* on removing (or moving) the same entry: the
* parent lock will serialize them, but the
* other process will be too late..
*/
#define check_parent(dir, dentry) \
((dir) == (dentry)->d_parent && !list_empty(&dentry->d_hash))
/*
* Locking the parent is needed to:
* - serialize directory operations
* - make sure the parent doesn't change from
* under us in the middle of an operation.
*
* NOTE! Right now we'd rather use a "struct inode"
* for this, but as I expect things to move toward
* using dentries instead for most things it is
* probably better to start with the conceptually
* better interface of relying on a path of dentries.
*/
static inline struct dentry *lock_parent(struct dentry *dentry)
{
struct dentry *dir = dget(dentry->d_parent);
down(&dir->d_inode->i_sem);
return dir;
}
static inline struct dentry *get_parent(struct dentry *dentry)
{
return dget(dentry->d_parent);
}
static inline void unlock_dir(struct dentry *dir)
{
up(&dir->d_inode->i_sem);
dput(dir);
}
/*
* Whee.. Deadlock country. Happily there are only two VFS
* operations that does this..
*/
static inline void double_lock(struct dentry *d1, struct dentry *d2)
{
struct semaphore *s1 = &d1->d_inode->i_sem;
struct semaphore *s2 = &d2->d_inode->i_sem;
if (s1 != s2) {
if ((unsigned long) s1 < (unsigned long) s2) {
struct semaphore *tmp = s2;
s2 = s1; s1 = tmp;
}
down(s1);
}
down(s2);
}
static inline void double_unlock(struct dentry *d1, struct dentry *d2)
{
struct semaphore *s1 = &d1->d_inode->i_sem;
struct semaphore *s2 = &d2->d_inode->i_sem;
up(s1);
if (s1 != s2)
up(s2);
dput(d1);
dput(d2);
}
#endif /* __KERNEL__ */
#endif /* _LINUX_FS_H */
......@@ -438,6 +438,15 @@ extern unsigned long page_unuse(struct page *);
extern int shrink_mmap(int, int);
extern void truncate_inode_pages(struct inode *, loff_t);
/* generic vm_area_ops exported for stackable file systems */
extern int filemap_swapout(struct page * page, struct file *file);
extern pte_t filemap_swapin(struct vm_area_struct * vma,
unsigned long offset, unsigned long entry);
extern int filemap_sync(struct vm_area_struct * vma, unsigned long address,
size_t size, unsigned int flags);
extern struct page *filemap_nopage(struct vm_area_struct * area,
unsigned long address, int no_share);
/*
* GFP bitmasks..
*/
......
......@@ -117,6 +117,9 @@ extern struct screen_info screen_info;
#define VIDEO_TYPE_PMAC 0x60 /* PowerMacintosh frame buffer. */
#define VIDEO_TYPE_SGI 0x70 /* Various SGI graphics hardware */
#define VIDEO_TYPE_MIPS_G364 0x71 /* MIPS Magnum 4000 G364 video */
/*
* This character is the same as _POSIX_VDISABLE: it cannot be used as
* a c_cc[] character, but indicates that a particular special character
......
......@@ -52,8 +52,7 @@ typedef struct socket_cap_t {
u_int irq_mask;
u_int map_size;
u_char pci_irq;
u_char cardbus;
struct pci_bus *cb_bus;
struct pci_dev *cb_dev;
struct bus_operations *bus;
} socket_cap_t;
......
......@@ -225,6 +225,13 @@ EXPORT_SYMBOL(page_readlink);
EXPORT_SYMBOL(page_follow_link);
EXPORT_SYMBOL(block_symlink);
/* for stackable file systems (lofs, wrapfs, etc.) */
EXPORT_SYMBOL(add_to_page_cache);
EXPORT_SYMBOL(filemap_nopage);
EXPORT_SYMBOL(filemap_swapout);
EXPORT_SYMBOL(filemap_sync);
EXPORT_SYMBOL(remove_inode_page);
#if !defined(CONFIG_NFSD) && defined(CONFIG_NFSD_MODULE)
EXPORT_SYMBOL(do_nfsservctl);
#endif
......@@ -450,4 +457,5 @@ EXPORT_SYMBOL(get_fast_time);
/* library functions */
EXPORT_SYMBOL(strnicmp);
/* init task, for moving kthread roots - ought to export a function ?? */
EXPORT_SYMBOL(init_task_union);
......@@ -1298,7 +1298,7 @@ asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd, off_t *offset, size_t cou
* it in the page cache, and handles the special cases reasonably without
* having a lot of duplicated code.
*/
static struct page * filemap_nopage(struct vm_area_struct * area,
struct page * filemap_nopage(struct vm_area_struct * area,
unsigned long address, int no_share)
{
int error;
......@@ -1595,7 +1595,7 @@ static inline int filemap_sync_pmd_range(pgd_t * pgd,
return error;
}
static int filemap_sync(struct vm_area_struct * vma, unsigned long address,
int filemap_sync(struct vm_area_struct * vma, unsigned long address,
size_t size, unsigned int flags)
{
pgd_t * dir;
......
......@@ -87,7 +87,7 @@
#include <linux/rtnetlink.h>
#include <net/br.h>
#include <linux/proc_fs.h>
#include <linux/br.h>
#include <linux/delay.h>
#ifndef min
#define min(a, b) (((a) <= (b)) ? (a) : (b))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment