From: Jim C. <jim...@gm...> - 2012-05-12 21:34:47
|
Hi Oliver, this extends previous 1-29: 19 - more refined, replaces old 29 - previous missed a banishment 34 - should fix regression you root-caused 0019-acx_compat-cleanup-ifdefs-in-acx_op_-add-remove-_int.patch 0029-merge-banish-ACX_MAC80211_-w-o-the-CONFIG_.patch 0030-merge-merge-acx_power_led.patch 0031-common.c-various-whitespace.patch 0032-whitespace-NOTE-chiptype-is-hardcoded.patch 0033-mem-inlines.h-shrink-source-by-macro.patch 0034-fix-merge-regression-merge-mem-pci-inlines.h-togethe.patch 34 - the ifdef guard name could be changed (unimportant) mem/pci-inlines should be removed from tree no longer needed thanks Jim |
From: Jim C. <jim...@gm...> - 2012-05-12 21:34:48
|
In acx_compat.h, add a kernel-version dependent macro (2.6.34) which defines ieee80211_VIF as either ieee80211_vif or ieee80211_if_init_conf. Change include order in acx.h so that acx_compat.h can use CONFIG_ACX_MAC80211_VERSION defined in acx_func.h Use ieee80211_VIF to declutter acx_op_(add|remove)_interface, esp fn-sig. One #if/#else/#end is left inside fn-body, cuz it has a different field-name in the 2 versions. Signed-off-by: Jim Cromie <jim...@gm...> --- acx.h | 2 +- acx_compat.h | 21 +++++++++++++++++++++ common.c | 48 +++++++----------------------------------------- 3 files changed, 29 insertions(+), 42 deletions(-) diff --git a/acx.h b/acx.h index 5f764a8..d96f123 100644 --- a/acx.h +++ b/acx.h @@ -23,10 +23,10 @@ * #define CONFIG_PM 0 // in include/generated/autoconf.h */ -#include "acx_compat.h" #include "acx_config.h" #include "acx_struct_hw.h" #include "acx_struct_dev.h" #include "acx_func.h" +#include "acx_compat.h" #endif /* _ACX_H_ */ diff --git a/acx_compat.h b/acx_compat.h index f839a06..7e8948d 100644 --- a/acx_compat.h +++ b/acx_compat.h @@ -28,3 +28,24 @@ do { \ #else #include <generated/utsrelease.h> #endif + +/* + * NOTICE: for clarity, put any CONFIG_ACX_MAC80211_VERSION dependent + * macros below here. See comments in acx_func.h regarding the + * purpose of this macro. + */ + +#if CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(2, 6, 34) +/* + * v2.6.34 added ieee80211_vif, and obsoleted ieee80211_if_init_conf. + * To declutter acx_op_(add|remove)_interface(..), define a macro to + * hide this struct change, naming it close to new one. This is + * surely not a solution for every conceivable _vif situation (the new + * struct surely holds a different set of fields), but is sufficient + * here. + */ +# define ieee80211_VIF ieee80211_if_init_conf +#else +# define ieee80211_VIF ieee80211_vif +#endif + diff --git a/common.c b/common.c index 9a8561f..d570355 100644 --- a/common.c +++ b/common.c @@ -6182,13 +6182,8 @@ end: int acx_debugfs_add_adev(struct acx_device *adev); void acx_debugfs_remove_adev(struct acx_device *adev); -#if CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(2, 6, 34) -int acx_op_add_interface(struct ieee80211_hw *ieee, - struct ieee80211_if_init_conf *conf) -#else int acx_op_add_interface(struct ieee80211_hw *ieee, - struct ieee80211_vif *vif) -#endif + struct ieee80211_VIF *vif) { acx_device_t *adev = ieee2adev(ieee); int err = -EOPNOTSUPP; @@ -6201,15 +6196,10 @@ int acx_op_add_interface(struct ieee80211_hw *ieee, FN_ENTER; acx_sem_lock(adev); -#if CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(2, 6, 34) - vif_type = conf->type; -#else vif_type = vif->type; -#endif adev->vif_type = vif_type; log(L_ANY, "vif_type=%04X\n", vif_type); - if (vif_type == NL80211_IFTYPE_MONITOR) adev->vif_monitor++; else if (adev->vif_operating) @@ -6217,8 +6207,8 @@ int acx_op_add_interface(struct ieee80211_hw *ieee, adev->vif_operating = 1; #if CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(2, 6, 34) - adev->vif = conf->vif; - mac_vif = conf->mac_addr; + adev->vif = vif->vif; + mac_vif = vif->mac_addr; #else adev->vif = vif; mac_vif = vif->addr; @@ -6266,12 +6256,7 @@ int acx_op_add_interface(struct ieee80211_hw *ieee, acx_debugfs_add_adev(adev); pr_info("Virtual interface added (type: 0x%08X, MAC: %s)\n", -#if CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(2, 6, 34) - adev->vif_type, acx_print_mac(mac, conf->mac_addr) -#else - adev->vif_type, acx_print_mac(mac, vif->addr) -#endif - ); + adev->vif_type, acx_print_mac(mac, vif->addr)); err = 0; @@ -6281,13 +6266,7 @@ out_unlock: return err; } -#if CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(2, 6, 34) -void acx_op_remove_interface(struct ieee80211_hw *hw, - struct ieee80211_if_init_conf *conf) -#else -void acx_op_remove_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) -#endif +void acx_op_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { acx_device_t *adev = ieee2adev(hw); @@ -6297,11 +6276,7 @@ void acx_op_remove_interface(struct ieee80211_hw *hw, acx_sem_lock(adev); acx_debugfs_remove_adev(adev); -#if CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(2, 6, 34) - if (conf->type == NL80211_IFTYPE_MONITOR) -#else if (vif->type == NL80211_IFTYPE_MONITOR) -#endif adev->vif_monitor--; else { adev->vif_operating = 0; @@ -6310,20 +6285,11 @@ void acx_op_remove_interface(struct ieee80211_hw *hw, acx_set_mode(adev, ACX_MODE_OFF); -#if CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(2, 6, 34) - log(L_DEBUG, "vif_operating=%d, conf->type=%d\n", - adev->vif_operating, conf->type); -#else log(L_DEBUG, "vif_operating=%d, vif->type=%d\n", adev->vif_operating, vif->type); -#endif + log(L_ANY, "Virtual interface removed: type=%d, MAC=%s\n", -#if CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(2, 6, 34) - conf->type, acx_print_mac(mac, conf->mac_addr) -#else - vif->type, acx_print_mac(mac, vif->addr) -#endif - ); + vif->type, acx_print_mac(mac, vif->addr)); acx_sem_unlock(adev); FN_EXIT0; -- 1.7.10.1.487.ga3935e6 |
From: Jim C. <jim...@gm...> - 2012-05-12 21:34:50
|
Use only the CONFIG_ACX_MAC80211_* symbols, the others add indirection and confusion. The critical fixes are those in acx_struct{hw,dev}.h, without these changes, the C files *MUST* define the non-CONFIG_* symbols to correctly control what symbols and fields are defined. And the C files are using the CONFIG_ACX_MAC80211_* symbols exclusively anyway. With the headers converted, we can remove the ACX_MAC80211_* defined in the C files without massive breakage. Signed-off-by: Jim Cromie <jim...@gm...> --- acx_struct_dev.h | 2 +- acx_struct_hw.h | 4 ++-- mem.c | 2 -- merge.c | 7 ------- pci.c | 1 - usb.c | 9 ++++----- 6 files changed, 7 insertions(+), 18 deletions(-) diff --git a/acx_struct_dev.h b/acx_struct_dev.h index f6ab6ba..4aa8058 100644 --- a/acx_struct_dev.h +++ b/acx_struct_dev.h @@ -520,7 +520,7 @@ struct acx_device { #endif /*** USB stuff ***/ -#ifdef ACX_MAC80211_USB +#ifdef CONFIG_ACX_MAC80211_USB struct usb_device *usbdev; rxbuffer_t rxtruncbuf; diff --git a/acx_struct_hw.h b/acx_struct_hw.h index 4096b35..3630145 100644 --- a/acx_struct_hw.h +++ b/acx_struct_hw.h @@ -892,7 +892,7 @@ struct rxdesc { } ACX_PACKED; /* size 52 = 0x34 */ -#if defined(ACX_MAC80211_PCI) || defined(ACX_MAC80211_MEM) +#if defined(CONFIG_ACX_MAC80211_PCI) || defined(CONFIG_ACX_MAC80211_MEM) /* Register I/O offsets */ #define ACX100_EEPROM_ID_OFFSET 0x380 @@ -999,7 +999,7 @@ struct rxhostdesc { /*********************************************************************** * BOM USB structures and constants */ -#ifdef ACX_MAC80211_USB +#ifdef CONFIG_ACX_MAC80211_USB /* Used for usb_txbuffer.desc field */ #define USB_TXBUF_TXDESC 0xA diff --git a/mem.c b/mem.c index a165986..dbabcfd 100644 --- a/mem.c +++ b/mem.c @@ -36,8 +36,6 @@ ** Eric McCorkle - Shadowsun */ -#define ACX_MAC80211_MEM 1 - #include "acx_debug.h" #define pr_acx pr_info diff --git a/merge.c b/merge.c index 3f16b1f..21fca06 100644 --- a/merge.c +++ b/merge.c @@ -30,13 +30,6 @@ #define pr_acx pr_info -/* this will be problematic when combined with the *_PCI macro. - acx_struct_dev.h defines iobase field 2x, with different types, for - MEM and PCI includes. Punt for now.. -*/ -#define ACX_MAC80211_MEM -/* #define ACX_MAC80211_PCI */ - #include "acx.h" #include "merge.h" diff --git a/pci.c b/pci.c index f5f3ddf..8d0cc49 100644 --- a/pci.c +++ b/pci.c @@ -15,7 +15,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define ACX_MAC80211_PCI 1 #include "acx_debug.h" diff --git a/usb.c b/usb.c index 829d89d..9fc9bb4 100644 --- a/usb.c +++ b/usb.c @@ -15,18 +15,17 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * USB support for TI ACX100/TNETW1450 based devices. Many parts are taken from - * the PCI driver. + * USB support for TI ACX100/TNETW1450 based devices. Many parts are + * taken from the PCI driver. * * Authors: * Martin Wawro <martin.wawro AT uni-dortmund.de> * Andreas Mohr <andi AT lisas.de> * * LOCKING - * callback functions called by USB core are running in interrupt context - * and thus have names with _i_. + * callback functions called by USB core are running in interrupt + * context and thus have names with _i_. */ -#define ACX_MAC80211_USB 1 #define pr_fmt(fmt) "acxusb.%s: " fmt, __FUNCTION__ #include "acx_debug.h" -- 1.7.10.1.487.ga3935e6 |
From: Jim C. <jim...@gm...> - 2012-05-12 21:34:51
|
Signed-off-by: Jim Cromie <jim...@gm...> --- acx_func.h | 6 ------ mem.c | 27 ++++----------------------- merge.c | 7 +++---- merge.h | 7 ++++++- pci.c | 25 +++---------------------- pci.h | 3 --- 6 files changed, 16 insertions(+), 59 deletions(-) diff --git a/acx_func.h b/acx_func.h index ae00a46..1247f52 100644 --- a/acx_func.h +++ b/acx_func.h @@ -588,9 +588,6 @@ int acx_issue_cmd_timeo_debug(acx_device_t * adev, unsigned cmd, * - * Mac80211 Ops * - - * Helpers - * - void acxpci_power_led(acx_device_t * adev, int enable); - * - * Ioctls * - int acx111pci_ioctl_info(struct net_device *ndev, struct iw_request_info * - *info, struct iw_param *vwrq, char *extra); * - int acx100pci_ioctl_set_phy_amp_bias(struct net_device *ndev, struct * - iw_request_info *info, struct iw_param *vwrq, char *extra); @@ -638,9 +635,6 @@ int acxmem_issue_cmd_timeo_debug(acx_device_t *adev, unsigned cmd, * Irq Handling, Timer * - void acxmem_set_interrupt_mask(acx_device_t *adev); * - - * Helpers - * - void acxmem_power_led(acx_device_t *adev, int enable); - * - * Ioctls * int acx111pci_ioctl_info(struct ieee80211_hw *hw, struct iw_request_info *info, struct iw_param *vwrq, char *extra); * int acx100mem_ioctl_set_phy_amp_bias(struct ieee80211_hw *hw, struct iw_request_info *info, struct iw_param *vwrq, char *extra); diff --git a/mem.c b/mem.c index dbabcfd..86dc79c 100644 --- a/mem.c +++ b/mem.c @@ -1760,29 +1760,10 @@ static const struct ieee80211_ops acxmem_hw_ops = { * ================================================== */ -void acxmem_power_led(acx_device_t *adev, int enable) -{ - u16 gpio_pled = IS_ACX111(adev) ? 0x0040 : 0x0800; - - /* A hack. Not moving message rate limiting to adev->xxx - * (it's only a debug message after all) */ - static int rate_limit = 0; - - if (rate_limit++ < 3) - log(L_IOCTL, "Please report in case toggling the power " - "LED doesn't work for your card!\n"); - if (enable) - write_reg16(adev, IO_ACX_GPIO_OUT, read_reg16(adev, IO_ACX_GPIO_OUT) - & ~gpio_pled); - else - write_reg16(adev, IO_ACX_GPIO_OUT, read_reg16(adev, IO_ACX_GPIO_OUT) - | gpio_pled); -} - INLINE_IO int acxmem_adev_present(acx_device_t *adev) { - /* fast version (accesses the first register, IO_ACX_SOFT_RESET, - * which should be safe): */ + /* fast version (accesses the first register, + * IO_ACX_SOFT_RESET, which should be safe): */ return acx_readl(adev->iobase) != 0xffffffff; } @@ -1804,7 +1785,7 @@ STATick void update_link_quality_led(acx_device_t *adev) if (time_after(jiffies, adev->brange_time_last_state_change + (HZ/2 - HZ/2 * (unsigned long)qual / adev->brange_max_quality ) )) { - acxmem_power_led(adev, (adev->brange_last_state == 0)); + acx_power_led(adev, (adev->brange_last_state == 0)); adev->brange_last_state ^= 1; /* toggle */ adev->brange_time_last_state_change = jiffies; } @@ -2484,7 +2465,7 @@ STATick int __devexit acxmem_remove(struct platform_device *pdev) /* disable power LED to save power :-) */ log(L_INIT, "switching off power LED to save power\n"); - acxmem_power_led(adev, 0); + acx_power_led(adev, 0); /* stop our eCPU */ if (IS_ACX111(adev)) { diff --git a/merge.c b/merge.c index 21fca06..3f07da7 100644 --- a/merge.c +++ b/merge.c @@ -4125,8 +4125,8 @@ void acx_op_stop(struct ieee80211_hw *hw) * BOM Helpers * ================================================== */ -# if 0 // defer -void acxmem_power_led(acx_device_t *adev, int enable) { +void acx_power_led(acx_device_t * adev, int enable) +{ u16 gpio_pled = IS_ACX111(adev) ? 0x0040 : 0x0800; /* A hack. Not moving message rate limiting to adev->xxx (it's @@ -4137,13 +4137,12 @@ void acxmem_power_led(acx_device_t *adev, int enable) { log(L_IOCTL, "Please report in case toggling the power " "LED doesn't work for your card!\n"); if (enable) - write_reg16(adev, IO_ACX_GPIO_OUT, + write_reg16(adev, IO_ACX_GPIO_OUT, read_reg16(adev, IO_ACX_GPIO_OUT) & ~gpio_pled); else write_reg16(adev, IO_ACX_GPIO_OUT, read_reg16(adev, IO_ACX_GPIO_OUT) | gpio_pled); } -#endif /* identical */ INLINE_IO int acxmem_adev_present(acx_device_t *adev) diff --git a/merge.h b/merge.h index 1f4bd11..fcac272 100644 --- a/merge.h +++ b/merge.h @@ -63,7 +63,12 @@ int acxmem_upload_fw(acx_device_t *adev); int acxmem_upload_radio(acx_device_t *adev); int acxpci_upload_radio(acx_device_t *adev); -#if defined(CONFIG_ACX_MAC80211_PCI) || defined(CONFIG_ACX_MAC80211_MEM) +void acx_power_led(acx_device_t * adev, int enable); + + +#if defined(CONFIG_ACX_MAC80211_PCI) \ + || defined(CONFIG_ACX_MAC80211_MEM) + void acxmem_update_queue_indicator(acx_device_t *adev, int txqueue); diff --git a/pci.c b/pci.c index 8d0cc49..95b9468 100644 --- a/pci.c +++ b/pci.c @@ -517,7 +517,7 @@ static void update_link_quality_led(acx_device_t * adev) (HZ / 2 - HZ / 2 * (unsigned long)qual / adev->brange_max_quality))) { - acxpci_l_power_led(adev, (adev->brange_last_state == 0)); + acx_power_led(adev, (adev->brange_last_state == 0)); adev->brange_last_state ^= 1; // toggle adev->brange_time_last_state_change = jiffies; } @@ -726,25 +726,6 @@ static const struct ieee80211_ops acxpci_hw_ops = { * ================================================== */ -void acxpci_power_led(acx_device_t * adev, int enable) -{ - u16 gpio_pled = IS_ACX111(adev) ? 0x0040 : 0x0800; - - /* A hack. Not moving message rate limiting to adev->xxx (it's - * only a debug message after all) */ - static int rate_limit = 0; - - if (rate_limit++ < 3) - log(L_IOCTL, "Please report in case toggling the power " - "LED doesn't work for your card\n"); - if (enable) - write_reg16(adev, IO_ACX_GPIO_OUT, - read_reg16(adev, IO_ACX_GPIO_OUT) & ~gpio_pled); - else - write_reg16(adev, IO_ACX_GPIO_OUT, - read_reg16(adev, IO_ACX_GPIO_OUT) | gpio_pled); -} - INLINE_IO int acxpci_adev_present(acx_device_t *adev) { /* fast version (accesses the first register, @@ -1505,7 +1486,7 @@ void __devexit acxpci_remove(struct pci_dev *pdev) #endif /* disable power LED to save power :-) */ log(L_INIT, "switching off power LED to save power\n"); - acxpci_power_led(adev, 0); + acx_power_led(adev, 0); /* stop our eCPU */ if (IS_ACX111(adev)) { /* FIXME: does this actually keep halting the @@ -2063,7 +2044,7 @@ static void vlynq_remove(struct vlynq_device *vdev) } /* disable power LED to save power :-) */ log(L_INIT, "switching off power LED to save power\n"); - acxpci_power_led(adev, 0); + acx_power_led(adev, 0); /* stop our eCPU */ /* OW PCI still does something here (although also need to be reviewed). */ diff --git a/pci.h b/pci.h index d7478c0..306f53b 100644 --- a/pci.h +++ b/pci.h @@ -39,9 +39,6 @@ tx_t *acxpci_alloc_tx(acx_device_t *adev); /* Irq Handling, Timer */ -/* Helpers */ -void acxpci_power_led(acx_device_t *adev, int enable); - /* Ioctls * Driver, Module */ -- 1.7.10.1.487.ga3935e6 |
From: Jim C. <jim...@gm...> - 2012-05-12 21:34:53
|
- change "acx_device_t * adev" to "acx_device_t *adev", per checkpatch style complaints - wrap long fn-protos, breaking on param decls, - goto labels in column 0 NB: I use Emacs, with style enforced by .emacs preference settings given in Documentation/CodingStyle. Its not perfect, but (apparently) good enough for Linux to not have refined it further. Signed-off-by: Jim Cromie <jim...@gm...> --- common.c | 139 ++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 84 insertions(+), 55 deletions(-) diff --git a/common.c b/common.c index dfaa5fb..59de25b 100644 --- a/common.c +++ b/common.c @@ -58,8 +58,8 @@ #ifdef OW_20100613_OBSELETE_ACXLOCK_REMOVE void acx_lock_unhold(void); void acx_sem_unhold(void); -void acx_lock_debug(acx_device_t * adev, const char *where); -void acx_unlock_debug(acx_device_t * adev, const char *where); +void acx_lock_debug(acx_device_t *adev, const char *where); +void acx_unlock_debug(acx_device_t *adev, const char *where); static inline const char *acx_sanitize_str(const char *s); #endif @@ -74,40 +74,40 @@ void acx_dump_bytes(const void *data, int num); const char *acx_cmd_status_str(unsigned int state); /* Data Access */ -static int acx100_init_memory_pools(acx_device_t * adev, const acx_ie_memmap_t * mmt); -static int acx100_create_dma_regions(acx_device_t * adev); -static int acx111_create_dma_regions(acx_device_t * adev); +static int acx100_init_memory_pools(acx_device_t *adev, const acx_ie_memmap_t * mmt); +static int acx100_create_dma_regions(acx_device_t *adev); +static int acx111_create_dma_regions(acx_device_t *adev); /* Firmware, EEPROM, Phy */ MODULE_FIRMWARE("tiacx111"); MODULE_FIRMWARE("tiacx111c16"); MODULE_FIRMWARE("tiacx111r16"); -void acx_get_firmware_version(acx_device_t * adev); -void acx_display_hardware_details(acx_device_t * adev); +void acx_get_firmware_version(acx_device_t *adev); +void acx_display_hardware_details(acx_device_t *adev); firmware_image_t *acx_read_fw(struct device *dev, const char *file, u32 * size); -void acx_parse_configoption(acx_device_t * adev, const acx111_ie_configoption_t * pcfg); +void acx_parse_configoption(acx_device_t *adev, const acx111_ie_configoption_t * pcfg); int acx_read_phy_reg(acx_device_t *adev, u32 reg, u8 *charbuf); int acx_write_phy_reg(acx_device_t *adev, u32 reg, u8 value); /* CMDs (Control Path) */ int acx_issue_cmd_timeo_debug(acx_device_t *adev, unsigned cmd, void *param, unsigned len, unsigned timeout, const char* cmdstr); int acx_configure_debug(acx_device_t *adev, void *pdr, int type, const char *typestr); -static int acx111_get_feature_config(acx_device_t * adev, u32 * feature_options, u32 * data_flow_options); -static int acx111_set_feature_config(acx_device_t * adev, u32 feature_options, u32 data_flow_options, unsigned int mode); -static inline int acx111_feature_off(acx_device_t * adev, u32 f, u32 d); -static inline int acx111_feature_on(acx_device_t * adev, u32 f, u32 d); -static inline int acx111_feature_set(acx_device_t * adev, u32 f, u32 d); -int acx_interrogate_debug(acx_device_t * adev, void *pdr, int type, const char *typestr); +static int acx111_get_feature_config(acx_device_t *adev, u32 * feature_options, u32 * data_flow_options); +static int acx111_set_feature_config(acx_device_t *adev, u32 feature_options, u32 data_flow_options, unsigned int mode); +static inline int acx111_feature_off(acx_device_t *adev, u32 f, u32 d); +static inline int acx111_feature_on(acx_device_t *adev, u32 f, u32 d); +static inline int acx111_feature_set(acx_device_t *adev, u32 f, u32 d); +int acx_interrogate_debug(acx_device_t *adev, void *pdr, int type, const char *typestr); static inline unsigned int acx_rate111to5bits(unsigned int rate); int acx_cmd_join_bssid(acx_device_t *adev, const u8 *bssid); /* Configuration (Control Path) */ -void acx_set_defaults(acx_device_t * adev); +void acx_set_defaults(acx_device_t *adev); void acx_update_card_settings(acx_device_t *adev); -void acx_start(acx_device_t * adev); +void acx_start(acx_device_t *adev); int acx_net_reset(struct ieee80211_hw *ieee); -int acx_init_mac(acx_device_t * adev); +int acx_init_mac(acx_device_t *adev); int acx_setup_modes(acx_device_t *adev); static int acx_set_mode(acx_device_t *adev, u16 mode); @@ -124,8 +124,8 @@ static void acx_update_reg_domain(acx_device_t *adev); static int acx1xx_set_tx_level_dbm(acx_device_t *adev, int level_dbm); static int acx1xx_update_tx_level_dbm(acx_device_t *adev); -static int acx1xx_get_tx_level(acx_device_t * adev); -static int acx1xx_set_tx_level(acx_device_t * adev, u8 level_val); +static int acx1xx_get_tx_level(acx_device_t *adev); +static int acx1xx_set_tx_level(acx_device_t *adev, u8 level_val); static int acx1xx_update_tx_level(acx_device_t *adev); static int acx1xx_get_antenna(acx_device_t *adev); @@ -188,13 +188,13 @@ static int acx_set_tim_template(acx_device_t *adev, u8 *data, int len); static int acx_set_probe_response_template(acx_device_t *adev, u8* data, int len); static u8* acx_beacon_find_tim(struct sk_buff *beacon_skb); -static int acx_init_max_template_generic(acx_device_t * adev, unsigned int len, unsigned int cmd); -static int acx_init_packet_templates(acx_device_t * adev); -static int acx_init_max_null_data_template(acx_device_t * adev); -static int acx_init_max_beacon_template(acx_device_t * adev); -static int acx_init_max_tim_template(acx_device_t * adev); -static int acx_init_max_probe_response_template(acx_device_t * adev); -static int acx_init_max_probe_request_template(acx_device_t * adev); +static int acx_init_max_template_generic(acx_device_t *adev, unsigned int len, unsigned int cmd); +static int acx_init_packet_templates(acx_device_t *adev); +static int acx_init_max_null_data_template(acx_device_t *adev); +static int acx_init_max_beacon_template(acx_device_t *adev); +static int acx_init_max_tim_template(acx_device_t *adev); +static int acx_init_max_probe_response_template(acx_device_t *adev); +static int acx_init_max_probe_request_template(acx_device_t *adev); #ifdef UNUSED_BUT_USEFULL static int acx_s_set_probe_request_template(acx_device_t *adev); @@ -203,14 +203,14 @@ static int acx_s_set_tim_template_off(acx_device_t *adev); #endif #if POWER_SAVE_80211 -static int acx_s_set_null_data_template(acx_device_t * adev); +static int acx_s_set_null_data_template(acx_device_t *adev); #endif /* Recalibration (Control Path) */ static int acx111_set_recalib_auto(acx_device_t *adev, int enable); static int acx111_update_recalib_auto(acx_device_t *adev); static int acx_recalib_radio(acx_device_t *adev); -static void acx_after_interrupt_recalib(acx_device_t * adev); +static void acx_after_interrupt_recalib(acx_device_t *adev); /* Other (Control Path) */ #if 0 @@ -218,30 +218,42 @@ static u8 acx_plcp_get_bitrate_cck(u8 plcp); static u8 acx_plcp_get_bitrate_ofdm(u8 plcp); #endif static void acx_set_sane_reg_domain(acx_device_t *adev, int do_set); -static void acx111_sens_radio_16_17(acx_device_t * adev); -static void acx_update_ratevector(acx_device_t * adev); +static void acx111_sens_radio_16_17(acx_device_t *adev); +static void acx_update_ratevector(acx_device_t *adev); #if POWER_SAVE_80211 -static void acx_s_update_80211_powersave_mode(acx_device_t * adev) +static void acx_s_update_80211_powersave_mode(acx_device_t *adev) #endif /* Proc, Debug */ #ifdef CONFIG_PROC_FS static int acx_proc_show_diag(struct seq_file *file, void *v); -static ssize_t acx_proc_write_diag(struct file *file, const char __user *buf, size_t count, loff_t *ppos); +static ssize_t acx_proc_write_diag(struct file *file, + const char __user *buf, size_t count, + loff_t *ppos); static int acx_proc_show_acx(struct seq_file *file, void *v); static int acx_proc_show_eeprom(struct seq_file *file, void *v); static int acx_proc_show_phy(struct seq_file *file, void *v); static int acx_proc_show_debug(struct seq_file *file, void *v); -static ssize_t acx_proc_write_debug(struct file *file, const char __user *buf, size_t count, loff_t *ppos); +static ssize_t acx_proc_write_debug(struct file *file, + const char __user *buf, size_t count, + loff_t *ppos); static int acx_proc_show_sensitivity(struct seq_file *file, void *v); -static ssize_t acx_proc_write_sensitivity(struct file *file, const char __user *buf, size_t count, loff_t *ppos); +static ssize_t acx_proc_write_sensitivity(struct file *file, + const char __user *buf, + size_t count, loff_t *ppos); static int acx_proc_show_tx_level(struct seq_file *file, void *v); -static ssize_t acx111_proc_write_tx_level(struct file *file, const char __user *buf, size_t count, loff_t *ppos); +static ssize_t acx111_proc_write_tx_level(struct file *file, + const char __user *buf, + size_t count, loff_t *ppos); static int acx_proc_show_reg_domain(struct seq_file *file, void *v); -static ssize_t acx_proc_write_reg_domain(struct file *file, const char __user *buf, size_t count, loff_t *ppos); +static ssize_t acx_proc_write_reg_domain(struct file *file, + const char __user *buf, + size_t count, loff_t *ppos); static int acx_proc_show_antenna(struct seq_file *file, void *v); -static ssize_t acx_proc_write_antenna(struct file *file, const char __user *buf, size_t count, loff_t *ppos); +static ssize_t acx_proc_write_antenna(struct file *file, + const char __user *buf, size_t count, + loff_t *ppos); /* obsoleted by debugfs.c static int acx_proc_open(struct inode *inode, struct file *file); @@ -252,7 +264,7 @@ int acx_proc_unregister_entries(struct ieee80211_hw *ieee); #endif /* Rx Path */ -void acx_process_rxbuf(acx_device_t * adev, rxbuffer_t * rxbuf); +void acx_process_rxbuf(acx_device_t *adev, rxbuffer_t * rxbuf); static void acx_rx(acx_device_t *adev, rxbuffer_t *rxbuf); /* Tx Path */ @@ -272,10 +284,17 @@ void acx_wake_queue(struct ieee80211_hw *hw, const char *msg); tx_t *acx_alloc_tx(acx_device_t *adev, unsigned int len); static void acx_dealloc_tx(acx_device_t *adev, tx_t *tx_opaque); static void *acx_get_txbuf(acx_device_t *adev, tx_t *tx_opaque); -static void acx_tx_data(acx_device_t *adev, tx_t *tx_opaque, int len, struct ieee80211_tx_info *ieeectl, struct sk_buff *skb); -void acxpcimem_handle_tx_error(acx_device_t *adev, u8 error, unsigned int finger, struct ieee80211_tx_info *info); -u16 acx111_tx_build_rateset(acx_device_t *adev, txdesc_t *txdesc, struct ieee80211_tx_info *info); -void acx111_tx_build_txstatus(acx_device_t *adev, struct ieee80211_tx_info *txstatus, u16 r111, u8 ack_failures); +static void acx_tx_data(acx_device_t *adev, tx_t *tx_opaque, + int len, struct ieee80211_tx_info *ieeectl, + struct sk_buff *skb); +void acxpcimem_handle_tx_error(acx_device_t *adev, u8 error, + unsigned int finger, + struct ieee80211_tx_info *info); +u16 acx111_tx_build_rateset(acx_device_t *adev, txdesc_t *txdesc, + struct ieee80211_tx_info *info); +void acx111_tx_build_txstatus(acx_device_t *adev, + struct ieee80211_tx_info *txstatus, u16 r111, + u8 ack_failures); u16 acx_rate111_hwvalue_to_bitrate(u16 hw_value); int acx_rate111_hwvalue_to_rateindex(u16 hw_value); @@ -300,27 +319,37 @@ void acx_after_interrupt_task(acx_device_t *adev); void acx_schedule_task(acx_device_t *adev, unsigned int set_flag); void acx_log_irq(u16 irqtype); void acx_timer(unsigned long address); -void acx_set_timer(acx_device_t * adev, int timeout_us); +void acx_set_timer(acx_device_t *adev, int timeout_us); /* Mac80211 Ops */ int acx_op_config(struct ieee80211_hw *hw, u32 changed); -void acx_op_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *info, u32 changed); -int acx_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key); -void acx_op_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, unsigned int *total_flags, u64 multicast); +void acx_op_bss_info_changed(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_bss_conf *info, u32 changed); +int acx_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, + struct ieee80211_vif *vif, struct ieee80211_sta *sta, + struct ieee80211_key_conf *key); +void acx_op_configure_filter(struct ieee80211_hw *hw, + unsigned int changed_flags, + unsigned int *total_flags, u64 multicast); #if CONFIG_ACX_MAC80211_VERSION >= KERNEL_VERSION(3, 2, 0) -int acx_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, const struct ieee80211_tx_queue_params *params); +int acx_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + u16 queue, const struct ieee80211_tx_queue_params *params); #else -int acx_conf_tx(struct ieee80211_hw *hw, u16 queue, const struct ieee80211_tx_queue_params *params); +int acx_conf_tx(struct ieee80211_hw *hw, u16 queue, + const struct ieee80211_tx_queue_params *params); #endif int acx_op_get_stats(struct ieee80211_hw *hw, struct ieee80211_low_level_stats *stats); #if CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(2, 6, 34) -int acx_e_op_get_tx_stats(struct ieee80211_hw *hw, struct ieee80211_tx_queue_stats *stats); +int acx_e_op_get_tx_stats(struct ieee80211_hw *hw, + struct ieee80211_tx_queue_stats *stats); #endif -int acx_op_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, bool set); +int acx_op_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, + bool set); static int acx_do_job_update_tim(acx_device_t *adev); /* Helpers */ @@ -540,11 +569,11 @@ BUILD_BUG_DECL(acx111_ie_len_dot11__VS__acx100_ie_len_dot11, /* We define rates without short-preamble support fo now */ static struct ieee80211_rate acx100_rates[] = { - { .bitrate = 10, .hw_value = RATE100_1, }, - { .bitrate = 20, .hw_value = RATE100_2, }, - { .bitrate = 55, .hw_value = RATE100_5, }, - { .bitrate = 110, .hw_value = RATE100_11, }, - { .bitrate = 220, .hw_value = RATE100_22, }, + { .bitrate = 10, .hw_value = RATE100_1, }, + { .bitrate = 20, .hw_value = RATE100_2, }, + { .bitrate = 55, .hw_value = RATE100_5, }, + { .bitrate = 110, .hw_value = RATE100_11, }, + { .bitrate = 220, .hw_value = RATE100_22, }, }; static struct ieee80211_rate acx111_rates[] = { -- 1.7.10.1.487.ga3935e6 |
From: Jim C. <jim...@gm...> - 2012-05-12 21:34:53
|
whitepace indenting per Linux emacs preferences, esp goto labels. a few unneeded braces removals. NOTICE: chip_type is hardcoded in mem.c, may surprise later. chip_type = CHIPTYPE_ACX100; Signed-off-by: Jim Cromie <jim...@gm...> --- mem.c | 24 ++++++++++++------------ pci.c | 67 ++++++++++++++++++++++++++++++++++--------------------------------- 2 files changed, 46 insertions(+), 45 deletions(-) diff --git a/mem.c b/mem.c index 86dc79c..0df85eb 100644 --- a/mem.c +++ b/mem.c @@ -2170,7 +2170,8 @@ STATick int __devinit acxmem_probe(struct platform_device *pdev) FN_ENTER; - ieee = ieee80211_alloc_hw(sizeof(struct acx_device), &acxmem_hw_ops); + ieee = ieee80211_alloc_hw(sizeof(struct acx_device), + &acxmem_hw_ops); if (!ieee) { pr_acx("could not allocate ieee80211 structure %s\n", pdev->name); @@ -2239,11 +2240,11 @@ STATick int __devinit acxmem_probe(struct platform_device *pdev) * Works for now (possible values are 1 and 2) */ chip_type = CHIPTYPE_ACX100; /* acx100 and acx111 have different PCI memory regions */ - if (chip_type == CHIPTYPE_ACX100) { + if (chip_type == CHIPTYPE_ACX100) chip_name = "ACX100"; - } else if (chip_type == CHIPTYPE_ACX111) { + else if (chip_type == CHIPTYPE_ACX111) chip_name = "ACX111"; - } else { + else { pr_acx("unknown chip type 0x%04X\n", chip_type); goto fail_unknown_chiptype; } @@ -2388,19 +2389,19 @@ STATick int __devinit acxmem_probe(struct platform_device *pdev) /* error paths: undo everything in reverse order... */ - fail_ieee80211_register_hw: +fail_ieee80211_register_hw: - fail_acx_setup_modes: +fail_acx_setup_modes: - fail_proc_register_entries: +fail_proc_register_entries: acx_proc_unregister_entries(ieee); - fail_complete_hw_reset: +fail_complete_hw_reset: - fail_request_irq: +fail_request_irq: free_irq(adev->irq, adev); - fail_ioremap: +fail_ioremap: if (adev->iobase) iounmap((void *)adev->iobase); @@ -2410,8 +2411,7 @@ fail_ieee80211_alloc_hw: platform_set_drvdata(pdev, NULL); ieee80211_free_hw(ieee); - done: - +done: FN_EXIT1(result); return result; } diff --git a/pci.c b/pci.c index 95b9468..27a3a5c 100644 --- a/pci.c +++ b/pci.c @@ -1102,7 +1102,8 @@ acxpci_probe(struct pci_dev *pdev, const struct pci_device_id *id) FN_ENTER; - ieee = ieee80211_alloc_hw(sizeof(struct acx_device), &acxpci_hw_ops); + ieee = ieee80211_alloc_hw(sizeof(struct acx_device), + &acxpci_hw_ops); if (!ieee) { pr_acx("could not allocate ieee80211 structure %s\n", pci_name(pdev)); @@ -1119,7 +1120,7 @@ acxpci_probe(struct pci_dev *pdev, const struct pci_device_id *id) */ ieee->wiphy->interface_modes = - BIT(NL80211_IFTYPE_STATION) | + BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP); ieee->queues = 1; @@ -1353,7 +1354,7 @@ acxpci_probe(struct pci_dev *pdev, const struct pci_device_id *id) err = acx_setup_modes(adev); if (err) { - pr_acx("can't setup hwmode\n"); + pr_acx("can't setup hwmode\n"); goto fail_setup_modes; } @@ -1377,53 +1378,53 @@ acxpci_probe(struct pci_dev *pdev, const struct pci_device_id *id) */ /* err = ieee80211_register_hw(ieee); */ - fail_ieee80211_register_hw: - ieee80211_unregister_hw(ieee); +fail_ieee80211_register_hw: + ieee80211_unregister_hw(ieee); /* err = acx_setup_modes(adev) */ - fail_setup_modes: +fail_setup_modes: /* acx_proc_register_entries(ieee, 0) */ - fail_proc_register_entries: - acx_proc_unregister_entries(ieee); +fail_proc_register_entries: + acx_proc_unregister_entries(ieee); /* acxpci_read_eeprom_byte(adev, 0x05, &adev->eeprom_version) */ - fail_read_eeprom_byte: +fail_read_eeprom_byte: /* acx_s_init_mac(adev) */ - fail_init_mac: +fail_init_mac: /* acxpci_s_reset_dev(adev) */ - fail_reset_dev: +fail_reset_dev: /* request_irq(adev->irq, acxpci_i_interrupt, IRQF_SHARED, KBUILD_MODNAME, */ - fail_request_irq: - free_irq(adev->irq, adev); - - fail_no_irq: +fail_request_irq: + free_irq(adev->irq, adev); +fail_no_irq: + /* pci_iomap(pdev, mem_region2, 0) */ - fail_iomap2: - pci_iounmap(pdev, mem2); +fail_iomap2: + pci_iounmap(pdev, mem2); /* pci_iomap(pdev, mem_region1, 0) */ - fail_iomap1: - pci_iounmap(pdev, mem1); +fail_iomap1: + pci_iounmap(pdev, mem1); /* err = pci_request_region(pdev, mem_region2, "acx_2"); */ - fail_request_mem_region2: - pci_release_region(pdev, mem_region2); +fail_request_mem_region2: + pci_release_region(pdev, mem_region2); /* err = pci_request_region(pdev, mem_region1, "acx_1"); */ - fail_request_mem_region1: - pci_release_region(pdev, mem_region1); +fail_request_mem_region1: + pci_release_region(pdev, mem_region1); - fail_unknown_chiptype: +fail_unknown_chiptype: /* pci_enable_device(pdev) */ - fail_pci_enable_device: - pci_disable_device(pdev); - pci_set_drvdata(pdev, NULL); +fail_pci_enable_device: + pci_disable_device(pdev); + pci_set_drvdata(pdev, NULL); /* OW TODO Check if OK for PM */ #ifdef CONFIG_PM @@ -1431,12 +1432,12 @@ acxpci_probe(struct pci_dev *pdev, const struct pci_device_id *id) #endif /* ieee80211_alloc_hw */ - fail_ieee80211_alloc_hw: - ieee80211_free_hw(ieee); - - done: - FN_EXIT1(result); - return result; +fail_ieee80211_alloc_hw: + ieee80211_free_hw(ieee); + +done: + FN_EXIT1(result); + return result; } -- 1.7.10.1.487.ga3935e6 |
From: Jim C. <jim...@gm...> - 2012-05-12 21:34:54
|
In prep for merge of mem-inlines.h and pci-inlines.h, hide some boilerplate code in macros. No object checksums were harmed (altered) by this patch. ;-) Signed-off-by: Jim Cromie <jim...@gm...> --- mem-inlines.h | 109 +++++++++++++++++++++++++++------------------------------- 1 file changed, 50 insertions(+), 59 deletions(-) diff --git a/mem-inlines.h b/mem-inlines.h index a9052b6..a1ac7d6 100644 --- a/mem-inlines.h +++ b/mem-inlines.h @@ -81,19 +81,21 @@ /* Endianess: read[lw], write[lw] do little-endian conversion internally */ #define acx_readl(v) readl((v)) #define acx_readw(v) readw((v)) +#define acx_readb(v) readb((v)) #define acx_writel(v, r) writel((v), (r)) #define acx_writew(v, r) writew((v), (r)) +#define acx_writeb(v, r) writeb((v), (r)) /* This controls checking of spin-locking in the mem-interface */ #define ACXMEM_SPIN_CHECK 0 #if ACXMEM_SPIN_CHECK -#define ACXMEM_WARN_NOT_SPIN_LOCKED \ -do { \ - if (!spin_is_locked(&adev->spinlock)){ \ +#define ACXMEM_WARN_NOT_SPIN_LOCKED \ +do { \ + if (!spin_is_locked(&adev->spinlock)){ \ logf0(L_ANY, "mem: warning: data access not locked!\n"); \ - dump_stack(); \ - } \ + dump_stack(); \ + } \ } while (0) #else #define ACXMEM_WARN_NOT_SPIN_LOCKED do { } while (0) @@ -119,21 +121,45 @@ INLINE_IO u32 read_id_register(acx_device_t *adev) return acx_readl(adev->iobase + ACX_SLV_REG_DATA); } +#define check_IO_ACX_ECPU_CTRL(adev, addr, offset) \ + \ + if (offset > IO_ACX_ECPU_CTRL) \ + addr = offset; \ + else \ + addr = adev->io[offset]; + +/* note the buried return */ +#define ret_addr_lt20_rd_(adev, addr, _lwb) \ + if (addr < 0x20) \ + return acx_read##_lwb(((u8 *) adev->iobase) + addr); + +#define ret_addr_lt20_rdl(adev, addr) ret_addr_lt20_rd_(adev, addr, l) +#define ret_addr_lt20_rdw(adev, addr) ret_addr_lt20_rd_(adev, addr, w) +#define ret_addr_lt20_rdb(adev, addr) ret_addr_lt20_rd_(adev, addr, b) + +/* note the buried return */ +#define ret_addr_lt20_wr_(adev, addr, _lwb, val) \ + if (addr < 0x20) { \ + acx_write##_lwb(val, ((u8 *) adev->iobase) + addr); \ + return; \ + } + +#define ret_addr_lt20_wrl(adev, addr, val) \ + ret_addr_lt20_wr_(adev, addr, l, val) +#define ret_addr_lt20_wrw(adev, addr, val) \ + ret_addr_lt20_wr_(adev, addr, w, val) +#define ret_addr_lt20_wrb(adev, addr, val) \ + ret_addr_lt20_wr_(adev, addr, b, val) + + INLINE_IO u32 read_reg32(acx_device_t *adev, unsigned int offset) { u32 val; u32 addr; ACXMEM_WARN_NOT_SPIN_LOCKED; - - if (offset > IO_ACX_ECPU_CTRL) - addr = offset; - else - addr = adev->io[offset]; - - if (addr < 0x20) { - return acx_readl(((u8 *) adev->iobase) + addr); - } + check_IO_ACX_ECPU_CTRL(adev, addr, offset); + ret_addr_lt20_rdl(adev, addr); acx_writel(addr, adev->iobase + ACX_SLV_REG_ADDR); val = acx_readl(adev->iobase + ACX_SLV_REG_DATA); @@ -147,15 +173,8 @@ INLINE_IO u16 read_reg16(acx_device_t *adev, unsigned int offset) u32 addr; ACXMEM_WARN_NOT_SPIN_LOCKED; - - if (offset > IO_ACX_ECPU_CTRL) - addr = offset; - else - addr = adev->io[offset]; - - if (addr < 0x20) { - return acx_readw(((u8 *) adev->iobase) + addr); - } + check_IO_ACX_ECPU_CTRL(adev, addr, offset); + ret_addr_lt20_rdw(adev, addr); acx_writel(addr, adev->iobase + ACX_SLV_REG_ADDR); lo = acx_readw((u16 *) (adev->iobase + ACX_SLV_REG_DATA)); @@ -169,14 +188,8 @@ INLINE_IO u8 read_reg8(acx_device_t *adev, unsigned int offset) u32 addr; ACXMEM_WARN_NOT_SPIN_LOCKED; - - if (offset > IO_ACX_ECPU_CTRL) - addr = offset; - else - addr = adev->io[offset]; - - if (addr < 0x20) - return readb(((u8 *) adev->iobase) + addr); + check_IO_ACX_ECPU_CTRL(adev, addr, offset); + ret_addr_lt20_rdb(adev, addr); acx_writel(addr, adev->iobase + ACX_SLV_REG_ADDR); lo = acx_readw((u8 *) (adev->iobase + ACX_SLV_REG_DATA)); @@ -189,16 +202,8 @@ INLINE_IO void write_reg32(acx_device_t *adev, unsigned int offset, u32 val) u32 addr; ACXMEM_WARN_NOT_SPIN_LOCKED; - - if (offset > IO_ACX_ECPU_CTRL) - addr = offset; - else - addr = adev->io[offset]; - - if (addr < 0x20) { - acx_writel(val, ((u8 *) adev->iobase) + addr); - return; - } + check_IO_ACX_ECPU_CTRL(adev, addr, offset); + ret_addr_lt20_wrl(adev, addr, val); acx_writel(addr, adev->iobase + ACX_SLV_REG_ADDR); acx_writel(val, adev->iobase + ACX_SLV_REG_DATA); @@ -209,16 +214,9 @@ INLINE_IO void write_reg16(acx_device_t *adev, unsigned int offset, u16 val) u32 addr; ACXMEM_WARN_NOT_SPIN_LOCKED; + check_IO_ACX_ECPU_CTRL(adev, addr, offset); + ret_addr_lt20_wrw(adev, addr, val); - if (offset > IO_ACX_ECPU_CTRL) - addr = offset; - else - addr = adev->io[offset]; - - if (addr < 0x20) { - acx_writew(val, ((u8 *) adev->iobase) + addr); - return; - } acx_writel(addr, adev->iobase + ACX_SLV_REG_ADDR); acx_writew(val, (u16 *) (adev->iobase + ACX_SLV_REG_DATA)); } @@ -228,16 +226,9 @@ INLINE_IO void write_reg8(acx_device_t *adev, unsigned int offset, u8 val) u32 addr; ACXMEM_WARN_NOT_SPIN_LOCKED; + check_IO_ACX_ECPU_CTRL(adev, addr, offset); + ret_addr_lt20_wrb(adev, addr, val); - if (offset > IO_ACX_ECPU_CTRL) - addr = offset; - else - addr = adev->io[offset]; - - if (addr < 0x20) { - writeb(val, ((u8 *) adev->iobase) + addr); - return; - } acx_writel(addr, adev->iobase + ACX_SLV_REG_ADDR); writeb(val, (u8 *) (adev->iobase + ACX_SLV_REG_DATA)); } -- 1.7.10.1.487.ga3935e6 |
From: Jim C. <jim...@gm...> - 2012-05-12 21:34:56
|
Oliver's testing with iperf revealed a lockup, masked by the "unnecessary" locking on pci preserved during the merge, which was undone by commit 510f22fe4e5f. His analysis determined that the root-cause was that the wrong IO_INLINE routines were used (merge.c has both). This patch merges (mem|pci)-inlines.h together, into inlines.h, using IS_PCI to sort out the differences. Signed-off-by: Jim Cromie <jim...@gm...> --- inlines.h | 449 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mem.c | 2 +- merge.c | 2 +- pci.c | 2 +- 4 files changed, 452 insertions(+), 3 deletions(-) diff --git a/inlines.h b/inlines.h new file mode 100644 index 0000000..f70dd9d --- /dev/null +++ b/inlines.h @@ -0,0 +1,449 @@ +#ifndef _MEM_INLINES_H_ +#define _MEM_INLINES_H_ + +/* currently need this even for no-mem builds, as it contains the + * locking elements used in merge.c. TBD whether its worth + * repartitioning to achieve this + */ +#if defined(CONFIG_ACX_MAC80211_MEM) || 1 + +/* + * BOM Data Access + * Locking in mem + * ================================================== + */ + +/* + * Locking in mem is more complex as for pci, because the different + * data-access functions below need to be protected against incoming + * interrupts. + * + * Data-access on the mem device is always going in serveral, + * none-atomic steps, involving 2 or more register writes + * (e.g. ACX_SLV_REG_ADDR, ACX_SLV_REG_DATA). + * + * If an interrupt is serviced while a data-access function is + * ongoing, this may give access interference with by the involved + * operations, since the irq routine is also using the same + * data-access functions. + * + * In case of interference, this often manifests during driver + * operations as failure of device cmds and subsequent hanging of the + * device. It especially appeared during sw-scans while a connection + * was up. + * + * For this reason, irqs shall be off while data access functions are + * executed, and for this we'll use the acx-spinlock. + * + * In pci we don't have this problem, because all data-access + * functions are atomic enough and we use dma (and the sw-scan problem + * is also not observed in pci, which indicates confirmation). + * + * Apart from this, the pure acx-sem locking is already coordinating + * accesses well enough, that simple driver operation without + * inbetween scans work without problems. + * + * Different locking approaches a possible to solves this (e.g. fine + * vs coarse-grained). + * + * The chosen approach is: + * + * 1) Mem.c data-access functions contain all a check to insure, they + * are executed under the acx-spinlock. => This is the red line that + * tells, if something needs coverage. + * + * 2) The scope of acx-spinlocking is local, in this case here only to + * mem.c. All common.c functions are already protected by the sem. + * + * 3) In order to consolidate locking calls and also to account for + * the logic of the various write_flush() calls around, locking in mem + * should be: + * + * a) as coarse-grained as possible, and ... + * + * b) ... as fine-grained as required. Basically that means, that + * before functions, that sleep, unlocking needs to be done. And + * locking is taken up again inside the sleeping + * function. Specifically the cmd-functions are used in this path. + * + * Once stable, the locking checks in the data-access functions could + * be #defined away. Mem.c is anyway more used two smaller cpus (pxa + * UP e.g.), so the implied runtime constraints by the lock won't take + * much effect. + */ + +/* These are used in many mem.c funcs, including those which should be + * merged with their pci counterparts. + */ +#define acxmem_lock_flags unsigned long flags=0 +#define acxmem_lock() if(IS_MEM(adev)) spin_lock_irqsave(&adev->spinlock, flags) +#define acxmem_unlock() if(IS_MEM(adev)) spin_unlock_irqrestore(&adev->spinlock, flags) + +/* Endianess: read[lw], write[lw] do little-endian conversion internally */ +#define acx_readl(v) readl((v)) +#define acx_readw(v) readw((v)) +#define acx_readb(v) readb((v)) +#define acx_writel(v, r) writel((v), (r)) +#define acx_writew(v, r) writew((v), (r)) +#define acx_writeb(v, r) writeb((v), (r)) + +/* This controls checking of spin-locking in the mem-interface */ +#define ACXMEM_SPIN_CHECK 0 + +#if ACXMEM_SPIN_CHECK +#define ACXMEM_WARN_NOT_SPIN_LOCKED \ +do { \ + if (!spin_is_locked(&adev->spinlock)){ \ + logf0(L_ANY, "mem: warning: data access not locked!\n"); \ + dump_stack(); \ + } \ +} while (0) +#else +#define ACXMEM_WARN_NOT_SPIN_LOCKED do { } while (0) +#endif + +typedef enum { + ACX_SOFT_RESET = 0x0000, + ACX_SLV_REG_ADDR = 0x0004, + ACX_SLV_REG_DATA = 0x0008, + ACX_SLV_REG_ADATA = 0x000c, + ACX_SLV_MEM_CP = 0x0010, + ACX_SLV_MEM_ADDR = 0x0014, /*redundant with IO_ACX_SLV_MEM_ADDR */ + ACX_SLV_MEM_DATA = 0x0018, /*redundant with IO_ACX_SLV_MEM_DATA*/ + ACX_SLV_MEM_CTL = 0x001c, /*redundant with IO_ACX_SLV_END_CTL */ +} acxreg_t; + +#define INLINE_IO static inline + +INLINE_IO u32 read_id_register(acx_device_t *adev) +{ + ACXMEM_WARN_NOT_SPIN_LOCKED; + acx_writel(0x24, adev->iobase + ACX_SLV_REG_ADDR); + return acx_readl(adev->iobase + ACX_SLV_REG_DATA); +} + +#define check_IO_ACX_ECPU_CTRL(adev, addr, offset) \ + \ + if (offset > IO_ACX_ECPU_CTRL) \ + addr = offset; \ + else \ + addr = adev->io[offset]; + +/* note the buried return */ +#define ret_addr_lt20_rd_(adev, addr, _lwb) \ + if (addr < 0x20) \ + return acx_read##_lwb(((u8 *) adev->iobase) + addr); + +#define ret_addr_lt20_rdl(adev, addr) ret_addr_lt20_rd_(adev, addr, l) +#define ret_addr_lt20_rdw(adev, addr) ret_addr_lt20_rd_(adev, addr, w) +#define ret_addr_lt20_rdb(adev, addr) ret_addr_lt20_rd_(adev, addr, b) + +/* note the buried return */ +#define ret_addr_lt20_wr_(adev, addr, _lwb, val) \ + if (addr < 0x20) { \ + acx_write##_lwb(val, ((u8 *) adev->iobase) + addr); \ + return; \ + } + +#define ret_addr_lt20_wrl(adev, addr, val) \ + ret_addr_lt20_wr_(adev, addr, l, val) +#define ret_addr_lt20_wrw(adev, addr, val) \ + ret_addr_lt20_wr_(adev, addr, w, val) +#define ret_addr_lt20_wrb(adev, addr, val) \ + ret_addr_lt20_wr_(adev, addr, b, val) + +INLINE_IO u32 read_reg32(acx_device_t *adev, unsigned int offset) +{ + u32 val; + u32 addr; + + if (IS_PCI(adev)) { + #if ACX_IO_WIDTH == 32 + return acx_readl((u8 *) adev->iobase + adev->io[offset]); + #else + return acx_readw((u8 *) adev->iobase + adev->io[offset]) + + (acx_readw((u8 *) adev->iobase + + adev->io[offset] + 2) << 16); + #endif + } + /* else IS_MEM */ + + ACXMEM_WARN_NOT_SPIN_LOCKED; + check_IO_ACX_ECPU_CTRL(adev, addr, offset); + ret_addr_lt20_rdl(adev, addr); + + acx_writel(addr, adev->iobase + ACX_SLV_REG_ADDR); + val = acx_readl(adev->iobase + ACX_SLV_REG_DATA); + + return val; +} + +INLINE_IO u16 read_reg16(acx_device_t *adev, unsigned int offset) +{ + u16 lo; + u32 addr; + + if (IS_PCI(adev)) + return acx_readw((u8 *) adev->iobase + adev->io[offset]); + + /* else IS_MEM */ + + ACXMEM_WARN_NOT_SPIN_LOCKED; + check_IO_ACX_ECPU_CTRL(adev, addr, offset); + ret_addr_lt20_rdw(adev, addr); + + acx_writel(addr, adev->iobase + ACX_SLV_REG_ADDR); + lo = acx_readw((u16 *) (adev->iobase + ACX_SLV_REG_DATA)); + + return lo; +} + +INLINE_IO u8 read_reg8(acx_device_t *adev, unsigned int offset) +{ + u8 lo; + u32 addr; + + if (IS_PCI(adev)) + return readb((u8 *) adev->iobase + adev->io[offset]); + + /* else IS_MEM */ + + ACXMEM_WARN_NOT_SPIN_LOCKED; + check_IO_ACX_ECPU_CTRL(adev, addr, offset); + ret_addr_lt20_rdb(adev, addr); + + acx_writel(addr, adev->iobase + ACX_SLV_REG_ADDR); + lo = acx_readw((u8 *) (adev->iobase + ACX_SLV_REG_DATA)); + + return (u8) lo; +} + +INLINE_IO void write_reg32(acx_device_t *adev, unsigned int offset, + u32 val) +{ + u32 addr; + + if (IS_PCI(adev)) { + #if ACX_IO_WIDTH == 32 + acx_writel(val, (u8 *) adev->iobase + adev->io[offset]); +#else + acx_writew(val & 0xffff, (u8 *) adev->iobase + + adev->io[offset]); + acx_writew(val >> 16, (u8 *) adev->iobase + + adev->io[offset] + 2); +#endif + } + /* else IS_MEM */ + + ACXMEM_WARN_NOT_SPIN_LOCKED; + check_IO_ACX_ECPU_CTRL(adev, addr, offset); + ret_addr_lt20_wrl(adev, addr, val); + + acx_writel(addr, adev->iobase + ACX_SLV_REG_ADDR); + acx_writel(val, adev->iobase + ACX_SLV_REG_DATA); +} + +INLINE_IO void write_reg16(acx_device_t *adev, unsigned int offset, + u16 val) +{ + u32 addr; + + if (IS_PCI(adev)) { + acx_writew(val, (u8 *) adev->iobase + adev->io[offset]); + return; + } + /* else IS_MEM */ + + ACXMEM_WARN_NOT_SPIN_LOCKED; + check_IO_ACX_ECPU_CTRL(adev, addr, offset); + ret_addr_lt20_wrw(adev, addr, val); + + acx_writel(addr, adev->iobase + ACX_SLV_REG_ADDR); + acx_writew(val, (u16 *) (adev->iobase + ACX_SLV_REG_DATA)); +} + +INLINE_IO void write_reg8(acx_device_t *adev, unsigned int offset, u8 val) +{ + u32 addr; + + if (IS_PCI(adev)) { + writeb(val, (u8 *) adev->iobase + adev->io[offset]); + return; + } + /* else IS_MEM */ + + ACXMEM_WARN_NOT_SPIN_LOCKED; + check_IO_ACX_ECPU_CTRL(adev, addr, offset); + ret_addr_lt20_wrb(adev, addr, val); + + acx_writel(addr, adev->iobase + ACX_SLV_REG_ADDR); + writeb(val, (u8 *) (adev->iobase + ACX_SLV_REG_DATA)); +} + + +/* Handle PCI posting properly: + * Make sure that writes reach the adapter in case they require to be + * executed *before* the next write, by reading a random (and safely + * accessible) register. This call has to be made if there is no read + * following (which would flush the data to the adapter), yet the + * written data has to reach the adapter immediately. + */ + +INLINE_IO void write_flush(acx_device_t *adev) +{ + /* readb(adev->iobase + adev->io[IO_ACX_INFO_MAILBOX_OFFS]); */ + if (IS_PCI(adev)) { + /* faster version (accesses the first register, + * IO_ACX_SOFT_RESET, which should also be safe): */ + readb(adev->iobase); + return; + } + /* else IS_MEM */ + /* faster version (accesses the first register, + * IO_ACX_SOFT_RESET, which should also be safe): */ + ACXMEM_WARN_NOT_SPIN_LOCKED; + (void) acx_readl(adev->iobase); +} + +INLINE_IO void set_regbits(acx_device_t *adev, unsigned int offset, + u32 bits) +{ + u32 tmp; + + ACXMEM_WARN_NOT_SPIN_LOCKED; + + tmp = read_reg32(adev, offset); + tmp = tmp | bits; + write_reg32(adev, offset, tmp); + write_flush(adev); +} + +INLINE_IO void clear_regbits(acx_device_t *adev, unsigned int offset, + u32 bits) +{ + u32 tmp; + + ACXMEM_WARN_NOT_SPIN_LOCKED; + + tmp = read_reg32(adev, offset); + tmp = tmp & ~bits; + write_reg32(adev, offset, tmp); + write_flush(adev); +} + +/* + * Copy from PXA memory to the ACX memory. This assumes both the PXA + * and ACX addresses are 32 bit aligned. Count is in bytes. + */ +INLINE_IO void write_slavemem32(acx_device_t *adev, u32 slave_address, u32 val) +{ + ACXMEM_WARN_NOT_SPIN_LOCKED; + + write_reg32(adev, IO_ACX_SLV_MEM_CTL, 0x0); + write_reg32(adev, IO_ACX_SLV_MEM_ADDR, slave_address); + udelay(10); + write_reg32(adev, IO_ACX_SLV_MEM_DATA, val); +} + +INLINE_IO u32 read_slavemem32(acx_device_t *adev, u32 slave_address) +{ + u32 val; + + ACXMEM_WARN_NOT_SPIN_LOCKED; + + write_reg32(adev, IO_ACX_SLV_MEM_CTL, 0x0); + write_reg32(adev, IO_ACX_SLV_MEM_ADDR, slave_address); + udelay (10); + val = read_reg32(adev, IO_ACX_SLV_MEM_DATA); + + return val; +} + +INLINE_IO void write_slavemem8(acx_device_t *adev, u32 slave_address, u8 val) +{ + u32 data; + u32 base; + int offset; + + ACXMEM_WARN_NOT_SPIN_LOCKED; + + /* + * Get the word containing the target address and the byte + * offset in that word. + */ + base = slave_address & ~3; + offset = (slave_address & 3) * 8; + + data = read_slavemem32(adev, base); + data &= ~(0xff << offset); + data |= val << offset; + write_slavemem32(adev, base, data); +} + +INLINE_IO u8 read_slavemem8(acx_device_t *adev, u32 slave_address) +{ + u8 val; + u32 base; + u32 data; + int offset; + + ACXMEM_WARN_NOT_SPIN_LOCKED; + + base = slave_address & ~3; + offset = (slave_address & 3) * 8; + + data = read_slavemem32(adev, base); + + val = (data >> offset) & 0xff; + + return val; +} + +/* + * doesn't split across word boundaries + */ +INLINE_IO void write_slavemem16(acx_device_t *adev, u32 slave_address, u16 val) +{ + u32 data; + u32 base; + int offset; + + ACXMEM_WARN_NOT_SPIN_LOCKED; + + /* + * Get the word containing the target address and the byte + * offset in that word. + */ + base = slave_address & ~3; + offset = (slave_address & 3) * 8; + + data = read_slavemem32(adev, base); + data &= ~(0xffff << offset); + data |= val << offset; + write_slavemem32(adev, base, data); +} + +/* + * doesn't split across word boundaries + */ +INLINE_IO u16 read_slavemem16(acx_device_t *adev, u32 slave_address) +{ + u16 val; + u32 base; + u32 data; + int offset; + + ACXMEM_WARN_NOT_SPIN_LOCKED; + + base = slave_address & ~3; + offset = (slave_address & 3) * 8; + + data = read_slavemem32(adev, base); + + val = (data >> offset) & 0xffff; + + return val; +} + +#endif /* CONFIG_ACX_MAC80211_MEM */ +#endif /* _MEM_INLINES_H_ */ diff --git a/mem.c b/mem.c index 0df85eb..a6abe99 100644 --- a/mem.c +++ b/mem.c @@ -139,7 +139,7 @@ char acxmem_printable(char c); * ================================================== */ -#include "mem-inlines.h" +#include "inlines.h" #if DUMP_MEM_DEFINED > 0 /* = static */ diff --git a/merge.c b/merge.c index 3f07da7..4541b2a 100644 --- a/merge.c +++ b/merge.c @@ -37,7 +37,7 @@ #include "pci.h" #include "mem.h" #include "io-acx.h" -#include "mem-inlines.h" +#include "inlines.h" /* from mem.c:98 */ #define FW_NO_AUTO_INCREMENT 1 diff --git a/pci.c b/pci.c index 27a3a5c..3b4abca 100644 --- a/pci.c +++ b/pci.c @@ -131,7 +131,7 @@ static void vlynq_remove(struct vlynq_device *vdev); * ================================================== */ -#include "pci-inlines.h" +#include "inlines.h" /* ----- */ -- 1.7.10.1.487.ga3935e6 |