summaryrefslogtreecommitdiffstats
path: root/platform-intel.h
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-07-06 14:46:47 +1000
committerNeilBrown <neilb@suse.de>2010-07-06 14:46:47 +1000
commit1538aca5cbbd99be47657e0ca0b7e2186426a1b1 (patch)
treef4750261bcd916a5714154d310c6a9e87769c7f0 /platform-intel.h
parent7d2e6486e34180215e4859c3b342246dfc6c07a0 (diff)
parentd19e3cfb6627c40e3a28454ebc2098c0e19b9a77 (diff)
downloadmdadm-1538aca5cbbd99be47657e0ca0b7e2186426a1b1.tar.gz
mdadm-1538aca5cbbd99be47657e0ca0b7e2186426a1b1.tar.xz
mdadm-1538aca5cbbd99be47657e0ca0b7e2186426a1b1.zip
Merge branch 'master' of git://github.com/djbw/mdadm
Diffstat (limited to 'platform-intel.h')
-rw-r--r--platform-intel.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/platform-intel.h b/platform-intel.h
index bbdc9f9..9088436 100644
--- a/platform-intel.h
+++ b/platform-intel.h
@@ -115,6 +115,55 @@ static inline int imsm_orom_has_chunk(const struct imsm_orom *orom, int chunk)
return !!(orom->sss & (1 << (fs - 1)));
}
+/**
+ * fls - find last (most-significant) bit set
+ * @x: the word to search
+ * The funciton is borrowed from Linux kernel code
+ * include/asm-generic/bitops/fls.h
+ */
+static inline int fls(int x)
+{
+ int r = 32;
+
+ if (!x)
+ return 0;
+ if (!(x & 0xffff0000u)) {
+ x <<= 16;
+ r -= 16;
+ }
+ if (!(x & 0xff000000u)) {
+ x <<= 8;
+ r -= 8;
+ }
+ if (!(x & 0xf0000000u)) {
+ x <<= 4;
+ r -= 4;
+ }
+ if (!(x & 0xc0000000u)) {
+ x <<= 2;
+ r -= 2;
+ }
+ if (!(x & 0x80000000u)) {
+ x <<= 1;
+ r -= 1;
+ }
+ return r;
+}
+
+/**
+ * imsm_orom_default_chunk - return the largest chunk size supported via orom
+ * @orom: orom pointer from find_imsm_orom
+ */
+static inline int imsm_orom_default_chunk(const struct imsm_orom *orom)
+{
+ int fs = fls(orom->sss);
+
+ if (!fs)
+ return 0;
+
+ return min(512, (1 << fs));
+}
+
struct sys_dev {
char *path;
struct sys_dev *next;