void *arg1, void *arg2)
{
struct tx_device_buffer *sp;
+ int rc;
if (priv->dev_state < DEVICE_STATE_BOOT) {
- kfree(p);
- if (complete_handler)
- (*complete_handler) (arg1, arg2);
- return 1;
+ rc = -EPERM;
+ goto err_complete;
}
if ((TX_DEVICE_BUFF_SIZE - 1) <= cnt_txqbody(priv)) {
/* in case of buffer overflow */
DPRINTK(1, "tx buffer overflow\n");
- kfree(p);
- if (complete_handler)
- (*complete_handler) (arg1, arg2);
- return 1;
+ rc = -EOVERFLOW;
+ goto err_complete;
}
sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qtail];
inc_txqtail(priv);
return 0;
+
+err_complete:
+ kfree(p);
+ if (complete_handler)
+ (*complete_handler) (arg1, arg2);
+
+ return rc;
}
/* write data */
static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer,
unsigned long size)
{
- int retval;
unsigned char rw_data;
struct hostif_hdr *hdr;
+ int rc;
hdr = (struct hostif_hdr *)buffer;
return 0;
}
- retval = ks7010_sdio_write(priv, DATA_WINDOW, buffer, size);
- if (retval) {
- DPRINTK(1, " write error : retval=%d\n", retval);
- return -4;
+ rc = ks7010_sdio_write(priv, DATA_WINDOW, buffer, size);
+ if (rc) {
+ DPRINTK(1, " write error : retval=%d\n", rc);
+ return rc;
}
rw_data = WRITE_STATUS_BUSY;
- retval =
- ks7010_sdio_write(priv, WRITE_STATUS, &rw_data, sizeof(rw_data));
- if (retval) {
+ rc = ks7010_sdio_write(priv, WRITE_STATUS, &rw_data, sizeof(rw_data));
+ if (rc) {
DPRINTK(1, " error : WRITE_STATUS=%02X\n", rw_data);
- return -3;
+ return rc;
}
return 0;
static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)
{
- int rc = 0;
- int retval;
+ int rc;
unsigned char *data_buf;
data_buf = kmalloc(sizeof(u32), GFP_KERNEL);
- if (!data_buf) {
- rc = 1;
- goto error_out;
- }
+ if (!data_buf)
+ return -ENOMEM;
memcpy(data_buf, &index, sizeof(index));
- retval = ks7010_sdio_write(priv, WRITE_INDEX, data_buf, sizeof(index));
- if (retval) {
- rc = 2;
+ rc = ks7010_sdio_write(priv, WRITE_INDEX, data_buf, sizeof(index));
+ if (rc)
goto error_out;
- }
- retval = ks7010_sdio_write(priv, READ_INDEX, data_buf, sizeof(index));
- if (retval) {
- rc = 3;
+ rc = ks7010_sdio_write(priv, READ_INDEX, data_buf, sizeof(index));
+ if (rc)
goto error_out;
- }
+
+ return 0;
+
error_out:
kfree(data_buf);
+
return rc;
}
static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,
unsigned char *data, unsigned int size)
{
- int rc = 0;
- int retval;
+ int rc;
unsigned char *read_buf;
read_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL);
- if (!read_buf) {
- rc = 1;
- goto error_out;
- }
- retval = ks7010_sdio_read(priv, address, read_buf, size);
- if (retval) {
- rc = 2;
+ if (!read_buf)
+ return -ENOMEM;
+
+ rc = ks7010_sdio_read(priv, address, read_buf, size);
+ if (rc)
goto error_out;
- }
- retval = memcmp(data, read_buf, size);
- if (retval) {
- DPRINTK(0, "data compare error (%d)\n", retval);
- rc = 3;
+ rc = memcmp(data, read_buf, size);
+ if (rc) {
+ DPRINTK(0, "data compare error (%d)\n", rc);
goto error_out;
}
+
+ return 0;
+
error_out:
kfree(read_buf);
+
return rc;
}
unsigned int size, offset, n = 0;
unsigned char *rom_buf;
unsigned char rw_data = 0;
- int retval, rc = 0;
+ int rc;
int length;
const struct firmware *fw_entry = NULL;
/* buffer allocate */
rom_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL);
if (!rom_buf)
- return 3;
+ return -ENOMEM;
sdio_claim_host(card->func);
/* 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) {
DPRINTK(0, "MAC firmware running ...\n");
- rc = 0;
- goto error_out0;
+ goto release_host_and_free;
}
- retval = request_firmware(&fw_entry, ROM_FILE, &priv->ks_wlan_hw.sdio_card->func->dev);
- if (retval)
- goto error_out0;
+ rc = request_firmware(&fw_entry, ROM_FILE, &priv->ks_wlan_hw.sdio_card->func->dev);
+ if (rc)
+ goto release_host_and_free;
length = fw_entry->size;
memcpy(rom_buf, fw_entry->data + n, size);
/* Update write index */
offset = n;
- retval =
- ks7010_sdio_update_index(priv,
- KS7010_IRAM_ADDRESS + offset);
- if (retval) {
- rc = 6;
- goto error_out1;
- }
+ rc = ks7010_sdio_update_index(priv,
+ KS7010_IRAM_ADDRESS + offset);
+ if (rc)
+ goto release_firmware;
/* Write data */
- retval = ks7010_sdio_write(priv, DATA_WINDOW, rom_buf, size);
- if (retval) {
- rc = 8;
- goto error_out1;
- }
+ rc = ks7010_sdio_write(priv, DATA_WINDOW, rom_buf, size);
+ if (rc)
+ goto release_firmware;
/* compare */
- retval =
- ks7010_sdio_data_compare(priv, DATA_WINDOW, rom_buf, size);
- if (retval) {
- rc = 9;
- goto error_out1;
- }
+ rc = ks7010_sdio_data_compare(priv, DATA_WINDOW, rom_buf, size);
+ if (rc)
+ goto release_firmware;
+
n += size;
} while (size);
/* Remap request */
rw_data = GCR_A_REMAP;
- retval = ks7010_sdio_write(priv, GCR_A, &rw_data, sizeof(rw_data));
- if (retval) {
- rc = 11;
- goto error_out1;
- }
+ rc = ks7010_sdio_write(priv, GCR_A, &rw_data, sizeof(rw_data));
+ if (rc)
+ goto release_firmware;
+
DPRINTK(4, " REMAP Request : GCR_A=%02X\n", rw_data);
/* Firmware running check */
for (n = 0; n < 50; ++n) {
mdelay(10); /* wait_ms(10); */
- retval =
- ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data));
- if (retval) {
- rc = 11;
- goto error_out1;
- }
+ rc = ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data));
+ if (rc)
+ goto release_firmware;
+
if (rw_data == GCR_A_RUN)
break;
}
DPRINTK(4, "firmware wakeup (%d)!!!!\n", n);
if ((50) <= n) {
DPRINTK(1, "firmware can't start\n");
- rc = 12;
- goto error_out1;
+ rc = -EIO;
+ goto release_firmware;
}
rc = 0;
- error_out1:
+ release_firmware:
release_firmware(fw_entry);
- error_out0:
+ release_host_and_free:
sdio_release_host(card->func);
kfree(rom_buf);
+
return rc;
}
struct local_ap_t *ap;
union iwreq_data wrqu;
struct net_device *netdev = priv->net_dev;
- int rc = 0;
DPRINTK(3, "\n");
ap = &priv->current_ap;
if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) {
memset(ap, 0, sizeof(struct local_ap_t));
- return 1;
+ return -EPERM;
}
/* bssid */
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);
- return rc;
+ return 0;
}
static
struct ieee802_1x_hdr *aa1x_hdr;
struct wpa_eapol_key *eap_key;
struct ethhdr *eth;
+ int rc;
packet_len = packet->len;
if (packet_len > ETH_FRAME_LEN) {
DPRINTK(1, "bad length packet_len=%d\n", packet_len);
- dev_kfree_skb(packet);
- return -1;
+ rc = -EOVERFLOW;
+ goto err_kfree_skb;
}
if (((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS)
if (!pp) {
DPRINTK(3, "allocate memory failed..\n");
- dev_kfree_skb(packet);
- return -2;
+ rc = -ENOMEM;
+ goto err_kfree_skb;
}
p = (unsigned char *)pp->data;
if (memcmp(&priv->eth_addr[0], eth->h_source, ETH_ALEN)) {
DPRINTK(1, "invalid mac address !!\n");
DPRINTK(1, "ethernet->h_source=%pM\n", eth->h_source);
- dev_kfree_skb(packet);
- kfree(pp);
- return -3;
+ rc = -ENXIO;
+ goto err_kfree;
}
/* MAC address copy */
}
return result;
+
+err_kfree:
+ kfree(pp);
+err_kfree_skb:
+ dev_kfree_skb(packet);
+
+ return rc;
}
#define ps_confirm_wait_inc(priv) do { \