30
30
#include <linux/slab.h>
31
31
#include <linux/errno.h>
32
32
#include <linux/init.h>
33
- #include <linux/timer .h>
33
+ #include <linux/hrtimer .h>
34
34
#include <linux/list.h>
35
35
#include <linux/interrupt.h>
36
36
#include <linux/platform_device.h>
@@ -240,7 +240,7 @@ enum dummy_rh_state {
240
240
struct dummy_hcd {
241
241
struct dummy * dum ;
242
242
enum dummy_rh_state rh_state ;
243
- struct timer_list timer ;
243
+ struct hrtimer timer ;
244
244
u32 port_status ;
245
245
u32 old_status ;
246
246
unsigned long re_timeout ;
@@ -1301,8 +1301,8 @@ static int dummy_urb_enqueue(
1301
1301
urb -> error_count = 1 ; /* mark as a new urb */
1302
1302
1303
1303
/* kick the scheduler, it'll do the rest */
1304
- if (!timer_pending (& dum_hcd -> timer ))
1305
- mod_timer (& dum_hcd -> timer , jiffies + 1 );
1304
+ if (!hrtimer_active (& dum_hcd -> timer ))
1305
+ hrtimer_start (& dum_hcd -> timer , ms_to_ktime ( 1 ), HRTIMER_MODE_REL );
1306
1306
1307
1307
done :
1308
1308
spin_unlock_irqrestore (& dum_hcd -> dum -> lock , flags );
@@ -1323,7 +1323,7 @@ static int dummy_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
1323
1323
rc = usb_hcd_check_unlink_urb (hcd , urb , status );
1324
1324
if (!rc && dum_hcd -> rh_state != DUMMY_RH_RUNNING &&
1325
1325
!list_empty (& dum_hcd -> urbp_list ))
1326
- mod_timer (& dum_hcd -> timer , jiffies );
1326
+ hrtimer_start (& dum_hcd -> timer , ns_to_ktime ( 0 ), HRTIMER_MODE_REL );
1327
1327
1328
1328
spin_unlock_irqrestore (& dum_hcd -> dum -> lock , flags );
1329
1329
return rc ;
@@ -1777,7 +1777,7 @@ static int handle_control_request(struct dummy_hcd *dum_hcd, struct urb *urb,
1777
1777
* drivers except that the callbacks are invoked from soft interrupt
1778
1778
* context.
1779
1779
*/
1780
- static void dummy_timer (struct timer_list * t )
1780
+ static enum hrtimer_restart dummy_timer (struct hrtimer * t )
1781
1781
{
1782
1782
struct dummy_hcd * dum_hcd = from_timer (dum_hcd , t , timer );
1783
1783
struct dummy * dum = dum_hcd -> dum ;
@@ -1808,16 +1808,14 @@ static void dummy_timer(struct timer_list *t)
1808
1808
break ;
1809
1809
}
1810
1810
1811
- /* FIXME if HZ != 1000 this will probably misbehave ... */
1812
-
1813
1811
/* look at each urb queued by the host side driver */
1814
1812
spin_lock_irqsave (& dum -> lock , flags );
1815
1813
1816
1814
if (!dum_hcd -> udev ) {
1817
1815
dev_err (dummy_dev (dum_hcd ),
1818
1816
"timer fired with no URBs pending?\n" );
1819
1817
spin_unlock_irqrestore (& dum -> lock , flags );
1820
- return ;
1818
+ return HRTIMER_NORESTART ;
1821
1819
}
1822
1820
dum_hcd -> next_frame_urbp = NULL ;
1823
1821
@@ -1995,10 +1993,12 @@ static void dummy_timer(struct timer_list *t)
1995
1993
dum_hcd -> udev = NULL ;
1996
1994
} else if (dum_hcd -> rh_state == DUMMY_RH_RUNNING ) {
1997
1995
/* want a 1 msec delay here */
1998
- mod_timer (& dum_hcd -> timer , jiffies + msecs_to_jiffies (1 ));
1996
+ hrtimer_start (& dum_hcd -> timer , ms_to_ktime (1 ), HRTIMER_MODE_REL );
1999
1997
}
2000
1998
2001
1999
spin_unlock_irqrestore (& dum -> lock , flags );
2000
+
2001
+ return HRTIMER_NORESTART ;
2002
2002
}
2003
2003
2004
2004
/*-------------------------------------------------------------------------*/
@@ -2387,7 +2387,7 @@ static int dummy_bus_resume(struct usb_hcd *hcd)
2387
2387
dum_hcd -> rh_state = DUMMY_RH_RUNNING ;
2388
2388
set_link_state (dum_hcd );
2389
2389
if (!list_empty (& dum_hcd -> urbp_list ))
2390
- mod_timer (& dum_hcd -> timer , jiffies );
2390
+ hrtimer_start (& dum_hcd -> timer , ns_to_ktime ( 0 ), HRTIMER_MODE_REL );
2391
2391
hcd -> state = HC_STATE_RUNNING ;
2392
2392
}
2393
2393
spin_unlock_irq (& dum_hcd -> dum -> lock );
@@ -2465,7 +2465,8 @@ static DEVICE_ATTR_RO(urbs);
2465
2465
2466
2466
static int dummy_start_ss (struct dummy_hcd * dum_hcd )
2467
2467
{
2468
- timer_setup (& dum_hcd -> timer , dummy_timer , 0 );
2468
+ hrtimer_init (& dum_hcd -> timer , CLOCK_MONOTONIC , HRTIMER_MODE_REL );
2469
+ dum_hcd -> timer .function = dummy_timer ;
2469
2470
dum_hcd -> rh_state = DUMMY_RH_RUNNING ;
2470
2471
dum_hcd -> stream_en_ep = 0 ;
2471
2472
INIT_LIST_HEAD (& dum_hcd -> urbp_list );
@@ -2494,7 +2495,8 @@ static int dummy_start(struct usb_hcd *hcd)
2494
2495
return dummy_start_ss (dum_hcd );
2495
2496
2496
2497
spin_lock_init (& dum_hcd -> dum -> lock );
2497
- timer_setup (& dum_hcd -> timer , dummy_timer , 0 );
2498
+ hrtimer_init (& dum_hcd -> timer , CLOCK_MONOTONIC , HRTIMER_MODE_REL );
2499
+ dum_hcd -> timer .function = dummy_timer ;
2498
2500
dum_hcd -> rh_state = DUMMY_RH_RUNNING ;
2499
2501
2500
2502
INIT_LIST_HEAD (& dum_hcd -> urbp_list );
@@ -2513,8 +2515,11 @@ static int dummy_start(struct usb_hcd *hcd)
2513
2515
2514
2516
static void dummy_stop (struct usb_hcd * hcd )
2515
2517
{
2516
- device_remove_file (dummy_dev (hcd_to_dummy_hcd (hcd )), & dev_attr_urbs );
2517
- dev_info (dummy_dev (hcd_to_dummy_hcd (hcd )), "stopped\n" );
2518
+ struct dummy_hcd * dum_hcd = hcd_to_dummy_hcd (hcd );
2519
+
2520
+ hrtimer_cancel (& dum_hcd -> timer );
2521
+ device_remove_file (dummy_dev (dum_hcd ), & dev_attr_urbs );
2522
+ dev_info (dummy_dev (dum_hcd ), "stopped\n" );
2518
2523
}
2519
2524
2520
2525
/*-------------------------------------------------------------------------*/
0 commit comments