usb: phy: mv-otg: use to_delayed_work instead of cast
authorCesar Eduardo Barros <cesarb@cesarb.net>
Tue, 4 Dec 2012 22:21:12 +0000 (20:21 -0200)
committerFelipe Balbi <balbi@ti.com>
Fri, 18 Jan 2013 13:08:42 +0000 (15:08 +0200)
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>
drivers/usb/otg/mv_otg.c

index 1dd57504186db5225b28b353527001b4e1914b2e..5104bc2b67b34fffa9d444d75d8b5b4083fb8789 100644 (file)
@@ -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 */