From patchwork Wed Jun 29 23:46:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Franky Lin X-Patchwork-Id: 930842 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5TNoWmH014452 for ; Wed, 29 Jun 2011 23:50:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758261Ab1F2Xua (ORCPT ); Wed, 29 Jun 2011 19:50:30 -0400 Received: from mms1.broadcom.com ([216.31.210.17]:2088 "EHLO mms1.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757987Ab1F2Xss (ORCPT ); Wed, 29 Jun 2011 19:48:48 -0400 Received: from [10.9.200.133] by mms1.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.3.2)); Wed, 29 Jun 2011 16:53:28 -0700 X-Server-Uuid: 02CED230-5797-4B57-9875-D5D2FEE4708A Received: from mail-irva-13.broadcom.com (10.11.16.103) by IRVEXCHHUB02.corp.ad.broadcom.com (10.9.200.133) with Microsoft SMTP Server id 8.2.247.2; Wed, 29 Jun 2011 16:48:23 -0700 Received: from mail-sj1-12.sj.broadcom.com (mail-sj1-12.sj.broadcom.com [10.17.16.106]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 7B3AC74D1D; Wed, 29 Jun 2011 16:48:30 -0700 (PDT) Received: from lc-sj1-3560.broadcom.com (lc-sj1-3560.sj.broadcom.com [10.17.194.250]) by mail-sj1-12.sj.broadcom.com (Postfix) with ESMTP id CF5C920506; Wed, 29 Jun 2011 16:48:23 -0700 (PDT) Received: by lc-sj1-3560.broadcom.com (Postfix, from userid 25250) id 7AA412C19D0E; Wed, 29 Jun 2011 16:48:23 -0700 (PDT) From: "Franky Lin" To: gregkh@suse.de cc: devel@linuxdriverproject.org, linux-wireless@vger.kernel.org Subject: [PATCH 005/119] staging: brcm80211: make use of linux error codes in srom.c Date: Wed, 29 Jun 2011 16:46:29 -0700 Message-ID: <1309391303-22741-6-git-send-email-frankyl@broadcom.com> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: <1309391303-22741-1-git-send-email-frankyl@broadcom.com> References: <1309391303-22741-1-git-send-email-frankyl@broadcom.com> MIME-Version: 1.0 X-WSS-ID: 621565723B411334593-01-01 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 29 Jun 2011 23:50:33 +0000 (UTC) From: Arend van Spriel The source file srom.c used meaningless non-zero numbers to return upon error conditions. These have been replaced by linux error codes. Signed-off-by: Arend van Spriel Reviewed-by: Roland Vossen --- drivers/staging/brcm80211/brcmsmac/srom.c | 36 +++++++++++++---------------- 1 files changed, 16 insertions(+), 20 deletions(-) diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index 31aa84d..34c19ef 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -870,7 +870,7 @@ int srom_var_init(struct si_pub *sih, uint bustype, void *curmap, if (curmap != NULL && bustype == PCI_BUS) return initvars_srom_pci(sih, curmap, vars, count); - return -1; + return -EINVAL; } /* In chips with chipcommon rev 32 and later, the srom is in chipcommon, @@ -935,7 +935,7 @@ sprom_read_pci(struct si_pub *sih, u16 *sprom, uint wordoff, if (sih->ccrev > 31 && ISSIM_ENAB(sih)) { /* use indirect since direct is too slow on QT */ if ((sih->cccaps & CC_CAP_SROM) == 0) - return 1; + return -ENODEV; ccregs = (void *)((u8 *) sprom - CC_SROM_OTP); buf[i] = @@ -953,7 +953,7 @@ sprom_read_pci(struct si_pub *sih, u16 *sprom, uint wordoff, /* bypass crc checking for simulation to allow srom hack */ if (ISSIM_ENAB(sih)) - return err; + return 0; if (check_crc) { @@ -962,7 +962,7 @@ sprom_read_pci(struct si_pub *sih, u16 *sprom, uint wordoff, * is blank, regardless of the rest of the content, so declare * it bad. */ - return 1; + return -ENODATA; } /* fixup the endianness so crc8 will pass */ @@ -970,7 +970,7 @@ sprom_read_pci(struct si_pub *sih, u16 *sprom, uint wordoff, if (brcmu_crc8((u8 *) buf, nwords * 2, CRC8_INIT_VALUE) != CRC8_GOOD_VALUE) { /* DBG only pci always read srom4 first, then srom8/9 */ - err = 1; + err = -EIO; } /* now correct the endianness of the byte array */ ltoh16_buf(buf, nwords * 2); @@ -987,7 +987,7 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) otp = kzalloc(OTP_SZ_MAX, GFP_ATOMIC); if (otp == NULL) { - return -EBADE; + return -ENOMEM; } err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz); @@ -1002,14 +1002,14 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) * is blank, regardless of the rest of the content, so declare * it bad. */ - return 1; + return -ENODATA; } /* fixup the endianness so crc8 will pass */ htol16_buf(buf, bufsz); if (brcmu_crc8((u8 *) buf, SROM4_WORDS * 2, CRC8_INIT_VALUE) != CRC8_GOOD_VALUE) { - err = 1; + err = -EIO; } /* now correct the endianness of the byte array */ ltoh16_buf(buf, bufsz); @@ -1219,13 +1219,12 @@ static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars, */ srom = kmalloc(SROM_MAX, GFP_ATOMIC); if (!srom) - return -2; + return -ENOMEM; sromwindow = (u16 *) SROM_OFFSET(sih); if (ai_is_sprom_available(sih)) { - err = - sprom_read_pci(sih, sromwindow, 0, srom, SROM_WORDS, - true); + err = sprom_read_pci(sih, sromwindow, 0, srom, SROM_WORDS, + true); if ((srom[SROM4_SIGN] == SROM4_SIGNATURE) || (((sih->buscoretype == PCIE_CORE_ID) @@ -1233,9 +1232,8 @@ static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars, || ((sih->buscoretype == PCI_CORE_ID) && (sih->buscorerev >= 0xe)))) { /* sromrev >= 4, read more */ - err = - sprom_read_pci(sih, sromwindow, 0, srom, - SROM4_WORDS, true); + err = sprom_read_pci(sih, sromwindow, 0, srom, + SROM4_WORDS, true); sromrev = srom[SROM4_CRCREV] & 0xff; } else if (err == 0) { /* srom is good and is rev < 4 */ @@ -1253,12 +1251,10 @@ static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars, if (err == 0) /* OTP only contain SROM rev8/rev9 for now */ sromrev = srom[SROM4_CRCREV] & 0xff; - else - err = 1; } #else else - err = 1; + err = -ENODEV; #endif if (!err) { @@ -1267,13 +1263,13 @@ static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars, /* srom version check: Current valid versions: 1, 2, 3, 4, 5, 8, 9 */ if ((sr & 0x33e) == 0) { - err = -2; + err = -EINVAL; goto errout; } base = kmalloc(MAXSZ_NVRAM_VARS, GFP_ATOMIC); if (!base) { - err = -2; + err = -ENOMEM; goto errout; }