All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ivo van Doorn <ivdoorn@gmail.com>
To: "John W. Linville" <linville@tuxdriver.com>
Cc: rt2400-devel@lists.sourceforge.net, linux-wireless@vger.kernel.org
Subject: [PATCH 7/9] rt2x00: Fix sparse warning on nested container_of()
Date: Mon, 16 Jun 2008 19:57:11 +0200	[thread overview]
Message-ID: <200806161957.11757.IvDoorn@gmail.com> (raw)
In-Reply-To: <200806161956.54342.IvDoorn@gmail.com>

Sparse produces warnings about nested contain_of() statements,
this means that lines like:
	interface_to_usbdev(to_usb_interface(rt2x00dev->dev));
will upset sparse.
Add a new macro to rt2x00usb.h which will convert to device
structure to the usb_device pointer in 2 steps to prevent this
sparse warning.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
---
 drivers/net/wireless/rt2x00/rt2500usb.c |    3 +--
 drivers/net/wireless/rt2x00/rt2x00usb.c |    9 +++------
 drivers/net/wireless/rt2x00/rt2x00usb.h |    6 ++++++
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 6b6e7b9..d095800 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1672,8 +1672,7 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
 static int rt2500usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
 {
 	struct rt2x00_dev *rt2x00dev = hw->priv;
-	struct usb_device *usb_dev =
-		interface_to_usbdev(to_usb_interface(rt2x00dev->dev));
+	struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
 	struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
 	struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif);
 	struct queue_entry_priv_usb_bcn *bcn_priv;
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index b94c461..5593b9a 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -40,8 +40,7 @@ int rt2x00usb_vendor_request(struct rt2x00_dev *rt2x00dev,
 			     void *buffer, const u16 buffer_length,
 			     const int timeout)
 {
-	struct usb_device *usb_dev =
-		interface_to_usbdev(to_usb_interface(rt2x00dev->dev));
+	struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
 	int status;
 	unsigned int i;
 	unsigned int pipe =
@@ -162,8 +161,7 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb)
 int rt2x00usb_write_tx_data(struct queue_entry *entry)
 {
 	struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
-	struct usb_device *usb_dev =
-		interface_to_usbdev(to_usb_interface(rt2x00dev->dev));
+	struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
 	struct queue_entry_priv_usb *entry_priv = entry->priv_data;
 	struct skb_frame_desc *skbdesc;
 	u32 length;
@@ -319,8 +317,7 @@ EXPORT_SYMBOL_GPL(rt2x00usb_disable_radio);
 void rt2x00usb_init_rxentry(struct rt2x00_dev *rt2x00dev,
 			    struct queue_entry *entry)
 {
-	struct usb_device *usb_dev =
-		interface_to_usbdev(to_usb_interface(rt2x00dev->dev));
+	struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
 	struct queue_entry_priv_usb *entry_priv = entry->priv_data;
 
 	usb_fill_bulk_urb(entry_priv->urb, usb_dev,
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.h b/drivers/net/wireless/rt2x00/rt2x00usb.h
index b1187c8..aad794a 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.h
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.h
@@ -26,6 +26,12 @@
 #ifndef RT2X00USB_H
 #define RT2X00USB_H
 
+#define to_usb_device_intf(d) \
+({ \
+	struct usb_interface *intf = to_usb_interface(d); \
+	interface_to_usbdev(intf); \
+})
+
 /*
  * This variable should be used with the
  * usb_driver structure initialization.
-- 
1.5.5.4


  reply	other threads:[~2008-06-16 17:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200806161954.04241.IvDoorn@gmail.com>
2008-06-16 17:54 ` [PATCH 1/9] rt2x00: Use ieee80211 fc handlers Ivo van Doorn
     [not found] ` <200806161954.34838.IvDoorn@gmail.com>
2008-06-16 17:55   ` [PATCH 2/9] rt2x00: Properly clean up beacon skbs Ivo van Doorn
2008-06-16 17:55     ` [PATCH 3/9] rt2x00: Convert rt2x00 to use generic DMA-mapping API Ivo van Doorn
2008-06-16 17:56       ` [PATCH 4/9] rt2x00: Centralize allocation of RX skbs Ivo van Doorn
2008-06-16 17:56         ` [PATCH 5/9] rt2x00: Replace statically allocated DMA buffers with mapped skb's Ivo van Doorn
2008-06-16 17:56           ` [PATCH 6/9] rt2x00: Cleanup symbol exports Ivo van Doorn
2008-06-16 17:57             ` Ivo van Doorn [this message]
2008-06-16 17:57               ` [PATCH 8/9] rt2x00: Increase queue size Ivo van Doorn
2008-06-16 17:58                 ` [PATCH 9/9] rt2x00: Release rt2x00 2.1.8 Ivo van Doorn

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=200806161957.11757.IvDoorn@gmail.com \
    --to=ivdoorn@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=rt2400-devel@lists.sourceforge.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.