Skip to content

Commit

Permalink
mailbox: rockchip: avoid 64-bit division
Browse files Browse the repository at this point in the history
The newly added rockchip mailbox driver causes a bug in
the ARM allyesconfig build because of a division of a resource_size_t
variable that may be 64 bit wide:

drivers/mailbox/built-in.o: In function `rockchip_mbox_probe':
:(.text+0x6614): undefined reference to `__aeabi_uldivmod'

This adds a cast to size_t, which turns it into a 32-bit division
in this case. This is safe because we know that we cannot possibly
map a resource that is longer than what a pointer contains, and
in practice it will be very short instead.

Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Jassi Brar <[email protected]>
  • Loading branch information
arndb authored and JassiBrar committed Mar 16, 2016
1 parent f70ed3b commit c5a9d1f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/mailbox/rockchip-mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ static int rockchip_mbox_probe(struct platform_device *pdev)
return PTR_ERR(mb->mbox_base);

/* Each channel has two buffers for A2B and B2A */
mb->buf_size = resource_size(res) / (drv_data->num_chans * 2);
mb->buf_size = (size_t)resource_size(res) / (drv_data->num_chans * 2);

mb->pclk = devm_clk_get(&pdev->dev, "pclk_mailbox");
if (IS_ERR(mb->pclk)) {
Expand Down

0 comments on commit c5a9d1f

Please sign in to comment.