[PATCH 17/32] rt2x00: Put net_device structure in data_ring
From: Ivo van Doorn <[EMAIL PROTECTED]> Change the structure stored in the data_ring structure from the rt2x00_pci or rt2x00_usb to net_device. This allows for better type checking, and the net_dev is more often used in the interrupt handlers. Signed-off-by: Ivo van Doorn <[EMAIL PROTECTED]> diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.c wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.c --- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.c 2006-04-27 21:48:21.0 +0200 +++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.c 2006-04-27 21:49:08.0 +0200 @@ -760,10 +760,8 @@ rt2400pci_write_tx_desc( static void rt2400pci_beacondone(void *data) { - struct data_ring*ring = (struct data_ring*)data; - struct rt2x00_pci *rt2x00pci = (struct rt2x00_pci*)ring->dev; - struct net_device *net_dev = pci_get_drvdata(rt2x00pci->pci_dev); - struct sk_buff *skb; + struct data_ring*ring = (struct data_ring*)data; + struct sk_buff *skb; struct ieee80211_tx_control beacon; memset(&beacon, 0x00, sizeof(beacon)); @@ -771,11 +769,11 @@ rt2400pci_beacondone(void *data) /* * TODO: What value should be passed as bss_idx? */ - skb = ieee80211_beacon_get(net_dev, 0, &beacon); + skb = ieee80211_beacon_get(ring->net_dev, 0, &beacon); if (!skb) return; - rt2400pci_beacon_update(net_dev, skb, &beacon); + rt2400pci_beacon_update(ring->net_dev, skb, &beacon); dev_kfree_skb_any(skb); } @@ -784,8 +782,8 @@ static void rt2400pci_rxdone(void *data) { struct data_ring*ring = (struct data_ring*)data; - struct rt2x00_pci *rt2x00pci = (struct rt2x00_pci*)ring->dev; - struct net_device *net_dev = pci_get_drvdata(rt2x00pci->pci_dev); + struct rt2x00_pci *rt2x00pci = + ieee80211_dev_hw_data(ring->net_dev); struct data_entry *entry; struct sk_buff *skb; struct rxd *rxd; @@ -817,7 +815,8 @@ rt2400pci_rxdone(void *data) rt2x00pci->rx_params.ssi = rt2x00_get_field32(rxd->word2, RXD_W2_RSSI); - __ieee80211_rx(net_dev, skb, &rt2x00pci->rx_params); + __ieee80211_rx(ring->net_dev, + skb, &rt2x00pci->rx_params); } rt2x00_set_field32(&rxd->word0, RXD_W0_OWNER_NIC, 1); @@ -835,8 +834,8 @@ static void rt2400pci_txdone(void *data) { struct data_ring*ring = (struct data_ring*)data; - struct rt2x00_pci *rt2x00pci = (struct rt2x00_pci*)ring->dev; - struct net_device *net_dev = pci_get_drvdata(rt2x00pci->pci_dev); + struct rt2x00_pci *rt2x00pci = + ieee80211_dev_hw_data(ring->net_dev); struct data_entry *entry; struct txd *txd; int tx_status; @@ -881,7 +880,8 @@ rt2400pci_txdone(void *data) entry->tx_status.retry_count = rt2x00_get_field32( txd->word0, TXD_W0_RETRY_COUNT); - ieee80211_tx_status(net_dev, entry->skb, &entry->tx_status); + ieee80211_tx_status(ring->net_dev, + entry->skb, &entry->tx_status); rt2x00_set_field32(&txd->word0, TXD_W0_VALID, 0); entry->skb = NULL; @@ -975,7 +975,7 @@ rt2400pci_alloc_ring( /* *Set device structure. */ - ring->dev = rt2x00pci; + ring->net_dev = pci_get_drvdata(rt2x00pci->pci_dev); /* * Initialize work structure for deferred work. diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500pci.c wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.c --- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500pci.c 2006-04-27 21:48:21.0 +0200 +++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.c 2006-04-27 21:49:08.0 +0200 @@ -834,10 +834,8 @@ rt2500pci_write_tx_desc( static void rt2500pci_beacondone(void *data) { - struct data_ring*ring = (struct data_ring*)data; - struct rt2x00_pci *rt2x00pci = (struct rt2x00_pci*)ring->dev; - struct net_device *net_dev = pci_get_drvdata(rt2x00pci->pci_dev); - struct sk_buff *skb; + struct data_ring*ring = (struct data_ring*)data; + struct sk_buff *skb; struct ieee80211_tx_control beacon; memset(&beacon, 0x00, sizeof(beacon)); @@ -845,11 +843,11 @@ rt2500pci_beacondone(void *data) /* * TODO: What value should be passed as bss_idx? */ - skb = ieee80211_beac
Re: [PATCH 17/32] rt2x00: Put net_device structure in data_ring
Hi Ivo, Ivo van Doorn wrote: > diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.c > wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.c > --- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.c > 2006-04-27 21:48:21.0 +0200 > +++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.c > 2006-04-27 21:49:08.0 +0200 > @@ -760,10 +760,8 @@ rt2400pci_write_tx_desc( > static void > rt2400pci_beacondone(void *data) > { > - struct data_ring*ring = (struct data_ring*)data; > - struct rt2x00_pci *rt2x00pci = (struct rt2x00_pci*)ring->dev; > - struct net_device *net_dev = pci_get_drvdata(rt2x00pci->pci_dev); > - struct sk_buff *skb; > + struct data_ring*ring = (struct data_ring*)data; No need for a cast here. In C you can cast from any struct pointer to void pointer and back without problems. > @@ -784,8 +782,8 @@ static void > rt2400pci_rxdone(void *data) > { > struct data_ring*ring = (struct data_ring*)data; No need for casting. > @@ -835,8 +834,8 @@ static void > rt2400pci_txdone(void *data) > { > struct data_ring*ring = (struct data_ring*)data; No need for casting. > diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500pci.c > wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.c > --- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500pci.c > 2006-04-27 21:48:21.0 +0200 > +++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.c > 2006-04-27 21:49:08.0 +0200 > @@ -834,10 +834,8 @@ rt2500pci_write_tx_desc( > static void > rt2500pci_beacondone(void *data) > { > - struct data_ring*ring = (struct data_ring*)data; > - struct rt2x00_pci *rt2x00pci = (struct rt2x00_pci*)ring->dev; > - struct net_device *net_dev = pci_get_drvdata(rt2x00pci->pci_dev); > - struct sk_buff *skb; > + struct data_ring*ring = (struct data_ring*)data; No need for casting. Many more of them. I guess you could just do a fgrep for "*ring = (struct data_ring*)data;" Regards Ingo Oeser - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 17/32] rt2x00: Put net_device structure in data_ring
On Friday 28 April 2006 13:45, Ingo Oeser wrote: > Hi Ivo, > > Ivo van Doorn wrote: > > diff -uprN > > wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.c > > wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.c > > --- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.c > > 2006-04-27 21:48:21.0 +0200 > > +++ > > wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.c > > 2006-04-27 21:49:08.0 +0200 > > @@ -760,10 +760,8 @@ rt2400pci_write_tx_desc( > > static void > > rt2400pci_beacondone(void *data) > > { > > - struct data_ring*ring = (struct data_ring*)data; > > - struct rt2x00_pci *rt2x00pci = (struct rt2x00_pci*)ring->dev; > > - struct net_device *net_dev = pci_get_drvdata(rt2x00pci->pci_dev); > > - struct sk_buff *skb; > > + struct data_ring*ring = (struct data_ring*)data; > > No need for a cast here. > In C you can cast from any struct pointer to void pointer and back > without problems. > > > @@ -784,8 +782,8 @@ static void > > rt2400pci_rxdone(void *data) > > { > > struct data_ring*ring = (struct data_ring*)data; > > No need for casting. > > > @@ -835,8 +834,8 @@ static void > > rt2400pci_txdone(void *data) > > { > > struct data_ring*ring = (struct data_ring*)data; > > No need for casting. > > > diff -uprN > > wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500pci.c > > wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.c > > --- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500pci.c > > 2006-04-27 21:48:21.0 +0200 > > +++ > > wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.c > > 2006-04-27 21:49:08.0 +0200 > > @@ -834,10 +834,8 @@ rt2500pci_write_tx_desc( > > static void > > rt2500pci_beacondone(void *data) > > { > > - struct data_ring*ring = (struct data_ring*)data; > > - struct rt2x00_pci *rt2x00pci = (struct rt2x00_pci*)ring->dev; > > - struct net_device *net_dev = pci_get_drvdata(rt2x00pci->pci_dev); > > - struct sk_buff *skb; > > + struct data_ring*ring = (struct data_ring*)data; > > No need for casting. > > Many more of them. > > I guess you could just do a fgrep for "*ring = (struct data_ring*)data;" Thanks, Not only the data_ring has unneeded casts, but they are also found on some other locations. I'll create a patch that removes them all. pgphbHi3TZhzS.pgp Description: PGP signature