mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-01-30 23:55:50 +00:00
staging: brmc80211: cleaned up sdio related error codes
Code cleanup. Replaced Broadcom proprietary error codes with Linux native ones. Signed-off-by: Roland Vossen <rvossen@broadcom.com> Reviewed-by: Arend van Spriel <arend@broadcom.com> Reviewed-by: Franky Lin <frankyl@broadcom.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
0c51cca851
commit
67f72befc7
@ -19,10 +19,6 @@
|
||||
|
||||
#include "sdio_host.h"
|
||||
|
||||
#define SDIOH_API_RC_SUCCESS (0x00)
|
||||
#define SDIOH_API_RC_FAIL (0x01)
|
||||
#define SDIOH_API_SUCCESS(status) (status == 0)
|
||||
|
||||
#define SDIOH_READ 0 /* Read request */
|
||||
#define SDIOH_WRITE 1 /* Write request */
|
||||
|
||||
|
@ -105,7 +105,7 @@ bool brcmf_sdcard_intr_query(void *sdh)
|
||||
|
||||
ASSERT(bcmsdh);
|
||||
status = brcmf_sdioh_interrupt_query(bcmsdh->sdioh, &on);
|
||||
if (SDIOH_API_SUCCESS(status))
|
||||
if (status == 0)
|
||||
return false;
|
||||
else
|
||||
return on;
|
||||
@ -114,41 +114,33 @@ bool brcmf_sdcard_intr_query(void *sdh)
|
||||
int brcmf_sdcard_intr_enable(void *sdh)
|
||||
{
|
||||
struct brcmf_sdio *bcmsdh = (struct brcmf_sdio *) sdh;
|
||||
int status;
|
||||
ASSERT(bcmsdh);
|
||||
|
||||
status = brcmf_sdioh_interrupt_set(bcmsdh->sdioh, true);
|
||||
return SDIOH_API_SUCCESS(status) ? 0 : -EIO;
|
||||
return brcmf_sdioh_interrupt_set(bcmsdh->sdioh, true);
|
||||
}
|
||||
|
||||
int brcmf_sdcard_intr_disable(void *sdh)
|
||||
{
|
||||
struct brcmf_sdio *bcmsdh = (struct brcmf_sdio *) sdh;
|
||||
int status;
|
||||
ASSERT(bcmsdh);
|
||||
|
||||
status = brcmf_sdioh_interrupt_set(bcmsdh->sdioh, false);
|
||||
return SDIOH_API_SUCCESS(status) ? 0 : -EIO;
|
||||
return brcmf_sdioh_interrupt_set(bcmsdh->sdioh, false);
|
||||
}
|
||||
|
||||
int brcmf_sdcard_intr_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh)
|
||||
{
|
||||
struct brcmf_sdio *bcmsdh = (struct brcmf_sdio *) sdh;
|
||||
int status;
|
||||
ASSERT(bcmsdh);
|
||||
|
||||
status = brcmf_sdioh_interrupt_register(bcmsdh->sdioh, fn, argh);
|
||||
return SDIOH_API_SUCCESS(status) ? 0 : -EIO;
|
||||
return brcmf_sdioh_interrupt_register(bcmsdh->sdioh, fn, argh);
|
||||
}
|
||||
|
||||
int brcmf_sdcard_intr_dereg(void *sdh)
|
||||
{
|
||||
struct brcmf_sdio *bcmsdh = (struct brcmf_sdio *) sdh;
|
||||
int status;
|
||||
ASSERT(bcmsdh);
|
||||
|
||||
status = brcmf_sdioh_interrupt_deregister(bcmsdh->sdioh);
|
||||
return SDIOH_API_SUCCESS(status) ? 0 : -EIO;
|
||||
return brcmf_sdioh_interrupt_deregister(bcmsdh->sdioh);
|
||||
}
|
||||
|
||||
#if defined(BCMDBG)
|
||||
@ -192,11 +184,11 @@ u8 brcmf_sdcard_cfg_read(void *sdh, uint fnc_num, u32 addr, int *err)
|
||||
brcmf_sdioh_cfg_read(bcmsdh->sdioh, fnc_num, addr,
|
||||
(u8 *) &data);
|
||||
#ifdef SDIOH_API_ACCESS_RETRY_LIMIT
|
||||
} while (!SDIOH_API_SUCCESS(status)
|
||||
} while (status != 0
|
||||
&& (retry++ < SDIOH_API_ACCESS_RETRY_LIMIT));
|
||||
#endif
|
||||
if (err)
|
||||
*err = (SDIOH_API_SUCCESS(status) ? 0 : -EIO);
|
||||
*err = status;
|
||||
|
||||
BCMSDH_INFO(("%s:fun = %d, addr = 0x%x, u8data = 0x%x\n",
|
||||
__func__, fnc_num, addr, data));
|
||||
@ -227,11 +219,11 @@ brcmf_sdcard_cfg_write(void *sdh, uint fnc_num, u32 addr, u8 data, int *err)
|
||||
brcmf_sdioh_cfg_write(bcmsdh->sdioh, fnc_num, addr,
|
||||
(u8 *) &data);
|
||||
#ifdef SDIOH_API_ACCESS_RETRY_LIMIT
|
||||
} while (!SDIOH_API_SUCCESS(status)
|
||||
} while (status != 0
|
||||
&& (retry++ < SDIOH_API_ACCESS_RETRY_LIMIT));
|
||||
#endif
|
||||
if (err)
|
||||
*err = SDIOH_API_SUCCESS(status) ? 0 : -EIO;
|
||||
*err = status;
|
||||
|
||||
BCMSDH_INFO(("%s:fun = %d, addr = 0x%x, u8data = 0x%x\n",
|
||||
__func__, fnc_num, addr, data));
|
||||
@ -252,7 +244,7 @@ u32 brcmf_sdcard_cfg_read_word(void *sdh, uint fnc_num, u32 addr, int *err)
|
||||
SDIOH_READ, fnc_num, addr, &data, 4);
|
||||
|
||||
if (err)
|
||||
*err = (SDIOH_API_SUCCESS(status) ? 0 : -EIO);
|
||||
*err = status;
|
||||
|
||||
BCMSDH_INFO(("%s:fun = %d, addr = 0x%x, u32data = 0x%x\n",
|
||||
__func__, fnc_num, addr, data));
|
||||
@ -277,7 +269,7 @@ brcmf_sdcard_cfg_write_word(void *sdh, uint fnc_num, u32 addr, u32 data,
|
||||
SDIOH_WRITE, fnc_num, addr, &data, 4);
|
||||
|
||||
if (err)
|
||||
*err = (SDIOH_API_SUCCESS(status) ? 0 : -EIO);
|
||||
*err = status;
|
||||
|
||||
BCMSDH_INFO(("%s:fun = %d, addr = 0x%x, u32data = 0x%x\n",
|
||||
__func__, fnc_num, addr, data));
|
||||
@ -320,7 +312,7 @@ int brcmf_sdcard_cis_read(void *sdh, uint func, u8 * cis, uint length)
|
||||
kfree(tmp_buf);
|
||||
}
|
||||
|
||||
return SDIOH_API_SUCCESS(status) ? 0 : -EIO;
|
||||
return status;
|
||||
}
|
||||
|
||||
static int brcmf_sdcard_set_sbaddr_window(void *sdh, u32 address)
|
||||
@ -371,12 +363,12 @@ u32 brcmf_sdcard_reg_read(void *sdh, u32 addr, uint size)
|
||||
status = brcmf_sdioh_request_word(bcmsdh->sdioh, SDIOH_CMD_TYPE_NORMAL,
|
||||
SDIOH_READ, SDIO_FUNC_1, addr, &word, size);
|
||||
|
||||
bcmsdh->regfail = !(SDIOH_API_SUCCESS(status));
|
||||
bcmsdh->regfail = (status != 0);
|
||||
|
||||
BCMSDH_INFO(("u32data = 0x%x\n", word));
|
||||
|
||||
/* if ok, return appropriately masked word */
|
||||
if (SDIOH_API_SUCCESS(status)) {
|
||||
if (status == 0) {
|
||||
switch (size) {
|
||||
case sizeof(u8):
|
||||
return word & 0xff;
|
||||
@ -425,9 +417,9 @@ u32 brcmf_sdcard_reg_write(void *sdh, u32 addr, uint size, u32 data)
|
||||
status =
|
||||
brcmf_sdioh_request_word(bcmsdh->sdioh, SDIOH_CMD_TYPE_NORMAL,
|
||||
SDIOH_WRITE, SDIO_FUNC_1, addr, &data, size);
|
||||
bcmsdh->regfail = !(SDIOH_API_SUCCESS(status));
|
||||
bcmsdh->regfail = (status != 0);
|
||||
|
||||
if (SDIOH_API_SUCCESS(status))
|
||||
if (status == 0)
|
||||
return 0;
|
||||
|
||||
BCMSDH_ERROR(("%s: error writing 0x%08x to addr 0x%04x size %d\n",
|
||||
@ -480,7 +472,7 @@ brcmf_sdcard_recv_buf(struct brcmf_sdio *bcmsdh, u32 addr, uint fn, uint flags,
|
||||
status = brcmf_sdioh_request_buffer(bcmsdh->sdioh, SDIOH_DATA_PIO,
|
||||
incr_fix, SDIOH_READ, fn, addr, width, nbytes, buf, pkt);
|
||||
|
||||
return SDIOH_API_SUCCESS(status) ? 0 : -EIO;
|
||||
return status;
|
||||
}
|
||||
|
||||
int
|
||||
@ -489,7 +481,6 @@ brcmf_sdcard_send_buf(void *sdh, u32 addr, uint fn, uint flags,
|
||||
bcmsdh_cmplt_fn_t complete, void *handle)
|
||||
{
|
||||
struct brcmf_sdio *bcmsdh = (struct brcmf_sdio *) sdh;
|
||||
int status;
|
||||
uint incr_fix;
|
||||
uint width;
|
||||
uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK;
|
||||
@ -521,16 +512,13 @@ brcmf_sdcard_send_buf(void *sdh, u32 addr, uint fn, uint flags,
|
||||
if (width == 4)
|
||||
addr |= SBSDIO_SB_ACCESS_2_4B_FLAG;
|
||||
|
||||
status = brcmf_sdioh_request_buffer(bcmsdh->sdioh, SDIOH_DATA_PIO,
|
||||
return brcmf_sdioh_request_buffer(bcmsdh->sdioh, SDIOH_DATA_PIO,
|
||||
incr_fix, SDIOH_WRITE, fn, addr, width, nbytes, buf, pkt);
|
||||
|
||||
return SDIOH_API_SUCCESS(status) ? 0 : -EIO;
|
||||
}
|
||||
|
||||
int brcmf_sdcard_rwdata(void *sdh, uint rw, u32 addr, u8 *buf, uint nbytes)
|
||||
{
|
||||
struct brcmf_sdio *bcmsdh = (struct brcmf_sdio *) sdh;
|
||||
int status;
|
||||
|
||||
ASSERT(bcmsdh);
|
||||
ASSERT(bcmsdh->init_success);
|
||||
@ -539,11 +527,9 @@ int brcmf_sdcard_rwdata(void *sdh, uint rw, u32 addr, u8 *buf, uint nbytes)
|
||||
addr &= SBSDIO_SB_OFT_ADDR_MASK;
|
||||
addr |= SBSDIO_SB_ACCESS_2_4B_FLAG;
|
||||
|
||||
status = brcmf_sdioh_request_buffer(bcmsdh->sdioh, SDIOH_DATA_PIO,
|
||||
return brcmf_sdioh_request_buffer(bcmsdh->sdioh, SDIOH_DATA_PIO,
|
||||
SDIOH_DATA_INC, (rw ? SDIOH_WRITE : SDIOH_READ), SDIO_FUNC_1,
|
||||
addr, 4, nbytes, buf, NULL);
|
||||
|
||||
return SDIOH_API_SUCCESS(status) ? 0 : -EIO;
|
||||
}
|
||||
|
||||
int brcmf_sdcard_abort(void *sdh, uint fn)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <linux/mmc/sdio_func.h>
|
||||
#include <linux/mmc/sdio_ids.h>
|
||||
#include <linux/suspend.h>
|
||||
#include <linux/errno.h>
|
||||
|
||||
#include <defs.h>
|
||||
#include <brcm_hw_ids.h>
|
||||
@ -174,7 +175,7 @@ extern int brcmf_sdioh_detach(struct sdioh_info *sd)
|
||||
|
||||
kfree(sd);
|
||||
}
|
||||
return SDIOH_API_RC_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Configure callback to client when we receive client interrupt */
|
||||
@ -186,7 +187,7 @@ brcmf_sdioh_interrupt_register(struct sdioh_info *sd, sdioh_cb_fn_t fn,
|
||||
if (fn == NULL) {
|
||||
sd_err(("%s: interrupt handler is NULL, not registering\n",
|
||||
__func__));
|
||||
return SDIOH_API_RC_FAIL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
sd->intr_handler = fn;
|
||||
@ -206,7 +207,7 @@ brcmf_sdioh_interrupt_register(struct sdioh_info *sd, sdioh_cb_fn_t fn,
|
||||
sdio_release_host(gInstance->func[1]);
|
||||
}
|
||||
|
||||
return SDIOH_API_RC_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *sd)
|
||||
@ -232,7 +233,7 @@ extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *sd)
|
||||
sd->intr_handler = NULL;
|
||||
sd->intr_handler_arg = NULL;
|
||||
|
||||
return SDIOH_API_RC_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int
|
||||
@ -240,7 +241,7 @@ brcmf_sdioh_interrupt_query(struct sdioh_info *sd, bool *onoff)
|
||||
{
|
||||
sd_trace(("%s: Entering\n", __func__));
|
||||
*onoff = sd->client_intr_enabled;
|
||||
return SDIOH_API_RC_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(BCMDBG)
|
||||
@ -501,7 +502,7 @@ brcmf_sdioh_cis_read(struct sdioh_info *sd, uint func, u8 *cisd, u32 length)
|
||||
if (!sd->func_cis_ptr[func]) {
|
||||
memset(cis, 0, length);
|
||||
sd_err(("%s: no func_cis_ptr[%d]\n", __func__, func));
|
||||
return SDIOH_API_RC_FAIL;
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
|
||||
sd_err(("%s: func_cis_ptr[%d]=0x%04x\n", __func__, func,
|
||||
@ -512,14 +513,14 @@ brcmf_sdioh_cis_read(struct sdioh_info *sd, uint func, u8 *cisd, u32 length)
|
||||
if (brcmf_sdioh_card_regread(sd, 0, offset, 1, &foo) < 0) {
|
||||
sd_err(("%s: regread failed: Can't read CIS\n",
|
||||
__func__));
|
||||
return SDIOH_API_RC_FAIL;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
*cis = (u8) (foo & 0xff);
|
||||
cis++;
|
||||
}
|
||||
|
||||
return SDIOH_API_RC_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int
|
||||
@ -532,7 +533,7 @@ brcmf_sdioh_request_byte(struct sdioh_info *sd, uint rw, uint func,
|
||||
regaddr));
|
||||
|
||||
BRCMF_PM_RESUME_WAIT(sdioh_request_byte_wait);
|
||||
BRCMF_PM_RESUME_RETURN_ERROR(SDIOH_API_RC_FAIL);
|
||||
BRCMF_PM_RESUME_RETURN_ERROR(-EIO);
|
||||
if (rw) { /* CMD52 Write */
|
||||
if (func == 0) {
|
||||
/* Can only directly write to some F0 registers.
|
||||
@ -616,25 +617,25 @@ brcmf_sdioh_request_byte(struct sdioh_info *sd, uint rw, uint func,
|
||||
"Err: %d\n", rw ? "Write" : "Read", func, regaddr,
|
||||
*byte, err_ret));
|
||||
|
||||
return ((err_ret == 0) ? SDIOH_API_RC_SUCCESS : SDIOH_API_RC_FAIL);
|
||||
return err_ret;
|
||||
}
|
||||
|
||||
extern int
|
||||
brcmf_sdioh_request_word(struct sdioh_info *sd, uint cmd_type, uint rw,
|
||||
uint func, uint addr, u32 *word, uint nbytes)
|
||||
{
|
||||
int err_ret = SDIOH_API_RC_FAIL;
|
||||
int err_ret = -EIO;
|
||||
|
||||
if (func == 0) {
|
||||
sd_err(("%s: Only CMD52 allowed to F0.\n", __func__));
|
||||
return SDIOH_API_RC_FAIL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
sd_info(("%s: cmd_type=%d, rw=%d, func=%d, addr=0x%05x, nbytes=%d\n",
|
||||
__func__, cmd_type, rw, func, addr, nbytes));
|
||||
|
||||
BRCMF_PM_RESUME_WAIT(sdioh_request_word_wait);
|
||||
BRCMF_PM_RESUME_RETURN_ERROR(SDIOH_API_RC_FAIL);
|
||||
BRCMF_PM_RESUME_RETURN_ERROR(-EIO);
|
||||
/* Claim host controller */
|
||||
sdio_claim_host(gInstance->func[func]);
|
||||
|
||||
@ -669,7 +670,7 @@ brcmf_sdioh_request_word(struct sdioh_info *sd, uint cmd_type, uint rw,
|
||||
rw ? "Write" : "Read", err_ret));
|
||||
}
|
||||
|
||||
return ((err_ret == 0) ? SDIOH_API_RC_SUCCESS : SDIOH_API_RC_FAIL);
|
||||
return err_ret;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -686,7 +687,7 @@ brcmf_sdioh_request_packet(struct sdioh_info *sd, uint fix_inc, uint write,
|
||||
|
||||
ASSERT(pkt);
|
||||
BRCMF_PM_RESUME_WAIT(sdioh_request_packet_wait);
|
||||
BRCMF_PM_RESUME_RETURN_ERROR(SDIOH_API_RC_FAIL);
|
||||
BRCMF_PM_RESUME_RETURN_ERROR(-EIO);
|
||||
|
||||
/* Claim host controller */
|
||||
sdio_claim_host(gInstance->func[func]);
|
||||
@ -743,7 +744,7 @@ brcmf_sdioh_request_packet(struct sdioh_info *sd, uint fix_inc, uint write,
|
||||
sdio_release_host(gInstance->func[func]);
|
||||
|
||||
sd_trace(("%s: Exit\n", __func__));
|
||||
return ((err_ret == 0) ? SDIOH_API_RC_SUCCESS : SDIOH_API_RC_FAIL);
|
||||
return err_ret;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -772,7 +773,7 @@ brcmf_sdioh_request_buffer(struct sdioh_info *sd, uint pio_dma, uint fix_inc,
|
||||
sd_trace(("%s: Enter\n", __func__));
|
||||
|
||||
BRCMF_PM_RESUME_WAIT(sdioh_request_buffer_wait);
|
||||
BRCMF_PM_RESUME_RETURN_ERROR(SDIOH_API_RC_FAIL);
|
||||
BRCMF_PM_RESUME_RETURN_ERROR(-EIO);
|
||||
/* Case 1: we don't have a packet. */
|
||||
if (pkt == NULL) {
|
||||
sd_data(("%s: Creating new %s Packet, len=%d\n",
|
||||
@ -781,7 +782,7 @@ brcmf_sdioh_request_buffer(struct sdioh_info *sd, uint pio_dma, uint fix_inc,
|
||||
if (!mypkt) {
|
||||
sd_err(("%s: brcmu_pkt_buf_get_skb failed: len %d\n",
|
||||
__func__, buflen_u));
|
||||
return SDIOH_API_RC_FAIL;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/* For a write, copy the buffer data into the packet. */
|
||||
@ -808,7 +809,7 @@ brcmf_sdioh_request_buffer(struct sdioh_info *sd, uint pio_dma, uint fix_inc,
|
||||
if (!mypkt) {
|
||||
sd_err(("%s: brcmu_pkt_buf_get_skb failed: len %d\n",
|
||||
__func__, pkt->len));
|
||||
return SDIOH_API_RC_FAIL;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/* For a write, copy the buffer data into the packet. */
|
||||
@ -845,7 +846,7 @@ extern int brcmf_sdioh_abort(struct sdioh_info *sd, uint func)
|
||||
&t_func);
|
||||
|
||||
sd_trace(("%s: Exit\n", __func__));
|
||||
return SDIOH_API_RC_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Reset and re-initialize the device */
|
||||
@ -853,7 +854,7 @@ int brcmf_sdioh_reset(struct sdioh_info *si)
|
||||
{
|
||||
sd_trace(("%s: Enter\n", __func__));
|
||||
sd_trace(("%s: Exit\n", __func__));
|
||||
return SDIOH_API_RC_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Disable device interrupt */
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <linux/mmc/card.h>
|
||||
#include <linux/mmc/sdio_func.h>
|
||||
#include <linux/mmc/sdio_ids.h>
|
||||
#include <linux/errno.h>
|
||||
#include <net/cfg80211.h>
|
||||
|
||||
#include <defs.h>
|
||||
@ -219,7 +220,7 @@ int brcmf_sdioh_interrupt_set(struct sdioh_info *sd, bool enable)
|
||||
if (enable && !(sd->intr_handler && sd->intr_handler_arg)) {
|
||||
sd_err(("%s: no handler registered, will not enable\n",
|
||||
__func__));
|
||||
return SDIOH_API_RC_FAIL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Ensure atomicity for enable/disable calls */
|
||||
@ -233,7 +234,7 @@ int brcmf_sdioh_interrupt_set(struct sdioh_info *sd, bool enable)
|
||||
|
||||
spin_unlock_irqrestore(&sdos->lock, flags);
|
||||
|
||||
return SDIOH_API_RC_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user