Framework for exporting system header to user space (#59)
[lunaix-os.git] / lunaix-os / kernel / block / blkbuf.c
index 4f255c90d08b9aa37f2e42cb12eba5cd2c231ef2..bb29150477632511e5e0fcee5875f40c1439cd7e 100644 (file)
@@ -3,6 +3,7 @@
 #include <lunaix/mm/valloc.h>
 #include <lunaix/owloysius.h>
 #include <lunaix/syslog.h>
+#include <asm/muldiv64.h>
 
 LOG_MODULE("blkbuf")  
 
@@ -17,7 +18,8 @@ static struct cake_pile* bb_pile;
 static inline u64_t
 __tolba(struct blkbuf_cache* cache, unsigned int blk_id)
 {
-    return ((u64_t)cache->blksize * (u64_t)blk_id) / cache->blkdev->blk_size;
+    return udiv64(((u64_t)cache->blksize * (u64_t)blk_id), 
+                    cache->blkdev->blk_size);
 }
 
 static void
@@ -242,4 +244,4 @@ __init_blkbuf()
     bb_zone = bcache_create_zone("blk_buf");
     bb_pile = cake_new_pile("blk_buf", sizeof(struct blk_buf), 1, 0);
 }
-owloysius_fetch_init(__init_blkbuf, on_earlyboot)
\ No newline at end of file
+owloysius_fetch_init(__init_blkbuf, on_sysconf)
\ No newline at end of file