]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/tlan.c
tlan: get rid of padding buffer
[linux-2.6-omap-h63xx.git] / drivers / net / tlan.c
index c99ce74a7aff7251c3821314fab0e43be38ffd2f..d1633fbf46ce80e398a7d31a32634f0d33030c7d 100644 (file)
@@ -218,8 +218,6 @@ static      int             bbuf;
 module_param(bbuf, int, 0);
 MODULE_PARM_DESC(bbuf, "ThunderLAN use big buffer (0-1)");
 
-static u8              *TLanPadBuffer;
-static  dma_addr_t     TLanPadBufferDMA;
 static char            TLanSignature[] = "TLAN";
 static  const char tlan_banner[] = "ThunderLAN driver v1.15\n";
 static  int tlan_have_pci;
@@ -465,25 +463,20 @@ static struct pci_driver tlan_driver = {
 
 static int __init tlan_probe(void)
 {
-       static int      pad_allocated;
+       int rc = -ENODEV;
 
        printk(KERN_INFO "%s", tlan_banner);
 
-       TLanPadBuffer = (u8 *) pci_alloc_consistent(NULL, TLAN_MIN_FRAME_SIZE, &TLanPadBufferDMA);
-
-       if (TLanPadBuffer == NULL) {
-               printk(KERN_ERR "TLAN: Could not allocate memory for pad buffer.\n");
-               return -ENOMEM;
-       }
-
-       memset(TLanPadBuffer, 0, TLAN_MIN_FRAME_SIZE);
-       pad_allocated = 1;
-
        TLAN_DBG(TLAN_DEBUG_PROBE, "Starting PCI Probe....\n");
 
        /* Use new style PCI probing. Now the kernel will
           do most of this for us */
-       pci_register_driver(&tlan_driver);
+       rc = pci_register_driver(&tlan_driver);
+
+       if (rc != 0) {
+               printk(KERN_ERR "TLAN: Could not register pci driver.\n");
+               goto err_out_pci_free;
+       }
 
        TLAN_DBG(TLAN_DEBUG_PROBE, "Starting EISA Probe....\n");
        TLan_EisaProbe();
@@ -493,11 +486,15 @@ static int __init tlan_probe(void)
                 tlan_have_pci, tlan_have_eisa);
 
        if (TLanDevicesInstalled == 0) {
-               pci_unregister_driver(&tlan_driver);
-               pci_free_consistent(NULL, TLAN_MIN_FRAME_SIZE, TLanPadBuffer, TLanPadBufferDMA);
-               return -ENODEV;
+               rc = -ENODEV;
+               goto  err_out_pci_unreg;
        }
        return 0;
+
+err_out_pci_unreg:
+       pci_unregister_driver(&tlan_driver);
+err_out_pci_free:
+       return rc;
 }
 
 
@@ -713,8 +710,6 @@ static void __exit tlan_exit(void)
        if (tlan_have_eisa)
                TLan_Eisa_Cleanup();
 
-       pci_free_consistent(NULL, TLAN_MIN_FRAME_SIZE, TLanPadBuffer, TLanPadBufferDMA);
-
 }
 
 
@@ -1085,7 +1080,6 @@ static int TLan_StartTx( struct sk_buff *skb, struct net_device *dev )
        TLanList        *tail_list;
        dma_addr_t      tail_list_phys;
        u8              *tail_buffer;
-       int             pad;
        unsigned long   flags;
 
        if ( ! priv->phyOnline ) {
@@ -1094,6 +1088,9 @@ static int TLan_StartTx( struct sk_buff *skb, struct net_device *dev )
                return 0;
        }
 
+       if (skb_padto(skb, TLAN_MIN_FRAME_SIZE))
+               return 0;
+
        tail_list = priv->txList + priv->txTail;
        tail_list_phys = priv->txListDMA + sizeof(TLanList) * priv->txTail;
 
@@ -1114,19 +1111,10 @@ static int TLan_StartTx( struct sk_buff *skb, struct net_device *dev )
                TLan_StoreSKB(tail_list, skb);
        }
 
-       pad = TLAN_MIN_FRAME_SIZE - skb->len;
-
-       if ( pad > 0 ) {
-               tail_list->frameSize = (u16) skb->len + pad;
-               tail_list->buffer[0].count = (u32) skb->len;
-               tail_list->buffer[1].count = TLAN_LAST_BUFFER | (u32) pad;
-               tail_list->buffer[1].address = TLanPadBufferDMA;
-       } else {
-               tail_list->frameSize = (u16) skb->len;
-               tail_list->buffer[0].count = TLAN_LAST_BUFFER | (u32) skb->len;
-               tail_list->buffer[1].count = 0;
-               tail_list->buffer[1].address = 0;
-       }
+       tail_list->frameSize = (u16) skb->len;
+       tail_list->buffer[0].count = TLAN_LAST_BUFFER | (u32) skb->len;
+       tail_list->buffer[1].count = 0;
+       tail_list->buffer[1].address = 0;
 
        spin_lock_irqsave(&priv->lock, flags);
        tail_list->cStat = TLAN_CSTAT_READY;
@@ -1389,7 +1377,7 @@ static void TLan_SetMulticastList( struct net_device *dev )
         *
         **************************************************************/
 
-u32 TLan_HandleInvalid( struct net_device *dev, u16 host_int )
+static u32 TLan_HandleInvalid( struct net_device *dev, u16 host_int )
 {
        /* printk( "TLAN:  Invalid interrupt on %s.\n", dev->name ); */
        return 0;
@@ -1421,7 +1409,7 @@ u32 TLan_HandleInvalid( struct net_device *dev, u16 host_int )
         *
         **************************************************************/
 
-u32 TLan_HandleTxEOF( struct net_device *dev, u16 host_int )
+static u32 TLan_HandleTxEOF( struct net_device *dev, u16 host_int )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
        int             eoc = 0;
@@ -1507,7 +1495,7 @@ u32 TLan_HandleTxEOF( struct net_device *dev, u16 host_int )
         *
         **************************************************************/
 
-u32 TLan_HandleStatOverflow( struct net_device *dev, u16 host_int )
+static u32 TLan_HandleStatOverflow( struct net_device *dev, u16 host_int )
 {
        TLan_ReadAndClearStats( dev, TLAN_RECORD );
 
@@ -1543,7 +1531,7 @@ u32 TLan_HandleStatOverflow( struct net_device *dev, u16 host_int )
         *
         **************************************************************/
 
-u32 TLan_HandleRxEOF( struct net_device *dev, u16 host_int )
+static u32 TLan_HandleRxEOF( struct net_device *dev, u16 host_int )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
        u32             ack = 0;
@@ -1678,7 +1666,7 @@ u32 TLan_HandleRxEOF( struct net_device *dev, u16 host_int )
         *
         **************************************************************/
 
-u32 TLan_HandleDummy( struct net_device *dev, u16 host_int )
+static u32 TLan_HandleDummy( struct net_device *dev, u16 host_int )
 {
        printk( "TLAN:  Test interrupt on %s.\n", dev->name );
        return 1;
@@ -1708,7 +1696,7 @@ u32 TLan_HandleDummy( struct net_device *dev, u16 host_int )
         *
         **************************************************************/
 
-u32 TLan_HandleTxEOC( struct net_device *dev, u16 host_int )
+static u32 TLan_HandleTxEOC( struct net_device *dev, u16 host_int )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
        TLanList                *head_list;
@@ -1756,7 +1744,7 @@ u32 TLan_HandleTxEOC( struct net_device *dev, u16 host_int )
         *
         **************************************************************/
 
-u32 TLan_HandleStatusCheck( struct net_device *dev, u16 host_int )
+static u32 TLan_HandleStatusCheck( struct net_device *dev, u16 host_int )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
        u32             ack;
@@ -1831,7 +1819,7 @@ u32 TLan_HandleStatusCheck( struct net_device *dev, u16 host_int )
         *
         **************************************************************/
 
-u32 TLan_HandleRxEOC( struct net_device *dev, u16 host_int )
+static u32 TLan_HandleRxEOC( struct net_device *dev, u16 host_int )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
        dma_addr_t      head_list_phys;
@@ -1891,7 +1879,7 @@ u32 TLan_HandleRxEOC( struct net_device *dev, u16 host_int )
         *
         **************************************************************/
 
-void TLan_Timer( unsigned long data )
+static void TLan_Timer( unsigned long data )
 {
        struct net_device       *dev = (struct net_device *) data;
        TLanPrivateInfo *priv = netdev_priv(dev);
@@ -1972,7 +1960,7 @@ void TLan_Timer( unsigned long data )
         *
         **************************************************************/
 
-void TLan_ResetLists( struct net_device *dev )
+static void TLan_ResetLists( struct net_device *dev )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
        int             i;
@@ -2032,7 +2020,7 @@ void TLan_ResetLists( struct net_device *dev )
 } /* TLan_ResetLists */
 
 
-void TLan_FreeLists( struct net_device *dev )
+static void TLan_FreeLists( struct net_device *dev )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
        int             i;
@@ -2081,7 +2069,7 @@ void TLan_FreeLists( struct net_device *dev )
         *
         **************************************************************/
 
-void TLan_PrintDio( u16 io_base )
+static void TLan_PrintDio( u16 io_base )
 {
        u32 data0, data1;
        int     i;
@@ -2116,7 +2104,7 @@ void TLan_PrintDio( u16 io_base )
         *
         **************************************************************/
 
-void TLan_PrintList( TLanList *list, char *type, int num)
+static void TLan_PrintList( TLanList *list, char *type, int num)
 {
        int i;
 
@@ -2152,7 +2140,7 @@ void TLan_PrintList( TLanList *list, char *type, int num)
         *
         **************************************************************/
 
-void TLan_ReadAndClearStats( struct net_device *dev, int record )
+static void TLan_ReadAndClearStats( struct net_device *dev, int record )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
        u32             tx_good, tx_under;
@@ -2227,7 +2215,7 @@ void TLan_ReadAndClearStats( struct net_device *dev, int record )
         *
         **************************************************************/
 
-void
+static void
 TLan_ResetAdapter( struct net_device *dev )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
@@ -2313,7 +2301,7 @@ TLan_ResetAdapter( struct net_device *dev )
 
 
 
-void
+static void
 TLan_FinishReset( struct net_device *dev )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
@@ -2437,7 +2425,7 @@ TLan_FinishReset( struct net_device *dev )
         *
         **************************************************************/
 
-void TLan_SetMac( struct net_device *dev, int areg, char *mac )
+static void TLan_SetMac( struct net_device *dev, int areg, char *mac )
 {
        int i;
 
@@ -2479,7 +2467,7 @@ void TLan_SetMac( struct net_device *dev, int areg, char *mac )
         *
         ********************************************************************/
 
-void TLan_PhyPrint( struct net_device *dev )
+static void TLan_PhyPrint( struct net_device *dev )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
        u16 i, data0, data1, data2, data3, phy;
@@ -2528,7 +2516,7 @@ void TLan_PhyPrint( struct net_device *dev )
         *
         ********************************************************************/
 
-void TLan_PhyDetect( struct net_device *dev )
+static void TLan_PhyDetect( struct net_device *dev )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
        u16             control;
@@ -2575,7 +2563,7 @@ void TLan_PhyDetect( struct net_device *dev )
 
 
 
-void TLan_PhyPowerDown( struct net_device *dev )
+static void TLan_PhyPowerDown( struct net_device *dev )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
        u16             value;
@@ -2600,7 +2588,7 @@ void TLan_PhyPowerDown( struct net_device *dev )
 
 
 
-void TLan_PhyPowerUp( struct net_device *dev )
+static void TLan_PhyPowerUp( struct net_device *dev )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
        u16             value;
@@ -2621,7 +2609,7 @@ void TLan_PhyPowerUp( struct net_device *dev )
 
 
 
-void TLan_PhyReset( struct net_device *dev )
+static void TLan_PhyReset( struct net_device *dev )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
        u16             phy;
@@ -2649,7 +2637,7 @@ void TLan_PhyReset( struct net_device *dev )
 
 
 
-void TLan_PhyStartLink( struct net_device *dev )
+static void TLan_PhyStartLink( struct net_device *dev )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
        u16             ability;
@@ -2736,7 +2724,7 @@ void TLan_PhyStartLink( struct net_device *dev )
 
 
 
-void TLan_PhyFinishAutoNeg( struct net_device *dev )
+static void TLan_PhyFinishAutoNeg( struct net_device *dev )
 {
        TLanPrivateInfo *priv = netdev_priv(dev);
        u16             an_adv;
@@ -2892,7 +2880,7 @@ void TLan_PhyMonitor( struct net_device *dev )
         *
         **************************************************************/
 
-int TLan_MiiReadReg( struct net_device *dev, u16 phy, u16 reg, u16 *val )
+static int TLan_MiiReadReg( struct net_device *dev, u16 phy, u16 reg, u16 *val )
 {
        u8      nack;
        u16     sio, tmp;
@@ -2982,7 +2970,7 @@ int TLan_MiiReadReg( struct net_device *dev, u16 phy, u16 reg, u16 *val )
         *
         **************************************************************/
 
-void TLan_MiiSendData( u16 base_port, u32 data, unsigned num_bits )
+static void TLan_MiiSendData( u16 base_port, u32 data, unsigned num_bits )
 {
        u16 sio;
        u32 i;
@@ -3024,7 +3012,7 @@ void TLan_MiiSendData( u16 base_port, u32 data, unsigned num_bits )
         *
         **************************************************************/
 
-void TLan_MiiSync( u16 base_port )
+static void TLan_MiiSync( u16 base_port )
 {
        int i;
        u16 sio;
@@ -3063,7 +3051,7 @@ void TLan_MiiSync( u16 base_port )
         *
         **************************************************************/
 
-void TLan_MiiWriteReg( struct net_device *dev, u16 phy, u16 reg, u16 val )
+static void TLan_MiiWriteReg( struct net_device *dev, u16 phy, u16 reg, u16 val )
 {
        u16     sio;
        int     minten;
@@ -3133,7 +3121,7 @@ void TLan_MiiWriteReg( struct net_device *dev, u16 phy, u16 reg, u16 val )
         *
         **************************************************************/
 
-void TLan_EeSendStart( u16 io_base )
+static void TLan_EeSendStart( u16 io_base )
 {
        u16     sio;
 
@@ -3173,7 +3161,7 @@ void TLan_EeSendStart( u16 io_base )
         *
         **************************************************************/
 
-int TLan_EeSendByte( u16 io_base, u8 data, int stop )
+static int TLan_EeSendByte( u16 io_base, u8 data, int stop )
 {
        int     err;
        u8      place;
@@ -3234,7 +3222,7 @@ int TLan_EeSendByte( u16 io_base, u8 data, int stop )
         *
         **************************************************************/
 
-void TLan_EeReceiveByte( u16 io_base, u8 *data, int stop )
+static void TLan_EeReceiveByte( u16 io_base, u8 *data, int stop )
 {
        u8  place;
        u16 sio;
@@ -3292,7 +3280,7 @@ void TLan_EeReceiveByte( u16 io_base, u8 *data, int stop )
         *
         **************************************************************/
 
-int TLan_EeReadByte( struct net_device *dev, u8 ee_addr, u8 *data )
+static int TLan_EeReadByte( struct net_device *dev, u8 ee_addr, u8 *data )
 {
        int err;
        TLanPrivateInfo *priv = netdev_priv(dev);