staging: brcm80211: absorb brcmf_sdcard_detach into brcmf_sdio_remove
authorFranky Lin <frankyl@broadcom.com>
Mon, 8 Aug 2011 13:58:36 +0000 (15:58 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 23 Aug 2011 20:00:05 +0000 (13:00 -0700)
To increase code readability of brcmfmac

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>
drivers/staging/brcm80211/brcmfmac/bcmsdh.c
drivers/staging/brcm80211/brcmfmac/sdio_host.h

index 6f88bd2e9aab4257399fd213d32fb0c067019402..0cd449d332e661c8d7f9c4dfd1e40aa934f6b44a 100644 (file)
@@ -57,19 +57,6 @@ static struct brcmf_sdioh_driver drvinfo = { NULL, NULL };
 
 module_param(sd_f2_blocksize, int, 0);
 
-int brcmf_sdcard_detach(struct brcmf_sdio_card *card)
-{
-       if (card != NULL) {
-               if (card->sdioh) {
-                       brcmf_sdioh_detach(card->sdioh);
-                       card->sdioh = NULL;
-               }
-               kfree(card);
-       }
-
-       return 0;
-}
-
 int
 brcmf_sdcard_iovar_op(struct brcmf_sdio_card *card, const char *name,
                void *params, int plen, void *arg, int len, bool set)
@@ -441,7 +428,6 @@ int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
 
        sdiodev->card->sdioh = brcmf_sdioh_attach((void *)0);
        if (!sdiodev->card->sdioh) {
-               brcmf_sdcard_detach(sdiodev->card);
                ret = -ENODEV;
                goto out;
        }
@@ -466,8 +452,8 @@ int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
        }
 
 out:
-       if ((ret) && (sdiodev->card))
-               brcmf_sdcard_detach(sdiodev->card);
+       if (ret)
+               brcmf_sdio_remove(sdiodev);
 
        return ret;
 }
@@ -475,8 +461,18 @@ EXPORT_SYMBOL(brcmf_sdio_probe);
 
 int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev)
 {
-       drvinfo.detach(sdiodev->bus);
-       brcmf_sdcard_detach(sdiodev->card);
+       if (sdiodev->bus) {
+               drvinfo.detach(sdiodev->bus);
+               sdiodev->bus = NULL;
+       }
+
+       if (sdiodev->card) {
+               if (sdiodev->card->sdioh)
+                       brcmf_sdioh_detach(sdiodev->card->sdioh);
+               kfree(sdiodev->card);
+               sdiodev->card = NULL;
+       }
+
        return 0;
 }
 EXPORT_SYMBOL(brcmf_sdio_remove);
index 68b684392af618148d8acbb3cd778a890832e500..cf3b8fc3a52ac721c0f665fa901b2227cc50f289 100644 (file)
@@ -136,9 +136,6 @@ struct brcmf_sdio_dev {
        void *bus;
 };
 
-/* Detach - freeup resources allocated in attach */
-extern int brcmf_sdcard_detach(struct brcmf_sdio_card *card);
-
 /* Enable/disable SD interrupt */
 extern int brcmf_sdcard_intr_enable(struct brcmf_sdio_card *card);
 extern int brcmf_sdcard_intr_disable(struct brcmf_sdio_card *card);