i2400m/usb: wrap USB power saving in #ifdef CONFIG_PM
authorInaky Perez-Gonzalez <inaky@linux.intel.com>
Thu, 8 Jan 2009 19:08:25 +0000 (11:08 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 8 Jan 2009 19:08:25 +0000 (11:08 -0800)
Current code was assuming PM was always enabled, which is not
correct. Code which accesses members in the struct usb_device that are
dependant on CONFIG_PM must be protected the same.

Reported by Randy Dunlap from a build error in the linux-next tree on
07/01/2009.

Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/wimax/i2400m/usb.c

index 6d4b65fd9c1785b82c7f835279a54046605deb57..c6d93465c7e24d8e3883061814411edc00f0ecc0 100644 (file)
@@ -397,11 +397,13 @@ int i2400mu_probe(struct usb_interface *iface,
        i2400m->bus_fw_name = I2400MU_FW_FILE_NAME;
        i2400m->bus_bm_mac_addr_impaired = 0;
 
+#ifdef CONFIG_PM
        iface->needs_remote_wakeup = 1;         /* autosuspend (15s delay) */
        device_init_wakeup(dev, 1);
        usb_autopm_enable(i2400mu->usb_iface);
        usb_dev->autosuspend_delay = 15 * HZ;
        usb_dev->autosuspend_disabled = 0;
+#endif
 
        result = i2400m_setup(i2400m, I2400M_BRI_MAC_REINIT);
        if (result < 0) {
@@ -493,7 +495,9 @@ int i2400mu_suspend(struct usb_interface *iface, pm_message_t pm_msg)
        int result = 0;
        struct device *dev = &iface->dev;
        struct i2400mu *i2400mu = usb_get_intfdata(iface);
+#ifdef CONFIG_PM
        struct usb_device *usb_dev = i2400mu->usb_dev;
+#endif
        struct i2400m *i2400m = &i2400mu->i2400m;
 
        d_fnstart(3, dev, "(iface %p pm_msg %u)\n", iface, pm_msg.event);
@@ -503,11 +507,13 @@ int i2400mu_suspend(struct usb_interface *iface, pm_message_t pm_msg)
        atomic_dec(&i2400mu->do_autopm);
        result = i2400m_cmd_enter_powersave(i2400m);
        atomic_inc(&i2400mu->do_autopm);
+#ifdef CONFIG_PM
        if (result < 0 && usb_dev->auto_pm == 0) {
                /* System suspend, can't fail */
                dev_err(dev, "failed to suspend, will reset on resume\n");
                result = 0;
        }
+#endif
        if (result < 0)
                goto error_enter_powersave;
        i2400mu_notification_release(i2400mu);