Subject: [PATCH 10/32] rt2x00: Move TSF counting activation to correct funtion

From: Ivo van Doorn <[email-masked]>
Date: Fri, 28 Apr 2006 00:03:01 +0200

From: Ivo van Doorn <[email-masked]>

Move the enabling of TSF counting into *_config_mode
where it actually belongs.
For rt2500usb this means that the rt2500usb_reset_tsf function
is now removed since it is still unknown in what registers the
TSF counters are stored in.

Signed-off-by: Ivo van Doorn <[email-masked]>

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:41:52.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.c	2006-04-27 21:42:29.000000000 +0200
@@ -385,6 +385,9 @@ rt2400pci_config_mode(struct rt2x00_pci 
 {
 	u32			reg;
 
+	/*
+	 * Apply hardware packet filter.
+	 */
 	rt2x00_register_read(rt2x00pci, RXCSR0, &reg);
 
 	if (mode == IW_MODE_ADHOC
@@ -408,6 +411,19 @@ rt2400pci_config_mode(struct rt2x00_pci 
 	}
 
 	rt2x00_register_write(rt2x00pci, RXCSR0, reg);
+
+	/*
+	 * Enable TSF counter.
+	 */
+	rt2x00_register_read(rt2x00pci, CSR14, &reg);
+	rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
+	if (mode == IW_MODE_ADHOC)
+		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 2);
+	else if (mode == IW_MODE_INFRA)
+		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 1);
+	else
+		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0);
+	rt2x00_register_write(rt2x00pci, CSR14, reg);
 }
 
 static void
@@ -1723,21 +1739,10 @@ static void
 rt2400pci_reset_tsf(struct net_device *net_dev)
 {
 	struct rt2x00_pci	*rt2x00pci = ieee80211_dev_hw_data(net_dev);
-	struct ieee80211_conf	*conf = ieee80211_get_hw_conf(net_dev);
 	u32			reg = 0;
 
 	rt2x00_register_write(rt2x00pci, CSR16, reg);
 	rt2x00_register_write(rt2x00pci, CSR17, reg);
-
-	rt2x00_register_read(rt2x00pci, CSR14, &reg);
-	rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
-	if (conf->mode == IW_MODE_ADHOC)
-		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 2);
-	else if (conf->mode == IW_MODE_INFRA)
-		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 1);
-	else
-		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0);
-	rt2x00_register_write(rt2x00pci, CSR14, reg);
 }
 
 static int
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:41:52.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.c	2006-04-27 21:42:29.000000000 +0200
@@ -385,6 +385,9 @@ rt2500pci_config_mode(struct rt2x00_pci 
 {
 	u32			reg;
 
+	/*
+	 * Apply hardware packet filter.
+	 */
 	rt2x00_register_read(rt2x00pci, RXCSR0, &reg);
 
 	if (mode == IW_MODE_ADHOC
@@ -411,6 +414,19 @@ rt2500pci_config_mode(struct rt2x00_pci 
 	rt2x00_set_field32(&reg, RXCSR0_DROP_BCAST, 0);
 
 	rt2x00_register_write(rt2x00pci, RXCSR0, reg);
+
+	/*
+	 * Enable TSF counter.
+	 */
+	rt2x00_register_read(rt2x00pci, CSR14, &reg);
+	rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
+	if (mode == IW_MODE_ADHOC)
+		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 2);
+	else if (mode == IW_MODE_INFRA)
+		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 1);
+	else
+		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0);
+	rt2x00_register_write(rt2x00pci, CSR14, reg);
 }
 
 static void
@@ -1809,21 +1825,10 @@ static void
 rt2500pci_reset_tsf(struct net_device *net_dev)
 {
 	struct rt2x00_pci	*rt2x00pci = ieee80211_dev_hw_data(net_dev);
-	struct ieee80211_conf	*conf = ieee80211_get_hw_conf(net_dev);
 	u32			reg = 0;
 
 	rt2x00_register_write(rt2x00pci, CSR16, reg);
 	rt2x00_register_write(rt2x00pci, CSR17, reg);
-
-	rt2x00_register_read(rt2x00pci, CSR14, &reg);
-	rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
-	if (conf->mode == IW_MODE_ADHOC)
-		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 2);
-	else if (conf->mode == IW_MODE_INFRA)
-		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 1);
-	else
-		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0);
-	rt2x00_register_write(rt2x00pci, CSR14, reg);
 }
 
 static int
diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500usb.c wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500usb.c
--- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500usb.c	2006-04-27 21:41:52.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500usb.c	2006-04-27 21:42:29.000000000 +0200
@@ -268,6 +268,9 @@ rt2500usb_config_mode(struct rt2x00_usb 
 {
 	u16			reg;
 
+	/*
+	 * Apply hardware packet filter.
+	 */
 	rt2x00_register_read(rt2x00usb, TXRX_CSR2, &reg);
 
 	if (mode == IW_MODE_ADHOC
@@ -1509,24 +1512,6 @@ rt2500usb_get_tx_stats(struct net_device
 	return 0;
 }
 
-static void
-rt2500usb_reset_tsf(struct net_device *net_dev)
-{
-	struct rt2x00_usb	*rt2x00usb = ieee80211_dev_hw_data(net_dev);
-	struct ieee80211_conf	*conf = ieee80211_get_hw_conf(net_dev);
-	u16			reg = 0;
-
-	rt2x00_register_read(rt2x00usb, TXRX_CSR19, &reg);
-	rt2x00_set_field16_nb(&reg, TXRX_CSR19_TSF_COUNT, 1);
-	if (conf->mode == IW_MODE_ADHOC)
-		rt2x00_set_field16_nb(&reg, TXRX_CSR19_TSF_SYNC, 2);
-	else if (conf->mode == IW_MODE_INFRA)
-		rt2x00_set_field16_nb(&reg, TXRX_CSR19_TSF_SYNC, 1);
-	else
-		rt2x00_set_field16_nb(&reg, TXRX_CSR19_TSF_SYNC, 0);
-	rt2x00_register_write(rt2x00usb, TXRX_CSR19, reg);
-}
-
 static int
 rt2500usb_beacon_update(struct net_device *net_dev,
 	struct sk_buff *skb, struct ieee80211_tx_control *control)
@@ -1880,7 +1865,6 @@ rt2500usb_init_hw(struct rt2x00_usb *rt2
 	hw->set_mac_address	= rt2500usb_set_mac_address;
 	hw->conf_tx		= rt2500usb_conf_tx;
 	hw->get_tx_stats	= rt2500usb_get_tx_stats;
-	hw->reset_tsf		= rt2500usb_reset_tsf;
 	hw->beacon_update	= rt2500usb_beacon_update;
 
 	/*
diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500usb.h wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500usb.h
--- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500usb.h	2006-04-27 21:36:19.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500usb.h	2006-04-27 21:42:29.000000000 +0200
@@ -748,7 +748,6 @@ static int rt2500usb_conf_tx(struct net_
 	int queue, const struct ieee80211_tx_queue_params *params);
 static int rt2500usb_get_tx_stats(struct net_device *net_dev,
 	struct ieee80211_tx_queue_stats *stats);
-static void rt2500usb_reset_tsf(struct net_device *net_dev);
 static int rt2500usb_beacon_update(struct net_device *net_dev,
 	struct sk_buff *skb, struct ieee80211_tx_control *control);