image_types_digi: make it compatible with python 2.6

Python 2.6 does not have bit_length function:

'int' object has no attribute 'bit_length'

Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
Javier Viguera 2013-11-05 11:16:13 +01:00
parent 767fc18b85
commit 1111a3d6a0
1 changed files with 8 additions and 1 deletions

View File

@ -7,9 +7,16 @@ def max_leb_count(d):
_flash_peb = d.getVar('FLASH_PEB', True)
_flash_psz = d.getVar('FLASH_PSZ', True)
for i in _flash_peb.split(','):
_mlc.append(str(2 ** (int(_flash_psz)/int(i) - 1).bit_length() - 1))
_mlc.append(str(next_power_of_2(int(_flash_psz)/int(i)) - 1))
return ','.join(_mlc)
# Return next power_of_2 bigger than passed argument
def next_power_of_2(n):
i = 1
while (n > i):
i <<= 1
return i
IMAGE_CMD_jffs2() {
nimg="$(echo ${FLASH_PEB} | awk -F, '{print NF}')"
for i in $(seq 1 ${nimg}); do