1 /* 2 * aQuantia Corporation Network Driver 3 * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * (1) Redistributions of source code must retain the above 10 * copyright notice, this list of conditions and the following 11 * disclaimer. 12 * 13 * (2) Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials provided 16 * with the distribution. 17 * 18 * (3)The name of the author may not be used to endorse or promote 19 * products derived from this software without specific prior 20 * written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 23 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 28 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 #ifndef _AQ_COMMON_H_ 36 #define _AQ_COMMON_H_ 37 38 #include <sys/types.h> 39 40 41 #define ETIME ETIMEDOUT 42 #define EOK 0 43 44 #define BIT(nr) (1UL << (nr)) 45 46 #define usec_delay(x) DELAY(x) 47 48 #ifndef msec_delay 49 #define msec_delay(x) DELAY(x*1000) 50 #define msec_delay_irq(x) DELAY(x*1000) 51 #endif 52 53 #define AQ_HW_WAIT_FOR(_B_, _US_, _N_) \ 54 do { \ 55 unsigned int i; \ 56 for (i = _N_; (!(_B_)) && i; --i) { \ 57 usec_delay(_US_); \ 58 } \ 59 if (!i) { \ 60 err = -1; \ 61 } \ 62 } while (0) 63 64 65 #define LOWORD(a) ((uint16_t)(a)) 66 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 67 68 #define AQ_VER "0.0.5" 69 70 #endif // _AQ_COMMON_H_ 71