Skip to content

Commit

Permalink
usb: phy: mv-otg: use to_delayed_work instead of cast
Browse files Browse the repository at this point in the history
Directly casting a work_struct pointer to a delayed_work is risky if the
work member of struct delayed_work is ever moved from being the first
member.

Instead, use the inline function to_delayed_work(), which does the same
cast in a safer way (using container_of).

Signed-off-by: Cesar Eduardo Barros <cesarb@cesarb.net>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Cesar Eduardo Barros authored and Felipe Balbi committed Jan 18, 2013
1 parent b2e587d commit 63a1307
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/usb/otg/mv_otg.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ static void mv_otg_work(struct work_struct *work)
struct usb_otg *otg;
int old_state;

mvotg = container_of((struct delayed_work *)work, struct mv_otg, work);
mvotg = container_of(to_delayed_work(work), struct mv_otg, work);

run:
/* work queue is single thread, or we need spin_lock to protect */
Expand Down

0 comments on commit 63a1307

Please sign in to comment.