···1304int atmel_open(struct net_device *dev)1305{1306 struct atmel_private *priv = netdev_priv(dev);1307- int i, channel;13081309 /* any scheduled timer is no longer needed and might screw things up.. */1310 del_timer_sync(&priv->management_timer);···1328 priv->site_survey_state = SITE_SURVEY_IDLE;1329 priv->station_is_associated = 0;13301331- if (!reset_atmel_card(dev))1332- return -EAGAIN;013331334 if (priv->config_reg_domain) {1335 priv->reg_domain = priv->config_reg_domain;···3062 }30633064 if (status == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) {3065- /* Do opensystem first, then try sharedkey */003066 if (system == WLAN_AUTH_OPEN) {3067 priv->CurrentAuthentTransactionSeqNum = 0x001;3068 priv->exclude_unencrypted = 1;3069 send_authentication_request(priv, WLAN_AUTH_SHARED_KEY, NULL, 0);0000003070 return;3071 } else if (priv->connect_to_any_BSS) {3072 int bss_index;···35893590 if (i == 0) {3591 printk(KERN_ALERT "%s: MAC failed to boot.\n", priv->dev->name);3592- return 0;3593 }35943595 if ((priv->host_info_base = atmel_read16(priv->dev, MR2)) == 0xffff) {3596 printk(KERN_ALERT "%s: card missing.\n", priv->dev->name);3597- return 0;3598 }35993600 /* now check for completion of MAC initialization through···3618 if (i == 0) {3619 printk(KERN_ALERT "%s: MAC failed to initialise.\n",3620 priv->dev->name);3621- return 0;3622 }36233624 /* Check for MAC_INIT_OK only on the register that the MAC_INIT_OK was set */3625 if ((mr3 & MAC_INIT_COMPLETE) &&3626 !(atmel_read16(priv->dev, MR3) & MAC_INIT_OK)) {3627 printk(KERN_ALERT "%s: MAC failed MR3 self-test.\n", priv->dev->name);3628- return 0;3629 }3630 if ((mr1 & MAC_INIT_COMPLETE) &&3631 !(atmel_read16(priv->dev, MR1) & MAC_INIT_OK)) {3632 printk(KERN_ALERT "%s: MAC failed MR1 self-test.\n", priv->dev->name);3633- return 0;3634 }36353636 atmel_copy_to_host(priv->dev, (unsigned char *)iface,···3651 iface->func_ctrl = le16_to_cpu(iface->func_ctrl);3652 iface->mac_status = le16_to_cpu(iface->mac_status);36533654- return 1;3655}36563657/* determine type of memory and MAC address */···3702 /* Standard firmware in flash, boot it up and ask3703 for the Mac Address */3704 priv->card_type = CARD_TYPE_SPI_FLASH;3705- if (atmel_wakeup_firmware(priv)) {3706 atmel_get_mib(priv, Mac_Address_Mib_Type, 0, dev->dev_addr, 6);37073708 /* got address, now squash it again until the network···3844 struct atmel_private *priv = netdev_priv(dev);3845 u8 configuration;3846 int old_state = priv->station_state;038473848 /* data to add to the firmware names, in priority order3849 this implemenents firmware versioning */···3878 dev->name);3879 strcpy(priv->firmware_id, "atmel_at76c502.bin");3880 }3881- if (request_firmware(&fw_entry, priv->firmware_id, priv->sys_dev) != 0) {03882 printk(KERN_ALERT3883 "%s: firmware %s is missing, cannot continue.\n",3884 dev->name, priv->firmware_id);3885- return 0;3886 }3887 } else {3888 int fw_index = 0;···3912 "%s: firmware %s is missing, cannot start.\n",3913 dev->name, priv->firmware_id);3914 priv->firmware_id[0] = '\0';3915- return 0;3916 }3917 }3918···3937 release_firmware(fw_entry);3938 }39393940- if (!atmel_wakeup_firmware(priv))3941- return 0;039423943 /* Check the version and set the correct flag for wpa stuff,3944 old and new firmware is incompatible.···3980 if (!priv->radio_on_broken) {3981 if (atmel_send_command_wait(priv, CMD_EnableRadio, NULL, 0) ==3982 CMD_STATUS_REJECTED_RADIO_OFF) {3983- printk(KERN_INFO3984- "%s: cannot turn the radio on. (Hey radio, you're beautiful!)\n",3985 dev->name);3986- return 0;3987 }3988 }3989···4017 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);4018 }40194020- return 1;4021}40224023static void atmel_send_command(struct atmel_private *priv, int command,
···1304int atmel_open(struct net_device *dev)1305{1306 struct atmel_private *priv = netdev_priv(dev);1307+ int i, channel, err;13081309 /* any scheduled timer is no longer needed and might screw things up.. */1310 del_timer_sync(&priv->management_timer);···1328 priv->site_survey_state = SITE_SURVEY_IDLE;1329 priv->station_is_associated = 0;13301331+ err = reset_atmel_card(dev);1332+ if (err)1333+ return err;13341335 if (priv->config_reg_domain) {1336 priv->reg_domain = priv->config_reg_domain;···3061 }30623063 if (status == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) {3064+ /* Flip back and forth between WEP auth modes until the max3065+ * authentication tries has been exceeded.3066+ */3067 if (system == WLAN_AUTH_OPEN) {3068 priv->CurrentAuthentTransactionSeqNum = 0x001;3069 priv->exclude_unencrypted = 1;3070 send_authentication_request(priv, WLAN_AUTH_SHARED_KEY, NULL, 0);3071+ return;3072+ } else if ( system == WLAN_AUTH_SHARED_KEY3073+ && priv->wep_is_on) {3074+ priv->CurrentAuthentTransactionSeqNum = 0x001;3075+ priv->exclude_unencrypted = 0;3076+ send_authentication_request(priv, WLAN_AUTH_OPEN, NULL, 0);3077 return;3078 } else if (priv->connect_to_any_BSS) {3079 int bss_index;···35803581 if (i == 0) {3582 printk(KERN_ALERT "%s: MAC failed to boot.\n", priv->dev->name);3583+ return -EIO;3584 }35853586 if ((priv->host_info_base = atmel_read16(priv->dev, MR2)) == 0xffff) {3587 printk(KERN_ALERT "%s: card missing.\n", priv->dev->name);3588+ return -ENODEV;3589 }35903591 /* now check for completion of MAC initialization through···3609 if (i == 0) {3610 printk(KERN_ALERT "%s: MAC failed to initialise.\n",3611 priv->dev->name);3612+ return -EIO;3613 }36143615 /* Check for MAC_INIT_OK only on the register that the MAC_INIT_OK was set */3616 if ((mr3 & MAC_INIT_COMPLETE) &&3617 !(atmel_read16(priv->dev, MR3) & MAC_INIT_OK)) {3618 printk(KERN_ALERT "%s: MAC failed MR3 self-test.\n", priv->dev->name);3619+ return -EIO;3620 }3621 if ((mr1 & MAC_INIT_COMPLETE) &&3622 !(atmel_read16(priv->dev, MR1) & MAC_INIT_OK)) {3623 printk(KERN_ALERT "%s: MAC failed MR1 self-test.\n", priv->dev->name);3624+ return -EIO;3625 }36263627 atmel_copy_to_host(priv->dev, (unsigned char *)iface,···3642 iface->func_ctrl = le16_to_cpu(iface->func_ctrl);3643 iface->mac_status = le16_to_cpu(iface->mac_status);36443645+ return 0;3646}36473648/* determine type of memory and MAC address */···3693 /* Standard firmware in flash, boot it up and ask3694 for the Mac Address */3695 priv->card_type = CARD_TYPE_SPI_FLASH;3696+ if (atmel_wakeup_firmware(priv) == 0) {3697 atmel_get_mib(priv, Mac_Address_Mib_Type, 0, dev->dev_addr, 6);36983699 /* got address, now squash it again until the network···3835 struct atmel_private *priv = netdev_priv(dev);3836 u8 configuration;3837 int old_state = priv->station_state;3838+ int err = 0;38393840 /* data to add to the firmware names, in priority order3841 this implemenents firmware versioning */···3868 dev->name);3869 strcpy(priv->firmware_id, "atmel_at76c502.bin");3870 }3871+ err = request_firmware(&fw_entry, priv->firmware_id, priv->sys_dev);3872+ if (err != 0) {3873 printk(KERN_ALERT3874 "%s: firmware %s is missing, cannot continue.\n",3875 dev->name, priv->firmware_id);3876+ return err;3877 }3878 } else {3879 int fw_index = 0;···3901 "%s: firmware %s is missing, cannot start.\n",3902 dev->name, priv->firmware_id);3903 priv->firmware_id[0] = '\0';3904+ return -ENOENT;3905 }3906 }3907···3926 release_firmware(fw_entry);3927 }39283929+ err = atmel_wakeup_firmware(priv);3930+ if (err != 0)3931+ return err;39323933 /* Check the version and set the correct flag for wpa stuff,3934 old and new firmware is incompatible.···3968 if (!priv->radio_on_broken) {3969 if (atmel_send_command_wait(priv, CMD_EnableRadio, NULL, 0) ==3970 CMD_STATUS_REJECTED_RADIO_OFF) {3971+ printk(KERN_INFO "%s: cannot turn the radio on.\n",03972 dev->name);3973+ return -EIO;3974 }3975 }3976···4006 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);4007 }40084009+ return 0;4010}40114012static void atmel_send_command(struct atmel_private *priv, int command,