Commit aa6ca807 authored by Tobin C. Harding's avatar Tobin C. Harding Committed by Greg Kroah-Hartman

staging: ks7010: remove custom return values

Driver code uses custom return values (often positive) to signal error
condition instead of using standard kernel error codes.

Replace custom return values with standard kernel error codes.
Signed-off-by: default avatarTobin C. Harding <me@tobin.cc>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7bb6313d
...@@ -241,21 +241,18 @@ static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p, ...@@ -241,21 +241,18 @@ static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p,
void *arg1, void *arg2) void *arg1, void *arg2)
{ {
struct tx_device_buffer *sp; struct tx_device_buffer *sp;
int rc;
if (priv->dev_state < DEVICE_STATE_BOOT) { if (priv->dev_state < DEVICE_STATE_BOOT) {
kfree(p); rc = -EPERM;
if (complete_handler) goto err_complete;
(*complete_handler) (arg1, arg2);
return 1;
} }
if ((TX_DEVICE_BUFF_SIZE - 1) <= cnt_txqbody(priv)) { if ((TX_DEVICE_BUFF_SIZE - 1) <= cnt_txqbody(priv)) {
/* in case of buffer overflow */ /* in case of buffer overflow */
DPRINTK(1, "tx buffer overflow\n"); DPRINTK(1, "tx buffer overflow\n");
kfree(p); rc = -EOVERFLOW;
if (complete_handler) goto err_complete;
(*complete_handler) (arg1, arg2);
return 1;
} }
sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qtail]; sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qtail];
...@@ -267,15 +264,22 @@ static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p, ...@@ -267,15 +264,22 @@ static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p,
inc_txqtail(priv); inc_txqtail(priv);
return 0; return 0;
err_complete:
kfree(p);
if (complete_handler)
(*complete_handler) (arg1, arg2);
return rc;
} }
/* write data */ /* write data */
static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer, static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer,
unsigned long size) unsigned long size)
{ {
int retval;
unsigned char rw_data; unsigned char rw_data;
struct hostif_hdr *hdr; struct hostif_hdr *hdr;
int rc;
hdr = (struct hostif_hdr *)buffer; hdr = (struct hostif_hdr *)buffer;
...@@ -285,18 +289,17 @@ static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer, ...@@ -285,18 +289,17 @@ static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer,
return 0; return 0;
} }
retval = ks7010_sdio_write(priv, DATA_WINDOW, buffer, size); rc = ks7010_sdio_write(priv, DATA_WINDOW, buffer, size);
if (retval) { if (rc) {
DPRINTK(1, " write error : retval=%d\n", retval); DPRINTK(1, " write error : retval=%d\n", rc);
return -4; return rc;
} }
rw_data = WRITE_STATUS_BUSY; rw_data = WRITE_STATUS_BUSY;
retval = rc = ks7010_sdio_write(priv, WRITE_STATUS, &rw_data, sizeof(rw_data));
ks7010_sdio_write(priv, WRITE_STATUS, &rw_data, sizeof(rw_data)); if (rc) {
if (retval) {
DPRINTK(1, " error : WRITE_STATUS=%02X\n", rw_data); DPRINTK(1, " error : WRITE_STATUS=%02X\n", rw_data);
return -3; return rc;
} }
return 0; return 0;
...@@ -675,30 +678,27 @@ static void trx_device_exit(struct ks_wlan_private *priv) ...@@ -675,30 +678,27 @@ static void trx_device_exit(struct ks_wlan_private *priv)
static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)
{ {
int rc = 0; int rc;
int retval;
unsigned char *data_buf; unsigned char *data_buf;
data_buf = kmalloc(sizeof(u32), GFP_KERNEL); data_buf = kmalloc(sizeof(u32), GFP_KERNEL);
if (!data_buf) { if (!data_buf)
rc = 1; return -ENOMEM;
goto error_out;
}
memcpy(data_buf, &index, sizeof(index)); memcpy(data_buf, &index, sizeof(index));
retval = ks7010_sdio_write(priv, WRITE_INDEX, data_buf, sizeof(index)); rc = ks7010_sdio_write(priv, WRITE_INDEX, data_buf, sizeof(index));
if (retval) { if (rc)
rc = 2;
goto error_out; goto error_out;
}
retval = ks7010_sdio_write(priv, READ_INDEX, data_buf, sizeof(index)); rc = ks7010_sdio_write(priv, READ_INDEX, data_buf, sizeof(index));
if (retval) { if (rc)
rc = 3;
goto error_out; goto error_out;
}
return 0;
error_out: error_out:
kfree(data_buf); kfree(data_buf);
return rc; return rc;
} }
...@@ -706,29 +706,28 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) ...@@ -706,29 +706,28 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)
static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address, static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,
unsigned char *data, unsigned int size) unsigned char *data, unsigned int size)
{ {
int rc = 0; int rc;
int retval;
unsigned char *read_buf; unsigned char *read_buf;
read_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL); read_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL);
if (!read_buf) { if (!read_buf)
rc = 1; return -ENOMEM;
goto error_out;
} rc = ks7010_sdio_read(priv, address, read_buf, size);
retval = ks7010_sdio_read(priv, address, read_buf, size); if (rc)
if (retval) {
rc = 2;
goto error_out; goto error_out;
}
retval = memcmp(data, read_buf, size);
if (retval) { rc = memcmp(data, read_buf, size);
DPRINTK(0, "data compare error (%d)\n", retval); if (rc) {
rc = 3; DPRINTK(0, "data compare error (%d)\n", rc);
goto error_out; goto error_out;
} }
return 0;
error_out: error_out:
kfree(read_buf); kfree(read_buf);
return rc; return rc;
} }
...@@ -738,28 +737,27 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv, ...@@ -738,28 +737,27 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,
unsigned int size, offset, n = 0; unsigned int size, offset, n = 0;
unsigned char *rom_buf; unsigned char *rom_buf;
unsigned char rw_data = 0; unsigned char rw_data = 0;
int retval, rc = 0; int rc;
int length; int length;
const struct firmware *fw_entry = NULL; const struct firmware *fw_entry = NULL;
/* buffer allocate */ /* buffer allocate */
rom_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL); rom_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL);
if (!rom_buf) if (!rom_buf)
return 3; return -ENOMEM;
sdio_claim_host(card->func); sdio_claim_host(card->func);
/* Firmware running ? */ /* Firmware running ? */
retval = ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data)); rc = ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data));
if (rw_data == GCR_A_RUN) { if (rw_data == GCR_A_RUN) {
DPRINTK(0, "MAC firmware running ...\n"); DPRINTK(0, "MAC firmware running ...\n");
rc = 0; goto release_host_and_free;
goto error_out0;
} }
retval = request_firmware(&fw_entry, ROM_FILE, &priv->ks_wlan_hw.sdio_card->func->dev); rc = request_firmware(&fw_entry, ROM_FILE, &priv->ks_wlan_hw.sdio_card->func->dev);
if (retval) if (rc)
goto error_out0; goto release_host_and_free;
length = fw_entry->size; length = fw_entry->size;
...@@ -779,67 +777,58 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv, ...@@ -779,67 +777,58 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,
memcpy(rom_buf, fw_entry->data + n, size); memcpy(rom_buf, fw_entry->data + n, size);
/* Update write index */ /* Update write index */
offset = n; offset = n;
retval = rc = ks7010_sdio_update_index(priv,
ks7010_sdio_update_index(priv, KS7010_IRAM_ADDRESS + offset);
KS7010_IRAM_ADDRESS + offset); if (rc)
if (retval) { goto release_firmware;
rc = 6;
goto error_out1;
}
/* Write data */ /* Write data */
retval = ks7010_sdio_write(priv, DATA_WINDOW, rom_buf, size); rc = ks7010_sdio_write(priv, DATA_WINDOW, rom_buf, size);
if (retval) { if (rc)
rc = 8; goto release_firmware;
goto error_out1;
}
/* compare */ /* compare */
retval = rc = ks7010_sdio_data_compare(priv, DATA_WINDOW, rom_buf, size);
ks7010_sdio_data_compare(priv, DATA_WINDOW, rom_buf, size); if (rc)
if (retval) { goto release_firmware;
rc = 9;
goto error_out1;
}
n += size; n += size;
} while (size); } while (size);
/* Remap request */ /* Remap request */
rw_data = GCR_A_REMAP; rw_data = GCR_A_REMAP;
retval = ks7010_sdio_write(priv, GCR_A, &rw_data, sizeof(rw_data)); rc = ks7010_sdio_write(priv, GCR_A, &rw_data, sizeof(rw_data));
if (retval) { if (rc)
rc = 11; goto release_firmware;
goto error_out1;
}
DPRINTK(4, " REMAP Request : GCR_A=%02X\n", rw_data); DPRINTK(4, " REMAP Request : GCR_A=%02X\n", rw_data);
/* Firmware running check */ /* Firmware running check */
for (n = 0; n < 50; ++n) { for (n = 0; n < 50; ++n) {
mdelay(10); /* wait_ms(10); */ mdelay(10); /* wait_ms(10); */
retval = rc = ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data));
ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data)); if (rc)
if (retval) { goto release_firmware;
rc = 11;
goto error_out1;
}
if (rw_data == GCR_A_RUN) if (rw_data == GCR_A_RUN)
break; break;
} }
DPRINTK(4, "firmware wakeup (%d)!!!!\n", n); DPRINTK(4, "firmware wakeup (%d)!!!!\n", n);
if ((50) <= n) { if ((50) <= n) {
DPRINTK(1, "firmware can't start\n"); DPRINTK(1, "firmware can't start\n");
rc = 12; rc = -EIO;
goto error_out1; goto release_firmware;
} }
rc = 0; rc = 0;
error_out1: release_firmware:
release_firmware(fw_entry); release_firmware(fw_entry);
error_out0: release_host_and_free:
sdio_release_host(card->func); sdio_release_host(card->func);
kfree(rom_buf); kfree(rom_buf);
return rc; return rc;
} }
......
...@@ -110,14 +110,13 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info) ...@@ -110,14 +110,13 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
struct local_ap_t *ap; struct local_ap_t *ap;
union iwreq_data wrqu; union iwreq_data wrqu;
struct net_device *netdev = priv->net_dev; struct net_device *netdev = priv->net_dev;
int rc = 0;
DPRINTK(3, "\n"); DPRINTK(3, "\n");
ap = &priv->current_ap; ap = &priv->current_ap;
if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) { if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) {
memset(ap, 0, sizeof(struct local_ap_t)); memset(ap, 0, sizeof(struct local_ap_t));
return 1; return -EPERM;
} }
/* bssid */ /* bssid */
...@@ -198,7 +197,7 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info) ...@@ -198,7 +197,7 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
DPRINTK(4, "\n ext_rate_set_size=%d\n rate_set_size=%d\n", DPRINTK(4, "\n ext_rate_set_size=%d\n rate_set_size=%d\n",
ap_info->ext_rate_set.size, ap_info->rate_set.size); ap_info->ext_rate_set.size, ap_info->rate_set.size);
return rc; return 0;
} }
static static
...@@ -1125,12 +1124,13 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet) ...@@ -1125,12 +1124,13 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet)
struct ieee802_1x_hdr *aa1x_hdr; struct ieee802_1x_hdr *aa1x_hdr;
struct wpa_eapol_key *eap_key; struct wpa_eapol_key *eap_key;
struct ethhdr *eth; struct ethhdr *eth;
int rc;
packet_len = packet->len; packet_len = packet->len;
if (packet_len > ETH_FRAME_LEN) { if (packet_len > ETH_FRAME_LEN) {
DPRINTK(1, "bad length packet_len=%d\n", packet_len); DPRINTK(1, "bad length packet_len=%d\n", packet_len);
dev_kfree_skb(packet); rc = -EOVERFLOW;
return -1; goto err_kfree_skb;
} }
if (((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) if (((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS)
...@@ -1157,8 +1157,8 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet) ...@@ -1157,8 +1157,8 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet)
if (!pp) { if (!pp) {
DPRINTK(3, "allocate memory failed..\n"); DPRINTK(3, "allocate memory failed..\n");
dev_kfree_skb(packet); rc = -ENOMEM;
return -2; goto err_kfree_skb;
} }
p = (unsigned char *)pp->data; p = (unsigned char *)pp->data;
...@@ -1171,9 +1171,8 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet) ...@@ -1171,9 +1171,8 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet)
if (memcmp(&priv->eth_addr[0], eth->h_source, ETH_ALEN)) { if (memcmp(&priv->eth_addr[0], eth->h_source, ETH_ALEN)) {
DPRINTK(1, "invalid mac address !!\n"); DPRINTK(1, "invalid mac address !!\n");
DPRINTK(1, "ethernet->h_source=%pM\n", eth->h_source); DPRINTK(1, "ethernet->h_source=%pM\n", eth->h_source);
dev_kfree_skb(packet); rc = -ENXIO;
kfree(pp); goto err_kfree;
return -3;
} }
/* MAC address copy */ /* MAC address copy */
...@@ -1276,6 +1275,13 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet) ...@@ -1276,6 +1275,13 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet)
} }
return result; return result;
err_kfree:
kfree(pp);
err_kfree_skb:
dev_kfree_skb(packet);
return rc;
} }
#define ps_confirm_wait_inc(priv) do { \ #define ps_confirm_wait_inc(priv) do { \
......
...@@ -89,10 +89,10 @@ int ks_wlan_update_phy_information(struct ks_wlan_private *priv) ...@@ -89,10 +89,10 @@ int ks_wlan_update_phy_information(struct ks_wlan_private *priv)
DPRINTK(4, "in_interrupt = %ld\n", in_interrupt()); DPRINTK(4, "in_interrupt = %ld\n", in_interrupt());
if (priv->dev_state < DEVICE_STATE_READY) if (priv->dev_state < DEVICE_STATE_READY)
return -1; /* not finished initialize */ return -EBUSY; /* not finished initialize */
if (atomic_read(&update_phyinfo)) if (atomic_read(&update_phyinfo))
return 1; return -EPERM;
/* The status */ /* The status */
wstats->status = priv->reg.operation_mode; /* Operation mode */ wstats->status = priv->reg.operation_mode; /* Operation mode */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment