The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/dev/rtw89/util.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
    2  * Copyright(c) 2019-2020  Realtek Corporation
    3  */
    4 #ifndef __RTW89_UTIL_H__
    5 #define __RTW89_UTIL_H__
    6 
    7 #include "core.h"
    8 
    9 #define rtw89_iterate_vifs_bh(rtwdev, iterator, data)                          \
   10         ieee80211_iterate_active_interfaces_atomic((rtwdev)->hw,               \
   11                         IEEE80211_IFACE_ITER_NORMAL, iterator, data)
   12 
   13 /* call this function with rtwdev->mutex is held */
   14 #define rtw89_for_each_rtwvif(rtwdev, rtwvif)                                  \
   15         list_for_each_entry(rtwvif, &(rtwdev)->rtwvifs_list, list)
   16 
   17 /* The result of negative dividend and positive divisor is undefined, but it
   18  * should be one case of round-down or round-up. So, make it round-down if the
   19  * result is round-up.
   20  * Note: the maximum value of divisor is 0x7FFF_FFFF, because we cast it to
   21  *       signed value to make compiler to use signed divide instruction.
   22  */
   23 static inline s32 s32_div_u32_round_down(s32 dividend, u32 divisor, s32 *remainder)
   24 {
   25         s32 i_divisor = (s32)divisor;
   26         s32 i_remainder;
   27         s32 quotient;
   28 
   29         quotient = dividend / i_divisor;
   30         i_remainder = dividend % i_divisor;
   31 
   32         if (i_remainder < 0) {
   33                 quotient--;
   34                 i_remainder += i_divisor;
   35         }
   36 
   37         if (remainder)
   38                 *remainder = i_remainder;
   39         return quotient;
   40 }
   41 
   42 static inline s32 s32_div_u32_round_closest(s32 dividend, u32 divisor)
   43 {
   44         return s32_div_u32_round_down(dividend + divisor / 2, divisor, NULL);
   45 }
   46 
   47 #endif

Cache object: f55d62453efc675501afa19e48521e56


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.