diff options
author | Dave Jiang <dave.jiang@intel.com> | 2010-06-15 18:41:53 -0700 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2010-06-15 18:41:53 -0700 |
commit | 0bd16cf2173695726f1ed2f9372c613003d80f9a (patch) | |
tree | ab82b85b1e1dfebccbcbbef03f4ad917b6ba1d83 /platform-intel.h | |
parent | 484240d8a3facde992009efd81bfa4cc0c79287d (diff) |
create: Check with OROM limit before setting default chunk size
Make create check with the appropriate meta data handler and see what the
largest chunk size is supported. The current 512K default is not supported
by existing imsm OROM.
[dan.j.williams@intel.com: trim the upper limit to 512k for future oroms]
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'platform-intel.h')
-rw-r--r-- | platform-intel.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/platform-intel.h b/platform-intel.h index bbdc9f95..90884361 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; |