Skip to content

Commit

Permalink
staging: brcm80211: move brcmf_mmc_suspend to sdio layer in fullmac
Browse files Browse the repository at this point in the history
brcmf_mmc_suspend is used for sdio suspend/resume function. Hence it
should be placed in sdio interface layer.

Reviewed-by: Roland Vossen <rvossen@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Franky Lin authored and Greg Kroah-Hartman committed Aug 23, 2011
1 parent 5744955 commit a9b9771
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 43 deletions.
38 changes: 28 additions & 10 deletions drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ module_param(clockoverride, int, 0644);
MODULE_PARM_DESC(clockoverride, "SDIO card clock override");

struct brcmf_sdmmc_instance *gInstance;
static atomic_t brcmf_mmc_suspend;

struct device sdmmc_dev;

Expand All @@ -157,31 +158,44 @@ static const struct sdio_device_id brcmf_sdmmc_ids[] = {
{ /* end: all zeroes */ },
};

#ifdef CONFIG_PM
#ifdef CONFIG_PM_SLEEP
static const struct dev_pm_ops brcmf_sdio_pm_ops = {
.suspend = brcmf_sdio_suspend,
.resume = brcmf_sdio_resume,
};
#endif /* CONFIG_PM */
#endif /* CONFIG_PM_SLEEP */

static struct sdio_driver brcmf_sdmmc_driver = {
.probe = brcmf_ops_sdio_probe,
.remove = brcmf_ops_sdio_remove,
.name = "brcmfmac",
.id_table = brcmf_sdmmc_ids,
#ifdef CONFIG_PM
#ifdef CONFIG_PM_SLEEP
.drv = {
.pm = &brcmf_sdio_pm_ops,
},
#endif /* CONFIG_PM */
#endif /* CONFIG_PM_SLEEP */
};

MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids);

BRCMF_PM_RESUME_WAIT_INIT(sdioh_request_byte_wait);
BRCMF_PM_RESUME_WAIT_INIT(sdioh_request_word_wait);
BRCMF_PM_RESUME_WAIT_INIT(sdioh_request_packet_wait);
BRCMF_PM_RESUME_WAIT_INIT(sdioh_request_buffer_wait);
#ifdef CONFIG_PM_SLEEP
DECLARE_WAIT_QUEUE_HEAD(sdioh_request_byte_wait);
DECLARE_WAIT_QUEUE_HEAD(sdioh_request_word_wait);
DECLARE_WAIT_QUEUE_HEAD(sdioh_request_packet_wait);
DECLARE_WAIT_QUEUE_HEAD(sdioh_request_buffer_wait);
#define BRCMF_PM_RESUME_WAIT(a) do { \
int retry = 0; \
while (atomic_read(&brcmf_mmc_suspend) && retry++ != 30) { \
wait_event_timeout(a, false, HZ/100); \
} \
} while (0)
#define BRCMF_PM_RESUME_RETURN_ERROR(a) \
do { if (atomic_read(&brcmf_mmc_suspend)) return a; } while (0)
#else
#define BRCMF_PM_RESUME_WAIT(a)
#define BRCMF_PM_RESUME_RETURN_ERROR(a)
#endif /* CONFIG_PM_SLEEP */

static int
brcmf_sdioh_card_regread(struct sdioh_info *sd, int func, u32 regaddr,
Expand Down Expand Up @@ -1049,6 +1063,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
sd_trace(("NIC found, calling brcmf_sdio_probe...\n"));
ret = brcmf_sdio_probe(&sdmmc_dev);
}
atomic_set(&brcmf_mmc_suspend, false);
}

gInstance->func[func->num] = func;
Expand Down Expand Up @@ -1077,14 +1092,16 @@ static void brcmf_ops_sdio_remove(struct sdio_func *func)
}


#ifdef CONFIG_PM
#ifdef CONFIG_PM_SLEEP
static int brcmf_sdio_suspend(struct device *dev)
{
mmc_pm_flag_t sdio_flags;
int ret = 0;

sd_trace(("%s\n", __func__));

atomic_set(&brcmf_mmc_suspend, true);

sdio_flags = sdio_get_host_pm_caps(gInstance->func[1]);
if (!(sdio_flags & MMC_PM_KEEP_POWER)) {
sd_err(("Host can't keep power while suspended\n"));
Expand All @@ -1105,9 +1122,10 @@ static int brcmf_sdio_suspend(struct device *dev)
static int brcmf_sdio_resume(struct device *dev)
{
brcmf_sdio_wdtmr_enable(true);
atomic_set(&brcmf_mmc_suspend, false);
return 0;
}
#endif /* CONFIG_PM */
#endif /* CONFIG_PM_SLEEP */

int brcmf_sdioh_osinit(struct sdioh_info *sd)
{
Expand Down
17 changes: 0 additions & 17 deletions drivers/staging/brcm80211/brcmfmac/dhd.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,18 +620,6 @@ struct bcmevent_name {
};

#if defined(CONFIG_PM_SLEEP)
extern atomic_t brcmf_mmc_suspend;
#define BRCMF_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
#define _BRCMF_PM_RESUME_WAIT(a, b) do { \
int retry = 0; \
while (atomic_read(&brcmf_mmc_suspend) && retry++ != b) { \
wait_event_timeout(a, false, HZ/100); \
} \
} while (0)
#define BRCMF_PM_RESUME_WAIT(a) _BRCMF_PM_RESUME_WAIT(a, 30)
#define BRCMF_PM_RESUME_RETURN_ERROR(a) \
do { if (atomic_read(&brcmf_mmc_suspend)) return a; } while (0)

#define BRCMF_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
#define BRCMF_SPINWAIT_SLEEP(a, exp, us) do { \
uint countdown = (us) + 9999; \
Expand All @@ -642,11 +630,6 @@ extern atomic_t brcmf_mmc_suspend;
} while (0)

#else

#define BRCMF_PM_RESUME_WAIT_INIT(a)
#define BRCMF_PM_RESUME_WAIT(a)
#define BRCMF_PM_RESUME_RETURN_ERROR(a)

#define BRCMF_SPINWAIT_SLEEP_INIT(a)
#define BRCMF_SPINWAIT_SLEEP(a, exp, us) do { \
uint countdown = (us) + 9; \
Expand Down
8 changes: 0 additions & 8 deletions drivers/staging/brcm80211/brcmfmac/dhd_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@
#include "wl_cfg80211.h"
#include "bcmchip.h"

#if defined(CONFIG_PM_SLEEP)
#include <linux/suspend.h>
atomic_t brcmf_mmc_suspend;
#endif /* defined(CONFIG_PM_SLEEP) */

MODULE_AUTHOR("Broadcom Corporation");
MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN fullmac driver.");
MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN fullmac cards");
Expand Down Expand Up @@ -1274,9 +1269,6 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen)
*/
memcpy(netdev_priv(net), &drvr_priv, sizeof(drvr_priv));

#if defined(CONFIG_PM_SLEEP)
atomic_set(&brcmf_mmc_suspend, false);
#endif /* defined(CONFIG_PM_SLEEP) */
return &drvr_priv->pub;

fail:
Expand Down
8 changes: 0 additions & 8 deletions drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -2102,10 +2102,6 @@ static s32 brcmf_cfg80211_resume(struct wiphy *wiphy)
*/
WL_TRACE("Enter\n");

#if defined(CONFIG_PM_SLEEP)
atomic_set(&brcmf_mmc_suspend, false);
#endif /* defined(CONFIG_PM_SLEEP) */

if (test_bit(WL_STATUS_READY, &cfg_priv->status))
brcmf_invoke_iscan(wiphy_to_cfg(wiphy));

Expand Down Expand Up @@ -2167,10 +2163,6 @@ static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy,
brcmf_set_mpc(ndev, 1);
}

#if defined(CONFIG_PM_SLEEP)
atomic_set(&brcmf_mmc_suspend, true);
#endif /* defined(CONFIG_PM_SLEEP) */

WL_TRACE("Exit\n");

return 0;
Expand Down

0 comments on commit a9b9771

Please sign in to comment.