Changeset 660


Ignore:
Timestamp:
Jan 25, 2021, 11:33:33 PM (5 years ago)
Author:
Paul Smedley
Message:

More code cleanups

Location:
GPL/branches/uniaud32-next
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/uniaud32-next/alsa-kernel/core/oss/pcm_oss.c

    r644 r660  
    3030#include <sound/initval.h>
    3131#include <sound/mixer_oss.h>
    32 #ifdef TARGET_OS2
    33 static inline unsigned int ld2(u_int32_t v)
    34 {
    35         unsigned r = 0;
    36 
    37         if (v >= 0x10000) {
    38                 v >>= 16;
    39                 r += 16;
    40         }
    41         if (v >= 0x100) {
    42                 v >>= 8;
    43                 r += 8;
    44         }
    45         if (v >= 0x10) {
    46                 v >>= 4;
    47                 r += 4;
    48         }
    49         if (v >= 4) {
    50                 v >>= 2;
    51                 r += 2;
    52         }
    53         if (v >= 2)
    54                 r++;
    55         return r;
    56 }
    57 #endif
    5832
    5933#define OSS_ALSAEMULVER         _SIOR ('M', 249, int)
     
    730704        if (!oss_buffer_size)
    731705                return -EINVAL;
    732 #ifndef TARGET_OS2 //fixme
    733706        oss_buffer_size = rounddown_pow_of_two(oss_buffer_size);
    734 #else
    735         oss_buffer_size = 1 << ld2(oss_buffer_size);
    736 #endif
    737707        if (atomic_read(&substream->mmap_count)) {
    738708                if (oss_buffer_size > runtime->oss.mmap_bytes)
     
    771741        if (min_period_size) {
    772742                min_period_size *= oss_frame_size;
    773 #ifndef TARGET_OS2 //fixme
    774743                min_period_size = roundup_pow_of_two(min_period_size);
    775 #else
    776                 min_period_size = 1 << (ld2(min_period_size - 1) + 1);
    777 #endif
    778744                if (oss_period_size < min_period_size)
    779745                        oss_period_size = min_period_size;
     
    784750        if (max_period_size) {
    785751                max_period_size *= oss_frame_size;
    786 #ifndef TARGET_OS2 //fixme
    787752                max_period_size = rounddown_pow_of_two(max_period_size);
    788 #else
    789                 max_period_size = 1 << ld2(max_period_size);
    790 #endif
    791753
    792754                if (oss_period_size > max_period_size)
  • GPL/branches/uniaud32-next/include/linux/bitops.h

    r647 r660  
    193193}
    194194
     195static inline unsigned fls_long(unsigned long l)
     196{
     197                return fls(l);
     198}
     199
    195200#endif /* _I386_BITOPS_H */
  • GPL/branches/uniaud32-next/include/linux/kernel.h

    r647 r660  
    1111#include <stdarg.h>
    1212//#include <linux/linkage.h>
     13#include <linux/bitops.h>
    1314#include <linux/gfp.h>
    1415#include <linux/types.h>
    15 #include <linux/bitops.h>
     16#include <linux/log2.h>
    1617
    1718/* Optimization barrier */
  • GPL/branches/uniaud32-next/include/linux/log2.h

    r647 r660  
    1414{
    1515        return (n != 0 && ((n & (n - 1)) == 0));
     16}
     17
     18/**
     19 * __roundup_pow_of_two() - round up to nearest power of two
     20 * @n: value to round up
     21 */
     22static inline /*__attribute__((const))*/
     23unsigned long __roundup_pow_of_two(unsigned long n)
     24{
     25        return 1UL << fls_long(n - 1);
     26}
     27
     28/**
     29 * __rounddown_pow_of_two() - round down to nearest power of two
     30 * @n: value to round down
     31 */
     32static inline /*__attribute__((const))*/
     33unsigned long __rounddown_pow_of_two(unsigned long n)
     34{
     35        return 1UL << (fls_long(n) - 1);
    1636}
    1737
     
    6282}
    6383
     84/**
     85 * roundup_pow_of_two - round the given value up to nearest power of two
     86 * @n: parameter
     87 *
     88 * round the given value up to the nearest power of two
     89 * - the result is undefined when n == 0
     90 * - this can be used to initialise global variables from constant data
     91 */
     92#define roundup_pow_of_two(n)                   \
     93(                                               \
     94        __roundup_pow_of_two(n)                 \
     95 )
     96
     97/**
     98 * rounddown_pow_of_two - round the given value down to nearest power of two
     99 * @n: parameter
     100 *
     101 * round the given value down to the nearest power of two
     102 * - the result is undefined when n == 0
     103 * - this can be used to initialise global variables from constant data
     104 */
     105#define rounddown_pow_of_two(n)                 \
     106(                                               \
     107        __rounddown_pow_of_two(n)               \
     108 )
     109
    64110#endif /* _LINUX_LOG2_H */
Note: See TracChangeset for help on using the changeset viewer.