Linux wireless drivers development
 help / color / mirror / Atom feed
* deauthentication and disassociation nl80211 commands
From: Maxim Levitsky @ 2009-10-05  2:11 UTC (permalink / raw)
  To: hostap@lists.shmoo.com; +Cc: linux-wireless

Here I want to ask and summarize problems we found in thread
'driver_nl80211 broken again'


First of all it it known that lifetime of connection to access point is
typically:

authentication request/response
association request/response

EAPOL 4 way handshake (for WPA)

<session>

disassociation
deauthentication

Today kernel explicitly requests the driver to perform both
disassociation and deauthentication in that order.
It is also possible to do disassociation and then association, skipping
the authentication step.

However, currently wpa_supplicant assumes that once it called
wpa_drv_disassociate it can again start the complete connect sequence
from the authentication.

In fact I have carefully studied the code and found that calls to
wpa_supplicant_deauthenticate (which is the only user of
wpa_drv_deauthenticate) only happen at deinitialization of wireless
interface and when wpa_supplicant really has to do it, that is if there
is a failure (mic failure for example).

My hacky patch that was rejected on the grounds that it is not right to
introduce the driver dependent behavior might actually be the correct
solution. It just makes the wpa_supplicant_disassociate do both
disassociation and deauthentication, as was always assumed by the
wpa_supplicant core.


Or kernel should became smarter and do the work for wpa_supplicant. 

In this case it should work like that:

If mac80211 is already authenticated to the AP that was requested, it
should just return success.
However currently (and I was told that this is feature, not a bug)
mac80211 would flatly refuse to do any scanning while it is in
authenticated but not associated state.

If it isn't authenticated to new AP then, new authentication should be
made.
(and old one can be kept, but removed after a timeout)


And the last question.
When do you plan to switch officially the wpa_supplicant to
driver_nl80211?

Currently it has this issue, and another issue that it (nl80211) reports
signal levels in another format that NetworkManager doesn't understand.

Other that that it is faster, and especially it allows me to bring
network up, when I press rfkill button within 4 seconds or less.


Best regards,
Maxim Levitsky


^ permalink raw reply

* Re: Disassociating atheros wlan with 2.6.31
From: Justin Mattock @ 2009-10-05  0:20 UTC (permalink / raw)
  To: Kristoffer Ericson
  Cc: Stefan Lippers-Hollmann, linux-wireless,
	linux-kernel@vger.kernel.org
In-Reply-To: <20091004174535.777d233c.kristoffer.ericson@gmail.com>

On Sun, Oct 4, 2009 at 8:45 AM, Kristoffer Ericson
<kristoffer.ericson@gmail.com> wrote:
> Hi,
>
> Did a bisect or more exactly tried to do a bisect. Ive managed to bisect myself
> into a deadend so far (must have marked good in wrong place). The disassociation happens
> at seemingly regular intervalls but once I started bisecting it started
> to be more irregular. Perhaps it was simply due to me not being able
> to user internet (and share) since my 3G modem oopsed all the time.
> Suspecting its load sensitive.
>
well, as easy as it seems I did at one point forget what was good/bad
on a bisect a few weeks ago.(hey your human).

> Anyhow heres what I got so far. The bad versions should be correct
> while the good versions might not be. Reason being that I didnt wait
> long enough for the disassociation to appear and thus faulty marking
> something as good.
> Using the bad should however narrow it down somewhat. From what
> I can see between my last good and bad is only non-related stuff,
> so must be atleast one "good" mistake in there.
>
> git bisect start
> # good: [07a2039b8eb0af4ff464efd3dfd95de5c02648c6] Linux 2.6.30
> git bisect good 07a2039b8eb0af4ff464efd3dfd95de5c02648c6
> # bad: [74fca6a42863ffacaf7ba6f1936a9f228950f657] Linux 2.6.31
> git bisect bad 74fca6a42863ffacaf7ba6f1936a9f228950f657
> # good: [925d74ae717c9a12d3618eb4b36b9fb632e2cef3] V4L/DVB (11736): videobuf: modify return value of VIDIOC_REQBUFS ioctl
> git bisect good 925d74ae717c9a12d3618eb4b36b9fb632e2cef3
> # bad: [a380137900fca5c79e6daa9500bdb6ea5649188e] ixgbe: Fix device capabilities of 82599 single speed fiber NICs.
> git bisect bad a380137900fca5c79e6daa9500bdb6ea5649188e
> # bad: [1dbb5765acc7a6fe4bc1957c001037cc9d02ae03] Staging: android: lowmemorykiller: fix up remaining checkpatch warnings
> git bisect bad 1dbb5765acc7a6fe4bc1957c001037cc9d02ae03
> # bad: [2b1b62e841867326fa260a581d97941c32abc35b] MIPS: Cavium-Octeon: Add more board type constants.
> git bisect bad 2b1b62e841867326fa260a581d97941c32abc35b
> # good: [517d08699b250021303f9a7cf0d758b6dc0748ed] Merge branch 'akpm'
> git bisect good 517d08699b250021303f9a7cf0d758b6dc0748ed
> # good: [5e2c217eee18a4627a32c49f57f47dbac67dcf23] V4L/DVB (11958): usbvision-core.c: vfree does its own NULL check
> git bisect good 5e2c217eee18a4627a32c49f57f47dbac67dcf23
> # bad: [a9349315f65cd6a16e8fab1f6cf0fd40f379c4db] V4L/DVB (11819): Siano: smscore - fix get_common_buffer bug
> git bisect bad a9349315f65cd6a16e8fab1f6cf0fd40f379c4db
> # good: [06f837cadbcdedb45f0702cb57c99c404ae921e6] V4L/DVB (11784): cx88: Fix race condition between cx8800 startup and hald
> git bisect good 06f837cadbcdedb45f0702cb57c99c404ae921e6
> # good: [1339f9108a84710969903e892dcf1849ae1215cf] V4L/DVB (11726): Modify the file license to match all other Siano's files
> git bisect good 1339f9108a84710969903e892dcf1849ae1215cf
>
> Best wishes
> Kristoffer Ericson
>

When I get a chance I can try a bisect and see.
If you decide to redu and come up with a specific
commit then I guess well go from there.

-- 
Justin P. Mattock

^ permalink raw reply

* [PATCH] Wireless / ath5k: Simplify suspend and resume callbacks
From: Rafael J. Wysocki @ 2009-10-04 22:52 UTC (permalink / raw)
  To: ath5k-devel; +Cc: John W. Linville, linux-wireless, Bob Copeland, LKML, pm list

From: Rafael J. Wysocki <rjw@sisk.pl>

Simplify the suspend and resume callbacks of ath5k by converting the
driver to struct dev_pm_ops and allowing the PCI PM core to do the
PCI-specific suspend/resume handling.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/net/wireless/ath/ath5k/base.c |   35 ++++++++++------------------------
 1 file changed, 11 insertions(+), 24 deletions(-)

Index: linux-2.6/drivers/net/wireless/ath/ath5k/base.c
===================================================================
--- linux-2.6.orig/drivers/net/wireless/ath/ath5k/base.c
+++ linux-2.6/drivers/net/wireless/ath/ath5k/base.c
@@ -195,12 +195,13 @@ static int __devinit	ath5k_pci_probe(str
 				const struct pci_device_id *id);
 static void __devexit	ath5k_pci_remove(struct pci_dev *pdev);
 #ifdef CONFIG_PM
-static int		ath5k_pci_suspend(struct pci_dev *pdev,
-					pm_message_t state);
-static int		ath5k_pci_resume(struct pci_dev *pdev);
+static int		ath5k_pci_suspend(struct device *dev);
+static int		ath5k_pci_resume(struct device *dev);
+
+SIMPLE_DEV_PM_OPS(ath5k_pm_ops, ath5k_pci_suspend, ath5k_pci_resume);
+#define ATH5K_PM_OPS	(&ath5k_pm_ops)
 #else
-#define ath5k_pci_suspend NULL
-#define ath5k_pci_resume NULL
+#define ATH5K_PM_OPS	NULL
 #endif /* CONFIG_PM */
 
 static struct pci_driver ath5k_pci_driver = {
@@ -208,8 +209,7 @@ static struct pci_driver ath5k_pci_drive
 	.id_table	= ath5k_pci_id_table,
 	.probe		= ath5k_pci_probe,
 	.remove		= __devexit_p(ath5k_pci_remove),
-	.suspend	= ath5k_pci_suspend,
-	.resume		= ath5k_pci_resume,
+	.driver.pm	= ATH5K_PM_OPS,
 };
 
 
@@ -669,33 +669,20 @@ ath5k_pci_remove(struct pci_dev *pdev)
 }
 
 #ifdef CONFIG_PM
-static int
-ath5k_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+static int ath5k_pci_suspend(struct device *dev)
 {
-	struct ieee80211_hw *hw = pci_get_drvdata(pdev);
+	struct ieee80211_hw *hw = pci_get_drvdata(to_pci_dev(dev));
 	struct ath5k_softc *sc = hw->priv;
 
 	ath5k_led_off(sc);
-
-	pci_save_state(pdev);
-	pci_disable_device(pdev);
-	pci_set_power_state(pdev, PCI_D3hot);
-
 	return 0;
 }
 
-static int
-ath5k_pci_resume(struct pci_dev *pdev)
+static int ath5k_pci_resume(struct device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev);
 	struct ieee80211_hw *hw = pci_get_drvdata(pdev);
 	struct ath5k_softc *sc = hw->priv;
-	int err;
-
-	pci_restore_state(pdev);
-
-	err = pci_enable_device(pdev);
-	if (err)
-		return err;
 
 	/*
 	 * Suspend/Resume resets the PCI configuration space, so we have to

^ permalink raw reply

* Re: Disassociating atheros wlan with 2.6.31
From: Kristoffer Ericson @ 2009-10-04 15:45 UTC (permalink / raw)
  To: Justin P. Mattock
  Cc: Stefan Lippers-Hollmann, linux-wireless,
	linux-kernel@vger.kernel.org
In-Reply-To: <4ABBD170.6060702@gmail.com>

Hi,

Did a bisect or more exactly tried to do a bisect. Ive managed to bisect myself
into a deadend so far (must have marked good in wrong place). The disassociation happens
at seemingly regular intervalls but once I started bisecting it started
to be more irregular. Perhaps it was simply due to me not being able
to user internet (and share) since my 3G modem oopsed all the time.
Suspecting its load sensitive.

Anyhow heres what I got so far. The bad versions should be correct
while the good versions might not be. Reason being that I didnt wait
long enough for the disassociation to appear and thus faulty marking
something as good. 
Using the bad should however narrow it down somewhat. From what
I can see between my last good and bad is only non-related stuff,
so must be atleast one "good" mistake in there.

git bisect start
# good: [07a2039b8eb0af4ff464efd3dfd95de5c02648c6] Linux 2.6.30
git bisect good 07a2039b8eb0af4ff464efd3dfd95de5c02648c6
# bad: [74fca6a42863ffacaf7ba6f1936a9f228950f657] Linux 2.6.31
git bisect bad 74fca6a42863ffacaf7ba6f1936a9f228950f657
# good: [925d74ae717c9a12d3618eb4b36b9fb632e2cef3] V4L/DVB (11736): videobuf: modify return value of VIDIOC_REQBUFS ioctl
git bisect good 925d74ae717c9a12d3618eb4b36b9fb632e2cef3
# bad: [a380137900fca5c79e6daa9500bdb6ea5649188e] ixgbe: Fix device capabilities of 82599 single speed fiber NICs.
git bisect bad a380137900fca5c79e6daa9500bdb6ea5649188e
# bad: [1dbb5765acc7a6fe4bc1957c001037cc9d02ae03] Staging: android: lowmemorykiller: fix up remaining checkpatch warnings
git bisect bad 1dbb5765acc7a6fe4bc1957c001037cc9d02ae03
# bad: [2b1b62e841867326fa260a581d97941c32abc35b] MIPS: Cavium-Octeon: Add more board type constants.
git bisect bad 2b1b62e841867326fa260a581d97941c32abc35b
# good: [517d08699b250021303f9a7cf0d758b6dc0748ed] Merge branch 'akpm'
git bisect good 517d08699b250021303f9a7cf0d758b6dc0748ed
# good: [5e2c217eee18a4627a32c49f57f47dbac67dcf23] V4L/DVB (11958): usbvision-core.c: vfree does its own NULL check
git bisect good 5e2c217eee18a4627a32c49f57f47dbac67dcf23
# bad: [a9349315f65cd6a16e8fab1f6cf0fd40f379c4db] V4L/DVB (11819): Siano: smscore - fix get_common_buffer bug
git bisect bad a9349315f65cd6a16e8fab1f6cf0fd40f379c4db
# good: [06f837cadbcdedb45f0702cb57c99c404ae921e6] V4L/DVB (11784): cx88: Fix race condition between cx8800 startup and hald
git bisect good 06f837cadbcdedb45f0702cb57c99c404ae921e6
# good: [1339f9108a84710969903e892dcf1849ae1215cf] V4L/DVB (11726): Modify the file license to match all other Siano's files
git bisect good 1339f9108a84710969903e892dcf1849ae1215cf

Best wishes
Kristoffer Ericson

On Thu, 24 Sep 2009 13:07:12 -0700
"Justin P. Mattock" <justinmattock@gmail.com> wrote:

> Stefan Lippers-Hollmann wrote:
> > Hi
> >
> > CCing linux-wireless@vger.kernel.org, as it's not very likely to get
> > noticed here by wireless developers.
> >
> > On Thursday 24 September 2009, Justin P. Mattock wrote:
> >    
> >> Kristoffer Ericson wrote:
> >>      
> >>> Greetings,
> >>>
> >>> When moving from vanilla 2.6.30->2.6.31 I noticed that I get dissasociated from
> >>> my wlan hub with regular intervalls. This did not happen on 2.6.30.
> >>> I cant see any pattern aside from that it happens at regular intervalls
> >>> (around 10-15mins). It works again when I re-identifies myself.
> >>>
> >>> Got an Asus 1000HE with Atheros chipset.
> >>> Havent had time to bisect it, just wanted to check
> >>> if this is an known issue. Ive ruled out faulty wlan hub
> >>> since everything works fine when going back to 2.6.30.
> >>>
> >>> nothing much on dmesg:
> >>> uhci_hcd 0000:00:1d.1: UHCI Host Controller
> >>> uhci_hcd 0000:00:1d.1: new USB bus registered, assigned bus number 3
> >>> uhci_hcd 0000:00:1d.1: irq 19, io base 0x0000d480
> >>> usb usb3: configuration #1 chosen from 1 choice
> >>> hub 3-0:1.0: USB hub found
> >>> hub 3-0:1.0: 2 ports detected
> >>> uhci_hcd 0000:00:1d.2: PCI INT C ->   GSI 18 (level, low) ->   IRQ 18
> >>> uhci_hcd 0000:00:1d.2: setting latency timer to 64
> >>> uhci_hcd 0000:00:1d.2: UHCI Host Controller
> >>> uhci_hcd 0000:00:1d.2: new USB bus registered, assigned bus number 4
> >>> uhci_hcd 0000:00:1d.2: irq 18, io base 0x0000d800
> >>> usb usb4: configuration #1 chosen from 1 choice
> >>> hub 4-0:1.0: USB hub found
> >>> hub 4-0:1.0: 2 ports detected
> >>> uhci_hcd 0000:00:1d.3: PCI INT D ->   GSI 16 (level, low) ->   IRQ 16
> >>> uhci_hcd 0000:00:1d.3: setting latency timer to 64
> >>> uhci_hcd 0000:00:1d.3: UHCI Host Controller
> >>> uhci_hcd 0000:00:1d.3: new USB bus registered, assigned bus number 5
> >>> uhci_hcd 0000:00:1d.3: irq 16, io base 0x0000d880
> >>> usb usb5: configuration #1 chosen from 1 choice
> >>> hub 5-0:1.0: USB hub found
> >>> hub 5-0:1.0: 2 ports detected
> >>> input: ETPS/2 Elantech Touchpad as /devices/platform/i8042/serio1/input/input7
> >>> usb 1-4: new high speed USB device using ehci_hcd and address 3
> >>> usb 1-4: configuration #1 chosen from 1 choice
> >>> hub 1-4:1.0: USB hub found
> >>> hub 1-4:1.0: 4 ports detected
> >>> usb 1-5: new high speed USB device using ehci_hcd and address 4
> >>> usb 1-5: configuration #1 chosen from 1 choice
> >>> usb 1-8: new high speed USB device using ehci_hcd and address 6
> >>> usb 1-8: configuration #1 chosen from 1 choice
> >>> Initializing USB Mass Storage driver...
> >>> scsi4 : SCSI emulation for USB Mass Storage devices
> >>> usbcore: registered new interface driver usb-storage
> >>> USB Mass Storage support registered.
> >>> usb-storage: device found at 4
> >>> usb-storage: waiting for device to settle before scanning
> >>> HDA Intel 0000:00:1b.0: PCI INT A ->   GSI 16 (level, low) ->   IRQ 16
> >>> HDA Intel 0000:00:1b.0: setting latency timer to 64
> >>> usb 2-2: new full speed USB device using uhci_hcd and address 2
> >>> ath9k 0000:01:00.0: PCI INT A ->   GSI 19 (level, low) ->   IRQ 19
> >>> ath9k 0000:01:00.0: setting latency timer to 64
> >>> usb 2-2: configuration #1 chosen from 1 choice
> >>> input: HDA Digital PCBeep as /devices/pci0000:00/0000:00:1b.0/input/input8
> >>> usbcore: registered new interface driver usbserial
> >>> USB Serial support registered for generic
> >>> usb 5-1: new full speed USB device using uhci_hcd and address 2
> >>> usb 5-1: configuration #1 chosen from 1 choice
> >>> usb 1-4.1: new full speed USB device using ehci_hcd and address 7
> >>> ath: EEPROM regdomain: 0x60
> >>> ath: EEPROM indicates we should expect a direct regpair map
> >>> ath: Country alpha2 being used: 00
> >>> ath: Regpair used: 0x60
> >>> Bluetooth: Core ver 2.15
> >>> NET: Registered protocol family 31
> >>> Bluetooth: HCI device and connection manager initialized
> >>> Bluetooth: HCI socket layer initialized
> >>> Bluetooth: Generic Bluetooth USB driver ver 0.5
> >>> usb 1-4.1: configuration #1 chosen from 1 choice
> >>> usb 1-4.2: new low speed USB device using ehci_hcd and address 8
> >>> usb 1-4.2: configuration #1 chosen from 1 choice
> >>> usb 1-4.4: new low speed USB device using ehci_hcd and address 9
> >>> usbcore: registered new interface driver hiddev
> >>> input: HID 04d9:1203 as /devices/pci0000:00/0000:00:1d.7/usb1/1-4/1-4.2/1-4.2:1.0/input/input9
> >>> generic-usb 0003:04D9:1203.0001: input,hidraw0: USB HID v1.11 Keyboard [HID 04d9:1203] on usb-0000:00:1d.7-4.2/input0
> >>> input: HID 04d9:1203 as /devices/pci0000:00/0000:00:1d.7/usb1/1-4/1-4.2/1-4.2:1.1/input/input10
> >>> generic-usb 0003:04D9:1203.0002: input,hidraw1: USB HID v1.11 Device [HID 04d9:1203] on usb-0000:00:1d.7-4.2/input1
> >>> usbcore: registered new interface driver usbhid
> >>> usbhid: v2.6:USB HID core driver
> >>> usb 1-4.4: configuration #1 chosen from 1 choice
> >>> input: B16_b_02 USB-PS/2 Optical Mouse as /devices/pci0000:00/0000:00:1d.7/usb1/1-4/1-4.4/1-4.4:1.0/input/input11
> >>> generic-usb 0003:046D:C025.0003: input,hidraw2: USB HID v1.10 Mouse [B16_b_02 USB-PS/2 Optical Mouse] on usb-0000:00:1d.7-4.4/input0
> >>> usbcore: registered new interface driver btusb
> >>> usbcore: registered new interface driver usbserial_generic
> >>> usbserial: USB Serial Driver core
> >>> USB Serial support registered for GSM modem (1-port)
> >>> option 2-2:1.0: GSM modem (1-port) converter detected
> >>> usb 2-2: GSM modem (1-port) converter now attached to ttyUSB0
> >>> option 2-2:1.1: GSM modem (1-port) converter detected
> >>> usb 2-2: GSM modem (1-port) converter now attached to ttyUSB1
> >>> usbcore: registered new interface driver option
> >>> option: v0.7.2:USB Driver for GSM modems
> >>> USB Serial support registered for pl2303
> >>> pl2303 1-4.1:1.0: pl2303 converter detected
> >>> usb 1-4.1: pl2303 converter now attached to ttyUSB2
> >>> usbcore: registered new interface driver pl2303
> >>> pl2303: Prolific PL2303 USB to serial adaptor driver
> >>> phy0: Selected rate control algorithm 'ath9k_rate_control'
> >>> Registered led device: ath9k-phy0::radio
> >>> Registered led device: ath9k-phy0::assoc
> >>> Registered led device: ath9k-phy0::tx
> >>> Registered led device: ath9k-phy0::rx
> >>> phy0: Atheros AR9280 MAC/BB Rev:2 AR5133 RF Rev:d0: mem=0xf8880000, irq=19
> >>> scsi 4:0:0:0: Direct-Access     Single   Flash Reader     1.00 PQ: 0 ANSI: 0
> >>> sd 4:0:0:0: Attached scsi generic sg1 type 0
> >>> sd 4:0:0:0: [sdb] 15954944 512-byte logical blocks: (8.16 GB/7.60 GiB)
> >>> usb-storage: device scan complete
> >>> sd 4:0:0:0: [sdb] Write Protect is off
> >>> sd 4:0:0:0: [sdb] Mode Sense: 03 00 00 00
> >>> sd 4:0:0:0: [sdb] Assuming drive cache: write through
> >>> sd 4:0:0:0: [sdb] Assuming drive cache: write through
> >>>    sdb: sdb1
> >>> sd 4:0:0:0: [sdb] Assuming drive cache: write through
> >>> sd 4:0:0:0: [sdb] Attached SCSI removable disk
> >>> EXT3-fs warning: maximal mount count reached, running e2fsck is recommended
> >>> EXT3 FS on sda1, internal journal
> >>> Bluetooth: L2CAP ver 2.13
> >>> Bluetooth: L2CAP socket layer initialized
> >>> Bluetooth: SCO (Voice Link) ver 0.6
> >>> Bluetooth: SCO socket layer initialized
> >>> Bluetooth: BNEP (Ethernet Emulation) ver 1.3
> >>> Bridge firewalling registered
> >>> Bluetooth: RFCOMM TTY layer initialized
> >>> Bluetooth: RFCOMM socket layer initialized
> >>> Bluetooth: RFCOMM ver 1.11
> >>> ATL1E 0000:03:00.0: irq 27 for MSI/MSI-X
> >>> fuse init (API version 7.12)
> >>> ip_tables: (C) 2000-2006 Netfilter Core Team
> >>> nf_conntrack version 0.5.0 (16384 buckets, 65536 max)
> >>> CONFIG_NF_CT_ACCT is deprecated and will be removed soon. Please use
> >>> nf_conntrack.acct=1 kernel parameter, acct=1 nf_conntrack module option or
> >>> sysctl net.netfilter.nf_conntrack_acct=1 to enable it.
> >>> wlan0: authenticate with AP 00:14:7c:ae:d1:90
> >>> wlan0: authenticated
> >>> wlan0: associate with AP 00:14:7c:ae:d1:90
> >>> wlan0: RX AssocResp from 00:14:7c:ae:d1:90 (capab=0x431 status=0 aid=5)
> >>> wlan0: associated
> >>> PPP generic driver version 2.4.2
> >>> NET: Registered protocol family 10
> >>> lo: Disabled Privacy Extensions
> >>> ADDRCONF(NETDEV_UP): eth0: link is not ready
> >>> PPP BSD Compression module registered
> >>> PPP Deflate Compression module registered
> >>> wlan0: no IPv6 routers present
> >>> CE: hpet increasing min_delta_ns to 15000 nsec
> >>> wlan0: no probe response from AP 00:14:7c:ae:d1:90 - disassociating
> >>> wlan0: authenticate with AP 00:14:7c:ae:d1:90
> >>> wlan0: authenticated
> >>> wlan0: associate with AP 00:14:7c:ae:d1:90
> >>> wlan0: RX AssocResp from 00:14:7c:ae:d1:90 (capab=0x431 status=0 aid=5)
> >>> wlan0: associated
> >>> wlan0: authenticate with AP 00:14:7c:ae:d1:90
> >>> wlan0: authenticated
> >>> wlan0: associate with AP 00:14:7c:ae:d1:90
> >>> wlan0: RX AssocResp from 00:14:7c:ae:d1:90 (capab=0x431 status=0 aid=5)
> >>> wlan0: associated
> >>> [kristoffer@boggieman wine.git]$
> >>>
> >>>
> >>>
> >>>        
> >> yeah I'm seeing this with my macbook pro(ath9k)
> >> while streaming music, all of a sudden things just crap out.
> >> (not sure if this is why, or something else).
> >>
> >> Justin P. Mattock
> >>      
> >
> > I'm getting similar reports for iwl3945 and 2.6.31.[01], but can't confirm
> > this on my own (non-iwl{3945,agn}, non-ath9k) hardware yet.
> >
> > Regards
> > 	Stefan Lippers-Hollmann
> >
> >    
> I don't mind doing a bisect from 30 - present, but first I need to
> do some other stuff.
> 
> Justin P. Mattock


-- 
Kristoffer Ericson <kristoffer.ericson@gmail.com>

^ permalink raw reply

* Re: [PATCH] [compat-2.6] Make it compile with wireless-testing master-2009-09-30
From: Luis R. Rodriguez @ 2009-10-03 19:23 UTC (permalink / raw)
  To: Hauke Mehrtens; +Cc: linux-wireless
In-Reply-To: <1254518013-30223-1-git-send-email-hauke@hauke-m.de>

On Fri, Oct 2, 2009 at 2:13 PM, Hauke Mehrtens <hauke@hauke-m.de> wrote:
> DIV_ROUND_CLOSEST is needed by the b44 driver.
> Most of the rest is needed because of "wext: refactor"
> in wireless-testing.

Applied, thanks!

  Luis

^ permalink raw reply

* Re: [PATCH] ar9170usb: LEDs are confused
From: Malte Gell @ 2009-10-03 17:28 UTC (permalink / raw)
  To: Christian Lamparter; +Cc: Joerg Albert, linux-wireless
In-Reply-To: <200910031329.47123.chunkeey@googlemail.com>


Christian Lamparter <chunkeey@googlemail.com> wrote

> On Saturday 03 October 2009 04:53:41 Malte Gell wrote:
> > Can I change the link(s) there at any time
> 
> yes, you can change then any time you want.

> > That's true! I just had to exchange the words "tx" with "assoc"
> > in the driver,  whereas a udev rule is complicated!
> 
> well, there's at least one upside: this rule could be easily
> modified to work with different wireless drivers.

Maybe a udev rule would even be the best solution, this way Linux distributors 
could easily adapt it to different hardware.
 
> by the way: Could you please do me a flavour (since you are
> the only WN111 v2 owner I know) and tell us what "hwtype"
> result you get with Joerg Albert's patch:
> 
> http://marc.info/?l=linux-wireless&m=125452461322729&q=raw

I'm so sorry, I do not have the WN111v2 any more! I gave it back a few days 
ago after I was able to get the Fritz WLAN N running... I had the WN111v2 just 
for a few days while the Fritz wasn't running.

Regards
Malte

^ permalink raw reply

* Re: [PATCH] ar9170usb: LEDs are confused
From: Christian Lamparter @ 2009-10-03 11:29 UTC (permalink / raw)
  To: Malte Gell, Joerg Albert; +Cc: linux-wireless
In-Reply-To: <200910030453.42131.malte.gell@gmx.de>

On Saturday 03 October 2009 04:53:41 Malte Gell wrote:
> Christian Lamparter <chunkeey@googlemail.com> wrote
> > If you take a look at the ledtriggers values in /sys/call/leds/
> > "none rfkill0 phy0rx phy0tx [phy0assoc] phy0radio",
> > you instantly see that the phyXname trigger is dynamic.
> 
> Can I change the link(s) there at any time
yes, you can change then any time you want.

> or will the ar9170usb change it again?
no, the setting stays. But of course,
it will be gone if the module is reloaded, or
the device has been replugged.
  
> > in my opinion, finding a simple udev rule is harder than simply
> > modify the driver code :-D.
> 
> That's true! I just had to exchange the words "tx" with "assoc" 
> in the driver,  whereas a udev rule is complicated!
well, there's at least one upside: this rule could be easily
modified to work with different wireless drivers.

by the way: Could you please do me a flavour (since you are
the only WN111 v2 owner I know) and tell us what "hwtype"
result you get with Joerg Albert's patch: 

http://marc.info/?l=linux-wireless&m=125452461322729&q=raw

Regards,
	Chr

^ permalink raw reply

* Re: driver_nl80211 broken again
From: Johannes Berg @ 2009-10-03  5:52 UTC (permalink / raw)
  To: Trepak Vilmos; +Cc: Jouni Malinen, hostap@lists.shmoo.com, linux-wireless
In-Reply-To: <4AC67144.5060508@netcomga.sk>

[-- Attachment #1: Type: text/plain, Size: 1687 bytes --]

On Fri, 2009-10-02 at 23:31 +0200, Trepak Vilmos wrote:
> Johannes Berg wrote:
> > On Thu, 2009-10-01 at 01:13 +0300, Jouni Malinen wrote:
> >> To me, this looks broken. When wpa_supplicant requests a
> >> disassociastion, it is _only_ asking for disassociation, not
> >> deauthentication. cfg80211/mac80211 may not currently handle that, but
> >> as far as I can tell, it sounds like an issue there and not in
> >> wpa_supplicant. Johannes may disagree with this, though.
> >
> > cfg80211/mac80211 _do_ handle that. If you ask for disassociation, it
> > stays authenticated, and later expects you to still remember that and
> > refuses authentication since you're already authenticated.
> >
> >> I don't think either of those options would be acceptable for
> >> wpa_supplicant and the correct fix is to make cfg80211/mac80211 be able
> >> to handle authentication to a STA that is already authenticated. If
> >> that is not acceptable, this hack needs to be hidden in driver_nl80211.c
> >> instead of polluting core wpa_supplicant code which is supposed to be
> >> driver independent. In other words, make driver_nl80211.c deauth if auth
> >> fails and then try auth again. I don't really like that much, but if
> >> this needs to be worked around in wpa_supplicant, that is the most
> >> likely place where such a change could be considered.
> >
> > I still don't see how it makes sense to authenticate while still being
> > authenticated.
> 
> The client might have lost state info (rebooted, etc.). Let it redo the
> auth if it wants to, deauth if it fails.

In case you haven't noticed, we're talking about the client
(wpa_supplicant) :)

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply

* Re: unable to compile - error: implicit declaration of function ‘DIV_ROUND_CLOSEST’
From: Parker @ 2009-10-03  4:47 UTC (permalink / raw)
  To: linux-wireless
In-Reply-To: <loom.20091003T045434-645@post.gmane.org>

Update - I downloaded the 9-30-2009 bleeding edge from the file repository and 
it compiled just fine.  I installed the drivers and rebooted and all is well.


^ permalink raw reply

* unable to compile - error: implicit declaration of function ‘DIV_ROUND_CLOSEST’
From: Parker @ 2009-10-03  2:58 UTC (permalink / raw)
  To: linux-wireless

I'm trying to compile compat-wireless-2.6.32-rc1.

Here is my term output.  Not sure what's wrong.

$ make
make -C /lib/modules/2.6.28-11-generic/build
M=/home/xxx/Desktop/compat-wireless-2.6.32-rc1 modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.28-11-generic'
  CC [M]  /home/xxx/Desktop/compat-wireless-2.6.32-rc1/drivers/net/b44.o
/home/xxx/Desktop/compat-wireless-2.6.32-rc1/drivers/net/b44.c: In function
‘b44_chip_reset’:
/home/xxx/Desktop/compat-wireless-2.6.32-rc1/drivers/net/b44.c:1300: error:
implicit declaration of function ‘DIV_ROUND_CLOSEST’
make[3]: *** [/home/xxx/Desktop/compat-wireless-2.6.32-rc1/drivers/net/b44.o]
Error 1
make[2]: *** [/home/xxx/Desktop/compat-wireless-2.6.32-rc1/drivers/net] Error 2
make[1]: *** [_module_/home/xxx/Desktop/compat-wireless-2.6.32-rc1] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.28-11-generic'
make: *** [modules] Error 2



^ permalink raw reply

* Re: [PATCH] ar9170usb: LEDs are confused
From: Malte Gell @ 2009-10-03  2:53 UTC (permalink / raw)
  To: Christian Lamparter
  Cc: linux-wireless, Luis R. Rodriguez, linville, Hin-Tak Leung
In-Reply-To: <200910022108.15155.chunkeey@googlemail.com>


Christian Lamparter <chunkeey@googlemail.com> wrote
 
> If you take a look at the ledtriggers values in /sys/call/leds/
> "none rfkill0 phy0rx phy0tx [phy0assoc] phy0radio",
> you instantly see that the phyXname trigger is dynamic.

Can I change the link(s) there at any time or will the ar9170usb change it 
again? 
 
> in my opinion, finding a simple udev rule is harder than simply
> modify the driver code :-D.

That's true! I just had to exchange the words "tx" with "assoc" in the driver, 
whereas a udev rule is complicated!

Regards
Malte

^ permalink raw reply

* compat-wireless 2.6.32 release
From: Luis R. Rodriguez @ 2009-10-03  0:07 UTC (permalink / raw)
  To: linux-wireless; +Cc: linux-kernel

Please give compat-wireless 2.6.32-rc1 some tests, its based on
v2.6.32-rc1-244-g90d5ffc, so its not exactly rc1 but has some extra
fixes Linus already picked up which are important for wireless. If you
want to test just 2.6.32-rc1 wireless bits and not the kernel this is
for you.

http://wireless.kernel.org/en/users/Download/stable
http://www.orbit-lab.org/kernel/compat-wireless-2.6-stable/v2.6.32/compat-wireless-2.6.32-rc1.tar.bz2

  Luis

^ permalink raw reply

* Re: [PATCH] ar9170usb: LEDs are confused
From: Christian Lamparter @ 2009-10-03  0:05 UTC (permalink / raw)
  To: Joerg Albert
  Cc: Malte Gell, linux-wireless, Luis R. Rodriguez, linville,
	Hin-Tak Leung
In-Reply-To: <4AC67DEB.80900@gmx.de>

On Saturday 03 October 2009 00:25:47 Joerg Albert wrote:
> On 10/02/2009 01:45 PM, Malte Gell wrote:
> > Christian Lamparter <chunkeey@googlemail.com> wrote
> > 
> >>> The Netgear (WN?) 111 even only has one blue LED as far as I know.
> >> the question is if it's the only device with this deficit, or not?
> > 
> > Is it feasable to write to the well known stick makers (Netgear, AVM, 
> > Belkin,Asus...) and just ask them? 
> 
> After looking into staging/otus/80211core/ledmgr.c, which has functions
> zfLedCtrlType1,2,3 for:
> - "Traditional single-LED state"
> - "Netgear Dual-LED state"
> - "Netgear Single-LED state"
> 
> (althrough they are not used there, as noone initializes wd->ledStruct.LEDCtrlType correctly)
On Windows platforms this setting is initialized by the Driver .inf file:

(ref: http://ftp.dlink.ru/pub/Wireless/DWA-160/Drivers/Rev.A-DWA-160_S0009/Drivers/Vista32/arusb_lh.inf )

[NTGR9010.reg]
HKR, Ndi,								Service,    0, "WNDA3100"

HKR, Ndi\Interfaces,					UpperRange, 0, "ndis5"
HKR, Ndi\Interfaces,					LowerRange, 0, "wlan,ethernet"

[...]

HKR,,					DfsChDisable,				0, 1
HKR,,					LEDCtrlType,				0, 2

vs.

[NTGR9001.reg]
HKR, Ndi,								Service,	0, "WN111v2"

HKR, Ndi\Interfaces,					UpperRange, 0, "ndis5"
HKR, Ndi\Interfaces,					LowerRange, 0, "wlan,ethernet"

[...]

HKR,,					DfsChDisable,				0, 1
HKR,,					LEDCtrlType,				0, 3


the situation is different for AVM:
there is not any reference of LEDCtrlType in any of AVM's inf files,
but the LEDCtrlType string does turn up in the driver file.

> I guess there is a way to determine the number of LED in a device from the EEPROM.
> I really doubt that Netgear would built different drivers/firmwares
> (if they built any instead of getting them from Atheros)
> for both WNDA3100 and WN111v2.
> 
> hal/hpmain.c, line 2322:
> #define ZM_SEEPROM_HARDWARE_TYPE_OFFSET   (0x1374)
> 
> the value from the above address is retrieved in rsp[5] and processed in
>  
> hal/hprw.c, lines 601f.
>         wd->ledStruct.ledMode[0] = (u16_t)(rsp[5]&0xffff);
>         wd->ledStruct.ledMode[1] = (u16_t)(rsp[5]>>16);
> 
> If the bits of ledMode[] are explained in 80211/ledmgr.c, lines 34ff.,
> Atheros provided a generic way for vendors to program LED behaviour
> via the EEPROM and Netgear got some extra handling in the driver
> (if otus is close the windows driver).
nice catch!

On Saturday 03 October 2009 01:03:28 Joerg Albert wrote:
> Hi,
> 
> could anyone with a WN111v2 (or any other device with one LED only)
> apply the patch below and look into syslog for the value of "hwtype"?
> 
> I get 22212221 for an AVM stick (057c:8401) and 22211111 for a Netgear WNDA3100 (0846:9010).
> 
> Thanks,
> Joerg.
> 
> 
Netgear WNDA3100:

LedMode[0] = 0x1111 => (blue LED)
 Bit 0 = 1		=> Power-on state: On
 Bit 6 = 0		=> Connect state
   Bit 4 = 1	=> always on (~ assoc/link LED?)
 Ton   = 1
 Toff  = 1

LedMode[1] = 0x2221 => (orange LED)
 Bit 0 = 1		=> Power-on state: On
 Bit 6 = 0		=> Connect state
   Bit 5 = 1	=> Idle off, acitve on (~ traffic/tx LED?)
 Ton   = 2
 Toff  = 2

this looks promising. The setting here does indeed match
the current driver behavior! 

AVM:
LedMode[0] = 0x2221 => (red LED?)
 Bit 0 = 1		=> Power-on state: On
 Bit 6 = 0		=> Connect state
   Bit 5 = 1	=> Idle off, acitve on (~ traffic/tx LED?)
 Ton   = 2
 Toff  = 2

LedMode[1] = 0x2221 => (green LED?)
 Bit 0 = 1		=> Power-on state: On
 Bit 6 = 0		=> Connect state
   Bit 5 = 1	=> Idle off, acitve on (~ traffic/tx LED?)
 Ton   = 2
 Toff  = 2

hmm, by this definition both LEDs are assigned as "traffic indicators".
This can not be right?! I did expect (based on Malte's description of
the Windows driver) something more like: 0x11112221.

Regards,
	Chr

^ permalink raw reply

* Re: [PATCH] ar9170usb: LEDs are confused
From: Joerg Albert @ 2009-10-02 23:03 UTC (permalink / raw)
  To: Malte Gell
  Cc: Christian Lamparter, linux-wireless, Luis R. Rodriguez, linville,
	Hin-Tak Leung
In-Reply-To: <4AC67DEB.80900@gmx.de>

Hi,

could anyone with a WN111v2 (or any other device with one LED only)
apply the patch below and look into syslog for the value of "hwtype"?

I get 22212221 for an AVM stick (057c:8401) and 22211111 for a Netgear WNDA3100 (0846:9010).

Thanks,
Joerg.

-- 
diff --git a/drivers/net/wireless/ath/ar9170/hw.h b/drivers/net/wireless/ath/ar9170/hw.h
index 6cbfb2f..74b619c 100644
--- a/drivers/net/wireless/ath/ar9170/hw.h
+++ b/drivers/net/wireless/ath/ar9170/hw.h
@@ -77,6 +77,7 @@ enum ar9170_cmd {
 #define AR9170_EP_IRQ				3
 #define AR9170_EP_CMD				4
 
+#define AR9170_EEPROM_HWTYPE                    0x1374
 #define AR9170_EEPROM_START			0x1600
 
 #define AR9170_GPIO_REG_BASE			0x1d0100
diff --git a/drivers/net/wireless/ath/ar9170/main.c b/drivers/net/wireless/ath/ar9170/main.c
index c1f8c69..bffd6c4 100644
--- a/drivers/net/wireless/ath/ar9170/main.c
+++ b/drivers/net/wireless/ath/ar9170/main.c
@@ -2598,6 +2598,7 @@ static int ar9170_read_eeprom(struct ar9170 *ar)
 	__le32 offsets[RW];
 	unsigned int rx_streams, tx_streams, tx_params = 0;
 	int i, j, err, bands = 0;
+	u32 hwtype;
 
 	BUILD_BUG_ON(sizeof(ar->eeprom) & 3);
 
@@ -2665,6 +2666,14 @@ static int ar9170_read_eeprom(struct ar9170 *ar)
 	/* second part of wiphy init */
 	SET_IEEE80211_PERM_ADDR(ar->hw, addr);
 
+	/* read hw type (aka the led modes) */
+	err = ar9170_read_reg(ar, AR9170_EEPROM_HWTYPE, &hwtype);
+	if (err)
+		return err;
+	/* jal: for debugging only */
+	printk(KERN_INFO "%s: hwtype %08x\n",
+	       wiphy_name(ar->hw->wiphy), hwtype);
+
 	return bands ? 0 : -EINVAL;
 }
 

^ permalink raw reply related

* [PATCH] b43: Protect sanity check against physical device removal
From: Michael Buesch @ 2009-10-02 22:57 UTC (permalink / raw)
  To: linville; +Cc: bcm43xx-dev, linux-wireless, Andrew Price

Fix IRQ mask sanity check for physically pulled device.

Tested-by: Andrew Price <andy@andrewprice.me.uk>
Signed-off-by: Michael Buesch <mb@bu3sch.de>

---
 drivers/net/wireless/b43/main.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- wireless-testing.orig/drivers/net/wireless/b43/main.c
+++ wireless-testing/drivers/net/wireless/b43/main.c
@@ -3874,6 +3874,7 @@ static struct b43_wldev * b43_wireless_c
 {
 	struct b43_wl *wl = dev->wl;
 	struct b43_wldev *orig_dev;
+	u32 mask;
 
 redo:
 	if (!dev || b43_status(dev) < B43_STAT_STARTED)
@@ -3920,7 +3921,8 @@ redo:
 			goto redo;
 		return dev;
 	}
-	B43_WARN_ON(b43_read32(dev, B43_MMIO_GEN_IRQ_MASK));
+	mask = b43_read32(dev, B43_MMIO_GEN_IRQ_MASK);
+	B43_WARN_ON(mask != 0xFFFFFFFF && mask);
 
 	/* Drain the TX queue */
 	while (skb_queue_len(&wl->tx_queue))

-- 
Greetings, Michael.

^ permalink raw reply

* Re: [PATCH] ar9170usb: LEDs are confused
From: Joerg Albert @ 2009-10-02 22:25 UTC (permalink / raw)
  To: Malte Gell
  Cc: Christian Lamparter, linux-wireless, Luis R. Rodriguez, linville,
	Hin-Tak Leung
In-Reply-To: <200910021345.55567.malte.gell@gmx.de>

On 10/02/2009 01:45 PM, Malte Gell wrote:
> Christian Lamparter <chunkeey@googlemail.com> wrote
> 
>>> The Netgear (WN?) 111 even only has one blue LED as far as I know.
>> the question is if it's the only device with this deficit, or not?
> 
> Is it feasable to write to the well known stick makers (Netgear, AVM, 
> Belkin,Asus...) and just ask them? 

After looking into staging/otus/80211core/ledmgr.c, which has functions
zfLedCtrlType1,2,3 for:
- "Traditional single-LED state"
- "Netgear Dual-LED state"
- "Netgear Single-LED state"

(althrough they are not used there, as noone initializes wd->ledStruct.LEDCtrlType correctly)

I guess there is a way to determine the number of LED in a device from the EEPROM.
I really doubt that Netgear would built different drivers/firmwares (if they built any instead of getting them from Atheros)
for both WNDA3100 and WN111v2.

hal/hpmain.c, line 2322:
#define ZM_SEEPROM_HARDWARE_TYPE_OFFSET   (0x1374)

the value from the above address is retrieved in rsp[5] and processed in
 
hal/hprw.c, lines 601f.
        wd->ledStruct.ledMode[0] = (u16_t)(rsp[5]&0xffff);
        wd->ledStruct.ledMode[1] = (u16_t)(rsp[5]>>16);

If the bits of ledMode[] are explained in 80211/ledmgr.c, lines 34ff., Atheros provided a generic way for vendors to
program LED behaviour via the EEPROM and Netgear got some extra handling in the driver (if otus is close the windows driver).

Regards,
Joerg.

^ permalink raw reply

* Re: driver_nl80211 broken again
From: Trepak Vilmos @ 2009-10-02 21:31 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Jouni Malinen, hostap@lists.shmoo.com, linux-wireless
In-Reply-To: <1254386786.3959.18.camel@johannes.local>

Johannes Berg wrote:
> On Thu, 2009-10-01 at 01:13 +0300, Jouni Malinen wrote:
>> To me, this looks broken. When wpa_supplicant requests a
>> disassociastion, it is _only_ asking for disassociation, not
>> deauthentication. cfg80211/mac80211 may not currently handle that, but
>> as far as I can tell, it sounds like an issue there and not in
>> wpa_supplicant. Johannes may disagree with this, though.
>
> cfg80211/mac80211 _do_ handle that. If you ask for disassociation, it
> stays authenticated, and later expects you to still remember that and
> refuses authentication since you're already authenticated.
>
>> I don't think either of those options would be acceptable for
>> wpa_supplicant and the correct fix is to make cfg80211/mac80211 be able
>> to handle authentication to a STA that is already authenticated. If
>> that is not acceptable, this hack needs to be hidden in driver_nl80211.c
>> instead of polluting core wpa_supplicant code which is supposed to be
>> driver independent. In other words, make driver_nl80211.c deauth if auth
>> fails and then try auth again. I don't really like that much, but if
>> this needs to be worked around in wpa_supplicant, that is the most
>> likely place where such a change could be considered.
>
> I still don't see how it makes sense to authenticate while still being
> authenticated.

The client might have lost state info (rebooted, etc.). Let it redo the
auth if it wants to, deauth if it fails.
~will~


^ permalink raw reply

* [PATCH] [compat-2.6] Make it compile with wireless-testing master-2009-09-30
From: Hauke Mehrtens @ 2009-10-02 21:13 UTC (permalink / raw)
  To: lrodriguez; +Cc: linux-wireless, Hauke Mehrtens

DIV_ROUND_CLOSEST is needed by the b44 driver.
Most of the rest is needed because of "wext: refactor"
in wireless-testing.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 compat/compat-2.6.29.h                        |    7 +++
 compat/patches/01-netdev.patch                |   64 ++++++++++++------------
 compat/patches/03-rfkill.patch                |    2 +-
 compat/patches/08-rename-iwl4965-config.patch |    2 +-
 compat/patches/09-threaded-irq.patch          |    2 +-
 compat/patches/98-add-compat-wireless.patch   |    4 +-
 compat/patches/99-change-makefiles.patch      |   17 +++++--
 config.mk                                     |    8 +++
 8 files changed, 64 insertions(+), 42 deletions(-)

diff --git a/compat/compat-2.6.29.h b/compat/compat-2.6.29.h
index 8ea43cb..fc7d983 100644
--- a/compat/compat-2.6.29.h
+++ b/compat/compat-2.6.29.h
@@ -43,6 +43,13 @@ static inline struct sk_buff *skb_queue_prev(const struct sk_buff_head *list,
 
 extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor);
 
+#define DIV_ROUND_CLOSEST(x, divisor)(			\
+{							\
+	typeof(divisor) __divisor = divisor;		\
+	(((x) + ((__divisor) / 2)) / (__divisor));	\
+}							\
+)
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */
 
 #endif /*  LINUX_26_29_COMPAT_H */
diff --git a/compat/patches/01-netdev.patch b/compat/patches/01-netdev.patch
index 9260bfb..b2e7136 100644
--- a/compat/patches/01-netdev.patch
+++ b/compat/patches/01-netdev.patch
@@ -157,7 +157,7 @@ without creating a headache on maintenance of the pathes.
  		sdata->u.mntr_flags = MONITOR_FLAG_CONTROL |
  				      MONITOR_FLAG_OTHER_BSS;
  		break;
-@@ -770,6 +790,8 @@
+@@ -774,6 +794,8 @@
  		return -ENOMEM;
  	dev_net_set(ndev, wiphy_net(local->hw.wiphy));
  
@@ -166,7 +166,7 @@ without creating a headache on maintenance of the pathes.
  	ndev->needed_headroom = local->tx_headroom +
  				4*6 /* four MAC addresses */
  				+ 2 + 2 + 2 + 2 /* ctl, dur, seq, qos */
-@@ -778,6 +800,7 @@
+@@ -782,6 +804,7 @@
  				- ETH_HLEN /* ethernet hard_header_len */
  				+ IEEE80211_ENCRYPT_HEADROOM;
  	ndev->needed_tailroom = IEEE80211_ENCRYPT_TAILROOM;
@@ -174,7 +174,7 @@ without creating a headache on maintenance of the pathes.
  
  	ret = dev_alloc_name(ndev, ndev->name);
  	if (ret < 0)
-@@ -810,6 +833,10 @@
+@@ -815,6 +838,10 @@
  	if (ret)
  		goto fail;
  
@@ -230,31 +230,17 @@ without creating a headache on maintenance of the pathes.
  	dev->irq = sdev->irq;
  	SET_ETHTOOL_OPS(dev, &b44_ethtool_ops);
  
---- a/net/wireless/wext.c	2009-08-04 10:50:33.634995059 -0700
-+++ b/net/wireless/wext.c	2009-08-04 10:50:34.175014901 -0700
-@@ -1118,8 +1118,13 @@
- 			return private(dev, iwr, cmd, info, handler);
- 	}
- 	/* Old driver API : call driver ioctl handler */
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29))
- 	if (dev->netdev_ops->ndo_do_ioctl)
- 		return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd);
-+#else
-+	if (dev->do_ioctl)
-+		return dev->do_ioctl(dev, ifr, cmd);
-+#endif
- 	return -EOPNOTSUPP;
- }
+--- a/net/wireless/wext-core.c
++++ b/net/wireless/wext-core.c
+@@ -340,6 +340,7 @@
  
-@@ -1272,6 +1277,7 @@
- }
- #endif
+ /* IW event code */
  
 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
  static int __net_init wext_pernet_init(struct net *net)
  {
  	skb_queue_head_init(&net->wext_nlevents);
-@@ -1314,6 +1320,29 @@
+@@ -382,6 +383,29 @@
  
  static DECLARE_WORK(wireless_nlevent_work, wireless_nlevent_process);
  
@@ -284,7 +270,7 @@ without creating a headache on maintenance of the pathes.
  static struct nlmsghdr *rtnetlink_ifinfo_prep(struct net_device *dev,
  					      struct sk_buff *skb)
  {
-@@ -1524,8 +1553,13 @@
+@@ -592,8 +616,13 @@
  
  	skb_shinfo(skb)->frag_list = compskb;
  #endif
@@ -298,6 +284,20 @@ without creating a headache on maintenance of the pathes.
  }
  EXPORT_SYMBOL(wireless_send_event);
  
+@@ -901,8 +930,13 @@
+ 			return private(dev, iwr, cmd, info, handler);
+ 	}
+ 	/* Old driver API : call driver ioctl handler */
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29))
+ 	if (dev->netdev_ops->ndo_do_ioctl)
+ 		return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd);
++#else
++	if (dev->do_ioctl)
++		return dev->do_ioctl(dev, ifr, cmd);
++#endif
+ 	return -EOPNOTSUPP;
+ }
+ 
 --- a/drivers/net/wireless/ipw2x00/ipw2100.c	2009-09-02 14:12:00.958117808 -0700
 +++ b/drivers/net/wireless/ipw2x00/ipw2100.c	2009-09-02 14:12:01.382115761 -0700
 @@ -6008,6 +6008,7 @@
@@ -335,7 +335,7 @@ without creating a headache on maintenance of the pathes.
  	priv->wireless_data.libipw = priv->ieee;
 --- a/drivers/net/wireless/ipw2x00/ipw2200.c	2009-08-20 13:47:07.311291621 -0700
 +++ b/drivers/net/wireless/ipw2x00/ipw2200.c	2009-08-20 13:47:07.783268230 -0700
-@@ -11623,6 +11623,7 @@
+@@ -11624,6 +11624,7 @@
  	return NETDEV_TX_OK;
  }
  
@@ -343,7 +343,7 @@ without creating a headache on maintenance of the pathes.
  static const struct net_device_ops ipw_prom_netdev_ops = {
  	.ndo_open 		= ipw_prom_open,
  	.ndo_stop		= ipw_prom_stop,
-@@ -11631,6 +11632,7 @@
+@@ -11632,6 +11633,7 @@
  	.ndo_set_mac_address 	= eth_mac_addr,
  	.ndo_validate_addr	= eth_validate_addr,
  };
@@ -351,7 +351,7 @@ without creating a headache on maintenance of the pathes.
  
  static int ipw_prom_alloc(struct ipw_priv *priv)
  {
-@@ -11651,7 +11653,13 @@
+@@ -11652,7 +11654,13 @@
  	memcpy(priv->prom_net_dev->dev_addr, priv->mac_addr, ETH_ALEN);
  
  	priv->prom_net_dev->type = ARPHRD_IEEE80211_RADIOTAP;
@@ -365,7 +365,7 @@ without creating a headache on maintenance of the pathes.
  
  	priv->prom_priv->ieee->iw_mode = IW_MODE_MONITOR;
  	SET_NETDEV_DEV(priv->prom_net_dev, &priv->pci_dev->dev);
-@@ -11679,6 +11687,7 @@
+@@ -11680,6 +11688,7 @@
  
  #endif
  
@@ -373,7 +373,7 @@ without creating a headache on maintenance of the pathes.
  static const struct net_device_ops ipw_netdev_ops = {
  	.ndo_init		= ipw_net_init,
  	.ndo_open		= ipw_net_open,
-@@ -11689,6 +11698,7 @@
+@@ -11690,6 +11699,7 @@
  	.ndo_change_mtu		= libipw_change_mtu,
  	.ndo_validate_addr	= eth_validate_addr,
  };
@@ -381,7 +381,7 @@ without creating a headache on maintenance of the pathes.
  
  static int __devinit ipw_pci_probe(struct pci_dev *pdev,
  				   const struct pci_device_id *ent)
-@@ -11790,7 +11800,15 @@
+@@ -11791,7 +11801,15 @@
  	priv->ieee->perfect_rssi = -20;
  	priv->ieee->worst_rssi = -85;
  
@@ -464,7 +464,7 @@ without creating a headache on maintenance of the pathes.
  	mesh_dev->ethtool_ops = &lbs_ethtool_ops;
  	memcpy(mesh_dev->dev_addr, priv->dev->dev_addr,
  			sizeof(priv->dev->dev_addr));
-@@ -1665,11 +1686,13 @@
+@@ -1666,11 +1687,13 @@
  	lbs_deb_leave(LBS_DEB_MAIN);
  }
  
@@ -478,7 +478,7 @@ without creating a headache on maintenance of the pathes.
  
  static int lbs_add_rtap(struct lbs_private *priv)
  {
-@@ -1690,7 +1713,13 @@
+@@ -1691,7 +1714,13 @@
  
  	memcpy(rtap_dev->dev_addr, priv->current_addr, ETH_ALEN);
  	rtap_dev->type = ARPHRD_IEEE80211_RADIOTAP;
@@ -511,7 +511,7 @@ without creating a headache on maintenance of the pathes.
  #define LBS_DEB_LEAVE	0x00000002
 --- a/drivers/net/wireless/mac80211_hwsim.c	2009-08-18 16:18:52.829350750 -0700
 +++ b/drivers/net/wireless/mac80211_hwsim.c	2009-08-18 16:18:52.977352457 -0700
-@@ -812,16 +812,22 @@
+@@ -816,16 +816,22 @@
  	.name = "mac80211_hwsim"
  };
  
diff --git a/compat/patches/03-rfkill.patch b/compat/patches/03-rfkill.patch
index dadcb9a..cfd07ca 100644
--- a/compat/patches/03-rfkill.patch
+++ b/compat/patches/03-rfkill.patch
@@ -208,7 +208,7 @@ This would do the policing from within mac80211.
  #include <net/cfg80211.h>
 --- a/drivers/net/wireless/ath/ath9k/hw.c	2009-09-23 10:28:55.875708257 -0700
 +++ b/drivers/net/wireless/ath/ath9k/hw.c	2009-09-23 10:28:56.211707588 -0700
-@@ -3688,7 +3688,7 @@
+@@ -3666,7 +3666,7 @@
  
  	pCap->hw_caps |= ATH9K_HW_CAP_ENHANCEDPM;
  
diff --git a/compat/patches/08-rename-iwl4965-config.patch b/compat/patches/08-rename-iwl4965-config.patch
index c6191f8..75ffbab 100644
--- a/compat/patches/08-rename-iwl4965-config.patch
+++ b/compat/patches/08-rename-iwl4965-config.patch
@@ -16,7 +16,7 @@ CONFIG_IWL4965 has to be set to y, to build correctly.
  iwlagn-$(CONFIG_IWL5000) += iwl-1000.o
 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c	2009-09-02 14:16:08.061113710 -0700
 +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c	2009-09-02 14:16:08.949100601 -0700
-@@ -3008,10 +3008,10 @@
+@@ -3236,10 +3236,10 @@
  
  /* Hardware specific file defines the PCI IDs table for that hardware module */
  static struct pci_device_id iwl_hw_card_ids[] = {
diff --git a/compat/patches/09-threaded-irq.patch b/compat/patches/09-threaded-irq.patch
index 4b9a361..4a23389 100644
--- a/compat/patches/09-threaded-irq.patch
+++ b/compat/patches/09-threaded-irq.patch
@@ -38,7 +38,7 @@ thread in process context as well.
  		if (err) {
  			b43err(dev->wl, "Cannot request IRQ-%d\n", dev->dev->irq);
  			goto out;
-@@ -4656,6 +4669,10 @@ static int b43_setup_bands(struct b43_wl
+@@ -4658,6 +4671,10 @@ static int b43_setup_bands(struct b43_wl
  
  static void b43_wireless_core_detach(struct b43_wldev *dev)
  {
diff --git a/compat/patches/98-add-compat-wireless.patch b/compat/patches/98-add-compat-wireless.patch
index eb83d40..e78c63f 100644
--- a/compat/patches/98-add-compat-wireless.patch
+++ b/compat/patches/98-add-compat-wireless.patch
@@ -20,8 +20,8 @@ added compat.h also for ssb, I forget.
 
 --- a/net/wireless/Makefile	2009-08-07 12:27:50.836497001 -0700
 +++ b/net/wireless/Makefile	2009-08-07 12:27:51.952497240 -0700
-@@ -11,3 +11,16 @@
- cfg80211-$(CONFIG_WIRELESS_EXT) += wext-compat.o wext-sme.o
+@@ -15,3 +15,16 @@
+ cfg80211-$(CONFIG_CFG80211_WEXT) += wext-compat.o wext-sme.o
  
  ccflags-y += -D__CHECK_ENDIAN__
 +# Compat-wireless kernel compatibility code
diff --git a/compat/patches/99-change-makefiles.patch b/compat/patches/99-change-makefiles.patch
index b5a0f10..e32f539 100644
--- a/compat/patches/99-change-makefiles.patch
+++ b/compat/patches/99-change-makefiles.patch
@@ -86,8 +86,15 @@ only the wireless stuff.
  obj-$(CONFIG_LIBERTAS_THINFIRM)	+= libertas_tf/
 --- a/net/wireless/Makefile
 +++ b/net/wireless/Makefile
-@@ -1,4 +1,3 @@
--obj-$(CONFIG_WIRELESS_EXT) += wext.o
- obj-$(CONFIG_CFG80211) += cfg80211.o
- obj-$(CONFIG_LIB80211) += lib80211.o
- obj-$(CONFIG_LIB80211_CRYPT_WEP) += lib80211_crypt_wep.o
+@@ -4,11 +4,6 @@
+ obj-$(CONFIG_LIB80211_CRYPT_CCMP) += lib80211_crypt_ccmp.o
+ obj-$(CONFIG_LIB80211_CRYPT_TKIP) += lib80211_crypt_tkip.o
+ 
+-obj-$(CONFIG_WEXT_CORE) += wext-core.o
+-obj-$(CONFIG_WEXT_PROC) += wext-proc.o
+-obj-$(CONFIG_WEXT_SPY) += wext-spy.o
+-obj-$(CONFIG_WEXT_PRIV) += wext-priv.o
+-
+ cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o
+ cfg80211-y += mlme.o ibss.o sme.o chan.o
+ cfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o
diff --git a/config.mk b/config.mk
index b482b68..9985687 100644
--- a/config.mk
+++ b/config.mk
@@ -119,6 +119,14 @@ CONFIG_LIB80211_CRYPT_TKIP=m
 
 CONFIG_WIRELESS_OLD_REGULATORY=n
 
+ifneq ($(CONFIG_WIRELESS_EXT),)
+CONFIG_WEXT_CORE=m
+CONFIG_WEXT_PROC=m
+CONFIG_WEXT_SPY=m
+CONFIG_WEXT_PRIV=m
+CONFIG_CFG80211_WEXT=y
+endif
+
 # mac80211 test driver
 CONFIG_MAC80211_HWSIM=m
 
-- 
1.6.2.1


^ permalink raw reply related

* Re: [PATCH 02/13] iwlwifi: fix EEPROM enhance tx power offset
From: reinette chatre @ 2009-10-02 20:59 UTC (permalink / raw)
  To: linville@tuxdriver.com
  Cc: linux-wireless@vger.kernel.org,
	ipw3945-devel@lists.sourceforge.net, Guy, Wey-Yi W
In-Reply-To: <1254516247-4085-3-git-send-email-reinette.chatre@intel.com>

John,

I neglected to mark this patch subject with v2.6.32 - could you please
take this patch for 2.6.32 also?

Thank you very much

Reinette


On Fri, 2009-10-02 at 13:43 -0700, Chatre, Reinette wrote:
> From: Wey-Yi Guy <wey-yi.w.guy@intel.com>
> 
> Set the correct EEPROM offset for enhance tx power for 6000 series
> 
> Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
> ---
>  drivers/net/wireless/iwlwifi/iwl-eeprom.h |   20 ++++++++++----------
>  1 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
> index 75fe022..3bcd600 100644
> --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
> +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
> @@ -220,35 +220,35 @@ struct iwl_eeprom_enhanced_txpwr {
>   * Section 10: 2.4 GHz 40MHz channels: 132, 44 (_above_)
>   */
>  /* 2.4 GHz band: CCK */
> -#define EEPROM_LB_CCK_20_COMMON       ((0xAA)\
> +#define EEPROM_LB_CCK_20_COMMON       ((0xA8)\
>  		| INDIRECT_ADDRESS | INDIRECT_REGULATORY)   /* 8 bytes */
>  /* 2.4 GHz band: 20MHz-Legacy, 20MHz-HT, 40MHz-HT */
> -#define EEPROM_LB_OFDM_COMMON       ((0xB2)\
> +#define EEPROM_LB_OFDM_COMMON       ((0xB0)\
>  		| INDIRECT_ADDRESS | INDIRECT_REGULATORY)   /* 24 bytes */
>  /* 5.2 GHz band: 20MHz-Legacy, 20MHz-HT, 40MHz-HT */
> -#define EEPROM_HB_OFDM_COMMON       ((0xCA)\
> +#define EEPROM_HB_OFDM_COMMON       ((0xC8)\
>  		| INDIRECT_ADDRESS | INDIRECT_REGULATORY)   /* 24 bytes */
>  /* 2.4GHz band channels:
>   *	1Legacy, 1HT, 2Legacy, 2HT, 10Legacy, 10HT, 11Legacy, 11HT */
> -#define EEPROM_LB_OFDM_20_BAND       ((0xE2)\
> +#define EEPROM_LB_OFDM_20_BAND       ((0xE0)\
>  		| INDIRECT_ADDRESS | INDIRECT_REGULATORY)   /* 64 bytes */
>  /* 2.4 GHz band HT40 channels: (1,+1) (2,+1) (6,+1) (7,+1) (9,+1) */
> -#define EEPROM_LB_OFDM_HT40_BAND       ((0x122)\
> +#define EEPROM_LB_OFDM_HT40_BAND       ((0x120)\
>  		| INDIRECT_ADDRESS | INDIRECT_REGULATORY)   /* 40 bytes */
>  /* 5.2GHz band channels: 36Legacy, 36HT, 64Legacy, 64HT, 100Legacy, 100HT */
> -#define EEPROM_HB_OFDM_20_BAND       ((0x14A)\
> +#define EEPROM_HB_OFDM_20_BAND       ((0x148)\
>  		| INDIRECT_ADDRESS | INDIRECT_REGULATORY)   /* 48 bytes */
>  /* 5.2 GHz band HT40 channels: (36,+1) (60,+1) (100,+1) */
> -#define EEPROM_HB_OFDM_HT40_BAND       ((0x17A)\
> +#define EEPROM_HB_OFDM_HT40_BAND       ((0x178)\
>  		| INDIRECT_ADDRESS | INDIRECT_REGULATORY)   /* 24 bytes */
>  /* 2.4 GHz band, channnel 13: Legacy, HT */
> -#define EEPROM_LB_OFDM_20_CHANNEL_13       ((0x192)\
> +#define EEPROM_LB_OFDM_20_CHANNEL_13       ((0x190)\
>  		| INDIRECT_ADDRESS | INDIRECT_REGULATORY)   /* 16 bytes */
>  /* 5.2 GHz band, channnel 140: Legacy, HT */
> -#define EEPROM_HB_OFDM_20_CHANNEL_140       ((0x1A2)\
> +#define EEPROM_HB_OFDM_20_CHANNEL_140       ((0x1A0)\
>  		| INDIRECT_ADDRESS | INDIRECT_REGULATORY)   /* 16 bytes */
>  /* 5.2 GHz band, HT40 channnels (132,+1) (44,+1) */
> -#define EEPROM_HB_OFDM_HT40_BAND_1       ((0x1B2)\
> +#define EEPROM_HB_OFDM_HT40_BAND_1       ((0x1B0)\
>  		| INDIRECT_ADDRESS | INDIRECT_REGULATORY)   /* 16 bytes */
>  
> 


^ permalink raw reply

* [PATCH 09/13] iwlwifi: LED cleanup
From: Reinette Chatre @ 2009-10-02 20:44 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, ipw3945-devel, Johannes Berg, Reinette Chatre
In-Reply-To: <1254516247-4085-1-git-send-email-reinette.chatre@intel.com>

From: Johannes Berg <johannes@sipsolutions.net>

The iwlwifi drivers have LED blinking requirements that
mac80211 cannot fulfill due to the use of just a single
LED instead of different ones for TX, RX, radio etc.
Instead, the single LED blinks according to transfers
and is solid on the rest of the time. As such, having
LED class devices registered that mac80211 triggers are
connected to is pointless as we don't use the triggers
anyway.

Remove all the useless code and add hooks into the
driver itself. At the same time, make the LED code
abstracted so the core code that determines blink rate
etc. can be shared between 3945 and agn in iwlcore.

At the same time, the fact that we removed the use of
the mac80211 LED triggers means we can also remove the
IWLWIFI_LEDS Kconfig symbol since the LED support is
now self-contained.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
 drivers/net/wireless/iwlwifi/Kconfig        |    9 -
 drivers/net/wireless/iwlwifi/Makefile       |    5 +-
 drivers/net/wireless/iwlwifi/iwl-1000.c     |    2 +
 drivers/net/wireless/iwlwifi/iwl-3945-led.c |  371 ++-------------------------
 drivers/net/wireless/iwlwifi/iwl-3945-led.h |   22 +--
 drivers/net/wireless/iwlwifi/iwl-3945.c     |   10 +-
 drivers/net/wireless/iwlwifi/iwl-3945.h     |    2 +-
 drivers/net/wireless/iwlwifi/iwl-4965.c     |    2 +
 drivers/net/wireless/iwlwifi/iwl-5000.c     |    5 +-
 drivers/net/wireless/iwlwifi/iwl-6000.c     |    2 +
 drivers/net/wireless/iwlwifi/iwl-agn-led.c  |   85 ++++++
 drivers/net/wireless/iwlwifi/iwl-agn-led.h  |   32 +++
 drivers/net/wireless/iwlwifi/iwl-agn.c      |    6 +-
 drivers/net/wireless/iwlwifi/iwl-core.c     |    7 +-
 drivers/net/wireless/iwlwifi/iwl-core.h     |    7 +
 drivers/net/wireless/iwlwifi/iwl-debug.h    |    2 -
 drivers/net/wireless/iwlwifi/iwl-debugfs.c  |    8 -
 drivers/net/wireless/iwlwifi/iwl-dev.h      |    7 +-
 drivers/net/wireless/iwlwifi/iwl-led.c      |  285 ++-------------------
 drivers/net/wireless/iwlwifi/iwl-led.h      |   38 +---
 drivers/net/wireless/iwlwifi/iwl3945-base.c |    8 +-
 21 files changed, 194 insertions(+), 721 deletions(-)
 create mode 100644 drivers/net/wireless/iwlwifi/iwl-agn-led.c
 create mode 100644 drivers/net/wireless/iwlwifi/iwl-agn-led.h

diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig
index 48d8f2c..c82c97b 100644
--- a/drivers/net/wireless/iwlwifi/Kconfig
+++ b/drivers/net/wireless/iwlwifi/Kconfig
@@ -2,15 +2,6 @@ config IWLWIFI
 	tristate "Intel Wireless Wifi"
 	depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL
 	select FW_LOADER
-	select MAC80211_LEDS if IWLWIFI_LEDS
-	select LEDS_CLASS if IWLWIFI_LEDS
-
-config IWLWIFI_LEDS
-	bool "Enable LED support in iwlagn and iwl3945 drivers"
-	depends on IWLWIFI
-	default y
-	---help---
-	  Select this if you want LED support.
 
 config IWLWIFI_SPECTRUM_MEASUREMENT
 	bool "Enable Spectrum Measurement in iwlagn driver"
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index 3f31d86..7f82044 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -1,9 +1,8 @@
 obj-$(CONFIG_IWLWIFI)	+= iwlcore.o
 iwlcore-objs 		:= iwl-core.o iwl-eeprom.o iwl-hcmd.o iwl-power.o
 iwlcore-objs 		+= iwl-rx.o iwl-tx.o iwl-sta.o iwl-calib.o
-iwlcore-objs 		+= iwl-scan.o
+iwlcore-objs 		+= iwl-scan.o iwl-led.o
 iwlcore-$(CONFIG_IWLWIFI_DEBUGFS) += iwl-debugfs.o
-iwlcore-$(CONFIG_IWLWIFI_LEDS) += iwl-led.o
 iwlcore-$(CONFIG_IWLWIFI_SPECTRUM_MEASUREMENT) += iwl-spectrum.o
 iwlcore-$(CONFIG_IWLWIFI_DEVICE_TRACING) += iwl-devtrace.o
 
@@ -11,7 +10,7 @@ CFLAGS_iwl-devtrace.o := -I$(src)
 
 # AGN
 obj-$(CONFIG_IWLAGN)	+= iwlagn.o
-iwlagn-objs		:= iwl-agn.o iwl-agn-rs.o
+iwlagn-objs		:= iwl-agn.o iwl-agn-rs.o iwl-agn-led.o
 
 iwlagn-$(CONFIG_IWL4965) += iwl-4965.o
 iwlagn-$(CONFIG_IWL5000) += iwl-5000.o
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index af91dba..86d93b5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -44,6 +44,7 @@
 #include "iwl-sta.h"
 #include "iwl-helpers.h"
 #include "iwl-5000-hw.h"
+#include "iwl-agn-led.h"
 
 /* Highest firmware API version supported */
 #define IWL1000_UCODE_API_MAX 3
@@ -145,6 +146,7 @@ static struct iwl_ops iwl1000_ops = {
 	.lib = &iwl1000_lib,
 	.hcmd = &iwl5000_hcmd,
 	.utils = &iwl5000_hcmd_utils,
+	.led = &iwlagn_led_ops,
 };
 
 struct iwl_cfg iwl1000_bgn_cfg = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-led.c b/drivers/net/wireless/iwlwifi/iwl-3945-led.c
index 8c29ded..a871d09 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-led.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-led.c
@@ -24,8 +24,6 @@
  *
  *****************************************************************************/
 
-#ifdef CONFIG_IWLWIFI_LEDS
-
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -43,388 +41,51 @@
 #include "iwl-3945.h"
 #include "iwl-core.h"
 #include "iwl-dev.h"
+#include "iwl-3945-led.h"
 
-#ifdef CONFIG_IWLWIFI_DEBUG
-static const char *led_type_str[] = {
-	__stringify(IWL_LED_TRG_TX),
-	__stringify(IWL_LED_TRG_RX),
-	__stringify(IWL_LED_TRG_ASSOC),
-	__stringify(IWL_LED_TRG_RADIO),
-	NULL
-};
-#endif /* CONFIG_IWLWIFI_DEBUG */
-
-static const struct {
-	u16 brightness;
-	u8 on_time;
-	u8 off_time;
-} blink_tbl[] =
-{
-	{300, 25, 25},
-	{200, 40, 40},
-	{100, 55, 55},
-	{70, 65, 65},
-	{50, 75, 75},
-	{20, 85, 85},
-	{15, 95, 95 },
-	{10, 110, 110},
-	{5, 130, 130},
-	{0, 167, 167},
-	/* SOLID_ON */
-	{-1, IWL_LED_SOLID, 0}
-};
-
-#define IWL_1MB_RATE (128 * 1024)
-#define IWL_LED_THRESHOLD (16)
-#define IWL_MAX_BLINK_TBL (ARRAY_SIZE(blink_tbl) - 1) /*Exclude Solid on*/
-#define IWL_SOLID_BLINK_IDX (ARRAY_SIZE(blink_tbl) - 1)
-
-static void iwl3945_led_cmd_callback(struct iwl_priv *priv,
-				     struct iwl_device_cmd *cmd,
-				     struct sk_buff *skb)
-{
-}
-
-static inline int iwl3945_brightness_to_idx(enum led_brightness brightness)
-{
-	return fls(0x000000FF & (u32)brightness);
-}
 
 /* Send led command */
-static int iwl_send_led_cmd(struct iwl_priv *priv,
-			    struct iwl_led_cmd *led_cmd)
+static int iwl3945_send_led_cmd(struct iwl_priv *priv,
+				struct iwl_led_cmd *led_cmd)
 {
 	struct iwl_host_cmd cmd = {
 		.id = REPLY_LEDS_CMD,
 		.len = sizeof(struct iwl_led_cmd),
 		.data = led_cmd,
 		.flags = CMD_ASYNC,
-		.callback = iwl3945_led_cmd_callback,
+		.callback = NULL,
 	};
 
 	return iwl_send_cmd(priv, &cmd);
 }
 
-
-
-/* Set led on command */
-static int iwl3945_led_pattern(struct iwl_priv *priv, int led_id,
-			       unsigned int idx)
-{
-	struct iwl_led_cmd led_cmd = {
-		.id = led_id,
-		.interval = IWL_DEF_LED_INTRVL
-	};
-
-	BUG_ON(idx > IWL_MAX_BLINK_TBL);
-
-	led_cmd.on = blink_tbl[idx].on_time;
-	led_cmd.off = blink_tbl[idx].off_time;
-
-	return iwl_send_led_cmd(priv, &led_cmd);
-}
-
-
 /* Set led on command */
-static int iwl3945_led_on(struct iwl_priv *priv, int led_id)
+static int iwl3945_led_on(struct iwl_priv *priv)
 {
 	struct iwl_led_cmd led_cmd = {
-		.id = led_id,
+		.id = IWL_LED_LINK,
 		.on = IWL_LED_SOLID,
 		.off = 0,
 		.interval = IWL_DEF_LED_INTRVL
 	};
-	return iwl_send_led_cmd(priv, &led_cmd);
+	return iwl3945_send_led_cmd(priv, &led_cmd);
 }
 
 /* Set led off command */
-static int iwl3945_led_off(struct iwl_priv *priv, int led_id)
+static int iwl3945_led_off(struct iwl_priv *priv)
 {
 	struct iwl_led_cmd led_cmd = {
-		.id = led_id,
+		.id = IWL_LED_LINK,
 		.on = 0,
 		.off = 0,
 		.interval = IWL_DEF_LED_INTRVL
 	};
-	IWL_DEBUG_LED(priv, "led off %d\n", led_id);
-	return iwl_send_led_cmd(priv, &led_cmd);
+	IWL_DEBUG_LED(priv, "led off\n");
+	return iwl3945_send_led_cmd(priv, &led_cmd);
 }
 
-/*
- *  Set led on in case of association
- *  */
-static int iwl3945_led_associate(struct iwl_priv *priv, int led_id)
-{
-	IWL_DEBUG_LED(priv, "Associated\n");
-
-	priv->allow_blinking = 1;
-	return iwl3945_led_on(priv, led_id);
-}
-/* Set Led off in case of disassociation */
-static int iwl3945_led_disassociate(struct iwl_priv *priv, int led_id)
-{
-	IWL_DEBUG_LED(priv, "Disassociated\n");
-
-	priv->allow_blinking = 0;
-
-	return 0;
-}
-
-/*
- * brightness call back function for Tx/Rx LED
- */
-static int iwl3945_led_associated(struct iwl_priv *priv, int led_id)
-{
-	if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
-	    !test_bit(STATUS_READY, &priv->status))
-		return 0;
-
-
-	/* start counting Tx/Rx bytes */
-	if (!priv->last_blink_time && priv->allow_blinking)
-		priv->last_blink_time = jiffies;
-	return 0;
-}
-
-/*
- * brightness call back for association and radio
- */
-static void iwl3945_led_brightness_set(struct led_classdev *led_cdev,
-				enum led_brightness brightness)
-{
-	struct iwl_led *led = container_of(led_cdev,
-					   struct iwl_led, led_dev);
-	struct iwl_priv *priv = led->priv;
-
-	if (test_bit(STATUS_EXIT_PENDING, &priv->status))
-		return;
-
-	IWL_DEBUG_LED(priv, "Led type = %s brightness = %d\n",
-			led_type_str[led->type], brightness);
-
-	switch (brightness) {
-	case LED_FULL:
-		if (led->led_on)
-			led->led_on(priv, IWL_LED_LINK);
-		break;
-	case LED_OFF:
-		if (led->led_off)
-			led->led_off(priv, IWL_LED_LINK);
-		break;
-	default:
-		if (led->led_pattern) {
-			int idx = iwl3945_brightness_to_idx(brightness);
-			led->led_pattern(priv, IWL_LED_LINK, idx);
-		}
-		break;
-	}
-}
-
-/*
- * Register led class with the system
- */
-static int iwl3945_led_register_led(struct iwl_priv *priv,
-				   struct iwl_led *led,
-				   enum led_type type, u8 set_led,
-				   char *trigger)
-{
-	struct device *device = wiphy_dev(priv->hw->wiphy);
-	int ret;
-
-	led->led_dev.name = led->name;
-	led->led_dev.brightness_set = iwl3945_led_brightness_set;
-	led->led_dev.default_trigger = trigger;
-
-	led->priv = priv;
-	led->type = type;
-
-	ret = led_classdev_register(device, &led->led_dev);
-	if (ret) {
-		IWL_ERR(priv, "Error: failed to register led handler.\n");
-		return ret;
-	}
-
-	led->registered = 1;
-
-	if (set_led && led->led_on)
-		led->led_on(priv, IWL_LED_LINK);
-	return 0;
-}
-
-
-/*
- * calculate blink rate according to last 2 sec Tx/Rx activities
- */
-static inline u8 get_blink_rate(struct iwl_priv *priv)
-{
-	int index;
-	s64 tpt = priv->rxtxpackets;
-
-	if (tpt < 0)
-		tpt = -tpt;
-
-	IWL_DEBUG_LED(priv, "tpt %lld \n", (long long)tpt);
-
-	if (!priv->allow_blinking)
-		index = IWL_MAX_BLINK_TBL;
-	else
-		for (index = 0; index < IWL_MAX_BLINK_TBL; index++)
-			if (tpt > (blink_tbl[index].brightness * IWL_1MB_RATE))
-				break;
-
-	IWL_DEBUG_LED(priv, "LED BLINK IDX=%d\n", index);
-	return index;
-}
-
-/*
- * this function called from handler. Since setting Led command can
- * happen very frequent we postpone led command to be called from
- * REPLY handler so we know ucode is up
- */
-void iwl3945_led_background(struct iwl_priv *priv)
-{
-	u8 blink_idx;
-
-	if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
-		priv->last_blink_time = 0;
-		return;
-	}
-	if (iwl_is_rfkill(priv)) {
-		priv->last_blink_time = 0;
-		return;
-	}
-
-	if (!priv->allow_blinking) {
-		priv->last_blink_time = 0;
-		if (priv->last_blink_rate != IWL_SOLID_BLINK_IDX) {
-			priv->last_blink_rate = IWL_SOLID_BLINK_IDX;
-			iwl3945_led_pattern(priv, IWL_LED_LINK,
-					    IWL_SOLID_BLINK_IDX);
-		}
-		return;
-	}
-	if (!priv->last_blink_time ||
-	    !time_after(jiffies, priv->last_blink_time +
-			msecs_to_jiffies(1000)))
-		return;
-
-	blink_idx = get_blink_rate(priv);
-
-	/* call only if blink rate change */
-	if (blink_idx != priv->last_blink_rate)
-		iwl3945_led_pattern(priv, IWL_LED_LINK, blink_idx);
-
-	priv->last_blink_time = jiffies;
-	priv->last_blink_rate = blink_idx;
-	priv->rxtxpackets = 0;
-}
-
-
-/* Register all led handler */
-int iwl3945_led_register(struct iwl_priv *priv)
-{
-	char *trigger;
-	int ret;
-
-	priv->last_blink_rate = 0;
-	priv->rxtxpackets = 0;
-	priv->led_tpt = 0;
-	priv->last_blink_time = 0;
-	priv->allow_blinking = 0;
-
-	trigger = ieee80211_get_radio_led_name(priv->hw);
-	snprintf(priv->led[IWL_LED_TRG_RADIO].name,
-		 sizeof(priv->led[IWL_LED_TRG_RADIO].name), "iwl-%s::radio",
-		 wiphy_name(priv->hw->wiphy));
-
-	priv->led[IWL_LED_TRG_RADIO].led_on = iwl3945_led_on;
-	priv->led[IWL_LED_TRG_RADIO].led_off = iwl3945_led_off;
-	priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL;
-
-	ret = iwl3945_led_register_led(priv,
-				   &priv->led[IWL_LED_TRG_RADIO],
-				   IWL_LED_TRG_RADIO, 1, trigger);
-
-	if (ret)
-		goto exit_fail;
-
-	trigger = ieee80211_get_assoc_led_name(priv->hw);
-	snprintf(priv->led[IWL_LED_TRG_ASSOC].name,
-		 sizeof(priv->led[IWL_LED_TRG_ASSOC].name), "iwl-%s::assoc",
-		 wiphy_name(priv->hw->wiphy));
-
-	ret = iwl3945_led_register_led(priv,
-				   &priv->led[IWL_LED_TRG_ASSOC],
-				   IWL_LED_TRG_ASSOC, 0, trigger);
-
-	/* for assoc always turn led on */
-	priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_associate;
-	priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_disassociate;
-	priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL;
-
-	if (ret)
-		goto exit_fail;
-
-	trigger = ieee80211_get_rx_led_name(priv->hw);
-	snprintf(priv->led[IWL_LED_TRG_RX].name,
-		 sizeof(priv->led[IWL_LED_TRG_RX].name), "iwl-%s::RX",
-		 wiphy_name(priv->hw->wiphy));
-
-	ret = iwl3945_led_register_led(priv,
-				   &priv->led[IWL_LED_TRG_RX],
-				   IWL_LED_TRG_RX, 0, trigger);
-
-	priv->led[IWL_LED_TRG_RX].led_on = iwl3945_led_associated;
-	priv->led[IWL_LED_TRG_RX].led_off = iwl3945_led_associated;
-	priv->led[IWL_LED_TRG_RX].led_pattern = iwl3945_led_pattern;
-
-	if (ret)
-		goto exit_fail;
-
-	trigger = ieee80211_get_tx_led_name(priv->hw);
-	snprintf(priv->led[IWL_LED_TRG_TX].name,
-		 sizeof(priv->led[IWL_LED_TRG_TX].name), "iwl-%s::TX",
-		 wiphy_name(priv->hw->wiphy));
-
-	ret = iwl3945_led_register_led(priv,
-				   &priv->led[IWL_LED_TRG_TX],
-				   IWL_LED_TRG_TX, 0, trigger);
-
-	priv->led[IWL_LED_TRG_TX].led_on = iwl3945_led_associated;
-	priv->led[IWL_LED_TRG_TX].led_off = iwl3945_led_associated;
-	priv->led[IWL_LED_TRG_TX].led_pattern = iwl3945_led_pattern;
-
-	if (ret)
-		goto exit_fail;
-
-	return 0;
-
-exit_fail:
-	iwl3945_led_unregister(priv);
-	return ret;
-}
-
-
-/* unregister led class */
-static void iwl3945_led_unregister_led(struct iwl_led *led, u8 set_led)
-{
-	if (!led->registered)
-		return;
-
-	led_classdev_unregister(&led->led_dev);
-
-	if (set_led)
-		led->led_dev.brightness_set(&led->led_dev, LED_OFF);
-	led->registered = 0;
-}
-
-/* Unregister all led handlers */
-void iwl3945_led_unregister(struct iwl_priv *priv)
-{
-	iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_ASSOC], 0);
-	iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_RX], 0);
-	iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_TX], 0);
-	iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_RADIO], 1);
-}
-
-#endif
+const struct iwl_led_ops iwl3945_led_ops = {
+	.cmd = iwl3945_send_led_cmd,
+	.on = iwl3945_led_on,
+	.off = iwl3945_led_off,
+};
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-led.h b/drivers/net/wireless/iwlwifi/iwl-3945-led.h
index 3b65642..5a1033c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-led.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-led.h
@@ -24,23 +24,9 @@
  *
  *****************************************************************************/
 
-#ifndef IWL3945_LEDS_H
-#define IWL3945_LEDS_H
+#ifndef __iwl_3945_led_h__
+#define __iwl_3945_led_h__
 
-struct iwl_priv;
+extern const struct iwl_led_ops iwl3945_led_ops;
 
-#ifdef CONFIG_IWLWIFI_LEDS
-
-#include "iwl-led.h"
-
-extern int iwl3945_led_register(struct iwl_priv *priv);
-extern void iwl3945_led_unregister(struct iwl_priv *priv);
-extern void iwl3945_led_background(struct iwl_priv *priv);
-
-#else
-static inline int iwl3945_led_register(struct iwl_priv *priv) { return 0; }
-static inline void iwl3945_led_unregister(struct iwl_priv *priv) {}
-static inline void iwl3945_led_background(struct iwl_priv *priv) {}
-
-#endif /* IWLWIFI_LEDS*/
-#endif /* IWL3945_LEDS_H */
+#endif /* __iwl_3945_led_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 7bf447e..8cc0dfc 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -46,7 +46,8 @@
 #include "iwl-eeprom.h"
 #include "iwl-helpers.h"
 #include "iwl-core.h"
-#include "iwl-agn-rs.h"
+#include "iwl-led.h"
+#include "iwl-3945-led.h"
 
 #define IWL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np)    \
 	[IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP,   \
@@ -359,7 +360,7 @@ void iwl3945_hw_rx_statistics(struct iwl_priv *priv,
 
 	memcpy(&priv->statistics_39, pkt->u.raw, sizeof(priv->statistics_39));
 
-	iwl3945_led_background(priv);
+	iwl_leds_background(priv);
 
 	priv->last_statistics_time = jiffies;
 }
@@ -572,10 +573,6 @@ static void iwl3945_pass_packet_to_mac80211(struct iwl_priv *priv,
 				       (struct ieee80211_hdr *)rxb->skb->data,
 				       le32_to_cpu(rx_end->status), stats);
 
-#ifdef CONFIG_IWLWIFI_LEDS
-	if (ieee80211_is_data(hdr->frame_control))
-		priv->rxtxpackets += len;
-#endif
 	iwl_update_stats(priv, false, hdr->frame_control, len);
 
 	memcpy(IEEE80211_SKB_RXCB(rxb->skb), stats, sizeof(*stats));
@@ -2880,6 +2877,7 @@ static struct iwl_ops iwl3945_ops = {
 	.lib = &iwl3945_lib,
 	.hcmd = &iwl3945_hcmd,
 	.utils = &iwl3945_hcmd_utils,
+	.led = &iwl3945_led_ops,
 };
 
 static struct iwl_cfg iwl3945_bg_cfg = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index 21679bf..f3907c1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -46,7 +46,7 @@ extern struct pci_device_id iwl3945_hw_card_ids[];
 #include "iwl-debug.h"
 #include "iwl-power.h"
 #include "iwl-dev.h"
-#include "iwl-3945-led.h"
+#include "iwl-led.h"
 
 /* Highest firmware API version supported */
 #define IWL3945_UCODE_API_MAX 2
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 0921e45..8717946 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -44,6 +44,7 @@
 #include "iwl-helpers.h"
 #include "iwl-calib.h"
 #include "iwl-sta.h"
+#include "iwl-agn-led.h"
 
 static int iwl4965_send_tx_power(struct iwl_priv *priv);
 static int iwl4965_hw_get_temperature(struct iwl_priv *priv);
@@ -2341,6 +2342,7 @@ static struct iwl_ops iwl4965_ops = {
 	.lib = &iwl4965_lib,
 	.hcmd = &iwl4965_hcmd,
 	.utils = &iwl4965_hcmd_utils,
+	.led = &iwlagn_led_ops,
 };
 
 struct iwl_cfg iwl4965_agn_cfg = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 01d53eb..6248535 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -42,6 +42,7 @@
 #include "iwl-io.h"
 #include "iwl-sta.h"
 #include "iwl-helpers.h"
+#include "iwl-agn-led.h"
 #include "iwl-5000-hw.h"
 #include "iwl-6000-hw.h"
 
@@ -1641,11 +1642,12 @@ static struct iwl_lib_ops iwl5150_lib = {
 	 },
 };
 
-struct iwl_ops iwl5000_ops = {
+static struct iwl_ops iwl5000_ops = {
 	.ucode = &iwl5000_ucode,
 	.lib = &iwl5000_lib,
 	.hcmd = &iwl5000_hcmd,
 	.utils = &iwl5000_hcmd_utils,
+	.led = &iwlagn_led_ops,
 };
 
 static struct iwl_ops iwl5150_ops = {
@@ -1653,6 +1655,7 @@ static struct iwl_ops iwl5150_ops = {
 	.lib = &iwl5150_lib,
 	.hcmd = &iwl5000_hcmd,
 	.utils = &iwl5000_hcmd_utils,
+	.led = &iwlagn_led_ops,
 };
 
 struct iwl_mod_params iwl50_mod_params = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 6f4ee27..a002214 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -45,6 +45,7 @@
 #include "iwl-helpers.h"
 #include "iwl-5000-hw.h"
 #include "iwl-6000-hw.h"
+#include "iwl-agn-led.h"
 
 /* Highest firmware API version supported */
 #define IWL6000_UCODE_API_MAX 4
@@ -227,6 +228,7 @@ static struct iwl_ops iwl6000_ops = {
 	.lib = &iwl6000_lib,
 	.hcmd = &iwl5000_hcmd,
 	.utils = &iwl5000_hcmd_utils,
+	.led = &iwlagn_led_ops,
 };
 
 
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-led.c b/drivers/net/wireless/iwlwifi/iwl-agn-led.c
new file mode 100644
index 0000000..3bccba2
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-led.c
@@ -0,0 +1,85 @@
+/******************************************************************************
+ *
+ * Copyright(c) 2003 - 2009 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called LICENSE.
+ *
+ * Contact Information:
+ *  Intel Linux Wireless <ilw@linux.intel.com>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ *****************************************************************************/
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/dma-mapping.h>
+#include <linux/delay.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/wireless.h>
+#include <net/mac80211.h>
+#include <linux/etherdevice.h>
+#include <asm/unaligned.h>
+
+#include "iwl-commands.h"
+#include "iwl-dev.h"
+#include "iwl-core.h"
+#include "iwl-io.h"
+#include "iwl-agn-led.h"
+
+/* Send led command */
+static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd)
+{
+	struct iwl_host_cmd cmd = {
+		.id = REPLY_LEDS_CMD,
+		.len = sizeof(struct iwl_led_cmd),
+		.data = led_cmd,
+		.flags = CMD_ASYNC,
+		.callback = NULL,
+	};
+	u32 reg;
+
+	reg = iwl_read32(priv, CSR_LED_REG);
+	if (reg != (reg & CSR_LED_BSM_CTRL_MSK))
+		iwl_write32(priv, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK);
+
+	return iwl_send_cmd(priv, &cmd);
+}
+
+/* Set led register off */
+static int iwl_led_on_reg(struct iwl_priv *priv)
+{
+	IWL_DEBUG_LED(priv, "led on\n");
+	iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON);
+	return 0;
+}
+
+/* Set led register off */
+static int iwl_led_off_reg(struct iwl_priv *priv)
+{
+	IWL_DEBUG_LED(priv, "LED Reg off\n");
+	iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_OFF);
+	return 0;
+}
+
+const struct iwl_led_ops iwlagn_led_ops = {
+	.cmd = iwl_send_led_cmd,
+	.on = iwl_led_on_reg,
+	.off = iwl_led_off_reg,
+};
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-led.h b/drivers/net/wireless/iwlwifi/iwl-agn-led.h
new file mode 100644
index 0000000..ab55f92
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-led.h
@@ -0,0 +1,32 @@
+/******************************************************************************
+ *
+ * Copyright(c) 2003 - 2009 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called LICENSE.
+ *
+ * Contact Information:
+ *  Intel Linux Wireless <ilw@linux.intel.com>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ *****************************************************************************/
+
+#ifndef __iwl_agn_led_h__
+#define __iwl_agn_led_h__
+
+extern const struct iwl_led_ops iwlagn_led_ops;
+
+#endif /* __iwl_agn_led_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 4fb50d0..046b571 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1801,7 +1801,7 @@ static void iwl_alive_start(struct iwl_priv *priv)
 	/* At this point, the NIC is initialized and operational */
 	iwl_rf_kill_ct_config(priv);
 
-	iwl_leds_register(priv);
+	iwl_leds_init(priv);
 
 	IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n");
 	set_bit(STATUS_READY, &priv->status);
@@ -1839,8 +1839,6 @@ static void __iwl_down(struct iwl_priv *priv)
 	if (!exit_pending)
 		set_bit(STATUS_EXIT_PENDING, &priv->status);
 
-	iwl_leds_unregister(priv);
-
 	iwl_clear_stations_table(priv);
 
 	/* Unblock any waiting calls */
@@ -2339,6 +2337,8 @@ static int iwl_mac_start(struct ieee80211_hw *hw)
 		}
 	}
 
+	iwl_led_start(priv);
+
 out:
 	priv->is_open = 1;
 	IWL_DEBUG_MAC80211(priv, "leave\n");
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 1cf2e04..34547cf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -2384,6 +2384,8 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
 			priv->timestamp = bss_conf->timestamp;
 			priv->assoc_capability = bss_conf->assoc_capability;
 
+			iwl_led_associate(priv);
+
 			/*
 			 * We have just associated, don't start scan too early
 			 * leave time for EAPOL exchange to complete.
@@ -2394,9 +2396,10 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
 					IWL_DELAY_NEXT_SCAN_AFTER_ASSOC;
 			if (!iwl_is_rfkill(priv))
 				priv->cfg->ops->lib->post_associate(priv);
-		} else
+		} else {
 			priv->assoc_id = 0;
-
+			iwl_led_disassociate(priv);
+		}
 	}
 
 	if (changes && iwl_is_associated(priv) && priv->assoc_id) {
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 3bd0e59..eb586a5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -187,11 +187,18 @@ struct iwl_lib_ops {
 	struct iwl_temp_ops temp_ops;
 };
 
+struct iwl_led_ops {
+	int (*cmd)(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd);
+	int (*on)(struct iwl_priv *priv);
+	int (*off)(struct iwl_priv *priv);
+};
+
 struct iwl_ops {
 	const struct iwl_ucode_ops *ucode;
 	const struct iwl_lib_ops *lib;
 	const struct iwl_hcmd_ops *hcmd;
 	const struct iwl_hcmd_utils_ops *utils;
+	const struct iwl_led_ops *led;
 };
 
 struct iwl_mod_params {
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index cbc6290..b9ca475 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -84,9 +84,7 @@ struct iwl_debugfs {
 		struct dentry *file_interrupt;
 		struct dentry *file_qos;
 		struct dentry *file_thermal_throttling;
-#ifdef CONFIG_IWLWIFI_LEDS
 		struct dentry *file_led;
-#endif
 		struct dentry *file_disable_ht40;
 		struct dentry *file_sleep_level_override;
 		struct dentry *file_current_sleep_command;
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index fa6371d..1794b9c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -677,7 +677,6 @@ static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
 	return ret;
 }
 
-#ifdef CONFIG_IWLWIFI_LEDS
 static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf,
 				  size_t count, loff_t *ppos)
 {
@@ -702,7 +701,6 @@ static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf,
 	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
 	return ret;
 }
-#endif
 
 static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
 				char __user *user_buf,
@@ -866,9 +864,7 @@ DEBUGFS_READ_FILE_OPS(channels);
 DEBUGFS_READ_FILE_OPS(status);
 DEBUGFS_READ_WRITE_FILE_OPS(interrupt);
 DEBUGFS_READ_FILE_OPS(qos);
-#ifdef CONFIG_IWLWIFI_LEDS
 DEBUGFS_READ_FILE_OPS(led);
-#endif
 DEBUGFS_READ_FILE_OPS(thermal_throttling);
 DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
@@ -1666,9 +1662,7 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
 	DEBUGFS_ADD_FILE(status, data);
 	DEBUGFS_ADD_FILE(interrupt, data);
 	DEBUGFS_ADD_FILE(qos, data);
-#ifdef CONFIG_IWLWIFI_LEDS
 	DEBUGFS_ADD_FILE(led, data);
-#endif
 	DEBUGFS_ADD_FILE(sleep_level_override, data);
 	DEBUGFS_ADD_FILE(current_sleep_command, data);
 	DEBUGFS_ADD_FILE(thermal_throttling, data);
@@ -1721,9 +1715,7 @@ void iwl_dbgfs_unregister(struct iwl_priv *priv)
 	DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_status);
 	DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_interrupt);
 	DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_qos);
-#ifdef CONFIG_IWLWIFI_LEDS
 	DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_led);
-#endif
 	DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_thermal_throttling);
 	DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_disable_ht40);
 	DEBUGFS_REMOVE(priv->dbgfs->dir_data);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index ad99ce7..eabc556 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -43,7 +43,6 @@
 #include "iwl-debug.h"
 #include "iwl-4965-hw.h"
 #include "iwl-3945-hw.h"
-#include "iwl-3945-led.h"
 #include "iwl-led.h"
 #include "iwl-power.h"
 #include "iwl-agn-rs.h"
@@ -73,7 +72,6 @@ struct iwl_tx_queue;
 
 /* shared structures from iwl-5000.c */
 extern struct iwl_mod_params iwl50_mod_params;
-extern struct iwl_ops iwl5000_ops;
 extern struct iwl_ucode_ops iwl5000_ucode;
 extern struct iwl_lib_ops iwl5000_lib;
 extern struct iwl_hcmd_ops iwl5000_hcmd;
@@ -1066,14 +1064,11 @@ struct iwl_priv {
 	struct iwl_init_alive_resp card_alive_init;
 	struct iwl_alive_resp card_alive;
 
-#ifdef CONFIG_IWLWIFI_LEDS
 	unsigned long last_blink_time;
 	u8 last_blink_rate;
 	u8 allow_blinking;
 	u64 led_tpt;
-	struct iwl_led led[IWL_LED_TRG_MAX];
-	unsigned int rxtxpackets;
-#endif
+
 	u16 active_rate;
 	u16 active_rate_basic;
 
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c
index 685ba9d..478c905 100644
--- a/drivers/net/wireless/iwlwifi/iwl-led.c
+++ b/drivers/net/wireless/iwlwifi/iwl-led.c
@@ -48,16 +48,6 @@ module_param(led_mode, int, S_IRUGO);
 MODULE_PARM_DESC(led_mode, "led mode: 0=blinking, 1=On(RF On)/Off(RF Off), "
 			   "(default 0)\n");
 
-#ifdef CONFIG_IWLWIFI_DEBUG
-static const char *led_type_str[] = {
-	__stringify(IWL_LED_TRG_TX),
-	__stringify(IWL_LED_TRG_RX),
-	__stringify(IWL_LED_TRG_ASSOC),
-	__stringify(IWL_LED_TRG_RADIO),
-	NULL
-};
-#endif /* CONFIG_IWLWIFI_DEBUG */
-
 
 static const struct {
 	u16 tpt;	/* Mb/s */
@@ -75,7 +65,7 @@ static const struct {
 	{5, 110, 110},
 	{1, 130, 130},
 	{0, 167, 167},
-/* SOLID_ON */
+	/* SOLID_ON */
 	{-1, IWL_LED_SOLID, 0}
 };
 
@@ -107,37 +97,11 @@ static inline u8 iwl_blink_compensation(struct iwl_priv *priv,
 	return (u8)((time * compensation) >> 6);
 }
 
-/*  [0-256] -> [0..8] FIXME: we need [0..10] */
-static inline int iwl_brightness_to_idx(enum led_brightness brightness)
-{
-	return fls(0x000000FF & (u32)brightness);
-}
-
-/* Send led command */
-static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd)
-{
-	struct iwl_host_cmd cmd = {
-		.id = REPLY_LEDS_CMD,
-		.len = sizeof(struct iwl_led_cmd),
-		.data = led_cmd,
-		.flags = CMD_ASYNC,
-		.callback = NULL,
-	};
-	u32 reg;
-
-	reg = iwl_read32(priv, CSR_LED_REG);
-	if (reg != (reg & CSR_LED_BSM_CTRL_MSK))
-		iwl_write32(priv, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK);
-
-	return iwl_send_cmd(priv, &cmd);
-}
-
 /* Set led pattern command */
-static int iwl_led_pattern(struct iwl_priv *priv, int led_id,
-			       unsigned int idx)
+static int iwl_led_pattern(struct iwl_priv *priv, unsigned int idx)
 {
 	struct iwl_led_cmd led_cmd = {
-		.id = led_id,
+		.id = IWL_LED_LINK,
 		.interval = IWL_DEF_LED_INTRVL
 	};
 
@@ -152,153 +116,32 @@ static int iwl_led_pattern(struct iwl_priv *priv, int led_id,
 		iwl_blink_compensation(priv, blink_tbl[idx].off_time,
 					priv->cfg->led_compensation);
 
-	return iwl_send_led_cmd(priv, &led_cmd);
-}
-
-/* Set led register off */
-static int iwl_led_on_reg(struct iwl_priv *priv, int led_id)
-{
-	IWL_DEBUG_LED(priv, "led on %d\n", led_id);
-	iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON);
-	return 0;
-}
-
-#if 0
-/* Set led on command */
-static int iwl_led_on(struct iwl_priv *priv, int led_id)
-{
-	struct iwl_led_cmd led_cmd = {
-		.id = led_id,
-		.on = IWL_LED_SOLID,
-		.off = 0,
-		.interval = IWL_DEF_LED_INTRVL
-	};
-	return iwl_send_led_cmd(priv, &led_cmd);
-}
-
-/* Set led off command */
-int iwl_led_off(struct iwl_priv *priv, int led_id)
-{
-	struct iwl_led_cmd led_cmd = {
-		.id = led_id,
-		.on = 0,
-		.off = 0,
-		.interval = IWL_DEF_LED_INTRVL
-	};
-	IWL_DEBUG_LED(priv, "led off %d\n", led_id);
-	return iwl_send_led_cmd(priv, &led_cmd);
+	return priv->cfg->ops->led->cmd(priv, &led_cmd);
 }
-#endif
 
-
-/* Set led register off */
-static int iwl_led_off_reg(struct iwl_priv *priv, int led_id)
+int iwl_led_start(struct iwl_priv *priv)
 {
-	IWL_DEBUG_LED(priv, "LED Reg off\n");
-	iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_OFF);
-	return 0;
+	return priv->cfg->ops->led->on(priv);
 }
+EXPORT_SYMBOL(iwl_led_start);
 
-/*
- * Set led register in case of disassociation according to rfkill state
- */
-static int iwl_led_associate(struct iwl_priv *priv, int led_id)
+int iwl_led_associate(struct iwl_priv *priv)
 {
 	IWL_DEBUG_LED(priv, "Associated\n");
 	if (led_mode == IWL_LED_BLINK)
 		priv->allow_blinking = 1;
-	return iwl_led_on_reg(priv, led_id);
-}
-static int iwl_led_disassociate(struct iwl_priv *priv, int led_id)
-{
-	priv->allow_blinking = 0;
-
-	return 0;
-}
-
-/*
- * brightness call back function for Tx/Rx LED
- */
-static int iwl_led_associated(struct iwl_priv *priv, int led_id)
-{
-	if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
-	    !test_bit(STATUS_READY, &priv->status))
-		return 0;
-
+	priv->last_blink_time = jiffies;
 
-	/* start counting Tx/Rx bytes */
-	if (!priv->last_blink_time && priv->allow_blinking)
-		priv->last_blink_time = jiffies;
 	return 0;
 }
 
-/*
- * brightness call back for association and radio
- */
-static void iwl_led_brightness_set(struct led_classdev *led_cdev,
-				       enum led_brightness brightness)
+int iwl_led_disassociate(struct iwl_priv *priv)
 {
-	struct iwl_led *led = container_of(led_cdev, struct iwl_led, led_dev);
-	struct iwl_priv *priv = led->priv;
-
-	if (test_bit(STATUS_EXIT_PENDING, &priv->status))
-		return;
-
-
-	IWL_DEBUG_LED(priv, "Led type = %s brightness = %d\n",
-			led_type_str[led->type], brightness);
-	switch (brightness) {
-	case LED_FULL:
-		if (led->led_on)
-			led->led_on(priv, IWL_LED_LINK);
-		break;
-	case LED_OFF:
-		if (led->led_off)
-			led->led_off(priv, IWL_LED_LINK);
-		break;
-	default:
-		if (led->led_pattern) {
-			int idx = iwl_brightness_to_idx(brightness);
-			led->led_pattern(priv, IWL_LED_LINK, idx);
-		}
-		break;
-	}
-}
-
-
-
-/*
- * Register led class with the system
- */
-static int iwl_leds_register_led(struct iwl_priv *priv, struct iwl_led *led,
-				   enum led_type type, u8 set_led,
-				   char *trigger)
-{
-	struct device *device = wiphy_dev(priv->hw->wiphy);
-	int ret;
-
-	led->led_dev.name = led->name;
-	led->led_dev.brightness_set = iwl_led_brightness_set;
-	led->led_dev.default_trigger = trigger;
-
-	led->priv = priv;
-	led->type = type;
-
-	ret = led_classdev_register(device, &led->led_dev);
-	if (ret) {
-		IWL_ERR(priv, "Error: failed to register led handler.\n");
-		return ret;
-	}
-
-	led->registered = 1;
-
-	if (set_led && led->led_on)
-		led->led_on(priv, IWL_LED_LINK);
+	priv->allow_blinking = 0;
 
 	return 0;
 }
 
-
 /*
  * calculate blink rate according to last second Tx/Rx activities
  */
@@ -324,7 +167,7 @@ static int iwl_get_blink_rate(struct iwl_priv *priv)
 		i = IWL_MAX_BLINK_TBL;
 	else
 		for (i = 0; i < IWL_MAX_BLINK_TBL; i++)
-			if (tpt  > (blink_tbl[i].tpt * IWL_1MB_RATE))
+			if (tpt > (blink_tbl[i].tpt * IWL_1MB_RATE))
 				break;
 
 	IWL_DEBUG_LED(priv, "LED BLINK IDX=%d\n", i);
@@ -353,8 +196,7 @@ void iwl_leds_background(struct iwl_priv *priv)
 		priv->last_blink_time = 0;
 		if (priv->last_blink_rate != IWL_SOLID_BLINK_IDX) {
 			priv->last_blink_rate = IWL_SOLID_BLINK_IDX;
-			iwl_led_pattern(priv, IWL_LED_LINK,
-					    IWL_SOLID_BLINK_IDX);
+			iwl_led_pattern(priv, IWL_SOLID_BLINK_IDX);
 		}
 		return;
 	}
@@ -367,111 +209,18 @@ void iwl_leds_background(struct iwl_priv *priv)
 
 	/* call only if blink rate change */
 	if (blink_idx != priv->last_blink_rate)
-		iwl_led_pattern(priv, IWL_LED_LINK, blink_idx);
+		iwl_led_pattern(priv, blink_idx);
 
 	priv->last_blink_time = jiffies;
 	priv->last_blink_rate = blink_idx;
 }
+EXPORT_SYMBOL(iwl_leds_background);
 
-/* Register all led handler */
-int iwl_leds_register(struct iwl_priv *priv)
+void iwl_leds_init(struct iwl_priv *priv)
 {
-	char *trigger;
-	int ret;
-
 	priv->last_blink_rate = 0;
 	priv->led_tpt = 0;
 	priv->last_blink_time = 0;
 	priv->allow_blinking = 0;
-
-	trigger = ieee80211_get_radio_led_name(priv->hw);
-	snprintf(priv->led[IWL_LED_TRG_RADIO].name,
-		 sizeof(priv->led[IWL_LED_TRG_RADIO].name), "iwl-%s::radio",
-		 wiphy_name(priv->hw->wiphy));
-
-	priv->led[IWL_LED_TRG_RADIO].led_on = iwl_led_on_reg;
-	priv->led[IWL_LED_TRG_RADIO].led_off = iwl_led_off_reg;
-	priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL;
-
-	ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RADIO],
-				   IWL_LED_TRG_RADIO, 1, trigger);
-	if (ret)
-		goto exit_fail;
-
-	trigger = ieee80211_get_assoc_led_name(priv->hw);
-	snprintf(priv->led[IWL_LED_TRG_ASSOC].name,
-		 sizeof(priv->led[IWL_LED_TRG_ASSOC].name), "iwl-%s::assoc",
-		 wiphy_name(priv->hw->wiphy));
-
-	ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_ASSOC],
-				   IWL_LED_TRG_ASSOC, 0, trigger);
-
-	/* for assoc always turn led on */
-	priv->led[IWL_LED_TRG_ASSOC].led_on = iwl_led_associate;
-	priv->led[IWL_LED_TRG_ASSOC].led_off = iwl_led_disassociate;
-	priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL;
-
-	if (ret)
-		goto exit_fail;
-
-	trigger = ieee80211_get_rx_led_name(priv->hw);
-	snprintf(priv->led[IWL_LED_TRG_RX].name,
-		 sizeof(priv->led[IWL_LED_TRG_RX].name), "iwl-%s::RX",
-		 wiphy_name(priv->hw->wiphy));
-
-	ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RX],
-				   IWL_LED_TRG_RX, 0, trigger);
-
-	priv->led[IWL_LED_TRG_RX].led_on = iwl_led_associated;
-	priv->led[IWL_LED_TRG_RX].led_off = iwl_led_associated;
-	priv->led[IWL_LED_TRG_RX].led_pattern = iwl_led_pattern;
-
-	if (ret)
-		goto exit_fail;
-
-	trigger = ieee80211_get_tx_led_name(priv->hw);
-	snprintf(priv->led[IWL_LED_TRG_TX].name,
-		 sizeof(priv->led[IWL_LED_TRG_TX].name), "iwl-%s::TX",
-		 wiphy_name(priv->hw->wiphy));
-
-	ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_TX],
-				   IWL_LED_TRG_TX, 0, trigger);
-
-	priv->led[IWL_LED_TRG_TX].led_on = iwl_led_associated;
-	priv->led[IWL_LED_TRG_TX].led_off = iwl_led_associated;
-	priv->led[IWL_LED_TRG_TX].led_pattern = iwl_led_pattern;
-
-	if (ret)
-		goto exit_fail;
-
-	return 0;
-
-exit_fail:
-	iwl_leds_unregister(priv);
-	return ret;
 }
-EXPORT_SYMBOL(iwl_leds_register);
-
-/* unregister led class */
-static void iwl_leds_unregister_led(struct iwl_led *led, u8 set_led)
-{
-	if (!led->registered)
-		return;
-
-	led_classdev_unregister(&led->led_dev);
-
-	if (set_led)
-		led->led_dev.brightness_set(&led->led_dev, LED_OFF);
-	led->registered = 0;
-}
-
-/* Unregister all led handlers */
-void iwl_leds_unregister(struct iwl_priv *priv)
-{
-	iwl_leds_unregister_led(&priv->led[IWL_LED_TRG_ASSOC], 0);
-	iwl_leds_unregister_led(&priv->led[IWL_LED_TRG_RX], 0);
-	iwl_leds_unregister_led(&priv->led[IWL_LED_TRG_TX], 0);
-	iwl_leds_unregister_led(&priv->led[IWL_LED_TRG_RADIO], 1);
-}
-EXPORT_SYMBOL(iwl_leds_unregister);
-
+EXPORT_SYMBOL(iwl_leds_init);
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.h b/drivers/net/wireless/iwlwifi/iwl-led.h
index dd76b26..f47f053 100644
--- a/drivers/net/wireless/iwlwifi/iwl-led.h
+++ b/drivers/net/wireless/iwlwifi/iwl-led.h
@@ -30,9 +30,6 @@
 
 struct iwl_priv;
 
-#ifdef CONFIG_IWLWIFI_LEDS
-#include <linux/leds.h>
-
 #define IWL_LED_SOLID 11
 #define IWL_LED_NAME_LEN 31
 #define IWL_DEF_LED_INTRVL cpu_to_le32(1000)
@@ -59,38 +56,11 @@ enum iwl_led_mode {
 	IWL_LED_BLINK,
 	IWL_LED_RF_STATE,
 };
-#endif
-
-#ifdef CONFIG_IWLWIFI_LEDS
-
-struct iwl_led {
-	struct iwl_priv *priv;
-	struct led_classdev led_dev;
-	char name[32];
-
-	int (*led_on) (struct iwl_priv *priv, int led_id);
-	int (*led_off) (struct iwl_priv *priv, int led_id);
-	int (*led_pattern) (struct iwl_priv *priv, int led_id, unsigned int idx);
 
-	enum led_type type;
-	unsigned int registered;
-};
-
-int iwl_leds_register(struct iwl_priv *priv);
-void iwl_leds_unregister(struct iwl_priv *priv);
+void iwl_leds_init(struct iwl_priv *priv);
 void iwl_leds_background(struct iwl_priv *priv);
+int iwl_led_start(struct iwl_priv *priv);
+int iwl_led_associate(struct iwl_priv *priv);
+int iwl_led_disassociate(struct iwl_priv *priv);
 
-#else
-static inline int iwl_leds_register(struct iwl_priv *priv)
-{
-	return 0;
-}
-static inline void iwl_leds_unregister(struct iwl_priv *priv)
-{
-}
-static inline void iwl_leds_background(struct iwl_priv *priv)
-{
-}
-
-#endif /* CONFIG_IWLWIFI_LEDS */
 #endif /* __iwl_leds_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index d0d1b7f..ecbe036 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -455,9 +455,6 @@ static void iwl3945_build_tx_cmd_basic(struct iwl_priv *priv,
 			tx->timeout.pm_frame_timeout = cpu_to_le16(2);
 	} else {
 		tx->timeout.pm_frame_timeout = 0;
-#ifdef CONFIG_IWLWIFI_LEDS
-		priv->rxtxpackets += le16_to_cpu(cmd->cmd.tx.len);
-#endif
 	}
 
 	tx->driver_txop = 0;
@@ -2483,7 +2480,7 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
 
 	iwl3945_reg_txpower_periodic(priv);
 
-	iwl3945_led_register(priv);
+	iwl_leds_init(priv);
 
 	IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n");
 	set_bit(STATUS_READY, &priv->status);
@@ -2521,7 +2518,6 @@ static void __iwl3945_down(struct iwl_priv *priv)
 	if (!exit_pending)
 		set_bit(STATUS_EXIT_PENDING, &priv->status);
 
-	iwl3945_led_unregister(priv);
 	iwl_clear_stations_table(priv);
 
 	/* Unblock any waiting calls */
@@ -3156,6 +3152,8 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw)
 	 * no need to poll the killswitch state anymore */
 	cancel_delayed_work(&priv->rfkill_poll);
 
+	iwl_led_start(priv);
+
 	priv->is_open = 1;
 	IWL_DEBUG_MAC80211(priv, "leave\n");
 	return 0;
-- 
1.5.6.3


^ permalink raw reply related

* [PATCH 12/13] iwlwifi: validate the signature for EEPROM and OTP
From: Reinette Chatre @ 2009-10-02 20:44 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, ipw3945-devel, Wey-Yi Guy, Reinette Chatre
In-Reply-To: <1254516247-4085-1-git-send-email-reinette.chatre@intel.com>

From: Wey-Yi Guy <wey-yi.w.guy@intel.com>

Both 1000 & 6000 series NICs contain on-chip OTP memory that
replaces the off-chip EEPROM memory. The nature of OTP means
there is a limited number of times a particular board can go through the
factory flow and be (re)calibrated. As a consequence there will be some boards
that contain EEPROM memory because OTP blocks were full.

In the signature validation routine, iwlwifi needs to make sure
"select bit" and "EEPROM/OTP signature" agree on the type of
NVM to be used to configure the system.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
 drivers/net/wireless/iwlwifi/iwl-csr.h    |    7 +++++-
 drivers/net/wireless/iwlwifi/iwl-eeprom.c |   33 ++++++++++++++++++++++++----
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h
index 06437d1..8f183e0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/iwlwifi/iwl-csr.h
@@ -230,13 +230,18 @@
 
 /* EEPROM GP */
 #define CSR_EEPROM_GP_VALID_MSK		(0x00000007)
-#define CSR_EEPROM_GP_BAD_SIGNATURE	(0x00000000)
 #define CSR_EEPROM_GP_IF_OWNER_MSK	(0x00000180)
 #define CSR_OTP_GP_REG_DEVICE_SELECT	(0x00010000) /* 0 - EEPROM, 1 - OTP */
 #define CSR_OTP_GP_REG_OTP_ACCESS_MODE	(0x00020000) /* 0 - absolute, 1 - relative */
 #define CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK          (0x00100000) /* bit 20 */
 #define CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK        (0x00200000) /* bit 21 */
 
+/* EEPROM signature */
+#define CSR_EEPROM_GP_BAD_SIGNATURE_BOTH_EEP_AND_OTP	(0x00000000)
+#define CSR_EEPROM_GP_BAD_SIG_EEP_GOOD_SIG_OTP		(0x00000001)
+#define CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K		(0x00000002)
+#define CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K		(0x00000004)
+
 /* CSR GIO */
 #define CSR_GIO_REG_VAL_L0S_ENABLED	(0x00000002)
 
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index 6e83312..2e8c405 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -215,12 +215,35 @@ static const struct iwl_txpwr_section enhinfo[] = {
 
 int iwlcore_eeprom_verify_signature(struct iwl_priv *priv)
 {
-	u32 gp = iwl_read32(priv, CSR_EEPROM_GP);
-	if ((gp & CSR_EEPROM_GP_VALID_MSK) == CSR_EEPROM_GP_BAD_SIGNATURE) {
-		IWL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp);
-		return -ENOENT;
+	u32 gp = iwl_read32(priv, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK;
+	int ret = 0;
+
+	IWL_DEBUG_INFO(priv, "EEPROM signature=0x%08x\n", gp);
+	switch (gp) {
+	case CSR_EEPROM_GP_BAD_SIG_EEP_GOOD_SIG_OTP:
+		if (priv->nvm_device_type != NVM_DEVICE_TYPE_OTP) {
+			IWL_ERR(priv, "EEPROM with bad signature: 0x%08x\n",
+				gp);
+			ret = -ENOENT;
+		}
+		break;
+	case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K:
+	case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K:
+		if (priv->nvm_device_type != NVM_DEVICE_TYPE_EEPROM) {
+			IWL_ERR(priv, "OTP with bad signature: 0x%08x\n", gp);
+			ret = -ENOENT;
+		}
+		break;
+	case CSR_EEPROM_GP_BAD_SIGNATURE_BOTH_EEP_AND_OTP:
+	default:
+		IWL_ERR(priv, "bad EEPROM/OTP signature, type=%s, "
+			"EEPROM_GP=0x%08x\n",
+			(priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
+			? "OTP" : "EEPROM", gp);
+		ret = -ENOENT;
+		break;
 	}
-	return 0;
+	return ret;
 }
 EXPORT_SYMBOL(iwlcore_eeprom_verify_signature);
 
-- 
1.5.6.3


^ permalink raw reply related

* [PATCH 13/13] iwlagn: fix compile warning in iwl5000_gain_computation
From: Reinette Chatre @ 2009-10-02 20:44 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, ipw3945-devel, Reinette Chatre
In-Reply-To: <1254516247-4085-1-git-send-email-reinette.chatre@intel.com>

From: Reinette Chatre <reinette.chatre@intel.com>

The return type of abs() was recently changed from int to long. With
min()'s type checking we thus need to make sure that values of the same
type are compared.

This fixes:

    CC [M]  drivers/net/wireless/iwlwifi/iwl-5000.o
drivers/net/wireless/iwlwifi/iwl-5000.c: In function ‘iwl5000_gain_computation’:
drivers/net/wireless/iwlwifi/iwl-5000.c:320: warning: comparison of distinct pointer types lacks a cast

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Reported-by: Marcel Holtmann <marcel@holtmann.org>
---
 drivers/net/wireless/iwlwifi/iwl-5000.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 98baf8a..8cc3d50 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -283,7 +283,7 @@ static void iwl5000_gain_computation(struct iwl_priv *priv,
 			(s32)average_noise[i])) / 1500;
 		/* bound gain by 2 bits value max, 3rd bit is sign */
 		data->delta_gain_code[i] =
-			min(abs(delta_g), CHAIN_NOISE_MAX_DELTA_GAIN_CODE);
+			min(abs(delta_g), (long) CHAIN_NOISE_MAX_DELTA_GAIN_CODE);
 
 		if (delta_g < 0)
 			/* set negative sign */
-- 
1.5.6.3


^ permalink raw reply related

* [PATCH 11/13] iwlwifi: replace iwl_poll_direct_bit with iwl_poll_bit for CSR access
From: Reinette Chatre @ 2009-10-02 20:44 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, ipw3945-devel, Abhijeet Kolekar, Reinette Chatre
In-Reply-To: <1254516247-4085-1-git-send-email-reinette.chatre@intel.com>

From: Abhijeet Kolekar <abhijeet.kolekar@intel.com>

Replace iwl_poll_direct_bit with iwl_poll_bit when accessing CSR registers.
There is no need to power up the mac to access CSR registers.

Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com>
Acked-by: Ben M Cahill <ben.m.cahill@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
 drivers/net/wireless/iwlwifi/iwl-3945.c   |   10 ++++++----
 drivers/net/wireless/iwlwifi/iwl-4965.c   |    6 ++++--
 drivers/net/wireless/iwlwifi/iwl-5000.c   |    6 ++++--
 drivers/net/wireless/iwlwifi/iwl-core.c   |    2 +-
 drivers/net/wireless/iwlwifi/iwl-eeprom.c |   12 ++++++++----
 5 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index bb045a0..4115672 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -999,8 +999,9 @@ static int iwl3945_apm_init(struct iwl_priv *priv)
 	* D0U* --> D0A* state */
 	iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
 
-	ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
-			    CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
+	ret = iwl_poll_bit(priv, CSR_GP_CNTRL,
+			CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
+			CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
 	if (ret < 0) {
 		IWL_DEBUG_INFO(priv, "Failed to init the card\n");
 		goto out;
@@ -1177,8 +1178,9 @@ static int iwl3945_apm_reset(struct iwl_priv *priv)
 
 	iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
 
-	iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
-			 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
+	iwl_poll_bit(priv, CSR_GP_CNTRL,
+			CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
+			CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
 
 	iwl_write_prph(priv, APMG_CLK_CTRL_REG,
 				APMG_CLK_VAL_BSM_CLK_RQT);
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index dd10c42..f8eed9a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -335,7 +335,8 @@ static int iwl4965_apm_init(struct iwl_priv *priv)
 	iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
 
 	/* wait for clock stabilization */
-	ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
+	ret = iwl_poll_bit(priv, CSR_GP_CNTRL,
+			CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
 			CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
 	if (ret < 0) {
 		IWL_DEBUG_INFO(priv, "Failed to init the card\n");
@@ -411,7 +412,8 @@ static int iwl4965_apm_reset(struct iwl_priv *priv)
 
 	iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
 
-	ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
+	ret = iwl_poll_bit(priv, CSR_GP_CNTRL,
+			CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
 			CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
 	if (ret < 0)
 		goto out;
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index d8dadbf..98baf8a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -98,7 +98,8 @@ int iwl5000_apm_init(struct iwl_priv *priv)
 	iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
 
 	/* wait for clock stabilization */
-	ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
+	ret = iwl_poll_bit(priv, CSR_GP_CNTRL,
+			CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
 			CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
 	if (ret < 0) {
 		IWL_DEBUG_INFO(priv, "Failed to init the card\n");
@@ -138,7 +139,8 @@ int iwl5000_apm_reset(struct iwl_priv *priv)
 	iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
 
 	/* wait for clock stabilization */
-	ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
+	ret = iwl_poll_bit(priv, CSR_GP_CNTRL,
+			CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
 			CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
 	if (ret < 0) {
 		IWL_DEBUG_INFO(priv, "Failed to init the card\n");
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 7c0ef8e..dc7fd87 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -1338,7 +1338,7 @@ int iwl_apm_stop_master(struct iwl_priv *priv)
 	/* set stop master bit */
 	iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
 
-	iwl_poll_direct_bit(priv, CSR_RESET,
+	iwl_poll_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED,
 			CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
 
 	spin_unlock_irqrestore(&priv->lock, flags);
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index e14c995..6e83312 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -283,7 +283,8 @@ int iwlcore_eeprom_acquire_semaphore(struct iwl_priv *priv)
 			    CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
 
 		/* See if we got it */
-		ret = iwl_poll_direct_bit(priv, CSR_HW_IF_CONFIG_REG,
+		ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG,
+				CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
 				CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
 				EEPROM_SEM_TIMEOUT);
 		if (ret >= 0) {
@@ -322,7 +323,8 @@ static int iwl_init_otp_access(struct iwl_priv *priv)
 		     CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
 
 	/* wait for clock to be ready */
-	ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
+	ret = iwl_poll_bit(priv, CSR_GP_CNTRL,
+				  CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
 				  CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
 				  25000);
 	if (ret < 0)
@@ -345,7 +347,8 @@ static int iwl_read_otp_word(struct iwl_priv *priv, u16 addr, u16 *eeprom_data)
 
 	_iwl_write32(priv, CSR_EEPROM_REG,
 		     CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
-	ret = iwl_poll_direct_bit(priv, CSR_EEPROM_REG,
+	ret = iwl_poll_bit(priv, CSR_EEPROM_REG,
+				  CSR_EEPROM_REG_READ_VALID_MSK,
 				  CSR_EEPROM_REG_READ_VALID_MSK,
 				  IWL_EEPROM_ACCESS_TIMEOUT);
 	if (ret < 0) {
@@ -537,7 +540,8 @@ int iwl_eeprom_init(struct iwl_priv *priv)
 			_iwl_write32(priv, CSR_EEPROM_REG,
 				     CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
 
-			ret = iwl_poll_direct_bit(priv, CSR_EEPROM_REG,
+			ret = iwl_poll_bit(priv, CSR_EEPROM_REG,
+						  CSR_EEPROM_REG_READ_VALID_MSK,
 						  CSR_EEPROM_REG_READ_VALID_MSK,
 						  IWL_EEPROM_ACCESS_TIMEOUT);
 			if (ret < 0) {
-- 
1.5.6.3


^ permalink raw reply related

* [PATCH 10/13] iwlwifi/iwl3945 : unify apm stop operation
From: Reinette Chatre @ 2009-10-02 20:44 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, ipw3945-devel, Abhijeet Kolekar, Reinette Chatre
In-Reply-To: <1254516247-4085-1-git-send-email-reinette.chatre@intel.com>

From: Abhijeet Kolekar <abhijeet.kolekar@intel.com>

Unify the usage of apm_stop_master and apm_stop
across all hardwares.

Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
 drivers/net/wireless/iwlwifi/iwl-1000.c |    2 +-
 drivers/net/wireless/iwlwifi/iwl-3945.c |   43 +---------------------------
 drivers/net/wireless/iwlwifi/iwl-4965.c |   38 +------------------------
 drivers/net/wireless/iwlwifi/iwl-5000.c |   46 ++-----------------------------
 drivers/net/wireless/iwlwifi/iwl-6000.c |    2 +-
 drivers/net/wireless/iwlwifi/iwl-core.c |   36 ++++++++++++++++++++++++
 drivers/net/wireless/iwlwifi/iwl-core.h |    3 +-
 drivers/net/wireless/iwlwifi/iwl-dev.h  |    1 -
 8 files changed, 47 insertions(+), 124 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index 86d93b5..679a67f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -112,7 +112,7 @@ static struct iwl_lib_ops iwl1000_lib = {
 	.apm_ops = {
 		.init =	iwl5000_apm_init,
 		.reset = iwl5000_apm_reset,
-		.stop = iwl5000_apm_stop,
+		.stop = iwl_apm_stop,
 		.config = iwl1000_nic_config,
 		.set_pwr_src = iwl_set_pwr_src,
 	},
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 8cc0dfc..bb045a0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -1167,48 +1167,9 @@ void iwl3945_hw_txq_ctx_stop(struct iwl_priv *priv)
 	iwl3945_hw_txq_ctx_free(priv);
 }
 
-static int iwl3945_apm_stop_master(struct iwl_priv *priv)
-{
-	int ret = 0;
-	unsigned long flags;
-
-	spin_lock_irqsave(&priv->lock, flags);
-
-	/* set stop master bit */
-	iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
-
-	iwl_poll_direct_bit(priv, CSR_RESET,
-			    CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
-
-	if (ret < 0)
-		goto out;
-
-out:
-	spin_unlock_irqrestore(&priv->lock, flags);
-	IWL_DEBUG_INFO(priv, "stop master\n");
-
-	return ret;
-}
-
-static void iwl3945_apm_stop(struct iwl_priv *priv)
-{
-	unsigned long flags;
-
-	iwl3945_apm_stop_master(priv);
-
-	spin_lock_irqsave(&priv->lock, flags);
-
-	iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
-
-	udelay(10);
-	/* clear "init complete"  move adapter D0A* --> D0U state */
-	iwl_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
-	spin_unlock_irqrestore(&priv->lock, flags);
-}
-
 static int iwl3945_apm_reset(struct iwl_priv *priv)
 {
-	iwl3945_apm_stop_master(priv);
+	iwl_apm_stop_master(priv);
 
 
 	iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
@@ -2841,7 +2802,7 @@ static struct iwl_lib_ops iwl3945_lib = {
 	.apm_ops = {
 		.init = iwl3945_apm_init,
 		.reset = iwl3945_apm_reset,
-		.stop = iwl3945_apm_stop,
+		.stop = iwl_apm_stop,
 		.config = iwl3945_nic_config,
 		.set_pwr_src = iwl3945_set_pwr_src,
 	},
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 8717946..dd10c42 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -396,45 +396,11 @@ static void iwl4965_nic_config(struct iwl_priv *priv)
 	spin_unlock_irqrestore(&priv->lock, flags);
 }
 
-static int iwl4965_apm_stop_master(struct iwl_priv *priv)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&priv->lock, flags);
-
-	/* set stop master bit */
-	iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
-
-	iwl_poll_direct_bit(priv, CSR_RESET,
-			CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
-
-	spin_unlock_irqrestore(&priv->lock, flags);
-	IWL_DEBUG_INFO(priv, "stop master\n");
-
-	return 0;
-}
-
-static void iwl4965_apm_stop(struct iwl_priv *priv)
-{
-	unsigned long flags;
-
-	iwl4965_apm_stop_master(priv);
-
-	spin_lock_irqsave(&priv->lock, flags);
-
-	iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
-
-	udelay(10);
-	/* clear "init complete"  move adapter D0A* --> D0U state */
-	iwl_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
-	spin_unlock_irqrestore(&priv->lock, flags);
-}
-
 static int iwl4965_apm_reset(struct iwl_priv *priv)
 {
 	int ret = 0;
 
-	iwl4965_apm_stop_master(priv);
+	iwl_apm_stop_master(priv);
 
 
 	iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
@@ -2306,7 +2272,7 @@ static struct iwl_lib_ops iwl4965_lib = {
 	.apm_ops = {
 		.init = iwl4965_apm_init,
 		.reset = iwl4965_apm_reset,
-		.stop = iwl4965_apm_stop,
+		.stop = iwl_apm_stop,
 		.config = iwl4965_nic_config,
 		.set_pwr_src = iwl_set_pwr_src,
 	},
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 6248535..d8dadbf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -72,26 +72,6 @@ static const u16 iwl5000_default_queue_to_tx_fifo[] = {
 	IWL_TX_FIFO_HCCA_2
 };
 
-/* FIXME: same implementation as 4965 */
-static int iwl5000_apm_stop_master(struct iwl_priv *priv)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&priv->lock, flags);
-
-	/* set stop master bit */
-	iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
-
-	iwl_poll_direct_bit(priv, CSR_RESET,
-				  CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
-
-	spin_unlock_irqrestore(&priv->lock, flags);
-	IWL_DEBUG_INFO(priv, "stop master\n");
-
-	return 0;
-}
-
-
 int iwl5000_apm_init(struct iwl_priv *priv)
 {
 	int ret = 0;
@@ -137,31 +117,11 @@ int iwl5000_apm_init(struct iwl_priv *priv)
 	return ret;
 }
 
-/* FIXME: this is identical to 4965 */
-void iwl5000_apm_stop(struct iwl_priv *priv)
-{
-	unsigned long flags;
-
-	iwl5000_apm_stop_master(priv);
-
-	spin_lock_irqsave(&priv->lock, flags);
-
-	iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
-
-	udelay(10);
-
-	/* clear "init complete"  move adapter D0A* --> D0U state */
-	iwl_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
-
-	spin_unlock_irqrestore(&priv->lock, flags);
-}
-
-
 int iwl5000_apm_reset(struct iwl_priv *priv)
 {
 	int ret = 0;
 
-	iwl5000_apm_stop_master(priv);
+	iwl_apm_stop_master(priv);
 
 	iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
 
@@ -1561,7 +1521,7 @@ struct iwl_lib_ops iwl5000_lib = {
 	.apm_ops = {
 		.init =	iwl5000_apm_init,
 		.reset = iwl5000_apm_reset,
-		.stop = iwl5000_apm_stop,
+		.stop = iwl_apm_stop,
 		.config = iwl5000_nic_config,
 		.set_pwr_src = iwl_set_pwr_src,
 	},
@@ -1613,7 +1573,7 @@ static struct iwl_lib_ops iwl5150_lib = {
 	.apm_ops = {
 		.init =	iwl5000_apm_init,
 		.reset = iwl5000_apm_reset,
-		.stop = iwl5000_apm_stop,
+		.stop = iwl_apm_stop,
 		.config = iwl5000_nic_config,
 		.set_pwr_src = iwl_set_pwr_src,
 	},
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index a002214..d1f0b0b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -193,7 +193,7 @@ static struct iwl_lib_ops iwl6000_lib = {
 	.apm_ops = {
 		.init =	iwl5000_apm_init,
 		.reset = iwl5000_apm_reset,
-		.stop = iwl5000_apm_stop,
+		.stop = iwl_apm_stop,
 		.config = iwl6000_nic_config,
 		.set_pwr_src = iwl_set_pwr_src,
 	},
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 34547cf..7c0ef8e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -1329,6 +1329,42 @@ void iwl_irq_handle_error(struct iwl_priv *priv)
 }
 EXPORT_SYMBOL(iwl_irq_handle_error);
 
+int iwl_apm_stop_master(struct iwl_priv *priv)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&priv->lock, flags);
+
+	/* set stop master bit */
+	iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
+
+	iwl_poll_direct_bit(priv, CSR_RESET,
+			CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
+
+	spin_unlock_irqrestore(&priv->lock, flags);
+	IWL_DEBUG_INFO(priv, "stop master\n");
+
+	return 0;
+}
+EXPORT_SYMBOL(iwl_apm_stop_master);
+
+void iwl_apm_stop(struct iwl_priv *priv)
+{
+	unsigned long flags;
+
+	iwl_apm_stop_master(priv);
+
+	spin_lock_irqsave(&priv->lock, flags);
+
+	iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
+
+	udelay(10);
+	/* clear "init complete"  move adapter D0A* --> D0U state */
+	iwl_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
+	spin_unlock_irqrestore(&priv->lock, flags);
+}
+EXPORT_SYMBOL(iwl_apm_stop);
+
 void iwl_configure_filter(struct ieee80211_hw *hw,
 			  unsigned int changed_flags,
 			  unsigned int *total_flags,
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index eb586a5..6688b69 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -658,6 +658,8 @@ extern void iwl_rx_reply_rx_phy(struct iwl_priv *priv,
 				    struct iwl_rx_mem_buffer *rxb);
 void iwl_rx_reply_compressed_ba(struct iwl_priv *priv,
 					   struct iwl_rx_mem_buffer *rxb);
+void iwl_apm_stop(struct iwl_priv *priv);
+int iwl_apm_stop_master(struct iwl_priv *priv);
 
 void iwl_setup_rxon_timing(struct iwl_priv *priv);
 static inline int iwl_send_rxon_assoc(struct iwl_priv *priv)
@@ -677,5 +679,4 @@ static inline const struct ieee80211_supported_band *iwl_get_hw_mode(
 {
 	return priv->hw->wiphy->bands[band];
 }
-
 #endif /* __iwl_core_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index eabc556..72946c1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -86,7 +86,6 @@ extern void iwl5000_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
 extern int iwl5000_calc_rssi(struct iwl_priv *priv,
 			     struct iwl_rx_phy_res *rx_resp);
 extern int iwl5000_apm_init(struct iwl_priv *priv);
-extern void iwl5000_apm_stop(struct iwl_priv *priv);
 extern int iwl5000_apm_reset(struct iwl_priv *priv);
 extern void iwl5000_nic_config(struct iwl_priv *priv);
 extern u16 iwl5000_eeprom_calib_version(struct iwl_priv *priv);
-- 
1.5.6.3


^ permalink raw reply related

* [PATCH 06/13] iwlwifi: clear the translate table area
From: Reinette Chatre @ 2009-10-02 20:44 UTC (permalink / raw)
  To: linville
  Cc: linux-wireless, ipw3945-devel, Huaxu Wan, Guo Chaohong,
	Reinette Chatre
In-Reply-To: <1254516247-4085-1-git-send-email-reinette.chatre@intel.com>

From: Huaxu Wan <huaxu.wan@linux.intel.com>

Driver should clear the translate table area after receiving "Alive"
response from uCode. This patch corrects a mistake when doing this.

Signed-off-by: Huaxu Wan <huaxu.wan@linux.intel.com>
Signed-off-by: Guo Chaohong <chaohong.guo@linux.intel.com>
Acked-by: Ben M Cahill  <ben.m.cahill@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
 drivers/net/wireless/iwlwifi/iwl-4965.c |    3 ++-
 drivers/net/wireless/iwlwifi/iwl-5000.c |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 4e492c1..0921e45 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -663,7 +663,8 @@ static int iwl4965_alive_notify(struct iwl_priv *priv)
 		iwl_write_targ_mem(priv, a, 0);
 	for (; a < priv->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET; a += 4)
 		iwl_write_targ_mem(priv, a, 0);
-	for (; a < sizeof(u16) * priv->hw_params.max_txq_num; a += 4)
+	for (; a < priv->scd_base_addr +
+	       IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(priv->hw_params.max_txq_num); a += 4)
 		iwl_write_targ_mem(priv, a, 0);
 
 	/* Tel 4965 where to find Tx byte count tables */
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 660fd51..01d53eb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -748,7 +748,8 @@ int iwl5000_alive_notify(struct iwl_priv *priv)
 	for (; a < priv->scd_base_addr + IWL50_SCD_TRANSLATE_TBL_OFFSET;
 		a += 4)
 		iwl_write_targ_mem(priv, a, 0);
-	for (; a < sizeof(u16) * priv->hw_params.max_txq_num; a += 4)
+	for (; a < priv->scd_base_addr +
+	       IWL50_SCD_TRANSLATE_TBL_OFFSET_QUEUE(priv->hw_params.max_txq_num); a += 4)
 		iwl_write_targ_mem(priv, a, 0);
 
 	iwl_write_prph(priv, IWL50_SCD_DRAM_BASE_ADDR,
-- 
1.5.6.3


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox