* [U-Boot] [PATCH 1/1] disk: part: avoid undefined reference to `__udivmoddi4'
@ 2019-06-02 8:35 Heinrich Schuchardt
2019-06-22 19:10 ` Simon Glass
0 siblings, 1 reply; 3+ messages in thread
From: Heinrich Schuchardt @ 2019-06-02 8:35 UTC (permalink / raw)
To: u-boot
When compiling with FTRACE=1 an error
ld.bfd: disk/built-in.o: in function `lba512_muldiv':
disk/part.c:114: undefined reference to `__udivmoddi4
occurred.
Use '>> 11' instead of '/ 2048' to avoid the division.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
disk/part.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/disk/part.c b/disk/part.c
index 98cc54db20..862078f3e7 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -103,17 +103,17 @@ typedef lbaint_t lba512_t;
#endif
/*
- * Overflowless variant of (block_count * mul_by / div_by)
+ * Overflowless variant of (block_count * mul_by / 2**div_by)
* when div_by > mul_by
*/
-static lba512_t lba512_muldiv(lba512_t block_count, lba512_t mul_by, lba512_t div_by)
+static lba512_t lba512_muldiv(lba512_t block_count, lba512_t mul_by, int div_by)
{
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 - div_by * bc_quot;
- return bc_quot * mul_by + (bc_rem * mul_by) / div_by;
+ 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);
}
void dev_print (struct blk_desc *dev_desc)
@@ -193,7 +193,7 @@ void dev_print (struct blk_desc *dev_desc)
lba512 = (lba * (dev_desc->blksz/512));
/* round to 1 digit */
/* 2048 = (1024 * 1024) / 512 MB */
- mb = lba512_muldiv(lba512, 10, 2048);
+ mb = lba512_muldiv(lba512, 10, 11);
mb_quot = mb / 10;
mb_rem = mb - (10 * mb_quot);
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH 1/1] disk: part: avoid undefined reference to `__udivmoddi4'
2019-06-02 8:35 [U-Boot] [PATCH 1/1] disk: part: avoid undefined reference to `__udivmoddi4' Heinrich Schuchardt
@ 2019-06-22 19:10 ` Simon Glass
2019-06-22 19:24 ` Heinrich Schuchardt
0 siblings, 1 reply; 3+ messages in thread
From: Simon Glass @ 2019-06-22 19:10 UTC (permalink / raw)
To: u-boot
On Sun, 2 Jun 2019 at 09:36, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> When compiling with FTRACE=1 an error
>
> ld.bfd: disk/built-in.o: in function `lba512_muldiv':
> disk/part.c:114: undefined reference to `__udivmoddi4
>
> occurred.
>
> Use '>> 11' instead of '/ 2048' to avoid the division.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> disk/part.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
Looks OK but I think you should rename div_by to shift_right, or similar.
- SImon
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH 1/1] disk: part: avoid undefined reference to `__udivmoddi4'
2019-06-22 19:10 ` Simon Glass
@ 2019-06-22 19:24 ` Heinrich Schuchardt
0 siblings, 0 replies; 3+ messages in thread
From: Heinrich Schuchardt @ 2019-06-22 19:24 UTC (permalink / raw)
To: u-boot
On 6/22/19 9:10 PM, Simon Glass wrote:
> On Sun, 2 Jun 2019 at 09:36, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>
>> When compiling with FTRACE=1 an error
>>
>> ld.bfd: disk/built-in.o: in function `lba512_muldiv':
>> disk/part.c:114: undefined reference to `__udivmoddi4
>>
>> occurred.
>>
>> Use '>> 11' instead of '/ 2048' to avoid the division.
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>> ---
>> disk/part.c | 12 ++++++------
>> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> Looks OK but I think you should rename div_by to shift_right, or similar.
Thanks for reviewing.
The patch is already merged. I will send a new patch to rename the
parameter.
Regards
Heinrcih
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-22 19:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-02 8:35 [U-Boot] [PATCH 1/1] disk: part: avoid undefined reference to `__udivmoddi4' Heinrich Schuchardt
2019-06-22 19:10 ` Simon Glass
2019-06-22 19:24 ` Heinrich Schuchardt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.