mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-11 13:04:03 +08:00
usb: r8a66597-hcd: Convert timers to use timer_setup()
In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. This rearranges the arrays of timers to minimize the need for a pointer back to the main structure. Cc: Chris Brandt <chris.brandt@renesas.com> Cc: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
7e33da59a6
commit
8e4e276a38
@ -1273,7 +1273,7 @@ static void set_td_timer(struct r8a66597 *r8a66597, struct r8a66597_td *td)
|
||||
break;
|
||||
}
|
||||
|
||||
mod_timer(&r8a66597->td_timer[td->pipenum],
|
||||
mod_timer(&r8a66597->timers[td->pipenum].td,
|
||||
jiffies + msecs_to_jiffies(time));
|
||||
}
|
||||
}
|
||||
@ -1733,9 +1733,10 @@ static void r8a66597_root_hub_control(struct r8a66597 *r8a66597, int port)
|
||||
}
|
||||
}
|
||||
|
||||
static void r8a66597_interval_timer(unsigned long _r8a66597)
|
||||
static void r8a66597_interval_timer(struct timer_list *t)
|
||||
{
|
||||
struct r8a66597 *r8a66597 = (struct r8a66597 *)_r8a66597;
|
||||
struct r8a66597_timers *timers = from_timer(timers, t, interval);
|
||||
struct r8a66597 *r8a66597 = timers->r8a66597;
|
||||
unsigned long flags;
|
||||
u16 pipenum;
|
||||
struct r8a66597_td *td;
|
||||
@ -1745,7 +1746,7 @@ static void r8a66597_interval_timer(unsigned long _r8a66597)
|
||||
for (pipenum = 0; pipenum < R8A66597_MAX_NUM_PIPE; pipenum++) {
|
||||
if (!(r8a66597->interval_map & (1 << pipenum)))
|
||||
continue;
|
||||
if (timer_pending(&r8a66597->interval_timer[pipenum]))
|
||||
if (timer_pending(&r8a66597->timers[pipenum].interval))
|
||||
continue;
|
||||
|
||||
td = r8a66597_get_td(r8a66597, pipenum);
|
||||
@ -1756,9 +1757,10 @@ static void r8a66597_interval_timer(unsigned long _r8a66597)
|
||||
spin_unlock_irqrestore(&r8a66597->lock, flags);
|
||||
}
|
||||
|
||||
static void r8a66597_td_timer(unsigned long _r8a66597)
|
||||
static void r8a66597_td_timer(struct timer_list *t)
|
||||
{
|
||||
struct r8a66597 *r8a66597 = (struct r8a66597 *)_r8a66597;
|
||||
struct r8a66597_timers *timers = from_timer(timers, t, td);
|
||||
struct r8a66597 *r8a66597 = timers->r8a66597;
|
||||
unsigned long flags;
|
||||
u16 pipenum;
|
||||
struct r8a66597_td *td, *new_td = NULL;
|
||||
@ -1768,7 +1770,7 @@ static void r8a66597_td_timer(unsigned long _r8a66597)
|
||||
for (pipenum = 0; pipenum < R8A66597_MAX_NUM_PIPE; pipenum++) {
|
||||
if (!(r8a66597->timeout_map & (1 << pipenum)))
|
||||
continue;
|
||||
if (timer_pending(&r8a66597->td_timer[pipenum]))
|
||||
if (timer_pending(&r8a66597->timers[pipenum].td))
|
||||
continue;
|
||||
|
||||
td = r8a66597_get_td(r8a66597, pipenum);
|
||||
@ -1942,7 +1944,7 @@ static int r8a66597_urb_enqueue(struct usb_hcd *hcd,
|
||||
if (request) {
|
||||
if (td->pipe->info.timer_interval) {
|
||||
r8a66597->interval_map |= 1 << td->pipenum;
|
||||
mod_timer(&r8a66597->interval_timer[td->pipenum],
|
||||
mod_timer(&r8a66597->timers[td->pipenum].interval,
|
||||
jiffies + msecs_to_jiffies(
|
||||
td->pipe->info.timer_interval));
|
||||
} else {
|
||||
@ -2495,11 +2497,10 @@ static int r8a66597_probe(struct platform_device *pdev)
|
||||
|
||||
for (i = 0; i < R8A66597_MAX_NUM_PIPE; i++) {
|
||||
INIT_LIST_HEAD(&r8a66597->pipe_queue[i]);
|
||||
setup_timer(&r8a66597->td_timer[i], r8a66597_td_timer,
|
||||
(unsigned long)r8a66597);
|
||||
setup_timer(&r8a66597->interval_timer[i],
|
||||
r8a66597_interval_timer,
|
||||
(unsigned long)r8a66597);
|
||||
r8a66597->timers[i].r8a66597 = r8a66597;
|
||||
timer_setup(&r8a66597->timers[i].td, r8a66597_td_timer, 0);
|
||||
timer_setup(&r8a66597->timers[i].interval,
|
||||
r8a66597_interval_timer, 0);
|
||||
}
|
||||
INIT_LIST_HEAD(&r8a66597->child_device);
|
||||
|
||||
|
@ -107,6 +107,14 @@ struct r8a66597_root_hub {
|
||||
struct r8a66597_device *dev;
|
||||
};
|
||||
|
||||
struct r8a66597;
|
||||
|
||||
struct r8a66597_timers {
|
||||
struct timer_list td;
|
||||
struct timer_list interval;
|
||||
struct r8a66597 *r8a66597;
|
||||
};
|
||||
|
||||
struct r8a66597 {
|
||||
spinlock_t lock;
|
||||
void __iomem *reg;
|
||||
@ -117,8 +125,7 @@ struct r8a66597 {
|
||||
struct list_head pipe_queue[R8A66597_MAX_NUM_PIPE];
|
||||
|
||||
struct timer_list rh_timer;
|
||||
struct timer_list td_timer[R8A66597_MAX_NUM_PIPE];
|
||||
struct timer_list interval_timer[R8A66597_MAX_NUM_PIPE];
|
||||
struct r8a66597_timers timers[R8A66597_MAX_NUM_PIPE];
|
||||
|
||||
unsigned short address_map;
|
||||
unsigned short timeout_map;
|
||||
|
Loading…
Reference in New Issue
Block a user