summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/rt2x00
AgeCommit message (Collapse)Author
2010-11-22rt2x00: Use static constJoe Perches
Using static const generally increases object text and decreases data size. It also generally decreases overall object size. text data bss dec hex filename 40197 56 8336 48589 bdcd drivers/net/wireless/rt2x00/rt2800lib.o.new 40205 56 8336 48597 bdd5 drivers/net/wireless/rt2x00/rt2800lib.o.old Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-17rt2x00: Modify rt2x00queue_remove_l2pad to make skb->data two-byte alignmentRA-Jay Hung
When send out skb data to mac80211, orignal code will cause mac80211 unaligned access, so modify code to make mac80211 can natural access. Signed-off-by: RA-Jay Hung <jay_hung@ralinktech.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-17rt2x00: Fix header_length in rt2x00lib_txdoneRA-Jay Hung
Put the assignment of header_length after pull out extra tx headroom Signed-off-by: RA-Jay Hung <jay_hung@ralinktech.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-17rt2x00: Fix rt2800 USB TX Path DMA issueRA-Jay Hung
rt2800usb chips need to add 1~3 bytes zero padding after each 802.11 header & payload, and at the end need to add 4 bytes zero padding whether doing TX bulk aggregation or not, TXINFO_W0_USB_DMA_TX_PKT_LEN in TXINFO must include 1-3 bytes padding after 802.11 header & payload but do not include 4 bytes end zero padding. In rt2800usb_get_tx_data_len do not consider multiple of the USB packet size case, sometimes this will cause USB DMA problem. Signed-off-by: RA-Jay Hung <jay_hung@ralinktech.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-17rt2x00: Use ioremap for SoC devices instead of KSEG1ADDR.Gertjan van Wingerde
Make the code a bit more portable to architectures that do not support KSEG1ADDR. Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com> Tested-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-17rt2x00: Remove unneccessary internal Kconfig symbols.Gertjan van Wingerde
CONFIG_RT2800PCI_PCI and CONFIG_RT2800PCI_SOC are strictly not needed as we can check the dependent symbols directly in the rest of Kconfig and the code, so clean up the Kconfig namespace a bit. Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-17rt2x00: Remove RT30XX Kconfig variables.Gertjan van Wingerde
Enabling of RT30xx devices via Kconfig variables was introduced when these devices weren't properly supported yet. Now that that they are properly supported and functional, we can remove these Kconfig variables for RT30xx devices and simply enable them whenever rt2800pci and/or rt2800usb is enabled. Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com> Acked-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-17rt2x00: Clean up Kconfig for RT2800 devices.Gertjan van Wingerde
General clean up of the Kconfig part for RT28XX devices. Also remove the indications of non functional support for rt27xx/rt28xx/rt30xx devices, as this is no longer true. They just work fine. Finally, remove the experimental indications for rt27xx/rt28xx/rt30xx devices as that is no longer true. Keep the experimental indications for rt33xx/rt35xx devices, though. Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com> Acked-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-17rt2x00: Add initial support for RT3370/RT3390 devices.Gertjan van Wingerde
Modified from Eddy's patch by adding the RT3370 USB support as well. Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com> Cc: Eddy Tsai <Eddy_Tsai@ralinktech.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-17rt2x00: Increase REGISTER_BUSY_COUNTIvo van Doorn
For some hardware the REGISTER_BUSY_COUNT isn't sufficient, increase the REGISTER_BUSY_COUNT to 100 to catch most devices which have more problems with accessing the registers. For normal operating devices nothing would change as they will exit the loop early anyway. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: Add watchdog functions for HW queueIvo van Doorn
Add watchdog functions for managing the Queues inside the hardware. Normally the driver doesn't have much to do with these queues directly, but the Ralink drivers did implement watchdog functions for these. These watchdog functions are not triggered that often, compared to the other watchdog functions, but I have at least seen them trigger once or twice during a long stresstest run. v2: Add extra documentation for register fields Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: Remove rt2x00lib_toggle_rxIvo van Doorn
As part of the queue refactoring, the rt2x00lib_toggle_rx can be removed and replaced with the call directly to the set_device_state callback function. We can remove the STATE_RADIO_RX_ON_LINK and STATE_RADIO_RX_OFF_LINK, as it was only used for special behavior inside rt2x00lib rather then the drivers. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: Fix rt2x00queue_kick_tx_queue argumentsIvo van Doorn
The queue_entry argument to rt2x00queue_kick_tx_queue, doesn't make sense due to the function name (it is called kick QUEUE)... But neither do we need the queue_entry, since we need the data_queue. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Helmut Schaa <helmut.schaa@googlemail.com> Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: Rename queue->lock to queue->index_lockIvo van Doorn
The queue->lock is only used to protect the index numbers. Rename the lock accordingly. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: checkpatch.pl error fixes for rt73usb.cMark Einon
rt73usb.c:43: ERROR: do not initialise statics to 0 or NULL Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: checkpatch.pl error fixes for rt2x00queue.cMark Einon
rt2x00queue.c:804: ERROR: space prohibited after that open parenthesis '(' rt2x00queue.c:805: ERROR: space prohibited before that close parenthesis ')' Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: checkpatch.pl error fixes for rt2x00link.cMark Einon
rt2x00link.c:70: ERROR: space prohibited before that close parenthesis ')' Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: checkpatch.pl error fixes for rt2x00lib.hMark Einon
rt2x00lib.h:60: ERROR: space prohibited after that open parenthesis '(' rt2x00lib.h:60: ERROR: space prohibited before that close parenthesis ')' Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: checkpatch.pl error fixes for rt2x00dev.cMark Einon
rt2x00dev.c:689: ERROR: spaces required around that '=' (ctx:WxV) Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: checkpatch.pl error fixes for rt2x00config.cMark Einon
rt2x00config.c:136: ERROR: space required before the open parenthesis '(' Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: checkpatch.pl error fixes for rt2800usb.hMark Einon
rt2800usb.h:43: ERROR: space prohibited after that open parenthesis '(' rt2800usb.h:43: ERROR: space prohibited before that close parenthesis ')' rt2800usb.h:44: ERROR: space prohibited after that open parenthesis '(' rt2800usb.h:44: ERROR: space prohibited before that close parenthesis ')' Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: checkpatch.pl error fixes for rt2800usb.cMark Einon
rt2800usb.c:48: ERROR: do not initialise statics to 0 or NULL Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: checkpatch.pl error fixes for rt2800pci.hMark Einon
rt2800pci.h:41: ERROR: Macros with complex values should be enclosed in parenthesis rt2800pci.h:42: ERROR: Macros with complex values should be enclosed in parenthesis rt2800pci.h:43: ERROR: Macros with complex values should be enclosed in parenthesis rt2800pci.h:44: ERROR: Macros with complex values should be enclosed in parenthesis rt2800pci.h:55: ERROR: space prohibited after that open parenthesis '(' rt2800pci.h:55: ERROR: space prohibited before that close parenthesis ')' rt2800pci.h:56: ERROR: space prohibited after that open parenthesis '(' rt2800pci.h:56: ERROR: space prohibited before that close parenthesis ')' Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: checkpatch.pl error fixes for rt2800lib.cMark Einon
rt2800lib.c:831: ERROR: inline keyword should sit between storage class and type Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: checkpatch.pl error fixes for rt2800.hMark Einon
rt2800.h:1511: ERROR: space prohibited after that open parenthesis '(' rt2800.h:1511: ERROR: space prohibited before that close parenthesis ')' rt2800.h:1513: ERROR: space prohibited after that open parenthesis '(' rt2800.h:1513: ERROR: space prohibited before that close parenthesis ')' rt2800.h:1515: ERROR: space prohibited after that open parenthesis '(' rt2800.h:1515: ERROR: space prohibited before that close parenthesis ')' rt2800.h:1517: ERROR: space prohibited after that open parenthesis '(' rt2800.h:1517: ERROR: space prohibited before that close parenthesis ')' rt2800.h:1519: ERROR: space prohibited after that open parenthesis '(' rt2800.h:1519: ERROR: space prohibited before that close parenthesis ')' rt2800.h:1521: ERROR: space prohibited after that open parenthesis '(' rt2800.h:1521: ERROR: space prohibited before that close parenthesis ')' rt2800.h:1661: ERROR: space prohibited after that open parenthesis '(' rt2800.h:1661: ERROR: space prohibited before that close parenthesis ')' rt2800.h:1662: ERROR: space prohibited after that open parenthesis '(' rt2800.h:1662: ERROR: space prohibited before that close parenthesis ')' rt2800.h:1663: ERROR: space prohibited before that close parenthesis ')' rt2800.h:2013: ERROR: space prohibited after that open parenthesis '(' rt2800.h:2013: ERROR: space prohibited before that close parenthesis ')' rt2800.h:2014: ERROR: space prohibited after that open parenthesis '(' rt2800.h:2014: ERROR: space prohibited before that close parenthesis ')' Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: checkpatch.pl error fixes for rt2500usb.cMark Einon
rt2500usb.c:42: ERROR: do not initialise statics to 0 or NULL Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: checkpatch.pl error fixes for rt2500pci.hMark Einon
rt2500pci.h:1091: ERROR: space prohibited after that open parenthesis '(' rt2500pci.h:1091: ERROR: space prohibited before that close parenthesis ')' rt2500pci.h:1092: ERROR: space prohibited after that open parenthesis '(' rt2500pci.h:1092: ERROR: space prohibited before that close parenthesis ')' Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: checkpatch.pl error fixes for rt2400pci.hMark Einon
rt2400pci.h:812: ERROR: space prohibited after that open parenthesis '(' rt2400pci.h:812: ERROR: space prohibited before that close parenthesis ')' rt2400pci.h:813: ERROR: space prohibited after that open parenthesis '(' rt2400pci.h:813: ERROR: space prohibited before that close parenthesis ')' rt2400pci.h:950: ERROR: Macros with complex values should be enclosed in parenthesis Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: Fix comments in rt73usb.h and rt61pci.hLalith Suresh
This patch fixes a few comments in rt73usb.h and rt61pci.h. Signed-off-by: Lalith Suresh <suresh.lalith@gmail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: Fix hw crypto in AP mode for some devicesHelmut Schaa
The BSSID register shouldn't be set in AP mode on some older devices (like rt73usb) as it breaks hw crypto on these. However, rt2800 devices explicitly need the BSSID register set to the same value as our own MAC address (only in AP mode). Hence, don't set the BSSID from rt2x00lib but move it down into rt2800 to avoid problems on older devices. This fixes a regression (at least for rt73usb) and avoids a new regression for rt2800 devices in 2.6.36. Reported-by: Johannes Stezenbach <js@sig21.net> Reported-by: Lee <lee-in-berlin@web.de> Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: Fix crash on USB unplugIvo van Doorn
By not scheduling the TX/RX completion worker threads when Radio is disabled, or hardware has been unplugged, the queues cannot be completely cleaned. This causes crashes when the hardware has been unplugged while the radio is still enabled. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: Fix MCU_SLEEP argumentsIvo van Doorn
Legacy driver uses 0xff as the second argument for the MCU_SLEEP command. It is still unknown what the values actually mean, but this will at least keep the command in-sync with the original driver. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: Implement flush callbackIvo van Doorn
Implement a basic flush callback function, which simply loops over all TX queues and waits until all frames have been transmitted and the status reports have been gathered. At this moment we don't support dropping any frames during the flush, but mac80211 will only send 'false' for this argument anyway, so this is not important at this time. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Helmut Schaa <helmut.schaa@googlemail.com> Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: Remove failsave from rt2x00usb_watchdog_tx_dmaIvo van Doorn
When the TX status handler failed to clear the queue in rt2x00usb_watchdog_tx_dma() we shouldn't use a failsave to use the rt2x00usb txdone handler. If a driver has overriden the txdone handler it must make sure the txdone handler is capable of cleaning up the queue itself. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: Rename rt2x00queue_timeoutIvo van Doorn
Rename rt2x00queue_timeout to rt2x00queue_status_timeout to better describe what is actually timing out (note that we already have a rt2x00queue_dma_timeout). Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Helmut Schaa <helmut.schaa@googlemail.com> Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: Optimize rt2x00debug_dump_frame when frame dumping is not activeHelmut Schaa
When rt2x00 is compiled with debugging but frame dumping is currently not active we can avoid the call to do_gettimeofday. Furthermore, frame dumping is not the default case, mark it as unlikely. Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: Reduce tx descriptor sizeHelmut Schaa
The tx descriptor values qid, cw_min, cw_max and aifs are directly accessible through the tx entry struct. So there's no need to copy them into the tx descriptor and passing them to the indiviual drivers. Instead we can just get the correct value from the tx entry. Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: Wait up to one second on rt2800 for WPDMA to be readyHelmut Schaa
At least some devices need such a long time to inititalize WPDMA. This only increases the maximum wait time and shouldn't affect devices that have been working before. Reported-by: Joshua Smith <jesmith@kaon.com> Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: Sync Tx and RX ring sizes with legacy driversHelmut Schaa
All rt2x00 devices used the same Tx and Rx ring size (24 entries) till now. Newer devices (like rt2800) can however make use of a larger TX and RX ring due to 11n capabilities (AMPDUs of size 64 for example). Hence, bring rt2x00 in sync with the legacy drivers and use the same TX and RX ring sizes. Also remove the global defines RX_ENTRIES, TX_ENTRIES, BEACON_ENTRIES and ATIM_ENTRIES and use per driver values. That is 24 entries for rt2400pci, 32 entries for rt2500pci, rt2500usb, rt61pci and rt73usb and 128 (RX) and 64 (TX) for rt2800pci and rt2800usb. Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00: Add TXOP_CTRL_CFG register definitionHelmut Schaa
Remove the magic value initialisation of the TXOP_CTRL_CFG register by defining its fields and using them during intialisation. The field RESERVED_TRUN_EN is referred to as reserved, however it is set to 1 by the legacy drivers. Hence, do the same. Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-15rt2x00pci: do not use GFP_DMAJohn W. Linville
Signed-off-by: John W. Linville <linville@tuxdriver.com> Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
2010-10-23Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6Linus Torvalds
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6: (1699 commits) bnx2/bnx2x: Unsupported Ethtool operations should return -EINVAL. vlan: Calling vlan_hwaccel_do_receive() is always valid. tproxy: use the interface primary IP address as a default value for --on-ip tproxy: added IPv6 support to the socket match cxgb3: function namespace cleanup tproxy: added IPv6 support to the TPROXY target tproxy: added IPv6 socket lookup function to nf_tproxy_core be2net: Changes to use only priority codes allowed by f/w tproxy: allow non-local binds of IPv6 sockets if IP_TRANSPARENT is enabled tproxy: added tproxy sockopt interface in the IPV6 layer tproxy: added udp6_lib_lookup function tproxy: added const specifiers to udp lookup functions tproxy: split off ipv6 defragmentation to a separate module l2tp: small cleanup nf_nat: restrict ICMP translation for embedded header can: mcp251x: fix generation of error frames can: mcp251x: fix endless loop in interrupt handler if CANINTF_MERRF is set can-raw: add msg_flags to distinguish local traffic 9p: client code cleanup rds: make local functions/variables static ... Fix up conflicts in net/core/dev.c, drivers/net/pcmcia/smc91c92_cs.c and drivers/net/wireless/ath/ath9k/debug.c as per David
2010-10-15Merge branch 'master' of ↵John W. Linville
git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6 into for-davem
2010-10-15llseek: automatically add .llseek fopArnd Bergmann
All file_operations should get a .llseek operation so we can make nonseekable_open the default for future file operations without a .llseek pointer. The three cases that we can automatically detect are no_llseek, seq_lseek and default_llseek. For cases where we can we can automatically prove that the file offset is always ignored, we use noop_llseek, which maintains the current behavior of not returning an error from a seek. New drivers should normally not use noop_llseek but instead use no_llseek and call nonseekable_open at open time. Existing drivers can be converted to do the same when the maintainer knows for certain that no user code relies on calling seek on the device file. The generated code is often incorrectly indented and right now contains comments that clarify for each added line why a specific variant was chosen. In the version that gets submitted upstream, the comments will be gone and I will manually fix the indentation, because there does not seem to be a way to do that using coccinelle. Some amount of new code is currently sitting in linux-next that should get the same modifications, which I will do at the end of the merge window. Many thanks to Julia Lawall for helping me learn to write a semantic patch that does all this. ===== begin semantic patch ===== // This adds an llseek= method to all file operations, // as a preparation for making no_llseek the default. // // The rules are // - use no_llseek explicitly if we do nonseekable_open // - use seq_lseek for sequential files // - use default_llseek if we know we access f_pos // - use noop_llseek if we know we don't access f_pos, // but we still want to allow users to call lseek // @ open1 exists @ identifier nested_open; @@ nested_open(...) { <+... nonseekable_open(...) ...+> } @ open exists@ identifier open_f; identifier i, f; identifier open1.nested_open; @@ int open_f(struct inode *i, struct file *f) { <+... ( nonseekable_open(...) | nested_open(...) ) ...+> } @ read disable optional_qualifier exists @ identifier read_f; identifier f, p, s, off; type ssize_t, size_t, loff_t; expression E; identifier func; @@ ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off) { <+... ( *off = E | *off += E | func(..., off, ...) | E = *off ) ...+> } @ read_no_fpos disable optional_qualifier exists @ identifier read_f; identifier f, p, s, off; type ssize_t, size_t, loff_t; @@ ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off) { ... when != off } @ write @ identifier write_f; identifier f, p, s, off; type ssize_t, size_t, loff_t; expression E; identifier func; @@ ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off) { <+... ( *off = E | *off += E | func(..., off, ...) | E = *off ) ...+> } @ write_no_fpos @ identifier write_f; identifier f, p, s, off; type ssize_t, size_t, loff_t; @@ ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off) { ... when != off } @ fops0 @ identifier fops; @@ struct file_operations fops = { ... }; @ has_llseek depends on fops0 @ identifier fops0.fops; identifier llseek_f; @@ struct file_operations fops = { ... .llseek = llseek_f, ... }; @ has_read depends on fops0 @ identifier fops0.fops; identifier read_f; @@ struct file_operations fops = { ... .read = read_f, ... }; @ has_write depends on fops0 @ identifier fops0.fops; identifier write_f; @@ struct file_operations fops = { ... .write = write_f, ... }; @ has_open depends on fops0 @ identifier fops0.fops; identifier open_f; @@ struct file_operations fops = { ... .open = open_f, ... }; // use no_llseek if we call nonseekable_open //////////////////////////////////////////// @ nonseekable1 depends on !has_llseek && has_open @ identifier fops0.fops; identifier nso ~= "nonseekable_open"; @@ struct file_operations fops = { ... .open = nso, ... +.llseek = no_llseek, /* nonseekable */ }; @ nonseekable2 depends on !has_llseek @ identifier fops0.fops; identifier open.open_f; @@ struct file_operations fops = { ... .open = open_f, ... +.llseek = no_llseek, /* open uses nonseekable */ }; // use seq_lseek for sequential files ///////////////////////////////////// @ seq depends on !has_llseek @ identifier fops0.fops; identifier sr ~= "seq_read"; @@ struct file_operations fops = { ... .read = sr, ... +.llseek = seq_lseek, /* we have seq_read */ }; // use default_llseek if there is a readdir /////////////////////////////////////////// @ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @ identifier fops0.fops; identifier readdir_e; @@ // any other fop is used that changes pos struct file_operations fops = { ... .readdir = readdir_e, ... +.llseek = default_llseek, /* readdir is present */ }; // use default_llseek if at least one of read/write touches f_pos ///////////////////////////////////////////////////////////////// @ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @ identifier fops0.fops; identifier read.read_f; @@ // read fops use offset struct file_operations fops = { ... .read = read_f, ... +.llseek = default_llseek, /* read accesses f_pos */ }; @ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @ identifier fops0.fops; identifier write.write_f; @@ // write fops use offset struct file_operations fops = { ... .write = write_f, ... + .llseek = default_llseek, /* write accesses f_pos */ }; // Use noop_llseek if neither read nor write accesses f_pos /////////////////////////////////////////////////////////// @ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @ identifier fops0.fops; identifier read_no_fpos.read_f; identifier write_no_fpos.write_f; @@ // write fops use offset struct file_operations fops = { ... .write = write_f, .read = read_f, ... +.llseek = noop_llseek, /* read and write both use no f_pos */ }; @ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @ identifier fops0.fops; identifier write_no_fpos.write_f; @@ struct file_operations fops = { ... .write = write_f, ... +.llseek = noop_llseek, /* write uses no f_pos */ }; @ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @ identifier fops0.fops; identifier read_no_fpos.read_f; @@ struct file_operations fops = { ... .read = read_f, ... +.llseek = noop_llseek, /* read uses no f_pos */ }; @ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @ identifier fops0.fops; @@ struct file_operations fops = { ... +.llseek = noop_llseek, /* no read or write fn */ }; ===== End semantic patch ===== Signed-off-by: Arnd Bergmann <arnd@arndb.de> Cc: Julia Lawall <julia@diku.dk> Cc: Christoph Hellwig <hch@infradead.org>
2010-10-11rt2x00: Fix URB error handlingIvo van Doorn
kill_urb guarentees that when the function returns, the URB has been fully killed. This means we don't need the extra sleeping after the call to kill_urb. kill_urb can however also guarentee the submit_urb to fail, as a result, we must catch the return value from submit_urb an correctly mark the entry as owned by the driver, and the status as broken. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-10-11rt2x00: Don't perform watchdog checks on empty queueIvo van Doorn
The currently used watchdog functions cannot be applied to empty queues. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-10-11rt2x00: Make queue_entry flags access atomicIvo van Doorn
All access to the queue_entry->flags can be done concurrently, so all flags must use the atomic operators. On most locations this was already done, so just fix the last few non-atomic versions. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-10-11rt2x00: Fix dead queue when skb allocation failedIvo van Doorn
When the RX skb allocation failed, we should recycle the previously allocated skbuffer. By calling return we would kill the RX queue completely since the entry would be invalidated. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-10-11rt2x00: Validate MCS on RX pathIvo van Doorn
Similar to the PLCP signal and bitrates values, we should validate the MCS value from the RX descriptor before sending it to mac80211. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-10-11rt2x00: Move watchdog work to kernel work_queueIvo van Doorn
The watchdog function must run on a work_queue which is independent of any other work inside rt2x00. The main reasons, being that a broken work on the mac80211 work_queue can otherwise prevent the watchdog to run (while in fact the watchdog could fix the issue). And on the other hand because the watchdog relies on the completion of the completion handlers for RX/TX which for the USB case, occur on the mac80211 workqueue. This fixes some "Queue %d failed to flush" errors, which were caused by the watchdog function waiting on the completion handler which was scheduled to run right after the watchdog. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>