linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cesar Eduardo Barros <cesarb@cesarb.net>
To: Felipe Balbi <balbi@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Cesar Eduardo Barros <cesarb@cesarb.net>
Subject: [PATCH] mv-otg: use to_delayed_work instead of cast
Date: Tue,  4 Dec 2012 20:21:12 -0200	[thread overview]
Message-ID: <1354659672-3409-1-git-send-email-cesarb@cesarb.net> (raw)

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>
---
 drivers/usb/otg/mv_otg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/otg/mv_otg.c b/drivers/usb/otg/mv_otg.c
index 3f124e8..156e1d9 100644
--- a/drivers/usb/otg/mv_otg.c
+++ b/drivers/usb/otg/mv_otg.c
@@ -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 */
-- 
1.7.11.7


                 reply	other threads:[~2012-12-04 22:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1354659672-3409-1-git-send-email-cesarb@cesarb.net \
    --to=cesarb@cesarb.net \
    --cc=balbi@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).