muldiv64() trivial fixes
cover muldiv64() trivial fixes
Some fixes in the use of muldiv64()
The patches have been generated with the help of coccinelle.
The first patch contains the scripts used to generate the two following patches. As it is done for linux, I've added the scripts under scripts/coccinelle.
Laurent Vivier (3):
scripts: add muldiv64() checking coccinelle scripts The only 64bit parameter of muldiv64() is the first one. remove useless muldiv64()
hw/timer/omap_gptimer.c | 4 +-- hw/usb/hcd-ohci.c | 2 +- scripts/coccinelle/remove_muldiv64.cocci | 6 +++++ scripts/coccinelle/swap_muldiv64.cocci | 46 ++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 scripts/coccinelle/remove_muldiv64.cocci create mode 100644 scripts/coccinelle/swap_muldiv64.cocci
Signature · 1 line
2.5.5
PATCH 1/3 scripts: add muldiv64() checking coccinelle scripts
--- scripts/coccinelle/remove_muldiv64.cocci | 6 +++++ scripts/coccinelle/swap_muldiv64.cocci | 46 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 scripts/coccinelle/remove_muldiv64.cocci create mode 100644 scripts/coccinelle/swap_muldiv64.cocci
scripts/coccinelle/remove_muldiv64.cocci new file +6 -0
@@ -0,0 +1,6 @@ +// replace muldiv64(a, 1, b) by "a / b" +@@ +expression a, b; +@@ +-muldiv64(a, 1, b) ++a / b
scripts/coccinelle/swap_muldiv64.cocci new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH 2/3 The only 64bit parameter of muldiv64() is the first one.
In reply to Laurent Viviermuldiv64() is "uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)"
Some time it is used as muldiv64(uint32_t a, uint64_t b, uint32_t c)"
This patch is the result of coccinelle script scripts/coccinelle/swap_muldiv64.cocci to reorder arguments.
--- hw/timer/omap_gptimer.c | 4 ++-- hw/usb/hcd-ohci.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
hw/timer/omap_gptimer.c +2 -2
@@ -133,8 +133,8 @@ static inline void omap_gp_timer_update(struct omap_gp_timer_s *timer)timer_mod (timer->timer, timer->time + expires);if (timer->ce && timer->match_val >= timer->val) { - matches =muldiv64 (timer->match_val - timer->val, - timer->ticks_per_sec, timer->rate); + matches =muldiv64 (timer->ticks_per_sec, + timer->match_val - timer->val, timer->rate);timer_mod (timer->match, timer->time + matches); }else timer_del (timer->match);
hw/usb/hcd-ohci.c +1 -1
@@ -1474,7 +1474,7 @@ static uint32_t ohci_get_frame_remaining(OHCIState *ohci)if (tks >= usb_frame_time)return (ohci->frt <<31 ); - tks =muldiv64 (1 , tks, usb_bit_time); + tks =muldiv64 (tks,1 , usb_bit_time); fr = (uint16_t )(ohci->fi - tks);return (ohci->frt <<31 ) | fr;
Signature · 1 line
2.5.5
PATCH 3/3 remove useless muldiv64()
In reply to Laurent Viviermuldiv64(a, 1, b) is like "a / b".
This patch is the result of coccinelle scriptscripts/coccinelle/remove_muldiv64.cocci.
--- hw/usb/hcd-ohci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/hcd-ohci.c +1 -1
@@ -1474,7 +1474,7 @@ static uint32_t ohci_get_frame_remaining(OHCIState *ohci)if (tks >= usb_frame_time)return (ohci->frt <<31 ); - tks =muldiv64 (tks,1 , usb_bit_time); + tks = tks / usb_bit_time; fr = (uint16_t )(ohci->fi - tks);return (ohci->frt <<31 ) | fr;
Signature · 1 line
2.5.5
Quoted 4 lines · Laurent Vivier
Some fixes in the use of
muldiv64()The patches have been generated with the help of coccinelle.
Quoted 8 lines
The first patch contains the scripts used to generate the two following patches. As it is done for linux, I've added the scripts under
scripts/coccinelle.Laurent Vivier (3):
scripts: addmuldiv64()checking coccinelle scripts The only 64bit parameter ofmuldiv64()is the first one. remove uselessmuldiv64()
r~