Merge https://gitlab.denx.de/u-boot/custodians/u-boot-spi
[oweals/u-boot.git] / disk / part.c
index 7e842147317194309b5691d0eda004d35545ef1a..4cc2fc19f7e3ab22ddaf1faf48cc3871f6f6ac56 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <env.h>
 #include <errno.h>
 #include <ide.h>
 #include <malloc.h>
@@ -103,17 +104,18 @@ typedef lbaint_t lba512_t;
 #endif
 
 /*
- * Overflowless variant of (block_count * mul_by / 2**div_by)
- * when div_by > mul_by
+ * Overflowless variant of (block_count * mul_by / 2**right_shift)
+ * when 2**right_shift > mul_by
  */
-static lba512_t lba512_muldiv(lba512_t block_count, lba512_t mul_by, int div_by)
+static lba512_t lba512_muldiv(lba512_t block_count, lba512_t mul_by,
+                             int right_shift)
 {
        lba512_t bc_quot, bc_rem;
 
        /* x * m / d == x / d * m + (x % d) * m / d */
-       bc_quot = block_count >> div_by;
-       bc_rem  = block_count - (bc_quot << div_by);
-       return bc_quot * mul_by + ((bc_rem * mul_by) >> div_by);
+       bc_quot = block_count >> right_shift;
+       bc_rem  = block_count - (bc_quot << right_shift);
+       return bc_quot * mul_by + ((bc_rem * mul_by) >> right_shift);
 }
 
 void dev_print (struct blk_desc *dev_desc)