diff options
author | Jason Cooper <jason@lakedaemon.net> | 2010-09-14 09:45:33 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-09-14 09:04:07 -0700 |
commit | ca8c1e5990926406708d99fe1ce2a6f5e12f9033 (patch) | |
tree | a91f355345095656e72711caa6b0e6144732f30b /drivers/staging/brcm80211/util | |
parent | 90ea22962c5160812c601a115fb7b80c60d49fad (diff) | |
download | op-kernel-dev-ca8c1e5990926406708d99fe1ce2a6f5e12f9033.zip op-kernel-dev-ca8c1e5990926406708d99fe1ce2a6f5e12f9033.tar.gz |
staging: brcm80211: fix "ERROR: do not use assignment in if condition"
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/brcm80211/util')
-rw-r--r-- | drivers/staging/brcm80211/util/bcmotp.c | 9 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/bcmsrom.c | 27 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/bcmutils.c | 42 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/hnddma.c | 52 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/hndpmu.c | 12 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/linux_osl.c | 9 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/nicpci.c | 3 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/nvram/nvram_ro.c | 12 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/siutils.c | 121 |
9 files changed, 175 insertions, 112 deletions
diff --git a/drivers/staging/brcm80211/util/bcmotp.c b/drivers/staging/brcm80211/util/bcmotp.c index 9011ed9..ea4dc1e 100644 --- a/drivers/staging/brcm80211/util/bcmotp.c +++ b/drivers/staging/brcm80211/util/bcmotp.c @@ -640,7 +640,8 @@ static void *BCMNMIATTACHFN(hndotp_init) (si_t *sih) osh = si_osh(oi->sih); /* Check for otp */ - if ((cc = si_setcoreidx(sih, SI_CC_IDX)) != NULL) { + cc = si_setcoreidx(sih, SI_CC_IDX); + if (cc != NULL) { cap = R_REG(osh, &cc->capabilities); if ((cap & CC_CAP_OTPSIZE) == 0) { /* Nothing there */ @@ -754,7 +755,8 @@ static int hndotp_nvread(void *oh, char *data, uint *len) /* Read the whole otp so we can easily manipulate it */ lim = hndotp_size(oh); - if ((rawotp = MALLOC(si_osh(oi->sih), lim)) == NULL) { + rawotp = MALLOC(si_osh(oi->sih), lim); + if (rawotp == NULL) { rc = -2; goto out; } @@ -927,7 +929,8 @@ BCMNMIATTACHFN(otp_read_region) (si_t *sih, int region, uint16 *data, void *oh; int err = 0; - if (!(wasup = si_is_otp_powered(sih))) + wasup = si_is_otp_powered(sih); + if (!wasup) si_otp_power(sih, TRUE); if (!si_is_otp_powered(sih) || si_is_otp_disabled(sih)) { diff --git a/drivers/staging/brcm80211/util/bcmsrom.c b/drivers/staging/brcm80211/util/bcmsrom.c index cb412f8..d800ca5 100644 --- a/drivers/staging/brcm80211/util/bcmsrom.c +++ b/drivers/staging/brcm80211/util/bcmsrom.c @@ -124,7 +124,8 @@ static int BCMATTACHFN(varbuf_append) (varbuf_t *b, const char *fmt, ...) } /* Remove any earlier occurrence of the same variable */ - if ((s = strchr(b->buf, '=')) != NULL) { + s = strchr(b->buf, '='); + if (s != NULL) { len = (size_t) (s - b->buf); for (s = b->base; s < b->buf;) { if ((bcmp(s, b->buf, len) == 0) && s[len] == '=') { @@ -1515,7 +1516,8 @@ static int otp_read_pci(osl_t *osh, si_t *sih, uint16 *buf, uint bufsz) ASSERT(bufsz <= OTP_SZ_MAX); - if ((otp = MALLOC(osh, OTP_SZ_MAX)) == NULL) { + otp = MALLOC(osh, OTP_SZ_MAX); + if (otp == NULL) { return BCME_ERROR; } @@ -1594,9 +1596,11 @@ BCMATTACHFN(initvars_flash) (si_t *sih, osl_t *osh, char **base, uint len) char devpath[SI_DEVPATH_BUFSZ]; /* allocate memory and read in flash */ - if (!(flash = MALLOC(osh, NVRAM_SPACE))) + flash = MALLOC(osh, NVRAM_SPACE); + if (!flash) return BCME_NOMEM; - if ((err = nvram_getall(flash, NVRAM_SPACE))) + err = nvram_getall(flash, NVRAM_SPACE); + if (err) goto exit; si_devpath(sih, devpath, sizeof(devpath)); @@ -1655,7 +1659,8 @@ BCMATTACHFN(initvars_flash_si) (si_t *sih, char **vars, uint *count) if (!vp) return BCME_NOMEM; - if ((err = initvars_flash(sih, osh, &vp, MAXSZ_NVRAM_VARS)) == 0) + err = initvars_flash(sih, osh, &vp, MAXSZ_NVRAM_VARS); + if (err == 0) err = initvars_table(osh, base, vp, vars, count); MFREE(osh, base, MAXSZ_NVRAM_VARS); @@ -1921,7 +1926,8 @@ BCMATTACHFN(initvars_srom_pci) (si_t *sih, void *curmap, char **vars, uint32 val; val = 0; - if ((value = si_getdevpathvar(sih, "sromrev"))) { + value = si_getdevpathvar(sih, "sromrev"); + if (value) { sromrev = (uint8) bcm_strtoul(value, NULL, 0); flash = TRUE; goto varscont; @@ -1929,7 +1935,8 @@ BCMATTACHFN(initvars_srom_pci) (si_t *sih, void *curmap, char **vars, BS_ERROR(("%s, SROM CRC Error\n", __func__)); - if ((value = si_getnvramflvar(sih, "sromrev"))) { + value = si_getnvramflvar(sih, "sromrev"); + if (value) { err = 0; goto errout; } @@ -1962,7 +1969,8 @@ BCMATTACHFN(initvars_srom_pci) (si_t *sih, void *curmap, char **vars, /* read variables from flash */ if (flash) { - if ((err = initvars_flash(sih, osh, &vp, MAXSZ_NVRAM_VARS))) + err = initvars_flash(sih, osh, &vp, MAXSZ_NVRAM_VARS); + if (err) goto errout; goto varsdone; } @@ -2006,7 +2014,8 @@ BCMATTACHFN(initvars_cis_sdio) (osl_t *osh, char **vars, uint *count) ASSERT(numfn <= SDIOD_MAX_IOFUNCS); for (fn = 0; fn <= numfn; fn++) { - if ((cis[fn] = MALLOC(osh, SBSDIO_CIS_SIZE_LIMIT)) == NULL) { + cis[fn] = MALLOC(osh, SBSDIO_CIS_SIZE_LIMIT) + if (cis[fn] == NULL) { rc = -1; break; } diff --git a/drivers/staging/brcm80211/util/bcmutils.c b/drivers/staging/brcm80211/util/bcmutils.c index 28483d5..64e71b9 100644 --- a/drivers/staging/brcm80211/util/bcmutils.c +++ b/drivers/staging/brcm80211/util/bcmutils.c @@ -190,10 +190,12 @@ void *BCMFASTPATH pktq_pdeq(struct pktq *pq, int prec) q = &pq->q[prec]; - if ((p = q->head) == NULL) + p = q->head; + if (p == NULL) return NULL; - if ((q->head = PKTLINK(p)) == NULL) + q->head = PKTLINK(p); + if (q->head == NULL) q->tail = NULL; q->len--; @@ -214,7 +216,8 @@ void *BCMFASTPATH pktq_pdeq_tail(struct pktq *pq, int prec) q = &pq->q[prec]; - if ((p = q->head) == NULL) + p = q->head; + if (p == NULL) return NULL; for (prev = NULL; p != q->tail; p = PKTLINK(p)) @@ -279,7 +282,8 @@ bool BCMFASTPATH pktq_pdel(struct pktq *pq, void *pktbuf, int prec) q = &pq->q[prec]; if (q->head == pktbuf) { - if ((q->head = PKTLINK(pktbuf)) == NULL) + q->head = PKTLINK(pktbuf); + if (q->head == NULL) q->tail = NULL; } else { for (p = q->head; p && PKTLINK(p) != pktbuf; p = PKTLINK(p)) ; @@ -329,10 +333,12 @@ void *BCMFASTPATH pktq_deq(struct pktq *pq, int *prec_out) q = &pq->q[prec]; - if ((p = q->head) == NULL) + p = q->head; + if (p == NULL) return NULL; - if ((q->head = PKTLINK(p)) == NULL) + q->head = PKTLINK(p); + if (q->head == NULL) q->tail = NULL; q->len--; @@ -362,7 +368,8 @@ void *BCMFASTPATH pktq_deq_tail(struct pktq *pq, int *prec_out) q = &pq->q[prec]; - if ((p = q->head) == NULL) + p = q->head; + if (p == NULL) return NULL; for (prev = NULL; p != q->tail; p = PKTLINK(p)) @@ -461,10 +468,12 @@ void *BCMFASTPATH pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out) q = &pq->q[prec]; - if ((p = q->head) == NULL) + p = q->head; + if (p == NULL) return NULL; - if ((q->head = PKTLINK(p)) == NULL) + q->head = PKTLINK(p); + if (q->head == NULL) q->tail = NULL; q->len--; @@ -847,7 +856,8 @@ int getintvar(char *vars, const char *name) { char *val; - if ((val = getvar(vars, name)) == NULL) + val = getvar(vars, name); + if (val == NULL) return 0; return bcm_strtoul(val, NULL, 0); @@ -859,7 +869,8 @@ int getintvararray(char *vars, const char *name, uint8 index) int i = 0; int val = 0; - if ((buf = getvar(vars, name)) == NULL) { + buf = getvar(vars, name); + if (buf == NULL) { return 0; } @@ -975,7 +986,8 @@ static void BCMINITFN(bcm_nvram_refresh) (char *flash) /* default "empty" vars cache */ bzero(flash, 2); - if ((ret = nvram_getall(flash, NVRAM_SPACE))) + ret = nvram_getall(flash, NVRAM_SPACE); + if (ret) return; /* determine nvram length */ @@ -1021,7 +1033,8 @@ int BCMINITFN(bcm_nvram_cache) (void *sih) osh = si_osh((si_t *) sih); /* allocate memory and read in flash */ - if (!(flash = MALLOC(osh, NVRAM_SPACE))) { + flash = MALLOC(osh, NVRAM_SPACE); + if (!flash) { ret = BCME_NOMEM; goto exit; } @@ -1030,7 +1043,8 @@ int BCMINITFN(bcm_nvram_cache) (void *sih) #ifdef BCMNVRAMR if (vars_len > 3) { /* copy into a properly-sized buffer */ - if (!(nvram_vars = MALLOC(osh, vars_len))) { + nvram_vars = MALLOC(osh, vars_len); + if (!nvram_vars) { ret = BCME_NOMEM; } else bcopy(flash, nvram_vars, vars_len); diff --git a/drivers/staging/brcm80211/util/hnddma.c b/drivers/staging/brcm80211/util/hnddma.c index 9c5f58a..837c97f 100644 --- a/drivers/staging/brcm80211/util/hnddma.c +++ b/drivers/staging/brcm80211/util/hnddma.c @@ -363,7 +363,8 @@ hnddma_t *dma_attach(osl_t *osh, char *name, si_t *sih, void *dmaregstx, uint size; /* allocate private info structure */ - if ((di = MALLOC(osh, sizeof(dma_info_t))) == NULL) { + di = MALLOC(osh, sizeof(dma_info_t)); + if (di == NULL) { #ifdef BCMDBG printf("dma_attach: out of memory, malloced %d bytes\n", MALLOCED(osh)); @@ -499,7 +500,8 @@ hnddma_t *dma_attach(osl_t *osh, char *name, si_t *sih, void *dmaregstx, /* allocate tx packet pointer vector */ if (ntxd) { size = ntxd * sizeof(void *); - if ((di->txp = MALLOC(osh, size)) == NULL) { + di->txp = MALLOC(osh, size); + if (di->txp == NULL) { DMA_ERROR(("%s: dma_attach: out of tx memory, malloced %d bytes\n", di->name, MALLOCED(osh))); goto fail; } @@ -509,7 +511,8 @@ hnddma_t *dma_attach(osl_t *osh, char *name, si_t *sih, void *dmaregstx, /* allocate rx packet pointer vector */ if (nrxd) { size = nrxd * sizeof(void *); - if ((di->rxp = MALLOC(osh, size)) == NULL) { + di->rxp = MALLOC(osh, size); + if (di->rxp == NULL) { DMA_ERROR(("%s: dma_attach: out of rx memory, malloced %d bytes\n", di->name, MALLOCED(osh))); goto fail; } @@ -545,16 +548,16 @@ hnddma_t *dma_attach(osl_t *osh, char *name, si_t *sih, void *dmaregstx, if (DMASGLIST_ENAB) { if (ntxd) { size = ntxd * sizeof(hnddma_seg_map_t); - if ((di->txp_dmah = - (hnddma_seg_map_t *) MALLOC(osh, size)) == NULL) + di->txp_dmah = (hnddma_seg_map_t *) MALLOC(osh, size); + if (di->txp_dmah == NULL) goto fail; bzero((char *)di->txp_dmah, size); } if (nrxd) { size = nrxd * sizeof(hnddma_seg_map_t); - if ((di->rxp_dmah = - (hnddma_seg_map_t *) MALLOC(osh, size)) == NULL) + di->rxp_dmah = (hnddma_seg_map_t *) MALLOC(osh, size); + if (di->rxp_dmah == NULL) goto fail; bzero((char *)di->rxp_dmah, size); } @@ -1395,10 +1398,9 @@ static void *dma_ringalloc(osl_t *osh, uint32 boundary, uint size, uint32 desc_strtaddr; uint32 alignbytes = 1 << *alignbits; - if (NULL == - (va = - DMA_ALLOC_CONSISTENT(osh, size, *alignbits, alloced, descpa, - dmah))) + va = DMA_ALLOC_CONSISTENT(osh, size, *alignbits, alloced, descpa, + dmah); + if (NULL == va) return NULL; desc_strtaddr = (uint32) ROUNDUP((uintptr) va, alignbytes); @@ -1517,10 +1519,9 @@ static bool dma32_alloc(dma_info_t *di, uint direction) align = (1 << align_bits); if (direction == DMA_TX) { - if ((va = - dma_ringalloc(di->osh, D32RINGALIGN, size, &align_bits, - &alloced, &di->txdpaorig, - &di->tx_dmah)) == NULL) { + va = dma_ringalloc(di->osh, D32RINGALIGN, size, &align_bits, + &alloced, &di->txdpaorig, &di->tx_dmah); + if (va == NULL) { DMA_ERROR(("%s: dma_alloc: DMA_ALLOC_CONSISTENT(ntxd) failed\n", di->name)); return FALSE; } @@ -1539,10 +1540,9 @@ static bool dma32_alloc(dma_info_t *di, uint direction) di->txdalloc = alloced; ASSERT(ISALIGNED((uintptr) di->txd32, align)); } else { - if ((va = - dma_ringalloc(di->osh, D32RINGALIGN, size, &align_bits, - &alloced, &di->rxdpaorig, - &di->rx_dmah)) == NULL) { + va = dma_ringalloc(di->osh, D32RINGALIGN, size, &align_bits, + &alloced, &di->rxdpaorig, &di->rx_dmah); + if (va == NULL) { DMA_ERROR(("%s: dma_alloc: DMA_ALLOC_CONSISTENT(nrxd) failed\n", di->name)); return FALSE; } @@ -2087,10 +2087,9 @@ static bool dma64_alloc(dma_info_t *di, uint direction) align = (1 << align_bits); if (direction == DMA_TX) { - if ((va = - dma_ringalloc(di->osh, D64RINGALIGN, size, &align_bits, - &alloced, &di->txdpaorig, - &di->tx_dmah)) == NULL) { + va = dma_ringalloc(di->osh, D64RINGALIGN, size, &align_bits, + &alloced, &di->txdpaorig, &di->tx_dmah); + if (va == NULL) { DMA_ERROR(("%s: dma64_alloc: DMA_ALLOC_CONSISTENT(ntxd) failed\n", di->name)); return FALSE; } @@ -2107,10 +2106,9 @@ static bool dma64_alloc(dma_info_t *di, uint direction) di->txdalloc = alloced; ASSERT(ISALIGNED((uintptr) di->txd64, align)); } else { - if ((va = - dma_ringalloc(di->osh, D64RINGALIGN, size, &align_bits, - &alloced, &di->rxdpaorig, - &di->rx_dmah)) == NULL) { + va = dma_ringalloc(di->osh, D64RINGALIGN, size, &align_bits, + &alloced, &di->rxdpaorig, &di->rx_dmah); + if (va == NULL) { DMA_ERROR(("%s: dma64_alloc: DMA_ALLOC_CONSISTENT(nrxd) failed\n", di->name)); return FALSE; } diff --git a/drivers/staging/brcm80211/util/hndpmu.c b/drivers/staging/brcm80211/util/hndpmu.c index 3781696..93872e1 100644 --- a/drivers/staging/brcm80211/util/hndpmu.c +++ b/drivers/staging/brcm80211/util/hndpmu.c @@ -679,12 +679,14 @@ static void si_pmu_res_masks(si_t *sih, uint32 * pmin, uint32 * pmax) } /* Apply nvram override to min mask */ - if ((val = getvar(NULL, "rmin")) != NULL) { + val = getvar(NULL, "rmin"); + if (val != NULL) { PMU_MSG(("Applying rmin=%s to min_mask\n", val)); min_mask = (uint32) bcm_strtoul(val, NULL, 0); } /* Apply nvram override to max mask */ - if ((val = getvar(NULL, "rmax")) != NULL) { + val = getvar(NULL, "rmax"); + if (val != NULL) { PMU_MSG(("Applying rmax=%s to max_mask\n", val)); max_mask = (uint32) bcm_strtoul(val, NULL, 0); } @@ -797,7 +799,8 @@ void BCMATTACHFN(si_pmu_res_init) (si_t *sih, osl_t *osh) /* Apply nvram overrides to up/down timers */ for (i = 0; i < rsrcs; i++) { snprintf(name, sizeof(name), "r%dt", i); - if ((val = getvar(NULL, name)) == NULL) + val = getvar(NULL, name); + if (val == NULL) continue; PMU_MSG(("Applying %s=%s to rsrc %d res_updn_timer\n", name, val, i)); @@ -847,7 +850,8 @@ void BCMATTACHFN(si_pmu_res_init) (si_t *sih, osl_t *osh) /* Apply nvram overrides to dependancies masks */ for (i = 0; i < rsrcs; i++) { snprintf(name, sizeof(name), "r%dd", i); - if ((val = getvar(NULL, name)) == NULL) + val = getvar(NULL, name); + if (val == NULL) continue; PMU_MSG(("Applying %s=%s to rsrc %d res_dep_mask\n", name, val, i)); diff --git a/drivers/staging/brcm80211/util/linux_osl.c b/drivers/staging/brcm80211/util/linux_osl.c index 694a5df..e4ab2a1 100644 --- a/drivers/staging/brcm80211/util/linux_osl.c +++ b/drivers/staging/brcm80211/util/linux_osl.c @@ -180,7 +180,8 @@ void *BCMFASTPATH osl_pktget(osl_t *osh, uint len) { struct sk_buff *skb; - if ((skb = dev_alloc_skb(len))) { + skb = dev_alloc_skb(len); + if (skb) { skb_put(skb, len); skb->priority = 0; @@ -312,7 +313,8 @@ void *osl_malloc(osl_t *osh, uint size) if (osh) ASSERT(osh->magic == OS_HANDLE_MAGIC); - if ((addr = kmalloc(size, GFP_ATOMIC)) == NULL) { + addr = kmalloc(size, GFP_ATOMIC); + if (addr == NULL) { if (osh) osh->failed++; return NULL; @@ -452,7 +454,8 @@ void *osl_pktdup(osl_t *osh, void *skb) { void *p; - if ((p = skb_clone((struct sk_buff *)skb, GFP_ATOMIC)) == NULL) + p = skb_clone((struct sk_buff *)skb, GFP_ATOMIC); + if (p == NULL) return NULL; /* skb_clone copies skb->cb.. we don't want that */ diff --git a/drivers/staging/brcm80211/util/nicpci.c b/drivers/staging/brcm80211/util/nicpci.c index 76105a0..0b4f562 100644 --- a/drivers/staging/brcm80211/util/nicpci.c +++ b/drivers/staging/brcm80211/util/nicpci.c @@ -113,7 +113,8 @@ void *pcicore_init(si_t *sih, osl_t *osh, void *regs) ASSERT(sih->bustype == PCI_BUS); /* alloc pcicore_info_t */ - if ((pi = MALLOC(osh, sizeof(pcicore_info_t))) == NULL) { + pi = MALLOC(osh, sizeof(pcicore_info_t)); + if (pi == NULL) { PCI_ERROR(("pci_attach: malloc failed! malloced %d bytes\n", MALLOCED(osh))); return NULL; diff --git a/drivers/staging/brcm80211/util/nvram/nvram_ro.c b/drivers/staging/brcm80211/util/nvram/nvram_ro.c index 06fe278..12983c4 100644 --- a/drivers/staging/brcm80211/util/nvram/nvram_ro.c +++ b/drivers/staging/brcm80211/util/nvram/nvram_ro.c @@ -57,7 +57,8 @@ static void BCMINITFN(get_flash_nvram) (si_t *sih, struct nvram_header *nvh) nvs = R_REG(osh, &nvh->len) - sizeof(struct nvram_header); bufsz = nvs + VARS_T_OH; - if ((new = (vars_t *) MALLOC(osh, bufsz)) == NULL) { + new = (vars_t *) MALLOC(osh, bufsz); + if (new == NULL) { NVR_MSG(("Out of memory for flash vars\n")); return; } @@ -91,7 +92,8 @@ int BCMATTACHFN(nvram_append) (void *si, char *varlst, uint varsz) uint bufsz = VARS_T_OH; vars_t *new; - if ((new = MALLOC(si_osh((si_t *) si), bufsz)) == NULL) + new = MALLOC(si_osh((si_t *) si), bufsz); + if (new == NULL) return BCME_NOMEM; new->vars = varlst; @@ -144,9 +146,11 @@ char *nvram_get(const char *name) char *v = NULL; vars_t *cur; - for (cur = vars; cur; cur = cur->next) - if ((v = findvar(cur->vars, cur->vars + cur->size, name))) + for (cur = vars; cur; cur = cur->next) { + v = findvar(cur->vars, cur->vars + cur->size, name); + if (v) break; + } return v; } diff --git a/drivers/staging/brcm80211/util/siutils.c b/drivers/staging/brcm80211/util/siutils.c index d9a64eb..be834f9 100644 --- a/drivers/staging/brcm80211/util/siutils.c +++ b/drivers/staging/brcm80211/util/siutils.c @@ -88,7 +88,8 @@ si_t *BCMATTACHFN(si_attach) (uint devid, osl_t *osh, void *regs, si_info_t *sii; /* alloc si_info_t */ - if ((sii = MALLOC(osh, sizeof(si_info_t))) == NULL) { + sii = MALLOC(osh, sizeof(si_info_t)); + if (sii == NULL) { SI_ERROR(("si_attach: malloc failed! malloced %d bytes\n", MALLOCED(osh))); return NULL; @@ -269,14 +270,13 @@ BCMATTACHFN(si_buscore_setup) (si_info_t *sii, chipcregs_t *cc, uint bustype, /* fixup necessary chip/core configurations */ if (BUSTYPE(sii->pub.bustype) == PCI_BUS) { if (SI_FAST(sii)) { - if (!sii->pch && - ((sii->pch = - (void *)(uintptr) pcicore_init(&sii->pub, - sii->osh, - (void *) - PCIEREGS(sii))) == - NULL)) - return FALSE; + if (!sii->pch) { + sii->pch = (void *)(uintptr)pcicore_init( + &sii->pub, sii->osh, + (void *)PCIEREGS(sii)); + if (sii->pch == NULL) + return FALSE; + } } if (si_pci_fixcfg(&sii->pub)) { SI_ERROR(("si_doattach: sb_pci_fixcfg failed\n")); @@ -300,15 +300,15 @@ static void BCMATTACHFN(si_nvram_process) (si_info_t *sii, char *pvars) /* do a pci config read to get subsystem id and subvendor id */ w = OSL_PCI_READ_CONFIG(sii->osh, PCI_CFG_SVID, sizeof(uint32)); /* Let nvram variables override subsystem Vend/ID */ - if ((sii->pub.boardvendor = - (uint16) si_getdevpathintvar(&sii->pub, "boardvendor")) - == 0) + sii->pub.boardvendor = (uint16)si_getdevpathintvar(&sii->pub, + "boardvendor"); + if (sii->pub.boardvendor == 0) sii->pub.boardvendor = w & 0xffff; else SI_ERROR(("Overriding boardvendor: 0x%x instead of 0x%x\n", sii->pub.boardvendor, w & 0xffff)); - if ((sii->pub.boardtype = - (uint16) si_getdevpathintvar(&sii->pub, "boardtype")) - == 0) + sii->pub.boardtype = (uint16)si_getdevpathintvar(&sii->pub, + "boardtype"); + if (sii->pub.boardtype == 0) sii->pub.boardtype = (w >> 16) & 0xffff; else SI_ERROR(("Overriding boardtype: 0x%x instead of 0x%x\n", sii->pub.boardtype, (w >> 16) & 0xffff)); @@ -331,11 +331,12 @@ static void BCMATTACHFN(si_nvram_process) (si_info_t *sii, char *pvars) case SI_BUS: case JTAG_BUS: sii->pub.boardvendor = VENDOR_BROADCOM; - if (pvars == NULL - || ((sii->pub.boardtype = getintvar(pvars, "prodid")) == 0)) - if ((sii->pub.boardtype = - getintvar(NULL, "boardtype")) == 0) + sii->pub.boardtype = getintvar(pvars, "prodid"); + if (pvars == NULL || (sii->pub.boardtype == 0)) { + sii->pub.boardtype = getintvar(NULL, "boardtype"); + if (sii->pub.boardtype == 0) sii->pub.boardtype = 0xffff; + } break; } @@ -456,7 +457,8 @@ static si_info_t *BCMATTACHFN(si_doattach) (si_info_t *sii, uint devid, } /* setup the GPIO based LED powersave register */ - if ((w = getintvar(pvars, "leddc")) == 0) + w = getintvar(pvars, "leddc"); + if (w == 0) w = DEFAULT_GPIOTIMERVAL; sb_corereg(sih, SI_CC_IDX, OFFSETOF(chipcregs_t, gpiotimerval), ~0, w); @@ -614,7 +616,8 @@ static si_info_t *BCMATTACHFN(si_doattach) (si_info_t *sii, uint devid, } /* setup the GPIO based LED powersave register */ - if ((w = getintvar(pvars, "leddc")) == 0) + w = getintvar(pvars, "leddc"); + if (w == 0) w = DEFAULT_GPIOTIMERVAL; si_corereg(sih, SI_CC_IDX, OFFSETOF(chipcregs_t, gpiotimerval), ~0, w); @@ -1331,15 +1334,24 @@ uint16 BCMATTACHFN(si_d11_devid) (si_t *sih) uint16 device; /* normal case: nvram variable with devpath->devid->wl0id */ - if ((device = (uint16) si_getdevpathintvar(sih, "devid")) != 0) ; + device = (uint16) si_getdevpathintvar(sih, "devid"); + if (device != 0) + goto bail; + /* Get devid from OTP/SPROM depending on where the SROM is read */ - else if ((device = (uint16) getintvar(sii->vars, "devid")) != 0) ; + device = (uint16) getintvar(sii->vars, "devid"); + if (device != 0) + goto bail; + /* no longer support wl0id, but keep the code here for backward compatibility. */ - else if ((device = (uint16) getintvar(sii->vars, "wl0id")) != 0) ; - else - /* ignore it */ - device = 0xffff; + device = (uint16) getintvar(sii->vars, "wl0id"); + if (device != 0) + goto bail; + + /* ignore it */ + device = 0xffff; +bail: return device; } @@ -1448,11 +1460,14 @@ void BCMINITFN(si_clkctl_init) (si_t *sih) fast = SI_FAST(sii); if (!fast) { origidx = sii->curidx; - if ((cc = - (chipcregs_t *) si_setcore(sih, CC_CORE_ID, 0)) == NULL) + cc = (chipcregs_t *) si_setcore(sih, CC_CORE_ID, 0); + if (cc == NULL) return; - } else if ((cc = (chipcregs_t *) CCREGS_FAST(sii)) == NULL) - return; + } else { + cc = (chipcregs_t *) CCREGS_FAST(sii); + if (cc == NULL) + return; + } ASSERT(cc != NULL); /* set all Instaclk chip ILP to 1 MHz */ @@ -1493,11 +1508,14 @@ uint16 BCMINITFN(si_clkctl_fast_pwrup_delay) (si_t *sih) if (!fast) { origidx = sii->curidx; INTR_OFF(sii, intr_val); - if ((cc = - (chipcregs_t *) si_setcore(sih, CC_CORE_ID, 0)) == NULL) + cc = (chipcregs_t *) si_setcore(sih, CC_CORE_ID, 0); + if (cc == NULL) goto done; - } else if ((cc = (chipcregs_t *) CCREGS_FAST(sii)) == NULL) - goto done; + } else { + cc = (chipcregs_t *) CCREGS_FAST(sii); + if (cc == NULL) + goto done; + } ASSERT(cc != NULL); slowminfreq = si_slowclk_freq(sii, FALSE, cc); @@ -1640,8 +1658,11 @@ static bool _si_clkctl_cc(si_info_t *sii, uint mode) goto done; cc = (chipcregs_t *) si_setcore(&sii->pub, CC_CORE_ID, 0); - } else if ((cc = (chipcregs_t *) CCREGS_FAST(sii)) == NULL) - goto done; + } else { + cc = (chipcregs_t *) CCREGS_FAST(sii); + if (cc == NULL) + goto done; + } ASSERT(cc != NULL); if (!CCCTL_ENAB(&sii->pub) && (sii->pub.ccrev < 20)) @@ -1893,9 +1914,8 @@ void si_sdio_init(si_t *sih) ASSERT(idx == si_findcoreidx(sih, D11_CORE_ID, 0)); /* switch to sdio core */ - if (! - (sdpregs = - (sdpcmd_regs_t *) si_setcore(sih, PCMCIA_CORE_ID, 0))) + sdpregs = (sdpcmd_regs_t *) si_setcore(sih, PCMCIA_CORE_ID, 0); + if (!sdpregs) sdpregs = (sdpcmd_regs_t *) si_setcore(sih, SDIOD_CORE_ID, 0); ASSERT(sdpregs); @@ -2408,7 +2428,8 @@ void *BCMATTACHFN(si_gpio_handler_register) (si_t *sih, uint32 event, if (sih->ccrev < 11) return NULL; - if ((gi = MALLOC(sii->osh, sizeof(gpioh_item_t))) == NULL) + gi = MALLOC(sii->osh, sizeof(gpioh_item_t)); + if (gi == NULL) return NULL; bzero(gi, sizeof(gpioh_item_t)); @@ -2525,11 +2546,13 @@ void si_socdevram(si_t *sih, bool set, uint8 *enable, uint8 *protect) *enable = *protect = 0; /* Switch to SOCRAM core */ - if (!(regs = si_setcore(sih, SOCRAM_CORE_ID, 0))) + regs = si_setcore(sih, SOCRAM_CORE_ID, 0); + if (!regs) goto done; /* Get info for determining size */ - if (!(wasup = si_iscoreup(sih))) + wasup = si_iscoreup(sih); + if (!wasup) si_core_reset(sih, 0, 0); corerev = si_corerev(sih); @@ -2606,11 +2629,13 @@ uint32 si_socdevram_size(si_t *sih) origidx = si_coreidx(sih); /* Switch to SOCRAM core */ - if (!(regs = si_setcore(sih, SOCRAM_CORE_ID, 0))) + regs = si_setcore(sih, SOCRAM_CORE_ID, 0); + if (!regs) goto done; /* Get info for determining size */ - if (!(wasup = si_iscoreup(sih))) + wasup = si_iscoreup(sih); + if (!wasup) si_core_reset(sih, 0, 0); corerev = si_corerev(sih); @@ -2659,11 +2684,13 @@ uint32 si_socram_size(si_t *sih) origidx = si_coreidx(sih); /* Switch to SOCRAM core */ - if (!(regs = si_setcore(sih, SOCRAM_CORE_ID, 0))) + regs = si_setcore(sih, SOCRAM_CORE_ID, 0); + if (!regs) goto done; /* Get info for determining size */ - if (!(wasup = si_iscoreup(sih))) + wasup = si_iscoreup(sih); + if (!wasup) si_core_reset(sih, 0, 0); corerev = si_corerev(sih); coreinfo = R_REG(sii->osh, ®s->coreinfo); |