staging/wlan-ng: Move firmware loading into driver
PATCH 1/1 staging/wlan-ng: Move firmware loading into driver
Move prism2 firmware loading from userspace into driver, using linux request_firmware(). Firmware is now loaded (if available) on device probing, before it is registered as a netdevice and advertised to userspace.
---
Some Notes:
- Applies against linux-next (as of 20090416), tested on my system
- The code in prism2fw.c is ported from the original linux-wlan-ng project prism2dl.c userpace utility for firmware uploading.
- Some definitions previously cleaned out of the header files have been re-inserted to support this code (simply re-copied from original .h files)
- The firmware file should be prism2_ru.hex in the 'standard' Linux firmware directory
- Previous patch to introduce ioctl barring mutex is reverted in this patch: now device initialisation order has changed that patch is no longer necessary.
- Had to define bswap16 & bswap32 utilities in prism2fw.c because no standard kernel provision for these seem to exist.
drivers/staging/wlan-ng/hfa384x.h +244 -0
@@ -64,6 +64,7 @@#define HFA384x_PORTID_MAX ((u16)7)#define HFA384x_NUMPORTS_MAX ((u16)(HFA384x_PORTID_MAX+1))#define HFA384x_PDR_LEN_MAX ((u16)512)/* in bytes, from EK */ +#define HFA384x_PDA_RECS_MAX ((u16)200)/* a guess */ #define HFA384x_PDA_LEN_MAX ((u16)1024)/* in bytes, from EK */ #define HFA384x_SCANRESULT_MAX ((u16)31)#define HFA384x_HSCANRESULT_MAX ((u16)31)
@@ -882,6 +883,249 @@ typedef union hfa384x_usbin {u8 boguspad[3000 ]; } __attribute__ ((packed)) hfa384x_usbin_t; +/*-------------------------------------------------------------------- +PD record structures. +--------------------------------------------------------------------*/ + +typedef struct hfa384x_pdr_pcb_partnum +{ +u8 num[8 ]; +} __attribute__ ((packed))hfa384x_pdr_pcb_partnum_t ; + +typedef struct hfa384x_pdr_pcb_tracenum +{ +u8 num[8 ]; +} __attribute__ ((packed))hfa384x_pdr_pcb_tracenum_t ; + +typedef struct hfa384x_pdr_nic_serial +{ +u8 num[12 ]; +} __attribute__ ((packed))hfa384x_pdr_nic_serial_t ; + +typedef struct hfa384x_pdr_mkk_measurements +{ +double carrier_freq; +double occupied_band; +double power_density; +double tx_spur_f1; +double tx_spur_f2; +double tx_spur_f3; +double tx_spur_f4; +double tx_spur_l1; +double tx_spur_l2; +double tx_spur_l3; +double tx_spur_l4; +double rx_spur_f1; +double rx_spur_f2; +double rx_spur_l1; +double rx_spur_l2; +} __attribute__ ((packed))hfa384x_pdr_mkk_measurements_t ; + +typedef struct hfa384x_pdr_nic_ramsize +{ +u8 size[12 ];/* units of KB */ +} __attribute__ ((packed))hfa384x_pdr_nic_ramsize_t ; + +typedef struct hfa384x_pdr_mfisuprange +{ +u16 id; +u16 variant; +u16 bottom; +u16 top; +} __attribute__ ((packed))hfa384x_pdr_mfisuprange_t ; + +typedef struct hfa384x_pdr_cfisuprange +{ +u16 id; +u16 variant; +u16 bottom; +u16 top; +} __attribute__ ((packed))hfa384x_pdr_cfisuprange_t ; + +typedef struct hfa384x_pdr_nicid +{ +u16 id; +u16 variant; +u16 major; +u16 minor; +} __attribute__ ((packed))hfa384x_pdr_nicid_t ; + + +typedef struct hfa384x_pdr_refdac_measurements +{ +u16 value[0 ]; +} __attribute__ ((packed))hfa384x_pdr_refdac_measurements_t ; + +typedef struct hfa384x_pdr_vgdac_measurements +{ +u16 value[0 ]; +} __attribute__ ((packed))hfa384x_pdr_vgdac_measurements_t ; + +typedef struct hfa384x_pdr_level_comp_measurements +{ +u16 value[0 ]; +} __attribute__ ((packed))hfa384x_pdr_level_compc_measurements_t ; + +typedef struct hfa384x_pdr_mac_address +{ +u8 addr[6 ]; +} __attribute__ ((packed))hfa384x_pdr_mac_address_t ; + +typedef struct hfa384x_pdr_mkk_callname +{ +u8 callname[8 ]; +} __attribute__ ((packed))hfa384x_pdr_mkk_callname_t ; + +typedef struct hfa384x_pdr_regdomain +{ +u16 numdomains; +u16 domain[5 ]; +} __attribute__ ((packed))hfa384x_pdr_regdomain_t ; + +typedef struct hfa384x_pdr_allowed_channel +{ +u16 ch_bitmap; +} __attribute__ ((packed))hfa384x_pdr_allowed_channel_t ; + +typedef struct hfa384x_pdr_default_channel +{ +u16 channel; +} __attribute__ ((packed))hfa384x_pdr_default_channel_t ; + +typedef struct hfa384x_pdr_privacy_option +{ +u16 available; +} __attribute__ ((packed))hfa384x_pdr_privacy_option_t ; + +typedef struct hfa384x_pdr_temptype +{ +u16 type; +} __attribute__ ((packed))hfa384x_pdr_temptype_t ; + +typedef struct hfa384x_pdr_refdac_setup +{ +u16 ch_value[14 ]; +} __attribute__ ((packed))hfa384x_pdr_refdac_setup_t ; + +typedef struct hfa384x_pdr_vgdac_setup +{ +u16 ch_value[14 ]; +} __attribute__ ((packed))hfa384x_pdr_vgdac_setup_t ; + +typedef struct hfa384x_pdr_level_comp_setup +{ +u16 ch_value[14 ]; +} __attribute__ ((packed))hfa384x_pdr_level_comp_setup_t ; + +typedef struct hfa384x_pdr_trimdac_setup +{ +u16 trimidac; +u16 trimqdac; +} __attribute__ ((packed))hfa384x_pdr_trimdac_setup_t ; + +typedef struct hfa384x_pdr_ifr_setting +{ +u16 value[3 ]; +} __attribute__ ((packed))hfa384x_pdr_ifr_setting_t ; + +typedef struct hfa384x_pdr_rfr_setting +{ +u16 value[3 ]; +} __attribute__ ((packed))hfa384x_pdr_rfr_setting_t ; + +typedef struct hfa384x_pdr_hfa3861_baseline +{ +u16 value[50 ]; +} __attribute__ ((packed))hfa384x_pdr_hfa3861_baseline_t ; + +typedef struct hfa384x_pdr_hfa3861_shadow +{ +u32 value[32 ]; +} __attribute__ ((packed))hfa384x_pdr_hfa3861_shadow_t ; + +typedef struct hfa384x_pdr_hfa3861_ifrf +{ +u32 value[20 ]; +} __attribute__ ((packed))hfa384x_pdr_hfa3861_ifrf_t ; + +typedef struct hfa384x_pdr_hfa3861_chcalsp +{ +u16 value[14 ]; +} __attribute__ ((packed))hfa384x_pdr_hfa3861_chcalsp_t ; + +typedef struct hfa384x_pdr_hfa3861_chcali +{ +u16 value[17 ]; +} __attribute__ ((packed))hfa384x_pdr_hfa3861_chcali_t ; + +typedef struct hfa384x_pdr_hfa3861_nic_config +{ +u16 config_bitmap; +} __attribute__ ((packed))hfa384x_pdr_nic_config_t ; + +typedef struct hfa384x_pdr_hfo_delay +{ +u8 hfo_delay; +} __attribute__ ((packed))hfa384x_hfo_delay_t ; + +typedef struct hfa384x_pdr_hfa3861_manf_testsp +{ +u16 value[30 ]; +} __attribute__ ((packed))hfa384x_pdr_hfa3861_manf_testsp_t ; + +typedef struct hfa384x_pdr_hfa3861_manf_testi +{ +u16 value[30 ]; +} __attribute__ ((packed))hfa384x_pdr_hfa3861_manf_testi_t ; + +typedef struct hfa384x_end_of_pda +{ +u16 crc; +} __attribute__ ((packed))hfa384x_pdr_end_of_pda_t ; + +typedef struct hfa384x_pdrec +{ +u16 len;/* in words */ +u16 code; +union pdr { +hfa384x_pdr_pcb_partnum_t pcb_partnum; +hfa384x_pdr_pcb_tracenum_t pcb_tracenum; +hfa384x_pdr_nic_serial_t nic_serial; +hfa384x_pdr_mkk_measurements_t mkk_measurements; +hfa384x_pdr_nic_ramsize_t nic_ramsize; +hfa384x_pdr_mfisuprange_t mfisuprange; +hfa384x_pdr_cfisuprange_t cfisuprange; +hfa384x_pdr_nicid_t nicid; +hfa384x_pdr_refdac_measurements_t refdac_measurements; +hfa384x_pdr_vgdac_measurements_t vgdac_measurements; +hfa384x_pdr_level_compc_measurements_t level_compc_measurements; +hfa384x_pdr_mac_address_t mac_address; +hfa384x_pdr_mkk_callname_t mkk_callname; +hfa384x_pdr_regdomain_t regdomain; +hfa384x_pdr_allowed_channel_t allowed_channel; +hfa384x_pdr_default_channel_t default_channel; +hfa384x_pdr_privacy_option_t privacy_option; +hfa384x_pdr_temptype_t temptype; +hfa384x_pdr_refdac_setup_t refdac_setup; +hfa384x_pdr_vgdac_setup_t vgdac_setup; +hfa384x_pdr_level_comp_setup_t level_comp_setup; +hfa384x_pdr_trimdac_setup_t trimdac_setup; +hfa384x_pdr_ifr_setting_t ifr_setting; +hfa384x_pdr_rfr_setting_t rfr_setting; +hfa384x_pdr_hfa3861_baseline_t hfa3861_baseline; +hfa384x_pdr_hfa3861_shadow_t hfa3861_shadow; +hfa384x_pdr_hfa3861_ifrf_t hfa3861_ifrf; +hfa384x_pdr_hfa3861_chcalsp_t hfa3861_chcalsp; +hfa384x_pdr_hfa3861_chcali_t hfa3861_chcali; +hfa384x_pdr_nic_config_t nic_config; +hfa384x_hfo_delay_t hfo_delay; +hfa384x_pdr_hfa3861_manf_testsp_t hfa3861_manf_testsp; +hfa384x_pdr_hfa3861_manf_testi_t hfa3861_manf_testi; +hfa384x_pdr_end_of_pda_t end_of_pda; + + } data; +} __attribute__ ((packed))hfa384x_pdrec_t ; +#ifdef __KERNEL__/*-------------------------------------------------------------------- --- MAC state structure, argument to all functions --
drivers/staging/wlan-ng/p80211metadef.h +48 -0
72 lines not on this page · raw message
drivers/staging/wlan-ng/p80211netdev.h +0 -3
@@ -227,8 +227,6 @@ typedef struct wlandevice {u8 spy_number;char spy_address[IW_MAX_SPY ][ETH_ALEN ];struct iw_quality spy_stat[IW_MAX_SPY ]; - -struct mutex ioctl_lock; } wlandevice_t;/* WEP stuff */
@@ -244,5 +242,4 @@ int register_wlandev(wlandevice_t *wlandint unregister_wlandev (wlandevice_t *wlandev);void p80211netdev_rx (wlandevice_t *wlandev,struct sk_buff *skb);void p80211netdev_hwremoved (wlandevice_t *wlandev); -void p80211_allow_ioctls (wlandevice_t *wlandev);#endif
drivers/staging/wlan-ng/p80211netdev.c +0 -14
@@ -567,8 +567,6 @@ static int p80211knetdev_do_ioctl(netdevpr_debug ("rx'd ioctl, cmd=%d, len=%d\n" , cmd, req->len); -mutex_lock (&wlandev->ioctl_lock); -#ifdef SIOCETHTOOL if (cmd ==SIOCETHTOOL ) { result =
@@ -609,8 +607,6 @@ static int p80211knetdev_do_ioctl(netdev result = -ENOMEM ; } bail: -mutex_unlock (&wlandev->ioctl_lock); -return result;/* If allocate,copyfrom or copyto fails, return errno */ }
@@ -772,11 +768,6 @@ int wlan_setup(wlandevice_t *wlandev) dev->ml_priv = wlandev; dev->netdev_ops = &p80211_netdev_ops; -mutex_init (&wlandev->ioctl_lock); -/* block ioctls until fully initialised. Don't forget to call -allow_ioctls at some point!*/ -mutex_lock (&wlandev->ioctl_lock); -#if (WIRELESS_EXT <21 ) dev->get_wireless_stats = p80211wext_get_wireless_stats;#endif
@@ -1117,8 +1108,3 @@ static void p80211knetdev_tx_timeout(netnetif_wake_queue (wlandev->netdev); } } - -void p80211_allow_ioctls (wlandevice_t *wlandev) -{ -mutex_unlock (&wlandev->ioctl_lock); -}
drivers/staging/wlan-ng/prism2usb.c +5 -4
@@ -2,6 +2,7 @@#include "prism2mgmt.c" #include "prism2mib.c" #include "prism2sta.c" +#include "prism2fw.c" #define PRISM_USB_DEVICE (vid, pid, name) \ USB_DEVICE(vid, pid), \
@@ -153,15 +154,16 @@ static int prism2sta_probe_usb(struct us wlandev->msdstate =WLAN_MSD_HWPRESENT ; +/* Try and load firmware, then enable card before we register */ +prism2_fwtry (dev, wlandev); +prism2sta_ifstate (wlandev, P80211ENUM_ifstate_enable); +if (register_wlandev (wlandev) !=0 ) {printk (KERN_ERR "%s: register_wlandev() failed.\n" , dev_info); result = -EIO ; goto failed; } -/* enable the card */ -prism2sta_ifstate (wlandev, P80211ENUM_ifstate_enable); - goto done; failed:
@@ -170,7 +172,6 @@ failed: wlandev =NULL ; done: -p80211_allow_ioctls (wlandev);usb_set_intfdata (interface, wlandev);return result; }
drivers/staging/wlan-ng/prism2fw.c +1410 -0
1,410 lines not on this page · raw message