diff options
| author | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-02-22 13:44:15 +0300 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-02-22 13:44:15 +0300 |
| commit | e6b377dbbb944d5e3ceef4e5d429fc5c841e3692 (patch) | |
| tree | c84b714acad1ad20a0f0ea223dc019dd1267f4b6 /include/linux/log2.h | |
| parent | 9eeb0ed0f30938f31a3d9135a88b9502192c18dd (diff) | |
| parent | c470abd4fde40ea6a0846a2beab642a578c0b8cd (diff) | |
| download | linux-e6b377dbbb944d5e3ceef4e5d429fc5c841e3692.tar.xz | |
Merge tag 'v4.10' into patchwork
Linux 4.10
* tag 'v4.10': (1558 commits)
Linux 4.10
Fix missing sanity check in /dev/sg
scsi: don't BUG_ON() empty DMA transfers
ipv6: release dst on error in ip6_dst_lookup_tail
printk: use rcuidle console tracepoint
ARM: multi_v7_defconfig: enable Qualcomm RPMCC
irda: Fix lockdep annotations in hashbin_delete().
vxlan: fix oops in dev_fill_metadata_dst
dccp: fix freeing skb too early for IPV6_RECVPKTINFO
dpaa_eth: small leak on error
packet: Do not call fanout_release from atomic contexts
reset: fix shared reset triggered_count decrement on error
ntb: ntb_hw_intel: link_poll isn't clearing the pending status properly
ntb_transport: Pick an unused queue
ntb: ntb_perf missing dmaengine_unmap_put
NTB: ntb_transport: fix debugfs_remove_recursive
Revert "nohz: Fix collision between tick and other hrtimers"
vfs: fix uninitialized flags in splice_to_pipe()
drm/radeon: Use mode h/vdisplay fields to hide out of bounds HW cursor
ARM: 8658/1: uaccess: fix zeroing of 64-bit get_user()
...
Diffstat (limited to 'include/linux/log2.h')
| -rw-r--r-- | include/linux/log2.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/include/linux/log2.h b/include/linux/log2.h index fd7ff3d91e6a..ef3d4f67118c 100644 --- a/include/linux/log2.h +++ b/include/linux/log2.h @@ -203,6 +203,17 @@ unsigned long __rounddown_pow_of_two(unsigned long n) * ... and so on. */ -#define order_base_2(n) ilog2(roundup_pow_of_two(n)) +static inline __attribute_const__ +int __order_base_2(unsigned long n) +{ + return n > 1 ? ilog2(n - 1) + 1 : 0; +} +#define order_base_2(n) \ +( \ + __builtin_constant_p(n) ? ( \ + ((n) == 0 || (n) == 1) ? 0 : \ + ilog2((n) - 1) + 1) : \ + __order_base_2(n) \ +) #endif /* _LINUX_LOG2_H */ |
