]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wireless/ipw2100.c
Merge branch 'locks' of git://linux-nfs.org/~bfields/linux
[linux-2.6-omap-h63xx.git] / drivers / net / wireless / ipw2100.c
index 2d46a16c09450c73d3ea5121af6f17391eca2fee..2ab107f457937b96b339711d6c7eaa6ffa8f79c0 100644 (file)
@@ -1267,7 +1267,7 @@ static int ipw2100_start_adapter(struct ipw2100_priv *priv)
                                       IPW2100_INTA_FATAL_ERROR |
                                       IPW2100_INTA_PARITY_ERROR);
                }
-       } while (i--);
+       } while (--i);
 
        /* Clear out any pending INTAs since we aren't supposed to have
         * interrupts enabled at this point... */
@@ -1339,7 +1339,7 @@ static int ipw2100_power_cycle_adapter(struct ipw2100_priv *priv)
 
                if (reg & IPW_AUX_HOST_RESET_REG_MASTER_DISABLED)
                        break;
-       } while (i--);
+       } while (--i);
 
        priv->status &= ~STATUS_RESET_PENDING;
 
@@ -1769,7 +1769,7 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred)
                if (priv->stop_rf_kill) {
                        priv->stop_rf_kill = 0;
                        queue_delayed_work(priv->workqueue, &priv->rf_kill,
-                                          round_jiffies(HZ));
+                                          round_jiffies_relative(HZ));
                }
 
                deferred = 1;
@@ -1858,14 +1858,6 @@ static void ipw2100_down(struct ipw2100_priv *priv)
 
        modify_acceptable_latency("ipw2100", INFINITE_LATENCY);
 
-#ifdef ACPI_CSTATE_LIMIT_DEFINED
-       if (priv->config & CFG_C3_DISABLED) {
-               IPW_DEBUG_INFO(": Resetting C3 transitions.\n");
-               acpi_set_cstate_limit(priv->cstate_limit);
-               priv->config &= ~CFG_C3_DISABLED;
-       }
-#endif
-
        /* We have to signal any supplicant if we are disassociating */
        if (associated)
                wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
@@ -2091,18 +2083,33 @@ static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status)
        /* RF_KILL is now enabled (else we wouldn't be here) */
        priv->status |= STATUS_RF_KILL_HW;
 
-#ifdef ACPI_CSTATE_LIMIT_DEFINED
-       if (priv->config & CFG_C3_DISABLED) {
-               IPW_DEBUG_INFO(": Resetting C3 transitions.\n");
-               acpi_set_cstate_limit(priv->cstate_limit);
-               priv->config &= ~CFG_C3_DISABLED;
-       }
-#endif
-
        /* Make sure the RF Kill check timer is running */
        priv->stop_rf_kill = 0;
        cancel_delayed_work(&priv->rf_kill);
-       queue_delayed_work(priv->workqueue, &priv->rf_kill, round_jiffies(HZ));
+       queue_delayed_work(priv->workqueue, &priv->rf_kill,
+                          round_jiffies_relative(HZ));
+}
+
+static void send_scan_event(void *data)
+{
+       struct ipw2100_priv *priv = data;
+       union iwreq_data wrqu;
+
+       wrqu.data.length = 0;
+       wrqu.data.flags = 0;
+       wireless_send_event(priv->net_dev, SIOCGIWSCAN, &wrqu, NULL);
+}
+
+static void ipw2100_scan_event_later(struct work_struct *work)
+{
+       send_scan_event(container_of(work, struct ipw2100_priv,
+                                       scan_event_later.work));
+}
+
+static void ipw2100_scan_event_now(struct work_struct *work)
+{
+       send_scan_event(container_of(work, struct ipw2100_priv,
+                                       scan_event_now));
 }
 
 static void isr_scan_complete(struct ipw2100_priv *priv, u32 status)
@@ -2111,6 +2118,18 @@ static void isr_scan_complete(struct ipw2100_priv *priv, u32 status)
        /* Age the scan results... */
        priv->ieee->scans++;
        priv->status &= ~STATUS_SCANNING;
+
+       /* Only userspace-requested scan completion events go out immediately */
+       if (!priv->user_requested_scan) {
+               if (!delayed_work_pending(&priv->scan_event_later))
+                       queue_delayed_work(priv->workqueue,
+                                       &priv->scan_event_later,
+                                       round_jiffies_relative(msecs_to_jiffies(4000)));
+       } else {
+               priv->user_requested_scan = 0;
+               cancel_delayed_work(&priv->scan_event_later);
+               queue_work(priv->workqueue, &priv->scan_event_now);
+       }
 }
 
 #ifdef CONFIG_IPW2100_DEBUG
@@ -2329,23 +2348,10 @@ static void ipw2100_corruption_detected(struct ipw2100_priv *priv, int i)
        u32 match, reg;
        int j;
 #endif
-#ifdef ACPI_CSTATE_LIMIT_DEFINED
-       int limit;
-#endif
 
        IPW_DEBUG_INFO(": PCI latency error detected at 0x%04zX.\n",
                       i * sizeof(struct ipw2100_status));
 
-#ifdef ACPI_CSTATE_LIMIT_DEFINED
-       IPW_DEBUG_INFO(": Disabling C3 transitions.\n");
-       limit = acpi_get_cstate_limit();
-       if (limit > 2) {
-               priv->cstate_limit = limit;
-               acpi_set_cstate_limit(2);
-               priv->config |= CFG_C3_DISABLED;
-       }
-#endif
-
 #ifdef IPW2100_DEBUG_C3
        /* Halt the fimrware so we can get a good image */
        write_register(priv->net_dev, IPW_REG_RESET_REG,
@@ -2503,9 +2509,9 @@ static void isr_rx_monitor(struct ipw2100_priv *priv, int i,
 
        ipw_rt->rt_hdr.it_version = PKTHDR_RADIOTAP_VERSION;
        ipw_rt->rt_hdr.it_pad = 0; /* always good to zero */
-       ipw_rt->rt_hdr.it_len = sizeof(struct ipw_rt_hdr); /* total hdr+data */
+       ipw_rt->rt_hdr.it_len = cpu_to_le16(sizeof(struct ipw_rt_hdr)); /* total hdr+data */
 
-       ipw_rt->rt_hdr.it_present = 1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL;
+       ipw_rt->rt_hdr.it_present = cpu_to_le32(1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL);
 
        ipw_rt->rt_dbmsignal = status->rssi + IPW2100_RSSI_TO_DBM;
 
@@ -2552,7 +2558,7 @@ static int ipw2100_corruption_check(struct ipw2100_priv *priv, int i)
 #ifdef CONFIG_IPW2100_MONITOR
                return 0;
 #else
-               switch (WLAN_FC_GET_TYPE(u->rx_data.header.frame_ctl)) {
+               switch (WLAN_FC_GET_TYPE(le16_to_cpu(u->rx_data.header.frame_ctl))) {
                case IEEE80211_FTYPE_MGMT:
                case IEEE80211_FTYPE_CTL:
                        return 0;
@@ -2671,7 +2677,7 @@ static void __ipw2100_rx_process(struct ipw2100_priv *priv)
 #endif
                        if (stats.len < sizeof(struct ieee80211_hdr_3addr))
                                break;
-                       switch (WLAN_FC_GET_TYPE(u->rx_data.header.frame_ctl)) {
+                       switch (WLAN_FC_GET_TYPE(le16_to_cpu(u->rx_data.header.frame_ctl))) {
                        case IEEE80211_FTYPE_MGMT:
                                ieee80211_rx_mgt(priv->ieee,
                                                 &u->rx_data.header, &stats);
@@ -4237,7 +4243,7 @@ static int ipw_radio_kill_sw(struct ipw2100_priv *priv, int disable_radio)
                        priv->stop_rf_kill = 0;
                        cancel_delayed_work(&priv->rf_kill);
                        queue_delayed_work(priv->workqueue, &priv->rf_kill,
-                                          round_jiffies(HZ));
+                                          round_jiffies_relative(HZ));
                } else
                        schedule_reset(priv);
        }
@@ -4378,6 +4384,7 @@ static void ipw2100_kill_workqueue(struct ipw2100_priv *priv)
                cancel_delayed_work(&priv->wx_event_work);
                cancel_delayed_work(&priv->hang_check);
                cancel_delayed_work(&priv->rf_kill);
+               cancel_delayed_work(&priv->scan_event_later);
                destroy_workqueue(priv->workqueue);
                priv->workqueue = NULL;
        }
@@ -5975,7 +5982,7 @@ static void ipw2100_rf_kill(struct work_struct *work)
                IPW_DEBUG_RF_KILL("RF Kill active, rescheduling GPIO check\n");
                if (!priv->stop_rf_kill)
                        queue_delayed_work(priv->workqueue, &priv->rf_kill,
-                                          round_jiffies(HZ));
+                                          round_jiffies_relative(HZ));
                goto exit_unlock;
        }
 
@@ -6041,7 +6048,7 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
         * ends up causing problems.  So, we just handle
         * the WX extensions through the ipw2100_ioctl interface */
 
-       /* memset() puts everything to 0, so we only have explicitely set
+       /* memset() puts everything to 0, so we only have explicitly set
         * those values that need to be something else */
 
        /* If power management is turned on, default to AUTO mode */
@@ -6121,6 +6128,8 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
        INIT_DELAYED_WORK(&priv->wx_event_work, ipw2100_wx_event_work);
        INIT_DELAYED_WORK(&priv->hang_check, ipw2100_hang_check);
        INIT_DELAYED_WORK(&priv->rf_kill, ipw2100_rf_kill);
+       INIT_WORK(&priv->scan_event_now, ipw2100_scan_event_now);
+       INIT_DELAYED_WORK(&priv->scan_event_later, ipw2100_scan_event_later);
 
        tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
                     ipw2100_irq_tasklet, (unsigned long)priv);
@@ -6582,8 +6591,7 @@ static const long ipw2100_frequencies[] = {
        2472, 2484
 };
 
-#define FREQ_COUNT (sizeof(ipw2100_frequencies) / \
-                    sizeof(ipw2100_frequencies[0]))
+#define FREQ_COUNT     ARRAY_SIZE(ipw2100_frequencies)
 
 static const long ipw2100_rates_11b[] = {
        1000000,
@@ -7425,6 +7433,8 @@ static int ipw2100_wx_set_scan(struct net_device *dev,
        }
 
        IPW_DEBUG_WX("Initiating scan...\n");
+
+       priv->user_requested_scan = 1;
        if (ipw2100_set_scan_options(priv) || ipw2100_start_scan(priv)) {
                IPW_DEBUG_WX("Start scan failed.\n");
 
@@ -7499,7 +7509,7 @@ static int ipw2100_wx_set_power(struct net_device *dev,
        switch (wrqu->power.flags & IW_POWER_MODE) {
        case IW_POWER_ON:       /* If not specified */
        case IW_POWER_MODE:     /* If set all mask */
-       case IW_POWER_ALL_R:    /* If explicitely state all */
+       case IW_POWER_ALL_R:    /* If explicitly state all */
                break;
        default:                /* Otherwise we don't support it */
                IPW_DEBUG_WX("SET PM Mode: %X not supported.\n",
@@ -7785,7 +7795,7 @@ static int ipw2100_wx_set_mlme(struct net_device *dev,
 {
        struct ipw2100_priv *priv = ieee80211_priv(dev);
        struct iw_mlme *mlme = (struct iw_mlme *)extra;
-       u16 reason;
+       __le16 reason;
 
        reason = cpu_to_le16(mlme->reason_code);