X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fatm%2Fambassador.c;h=b34b3829f6a9a1fa5a37fe4df0dd607dd3e76c13;hb=444ad82bc3eaa554be40d22dc248e58aeefd54d9;hp=9fffa7af6db1f5c2feaf448fd7dec744e41ab308;hpb=bdbf77d6707a52bdeff223d0a60df12d086d21d7;p=linux-2.6 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c index 9fffa7af6d..b34b3829f6 100644 --- a/drivers/atm/ambassador.c +++ b/drivers/atm/ambassador.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -820,7 +821,7 @@ static inline void fill_rx_pool (amb_dev * dev, unsigned char pool, } // cast needed as there is no %? for pointer differences PRINTD (DBG_SKB, "allocated skb at %p, head %p, area %li", - skb, skb->head, (long) (skb->end - skb->head)); + skb, skb->head, (long) (skb_end_pointer(skb) - skb->head)); rx.handle = virt_to_bus (skb); rx.host_address = cpu_to_be32 (virt_to_bus (skb->data)); if (rx_give (dev, &rx, pool)) @@ -972,7 +973,7 @@ static int make_rate (unsigned int rate, rounding r, } case round_up: { // check all bits that we are discarding - if (man & (-1>>9)) { + if (man & (~0U>>9)) { man = (man>>(32-9)) + 1; if (man == (1<<9)) { // no need to check for round up outside of range @@ -1039,7 +1040,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 @@ -1095,6 +1096,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; } @@ -2068,18 +2071,6 @@ static void __devinit amb_ucode_version (amb_dev * dev) { PRINTK (KERN_INFO, "microcode version is %u.%u", major, minor); } -// swap bits within byte to get Ethernet ordering -static u8 bit_swap (u8 byte) -{ - const u8 swap[] = { - 0x0, 0x8, 0x4, 0xc, - 0x2, 0xa, 0x6, 0xe, - 0x1, 0x9, 0x5, 0xd, - 0x3, 0xb, 0x7, 0xf - }; - return ((swap[byte & 0xf]<<4) | swap[byte>>4]); -} - // get end station address static void __devinit amb_esi (amb_dev * dev, u8 * esi) { u32 lower4; @@ -2101,9 +2092,9 @@ static void __devinit amb_esi (amb_dev * dev, u8 * esi) { PRINTDB (DBG_INIT, "ESI:"); for (i = 0; i < ESI_LEN; ++i) { if (i < 4) - esi[i] = bit_swap (lower4>>(8*i)); + esi[i] = bitrev8(lower4>>(8*i)); else - esi[i] = bit_swap (upper2>>(8*(i-4))); + esi[i] = bitrev8(upper2>>(8*(i-4))); PRINTDM (DBG_INIT, " %02x", esi[i]); }