X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Fnet%2Fsb1000.c;h=fc0e38bddeebbc7a5fea9b772ff2f3949a602aa4;hb=45f5fa32b130b2a59f9b726be45ce7fa73fb834c;hp=66cf226c4ee32bd58091ba39c3882de16310d1d1;hpb=f71e130966ba429dbd24be08ddbcdf263df9a5ad;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/net/sb1000.c b/drivers/net/sb1000.c index 66cf226..fc0e38b 100644 --- a/drivers/net/sb1000.c +++ b/drivers/net/sb1000.c @@ -28,7 +28,7 @@ Small changes to make it work with 2.1.x kernels. Hopefully, nothing major will change before official release of Linux 2.2. - + Merged with 2.2 - Alan Cox */ @@ -76,7 +76,6 @@ struct sb1000_private { unsigned char rx_session_id[NPIDS]; unsigned char rx_frame_id[NPIDS]; unsigned char rx_pkt_type[NPIDS]; - struct net_device_stats stats; }; /* prototypes for Linux interface */ @@ -84,37 +83,36 @@ extern int sb1000_probe(struct net_device *dev); static int sb1000_open(struct net_device *dev); static int sb1000_dev_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd); static int sb1000_start_xmit(struct sk_buff *skb, struct net_device *dev); -static irqreturn_t sb1000_interrupt(int irq, void *dev_id, struct pt_regs *regs); -static struct net_device_stats *sb1000_stats(struct net_device *dev); +static irqreturn_t sb1000_interrupt(int irq, void *dev_id); static int sb1000_close(struct net_device *dev); /* SB1000 hardware routines to be used during open/configuration phases */ -static inline int card_wait_for_busy_clear(const int ioaddr[], +static int card_wait_for_busy_clear(const int ioaddr[], const char* name); -static inline int card_wait_for_ready(const int ioaddr[], const char* name, +static int card_wait_for_ready(const int ioaddr[], const char* name, unsigned char in[]); static int card_send_command(const int ioaddr[], const char* name, const unsigned char out[], unsigned char in[]); /* SB1000 hardware routines to be used during frame rx interrupt */ -static inline int sb1000_wait_for_ready(const int ioaddr[], const char* name); -static inline int sb1000_wait_for_ready_clear(const int ioaddr[], +static int sb1000_wait_for_ready(const int ioaddr[], const char* name); +static int sb1000_wait_for_ready_clear(const int ioaddr[], const char* name); -static inline void sb1000_send_command(const int ioaddr[], const char* name, +static void sb1000_send_command(const int ioaddr[], const char* name, const unsigned char out[]); -static inline void sb1000_read_status(const int ioaddr[], unsigned char in[]); -static inline void sb1000_issue_read_command(const int ioaddr[], +static void sb1000_read_status(const int ioaddr[], unsigned char in[]); +static void sb1000_issue_read_command(const int ioaddr[], const char* name); /* SB1000 commands for open/configuration */ -static inline int sb1000_reset(const int ioaddr[], const char* name); -static inline int sb1000_check_CRC(const int ioaddr[], const char* name); +static int sb1000_reset(const int ioaddr[], const char* name); +static int sb1000_check_CRC(const int ioaddr[], const char* name); static inline int sb1000_start_get_set_command(const int ioaddr[], const char* name); -static inline int sb1000_end_get_set_command(const int ioaddr[], +static int sb1000_end_get_set_command(const int ioaddr[], const char* name); -static inline int sb1000_activate(const int ioaddr[], const char* name); +static int sb1000_activate(const int ioaddr[], const char* name); static int sb1000_get_firmware_version(const int ioaddr[], const char* name, unsigned char version[], int do_end); static int sb1000_get_frequency(const int ioaddr[], const char* name, @@ -127,8 +125,8 @@ static int sb1000_set_PIDs(const int ioaddr[], const char* name, const short PID[]); /* SB1000 commands for frame rx interrupt */ -static inline int sb1000_rx(struct net_device *dev); -static inline void sb1000_error_dpc(struct net_device *dev); +static int sb1000_rx(struct net_device *dev); +static void sb1000_error_dpc(struct net_device *dev); static const struct pnp_device_id sb1000_pnp_ids[] = { { "GIC1000", 0 }, @@ -136,6 +134,16 @@ static const struct pnp_device_id sb1000_pnp_ids[] = { }; MODULE_DEVICE_TABLE(pnp, sb1000_pnp_ids); +static const struct net_device_ops sb1000_netdev_ops = { + .ndo_open = sb1000_open, + .ndo_start_xmit = sb1000_start_xmit, + .ndo_do_ioctl = sb1000_dev_ioctl, + .ndo_stop = sb1000_close, + .ndo_change_mtu = eth_change_mtu, + .ndo_set_mac_address = eth_mac_addr, + .ndo_validate_addr = eth_validate_addr, +}; + static int sb1000_probe_one(struct pnp_dev *pdev, const struct pnp_device_id *id) { @@ -143,7 +151,7 @@ sb1000_probe_one(struct pnp_dev *pdev, const struct pnp_device_id *id) unsigned short ioaddr[2], irq; unsigned int serial_number; int error = -ENODEV; - + if (pnp_device_attach(pdev) < 0) return -ENODEV; if (pnp_activate_dev(pdev) < 0) @@ -153,12 +161,12 @@ sb1000_probe_one(struct pnp_dev *pdev, const struct pnp_device_id *id) goto out_disable; if (!pnp_irq_valid(pdev, 0)) goto out_disable; - + serial_number = pdev->card->serial; - + ioaddr[0] = pnp_port_start(pdev, 0); ioaddr[1] = pnp_port_start(pdev, 0); - + irq = pnp_irq(pdev, 0); if (!request_region(ioaddr[0], 16, "sb1000")) @@ -172,7 +180,7 @@ sb1000_probe_one(struct pnp_dev *pdev, const struct pnp_device_id *id) goto out_release_regions; } - + dev->base_addr = ioaddr[0]; /* mem_start holds the second I/O address */ dev->mem_start = ioaddr[1]; @@ -189,18 +197,12 @@ sb1000_probe_one(struct pnp_dev *pdev, const struct pnp_device_id *id) */ dev->flags = IFF_POINTOPOINT|IFF_NOARP; - SET_MODULE_OWNER(dev); SET_NETDEV_DEV(dev, &pdev->dev); if (sb1000_debug > 0) printk(KERN_NOTICE "%s", version); - /* The SB1000-specific entries in the device structure. */ - dev->open = sb1000_open; - dev->do_ioctl = sb1000_dev_ioctl; - dev->hard_start_xmit = sb1000_start_xmit; - dev->stop = sb1000_close; - dev->get_stats = sb1000_stats; + dev->netdev_ops = &sb1000_netdev_ops; /* hardware address is 0:0:serial_number */ dev->dev_addr[2] = serial_number >> 24 & 0xff; @@ -246,7 +248,7 @@ static struct pnp_driver sb1000_driver = { .remove = sb1000_remove_one, }; - + /* * SB1000 hardware routines to be used during open/configuration phases */ @@ -254,7 +256,7 @@ static struct pnp_driver sb1000_driver = { static const int TimeOutJiffies = (875 * HZ) / 100; /* Card Wait For Busy Clear (cannot be used during an interrupt) */ -static inline int +static int card_wait_for_busy_clear(const int ioaddr[], const char* name) { unsigned char a; @@ -278,7 +280,7 @@ card_wait_for_busy_clear(const int ioaddr[], const char* name) } /* Card Wait For Ready (cannot be used during an interrupt) */ -static inline int +static int card_wait_for_ready(const int ioaddr[], const char* name, unsigned char in[]) { unsigned char a; @@ -351,14 +353,14 @@ card_send_command(const int ioaddr[], const char* name, return 0; } - + /* * SB1000 hardware routines to be used during frame rx interrupt */ static const int Sb1000TimeOutJiffies = 7 * HZ; /* Card Wait For Ready (to be used during frame rx) */ -static inline int +static int sb1000_wait_for_ready(const int ioaddr[], const char* name) { unsigned long timeout; @@ -384,7 +386,7 @@ sb1000_wait_for_ready(const int ioaddr[], const char* name) } /* Card Wait For Ready Clear (to be used during frame rx) */ -static inline int +static int sb1000_wait_for_ready_clear(const int ioaddr[], const char* name) { unsigned long timeout; @@ -409,7 +411,7 @@ sb1000_wait_for_ready_clear(const int ioaddr[], const char* name) } /* Card Send Command (to be used during frame rx) */ -static inline void +static void sb1000_send_command(const int ioaddr[], const char* name, const unsigned char out[]) { @@ -426,7 +428,7 @@ sb1000_send_command(const int ioaddr[], const char* name, } /* Card Read Status (to be used during frame rx) */ -static inline void +static void sb1000_read_status(const int ioaddr[], unsigned char in[]) { in[1] = inb(ioaddr[0] + 1); @@ -438,10 +440,10 @@ sb1000_read_status(const int ioaddr[], unsigned char in[]) } /* Issue Read Command (to be used during frame rx) */ -static inline void +static void sb1000_issue_read_command(const int ioaddr[], const char* name) { - const unsigned char Command0[6] = {0x20, 0x00, 0x00, 0x01, 0x00, 0x00}; + static const unsigned char Command0[6] = {0x20, 0x00, 0x00, 0x01, 0x00, 0x00}; sb1000_wait_for_ready_clear(ioaddr, name); outb(0xa0, ioaddr[0] + 6); @@ -449,17 +451,18 @@ sb1000_issue_read_command(const int ioaddr[], const char* name) return; } - + /* * SB1000 commands for open/configuration */ /* reset SB1000 card */ -static inline int +static int sb1000_reset(const int ioaddr[], const char* name) { + static const unsigned char Command0[6] = {0x80, 0x16, 0x00, 0x00, 0x00, 0x00}; + unsigned char st[7]; int port, status; - const unsigned char Command0[6] = {0x80, 0x16, 0x00, 0x00, 0x00, 0x00}; port = ioaddr[1] + 6; outb(0x4, port); @@ -483,12 +486,13 @@ sb1000_reset(const int ioaddr[], const char* name) } /* check SB1000 firmware CRC */ -static inline int +static int sb1000_check_CRC(const int ioaddr[], const char* name) { + static const unsigned char Command0[6] = {0x80, 0x1f, 0x00, 0x00, 0x00, 0x00}; + unsigned char st[7]; int crc, status; - const unsigned char Command0[6] = {0x80, 0x1f, 0x00, 0x00, 0x00, 0x00}; /* check CRC */ if ((status = card_send_command(ioaddr, name, Command0, st))) @@ -502,32 +506,35 @@ sb1000_check_CRC(const int ioaddr[], const char* name) static inline int sb1000_start_get_set_command(const int ioaddr[], const char* name) { + static const unsigned char Command0[6] = {0x80, 0x1b, 0x00, 0x00, 0x00, 0x00}; + unsigned char st[7]; - const unsigned char Command0[6] = {0x80, 0x1b, 0x00, 0x00, 0x00, 0x00}; return card_send_command(ioaddr, name, Command0, st); } -static inline int +static int sb1000_end_get_set_command(const int ioaddr[], const char* name) { + static const unsigned char Command0[6] = {0x80, 0x1b, 0x02, 0x00, 0x00, 0x00}; + static const unsigned char Command1[6] = {0x20, 0x00, 0x00, 0x00, 0x00, 0x00}; + unsigned char st[7]; int status; - const unsigned char Command0[6] = {0x80, 0x1b, 0x02, 0x00, 0x00, 0x00}; - const unsigned char Command1[6] = {0x20, 0x00, 0x00, 0x00, 0x00, 0x00}; if ((status = card_send_command(ioaddr, name, Command0, st))) return status; return card_send_command(ioaddr, name, Command1, st); } -static inline int +static int sb1000_activate(const int ioaddr[], const char* name) { + static const unsigned char Command0[6] = {0x80, 0x11, 0x00, 0x00, 0x00, 0x00}; + static const unsigned char Command1[6] = {0x80, 0x16, 0x00, 0x00, 0x00, 0x00}; + unsigned char st[7]; int status; - const unsigned char Command0[6] = {0x80, 0x11, 0x00, 0x00, 0x00, 0x00}; - const unsigned char Command1[6] = {0x80, 0x16, 0x00, 0x00, 0x00, 0x00}; ssleep(1); if ((status = card_send_command(ioaddr, name, Command0, st))) @@ -548,9 +555,10 @@ static int sb1000_get_firmware_version(const int ioaddr[], const char* name, unsigned char version[], int do_end) { + static const unsigned char Command0[6] = {0x80, 0x23, 0x00, 0x00, 0x00, 0x00}; + unsigned char st[7]; int status; - const unsigned char Command0[6] = {0x80, 0x23, 0x00, 0x00, 0x00, 0x00}; if ((status = sb1000_start_get_set_command(ioaddr, name))) return status; @@ -570,9 +578,10 @@ sb1000_get_firmware_version(const int ioaddr[], const char* name, static int sb1000_get_frequency(const int ioaddr[], const char* name, int* frequency) { + static const unsigned char Command0[6] = {0x80, 0x44, 0x00, 0x00, 0x00, 0x00}; + unsigned char st[7]; int status; - const unsigned char Command0[6] = {0x80, 0x44, 0x00, 0x00, 0x00, 0x00}; udelay(1000); if ((status = sb1000_start_get_set_command(ioaddr, name))) @@ -617,12 +626,13 @@ sb1000_set_frequency(const int ioaddr[], const char* name, int frequency) static int sb1000_get_PIDs(const int ioaddr[], const char* name, short PID[]) { + static const unsigned char Command0[6] = {0x80, 0x40, 0x00, 0x00, 0x00, 0x00}; + static const unsigned char Command1[6] = {0x80, 0x41, 0x00, 0x00, 0x00, 0x00}; + static const unsigned char Command2[6] = {0x80, 0x42, 0x00, 0x00, 0x00, 0x00}; + static const unsigned char Command3[6] = {0x80, 0x43, 0x00, 0x00, 0x00, 0x00}; + unsigned char st[7]; int status; - const unsigned char Command0[6] = {0x80, 0x40, 0x00, 0x00, 0x00, 0x00}; - const unsigned char Command1[6] = {0x80, 0x41, 0x00, 0x00, 0x00, 0x00}; - const unsigned char Command2[6] = {0x80, 0x42, 0x00, 0x00, 0x00, 0x00}; - const unsigned char Command3[6] = {0x80, 0x43, 0x00, 0x00, 0x00, 0x00}; udelay(1000); if ((status = sb1000_start_get_set_command(ioaddr, name))) @@ -651,6 +661,8 @@ sb1000_get_PIDs(const int ioaddr[], const char* name, short PID[]) static int sb1000_set_PIDs(const int ioaddr[], const char* name, const short PID[]) { + static const unsigned char Command4[6] = {0x80, 0x2e, 0x00, 0x00, 0x00, 0x00}; + unsigned char st[7]; short p; int status; @@ -658,7 +670,6 @@ sb1000_set_PIDs(const int ioaddr[], const char* name, const short PID[]) unsigned char Command1[6] = {0x80, 0x32, 0x00, 0x00, 0x00, 0x00}; unsigned char Command2[6] = {0x80, 0x33, 0x00, 0x00, 0x00, 0x00}; unsigned char Command3[6] = {0x80, 0x34, 0x00, 0x00, 0x00, 0x00}; - const unsigned char Command4[6] = {0x80, 0x2e, 0x00, 0x00, 0x00, 0x00}; udelay(1000); if ((status = sb1000_start_get_set_command(ioaddr, name))) @@ -697,8 +708,8 @@ sb1000_set_PIDs(const int ioaddr[], const char* name, const short PID[]) return sb1000_end_get_set_command(ioaddr, name); } - -static inline void + +static void sb1000_print_status_buffer(const char* name, unsigned char st[], unsigned char buffer[], int size) { @@ -729,7 +740,7 @@ sb1000_print_status_buffer(const char* name, unsigned char st[], /* receive a single frame and assemble datagram * (this is the heart of the interrupt routine) */ -static inline int +static int sb1000_rx(struct net_device *dev) { @@ -740,7 +751,7 @@ sb1000_rx(struct net_device *dev) unsigned int skbsize; struct sk_buff *skb; struct sb1000_private *lp = netdev_priv(dev); - struct net_device_stats *stats = &lp->stats; + struct net_device_stats *stats = &dev->stats; /* SB1000 frame constants */ const int FrameSize = FRAMESIZE; @@ -834,7 +845,7 @@ printk("cm0: IP identification: %02x%02x fragment offset: %02x%02x\n", buffer[3 goto dropped_frame; } skb->dev = dev; - skb->mac.raw = skb->data; + skb_reset_mac_header(skb); skb->protocol = (unsigned short) buffer[NewDatagramHeaderSkip + 16]; insw(ioaddr, skb_put(skb, NewDatagramDataSize), NewDatagramDataSize / 2); @@ -864,7 +875,6 @@ printk("cm0: IP identification: %02x%02x fragment offset: %02x%02x\n", buffer[3 /* datagram completed: send to upper level */ skb_trim(skb, dlen); netif_rx(skb); - dev->last_rx = jiffies; stats->rx_bytes+=dlen; stats->rx_packets++; lp->rx_skb[ns] = NULL; @@ -892,14 +902,15 @@ dropped_frame: return -1; } -static inline void +static void sb1000_error_dpc(struct net_device *dev) { + static const unsigned char Command0[6] = {0x80, 0x26, 0x00, 0x00, 0x00, 0x00}; + char *name; unsigned char st[5]; int ioaddr[2]; struct sb1000_private *lp = netdev_priv(dev); - const unsigned char Command0[6] = {0x80, 0x26, 0x00, 0x00, 0x00, 0x00}; const int ErrorDpcCounterInitialize = 200; ioaddr[0] = dev->base_addr; @@ -916,7 +927,7 @@ sb1000_error_dpc(struct net_device *dev) return; } - + /* * Linux interface functions */ @@ -1003,11 +1014,11 @@ static int sb1000_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) switch (cmd) { case SIOCGCMSTATS: /* get statistics */ - stats[0] = lp->stats.rx_bytes; + stats[0] = dev->stats.rx_bytes; stats[1] = lp->rx_frames; - stats[2] = lp->stats.rx_packets; - stats[3] = lp->stats.rx_errors; - stats[4] = lp->stats.rx_dropped; + stats[2] = dev->stats.rx_packets; + stats[3] = dev->stats.rx_errors; + stats[4] = dev->stats.rx_dropped; if(copy_to_user(ifr->ifr_data, stats, sizeof(stats))) return -EFAULT; status = 0; @@ -1079,24 +1090,19 @@ sb1000_start_xmit(struct sk_buff *skb, struct net_device *dev) } /* SB1000 interrupt handler. */ -static irqreturn_t sb1000_interrupt(int irq, void *dev_id, struct pt_regs *regs) +static irqreturn_t sb1000_interrupt(int irq, void *dev_id) { + static const unsigned char Command0[6] = {0x80, 0x2c, 0x00, 0x00, 0x00, 0x00}; + static const unsigned char Command1[6] = {0x80, 0x2e, 0x00, 0x00, 0x00, 0x00}; + char *name; unsigned char st; int ioaddr[2]; - struct net_device *dev = (struct net_device *) dev_id; + struct net_device *dev = dev_id; struct sb1000_private *lp = netdev_priv(dev); - const unsigned char Command0[6] = {0x80, 0x2c, 0x00, 0x00, 0x00, 0x00}; - const unsigned char Command1[6] = {0x80, 0x2e, 0x00, 0x00, 0x00, 0x00}; const int MaxRxErrorCount = 6; - if (dev == NULL) { - printk(KERN_ERR "sb1000_interrupt(): irq %d for unknown device.\n", - irq); - return IRQ_NONE; - } - ioaddr[0] = dev->base_addr; /* mem_start holds the second I/O address */ ioaddr[1] = dev->mem_start; @@ -1139,12 +1145,6 @@ static irqreturn_t sb1000_interrupt(int irq, void *dev_id, struct pt_regs *regs) return IRQ_HANDLED; } -static struct net_device_stats *sb1000_stats(struct net_device *dev) -{ - struct sb1000_private *lp = netdev_priv(dev); - return &lp->stats; -} - static int sb1000_close(struct net_device *dev) { int i; @@ -1155,7 +1155,7 @@ static int sb1000_close(struct net_device *dev) printk(KERN_DEBUG "%s: Shutting down sb1000.\n", dev->name); netif_stop_queue(dev); - + ioaddr[0] = dev->base_addr; /* mem_start holds the second I/O address */ ioaddr[1] = dev->mem_start;