X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fatm%2Fambassador.c;h=6adb72a2f8769bd9205395b266088ee02e07ccee;hb=ccc751841567816532874afcaeb449dbf6ca7d3a;hp=59651abfa4f8b683bc82d33fb7077224ee3256e2;hpb=b643b0fdbc59cf6bbb086974b29d2571e9e9f646;p=linux-2.6 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c index 59651abfa4..6adb72a2f8 100644 --- a/drivers/atm/ambassador.c +++ b/drivers/atm/ambassador.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -437,7 +438,7 @@ static inline void dump_skb (char * prefix, unsigned int vc, struct sk_buff * sk /* see limitations under Hardware Features */ -static inline int check_area (void * start, size_t length) { +static int check_area (void * start, size_t length) { // assumes length > 0 const u32 fourmegmask = -1 << 22; const u32 twofivesixmask = -1 << 8; @@ -456,7 +457,7 @@ static inline int check_area (void * start, size_t length) { /********** free an skb (as per ATM device driver documentation) **********/ -static inline void amb_kfree_skb (struct sk_buff * skb) { +static void amb_kfree_skb (struct sk_buff * skb) { if (ATM_SKB(skb)->vcc->pop) { ATM_SKB(skb)->vcc->pop (ATM_SKB(skb)->vcc, skb); } else { @@ -466,7 +467,7 @@ static inline void amb_kfree_skb (struct sk_buff * skb) { /********** TX completion **********/ -static inline void tx_complete (amb_dev * dev, tx_out * tx) { +static void tx_complete (amb_dev * dev, tx_out * tx) { tx_simple * tx_descr = bus_to_virt (tx->handle); struct sk_buff * skb = tx_descr->skb; @@ -643,7 +644,7 @@ static int command_do (amb_dev * dev, command * cmd) { /********** TX queue pair **********/ -static inline int tx_give (amb_dev * dev, tx_in * tx) { +static int tx_give (amb_dev * dev, tx_in * tx) { amb_txq * txq = &dev->txq; unsigned long flags; @@ -675,7 +676,7 @@ static inline int tx_give (amb_dev * dev, tx_in * tx) { } } -static inline int tx_take (amb_dev * dev) { +static int tx_take (amb_dev * dev) { amb_txq * txq = &dev->txq; unsigned long flags; @@ -703,7 +704,7 @@ static inline int tx_take (amb_dev * dev) { /********** RX queue pairs **********/ -static inline int rx_give (amb_dev * dev, rx_in * rx, unsigned char pool) { +static int rx_give (amb_dev * dev, rx_in * rx, unsigned char pool) { amb_rxq * rxq = &dev->rxq[pool]; unsigned long flags; @@ -728,7 +729,7 @@ static inline int rx_give (amb_dev * dev, rx_in * rx, unsigned char pool) { } } -static inline int rx_take (amb_dev * dev, unsigned char pool) { +static int rx_take (amb_dev * dev, unsigned char pool) { amb_rxq * rxq = &dev->rxq[pool]; unsigned long flags; @@ -761,7 +762,7 @@ static inline int rx_take (amb_dev * dev, unsigned char pool) { /********** RX Pool handling **********/ /* pre: buffers_wanted = 0, post: pending = 0 */ -static inline void drain_rx_pool (amb_dev * dev, unsigned char pool) { +static void drain_rx_pool (amb_dev * dev, unsigned char pool) { amb_rxq * rxq = &dev->rxq[pool]; PRINTD (DBG_FLOW|DBG_POOL, "drain_rx_pool %p %hu", dev, pool); @@ -796,7 +797,7 @@ static void drain_rx_pools (amb_dev * dev) { drain_rx_pool (dev, pool); } -static inline void fill_rx_pool (amb_dev * dev, unsigned char pool, +static void fill_rx_pool (amb_dev * dev, unsigned char pool, gfp_t priority) { rx_in rx; @@ -846,7 +847,7 @@ static void fill_rx_pools (amb_dev * dev) { /********** enable host interrupts **********/ -static inline void interrupts_on (amb_dev * dev) { +static void interrupts_on (amb_dev * dev) { wr_plain (dev, offsetof(amb_mem, interrupt_control), rd_plain (dev, offsetof(amb_mem, interrupt_control)) | AMB_INTERRUPT_BITS); @@ -854,7 +855,7 @@ static inline void interrupts_on (amb_dev * dev) { /********** disable host interrupts **********/ -static inline void interrupts_off (amb_dev * dev) { +static void interrupts_off (amb_dev * dev) { wr_plain (dev, offsetof(amb_mem, interrupt_control), rd_plain (dev, offsetof(amb_mem, interrupt_control)) &~ AMB_INTERRUPT_BITS); @@ -1040,7 +1041,7 @@ static int amb_open (struct atm_vcc * atm_vcc) struct atm_qos * qos; struct atm_trafprm * txtp; struct atm_trafprm * rxtp; - u16 tx_rate_bits; + u16 tx_rate_bits = -1; // hush gcc u16 tx_vc_bits = -1; // hush gcc u16 tx_frame_bits = -1; // hush gcc @@ -1096,6 +1097,8 @@ static int amb_open (struct atm_vcc * atm_vcc) r = round_up; } error = make_rate (pcr, r, &tx_rate_bits, NULL); + if (error) + return error; tx_vc_bits = TX_UBR_CAPPED; tx_frame_bits = TX_FRAME_CAPPED; } @@ -1175,7 +1178,7 @@ static int amb_open (struct atm_vcc * atm_vcc) vcc->tx_frame_bits = tx_frame_bits; - down (&dev->vcc_sf); + mutex_lock(&dev->vcc_sf); if (dev->rxer[vci]) { // RXer on the channel already, just modify rate... cmd.request = cpu_to_be32 (SRB_MODIFY_VC_RATE); @@ -1201,7 +1204,7 @@ static int amb_open (struct atm_vcc * atm_vcc) schedule(); } dev->txer[vci].tx_present = 1; - up (&dev->vcc_sf); + mutex_unlock(&dev->vcc_sf); } if (rxtp->traffic_class != ATM_NONE) { @@ -1209,7 +1212,7 @@ static int amb_open (struct atm_vcc * atm_vcc) vcc->rx_info.pool = pool; - down (&dev->vcc_sf); + mutex_lock(&dev->vcc_sf); /* grow RX buffer pool */ if (!dev->rxq[pool].buffers_wanted) dev->rxq[pool].buffers_wanted = rx_lats; @@ -1235,7 +1238,7 @@ static int amb_open (struct atm_vcc * atm_vcc) schedule(); // this link allows RX frames through dev->rxer[vci] = atm_vcc; - up (&dev->vcc_sf); + mutex_unlock(&dev->vcc_sf); } // indicate readiness @@ -1260,7 +1263,7 @@ static void amb_close (struct atm_vcc * atm_vcc) { if (atm_vcc->qos.txtp.traffic_class != ATM_NONE) { command cmd; - down (&dev->vcc_sf); + mutex_lock(&dev->vcc_sf); if (dev->rxer[vci]) { // RXer still on the channel, just modify rate... XXX not really needed cmd.request = cpu_to_be32 (SRB_MODIFY_VC_RATE); @@ -1275,7 +1278,7 @@ static void amb_close (struct atm_vcc * atm_vcc) { dev->txer[vci].tx_present = 0; while (command_do (dev, &cmd)) schedule(); - up (&dev->vcc_sf); + mutex_unlock(&dev->vcc_sf); } // disable RXing @@ -1285,7 +1288,7 @@ static void amb_close (struct atm_vcc * atm_vcc) { // this is (the?) one reason why we need the amb_vcc struct unsigned char pool = vcc->rx_info.pool; - down (&dev->vcc_sf); + mutex_lock(&dev->vcc_sf); if (dev->txer[vci].tx_present) { // TXer still on the channel, just go to pool zero XXX not really needed cmd.request = cpu_to_be32 (SRB_MODIFY_VC_FLAGS); @@ -1312,7 +1315,7 @@ static void amb_close (struct atm_vcc * atm_vcc) { dev->rxq[pool].buffers_wanted = 0; drain_rx_pool (dev, pool); } - up (&dev->vcc_sf); + mutex_unlock(&dev->vcc_sf); } // free our structure @@ -2161,7 +2164,6 @@ static int __devinit amb_init (amb_dev * dev) static void setup_dev(amb_dev *dev, struct pci_dev *pci_dev) { unsigned char pool; - memset (dev, 0, sizeof(amb_dev)); // set up known dev items straight away dev->pci_dev = pci_dev; @@ -2187,7 +2189,7 @@ static void setup_dev(amb_dev *dev, struct pci_dev *pci_dev) // semaphore for txer/rxer modifications - we cannot use a // spinlock as the critical region needs to switch processes - init_MUTEX (&dev->vcc_sf); + mutex_init(&dev->vcc_sf); // queue manipulation spinlocks; we want atomic reads and // writes to the queue descriptors (handles IRQ and SMP) // consider replacing "int pending" -> "atomic_t available" @@ -2251,7 +2253,7 @@ static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_ goto out_disable; } - dev = kmalloc (sizeof(amb_dev), GFP_KERNEL); + dev = kzalloc(sizeof(amb_dev), GFP_KERNEL); if (!dev) { PRINTK (KERN_ERR, "out of memory!"); err = -ENOMEM;