complete_handler() takes void * types as parameters. void * parameters are then cast to struct types. Call sites for this function either pass in NULL or pointers to the struct types cast to void *. This casting is unnecessary and can be removed. Struct tx_device_buffer (which contains a pointer member to the complete_handler() function) has as member 'ks_wlan_priv *priv' this is unnecessary, we always have a pointer to this struct there is no need to store it here. The complete_handler can be more clearly defined by using struct pointer types instead of void * types. The code is currently unnecessarily complex, storing and passing extraneous pointer parameters. Remove unnecessary parameters, unnecessary casting to/from 'void *'. Fix all call sites involving complete_handler(). Signed-off-by: Tobin C. Harding <me@xxxxxxxx> --- drivers/staging/ks7010/ks7010_sdio.c | 21 +++++++++++---------- drivers/staging/ks7010/ks7010_sdio.h | 6 +++--- drivers/staging/ks7010/ks_hostif.c | 35 ++++++++++++++++------------------- drivers/staging/ks7010/ks_hostif.h | 7 ++++--- drivers/staging/ks7010/ks_wlan_net.c | 12 ++++-------- 5 files changed, 38 insertions(+), 43 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index b103a20..0f173c3 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -237,8 +237,9 @@ int ks_wlan_hw_power_save(struct ks_wlan_private *priv) static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p, unsigned long size, - void (*complete_handler)(void *arg1, void *arg2), - void *arg1, void *arg2) + void (*complete_handler)(struct ks_wlan_private *priv, + struct sk_buff *skb), + struct sk_buff *skb) { struct tx_device_buffer *sp; int ret; @@ -259,8 +260,7 @@ static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p, sp->sendp = p; sp->size = size; sp->complete_handler = complete_handler; - sp->arg1 = arg1; - sp->arg2 = arg2; + sp->skb = skb; inc_txqtail(priv); return 0; @@ -268,7 +268,7 @@ static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p, err_complete: kfree(p); if (complete_handler) - (*complete_handler) (arg1, arg2); + (*complete_handler)(priv, skb); return ret; } @@ -327,7 +327,7 @@ static void tx_device_task(struct ks_wlan_private *priv) } kfree(sp->sendp); if (sp->complete_handler) /* TX Complete */ - (*sp->complete_handler) (sp->arg1, sp->arg2); + (*sp->complete_handler)(priv, sp->skb); inc_txqhead(priv); if (cnt_txqbody(priv) > 0) { @@ -337,8 +337,9 @@ static void tx_device_task(struct ks_wlan_private *priv) } int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, - void (*complete_handler)(void *arg1, void *arg2), - void *arg1, void *arg2) + void (*complete_handler)(struct ks_wlan_private *priv, + struct sk_buff *skb), + struct sk_buff *skb) { int result = 0; struct hostif_hdr *hdr; @@ -356,7 +357,7 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, DPRINTK(4, "event=%04X\n", hdr->event); spin_lock(&priv->tx_dev.tx_dev_lock); - result = enqueue_txdev(priv, p, size, complete_handler, arg1, arg2); + result = enqueue_txdev(priv, p, size, complete_handler, skb); spin_unlock(&priv->tx_dev.tx_dev_lock); if (cnt_txqbody(priv) > 0) { @@ -628,7 +629,7 @@ static void trx_device_exit(struct ks_wlan_private *priv) sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead]; kfree(sp->sendp); /* allocated memory free */ if (sp->complete_handler) /* TX Complete */ - (*sp->complete_handler) (sp->arg1, sp->arg2); + (*sp->complete_handler)(priv, sp->skb); inc_txqhead(priv); } diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h index e9b0ad9..5aa593a 100644 --- a/drivers/staging/ks7010/ks7010_sdio.h +++ b/drivers/staging/ks7010/ks7010_sdio.h @@ -108,9 +108,9 @@ struct ks_sdio_card { struct tx_device_buffer { unsigned char *sendp; /* pointer of send req data */ unsigned int size; - void (*complete_handler)(void *arg1, void *arg2); - void *arg1; - void *arg2; + void (*complete_handler)(struct ks_wlan_private *priv, + struct sk_buff *skb); + struct sk_buff *skb; }; struct tx_device { diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 5292463..a04e4e3 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -1254,10 +1254,8 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb) pp->header.event = cpu_to_le16((uint16_t)HIF_DATA_REQ); /* tx request */ - result = - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + skb_len), - (void *)send_packet_complete, (void *)priv, - (void *)skb); + result = ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + skb_len), + send_packet_complete, skb); /* MIC FAILURE REPORT check */ if (eth_proto == ETHER_PROTOCOL_TYPE_EAP && @@ -1308,7 +1306,7 @@ void hostif_mib_get_request(struct ks_wlan_private *priv, /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); } static @@ -1343,8 +1341,7 @@ void hostif_mib_set_request(struct ks_wlan_private *priv, /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL, - NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL); } static @@ -1367,7 +1364,7 @@ void hostif_start_request(struct ks_wlan_private *priv, unsigned char mode) /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); priv->aplist.size = 0; priv->scan_ind_count = 0; @@ -1413,7 +1410,7 @@ void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv) /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); } static @@ -1480,7 +1477,7 @@ void hostif_infrastructure_set_request(struct ks_wlan_private *priv) /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); } static void hostif_infrastructure_set2_request(struct ks_wlan_private *priv) @@ -1548,7 +1545,7 @@ static void hostif_infrastructure_set2_request(struct ks_wlan_private *priv) /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); } static @@ -1593,7 +1590,7 @@ void hostif_adhoc_set_request(struct ks_wlan_private *priv) /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); } static @@ -1641,7 +1638,7 @@ void hostif_adhoc_set2_request(struct ks_wlan_private *priv) /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); } static @@ -1663,7 +1660,7 @@ void hostif_stop_request(struct ks_wlan_private *priv) /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); } static @@ -1692,7 +1689,7 @@ void hostif_phy_information_request(struct ks_wlan_private *priv) /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); } static @@ -1719,7 +1716,7 @@ void hostif_power_mngmt_request(struct ks_wlan_private *priv, /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); } static @@ -1742,7 +1739,7 @@ void hostif_sleep_request(struct ks_wlan_private *priv, unsigned long mode) /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); } else if (mode == SLP_ACTIVE) { atomic_set(&priv->sleepstatus.wakeup_request, 1); @@ -1804,7 +1801,7 @@ void hostif_bss_scan_request(struct ks_wlan_private *priv, /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); priv->aplist.size = 0; priv->scan_ind_count = 0; @@ -1832,7 +1829,7 @@ void hostif_mic_failure_request(struct ks_wlan_private *priv, /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); } /* Device I/O Receive indicate */ diff --git a/drivers/staging/ks7010/ks_hostif.h b/drivers/staging/ks7010/ks_hostif.h index aa11d43..d773432 100644 --- a/drivers/staging/ks7010/ks_hostif.h +++ b/drivers/staging/ks7010/ks_hostif.h @@ -656,9 +656,10 @@ void hostif_sme_enqueue(struct ks_wlan_private *priv, uint16_t event); int hostif_init(struct ks_wlan_private *priv); void hostif_exit(struct ks_wlan_private *priv); int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, - void (*complete_handler)(void *arg1, void *arg2), - void *arg1, void *arg2); -void send_packet_complete(void *arg1, void *arg2); + void (*complete_handler)(struct ks_wlan_private *priv, + struct sk_buff *skb), + struct sk_buff *skb); +void send_packet_complete(struct ks_wlan_private *priv, struct sk_buff *skb); void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv); int ks_wlan_hw_power_save(struct ks_wlan_private *priv); diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index a34ff47..0ef52c8 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2908,11 +2908,8 @@ int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev) return 0; } -void send_packet_complete(void *arg1, void *arg2) +void send_packet_complete(struct ks_wlan_private *priv, struct sk_buff *skb) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)arg1; - struct sk_buff *packet = (struct sk_buff *)arg2; - DPRINTK(3, "\n"); priv->nstats.tx_packets++; @@ -2920,10 +2917,9 @@ void send_packet_complete(void *arg1, void *arg2) if (netif_queue_stopped(priv->net_dev)) netif_wake_queue(priv->net_dev); - if (packet) { - priv->nstats.tx_bytes += packet->len; - dev_kfree_skb(packet); - packet = NULL; + if (skb) { + priv->nstats.tx_bytes += skb->len; + dev_kfree_skb(skb); } } -- 2.7.4 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel