Skip to content

Commit

Permalink
IB/qib: Use setup_timer and mod_timer
Browse files Browse the repository at this point in the history
Use setup_timer and mod_timer API instead of structure assignments.

This is done using Coccinelle and semantic patch used
for this as follows:

@@
expression x,y,z,a,b;
@@

-init_timer (&x);
+setup_timer (&x, y, z);
+mod_timer (&a, b);
-x.function = y;
-x.data = z;
-x.expires = b;
-add_timer(&a);

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
  • Loading branch information
Himanshu Jha authored and Doug Ledford committed Sep 29, 2017
1 parent e538e0a commit e1ac263
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
8 changes: 3 additions & 5 deletions drivers/infiniband/hw/qib/qib_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,11 +735,9 @@ void qib_set_led_override(struct qib_pportdata *ppd, unsigned int val)
*/
if (atomic_inc_return(&ppd->led_override_timer_active) == 1) {
/* Need to start timer */
init_timer(&ppd->led_override_timer);
ppd->led_override_timer.function = qib_run_led_override;
ppd->led_override_timer.data = (unsigned long) ppd;
ppd->led_override_timer.expires = jiffies + 1;
add_timer(&ppd->led_override_timer);
setup_timer(&ppd->led_override_timer, qib_run_led_override,
(unsigned long)ppd);
mod_timer(&ppd->led_override_timer, jiffies + 1);
} else {
if (ppd->led_override_vals[0] || ppd->led_override_vals[1])
mod_timer(&ppd->led_override_timer, jiffies + 1);
Expand Down
10 changes: 4 additions & 6 deletions drivers/infiniband/hw/qib/qib_mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -2478,12 +2478,10 @@ void qib_notify_create_mad_agent(struct rvt_dev_info *rdi, int port_idx)

/* Initialize xmit_wait structure */
dd->pport[port_idx].cong_stats.counter = 0;
init_timer(&dd->pport[port_idx].cong_stats.timer);
dd->pport[port_idx].cong_stats.timer.function = xmit_wait_timer_func;
dd->pport[port_idx].cong_stats.timer.data =
(unsigned long)(&dd->pport[port_idx]);
dd->pport[port_idx].cong_stats.timer.expires = 0;
add_timer(&dd->pport[port_idx].cong_stats.timer);
setup_timer(&dd->pport[port_idx].cong_stats.timer,
xmit_wait_timer_func,
(unsigned long)(&dd->pport[port_idx]));
mod_timer(&dd->pport[port_idx].cong_stats.timer, 0);
}

void qib_notify_free_mad_agent(struct rvt_dev_info *rdi, int port_idx)
Expand Down

0 comments on commit e1ac263

Please sign in to comment.