提交 348a8fbc 编写于 作者: V Vasanthakumar Thiagarajan 提交者: Kalle Valo

ath6kl: Merge scatter rw request functions into one

Signed-off-by: NVasanthakumar Thiagarajan <vthiagar@qca.qualcomm.com>
Signed-off-by: NKalle Valo <kvalo@qca.qualcomm.com>
上级 da220695
...@@ -24,29 +24,6 @@ ...@@ -24,29 +24,6 @@
#define ATH6KL_TIME_QUANTUM 10 /* in ms */ #define ATH6KL_TIME_QUANTUM 10 /* in ms */
static void ath6kl_add_io_pkt(struct ath6kl_device *dev,
struct htc_packet *packet)
{
spin_lock_bh(&dev->lock);
list_add_tail(&packet->list, &dev->reg_io);
spin_unlock_bh(&dev->lock);
}
static struct htc_packet *ath6kl_get_io_pkt(struct ath6kl_device *dev)
{
struct htc_packet *packet = NULL;
spin_lock_bh(&dev->lock);
if (!list_empty(&dev->reg_io)) {
packet = list_first_entry(&dev->reg_io,
struct htc_packet, list);
list_del(&packet->list);
}
spin_unlock_bh(&dev->lock);
return packet;
}
static int ath6kldev_cp_scat_dma_buf(struct hif_scatter_req *req, bool from_dma) static int ath6kldev_cp_scat_dma_buf(struct hif_scatter_req *req, bool from_dma)
{ {
u8 *buf; u8 *buf;
...@@ -191,65 +168,6 @@ int ath6kldev_rx_control(struct ath6kl_device *dev, bool enable_rx) ...@@ -191,65 +168,6 @@ int ath6kldev_rx_control(struct ath6kl_device *dev, bool enable_rx)
return status; return status;
} }
static void ath6kldev_rw_async_handler(struct htc_target *target,
struct htc_packet *packet)
{
struct ath6kl_device *dev = target->dev;
struct hif_scatter_req *req = packet->pkt_cntxt;
req->status = packet->status;
ath6kl_add_io_pkt(dev, packet);
req->complete(target, req);
}
static int ath6kldev_rw_scatter(struct ath6kl *ar, struct hif_scatter_req *req)
{
struct ath6kl_device *dev = ar->htc_target->dev;
struct htc_packet *packet = NULL;
int status = 0;
u32 request = req->req;
u8 *virt_dma_buf;
if (!req->len)
return 0;
if (request & HIF_ASYNCHRONOUS) {
/* use an I/O packet to carry this request */
packet = ath6kl_get_io_pkt(dev);
if (!packet) {
status = -ENOMEM;
goto out;
}
packet->pkt_cntxt = req;
packet->completion = ath6kldev_rw_async_handler;
packet->context = ar->htc_target;
}
virt_dma_buf = req->virt_dma_buf;
if (request & HIF_ASYNCHRONOUS)
status = hif_write_async(dev->ar, req->addr, virt_dma_buf,
req->len, request, packet);
else
status = hif_read_write_sync(dev->ar, req->addr, virt_dma_buf,
req->len, request);
out:
if (status)
if (request & HIF_ASYNCHRONOUS) {
if (packet != NULL)
ath6kl_add_io_pkt(dev, packet);
req->status = status;
req->complete(ar->htc_target, req);
status = 0;
}
return status;
}
int ath6kldev_submit_scat_req(struct ath6kl_device *dev, int ath6kldev_submit_scat_req(struct ath6kl_device *dev,
struct hif_scatter_req *scat_req, bool read) struct hif_scatter_req *scat_req, bool read)
{ {
...@@ -285,10 +203,7 @@ int ath6kldev_submit_scat_req(struct ath6kl_device *dev, ...@@ -285,10 +203,7 @@ int ath6kldev_submit_scat_req(struct ath6kl_device *dev,
return status; return status;
} }
if (scat_req->virt_scat) status = ath6kl_hif_scat_req_rw(dev->ar, scat_req);
status = ath6kldev_rw_scatter(dev->ar, scat_req);
else
status = ath6kl_hif_scat_req_rw(dev->ar, scat_req);
if (read) { if (read) {
/* in sync mode, we can touch the scatter request */ /* in sync mode, we can touch the scatter request */
...@@ -699,21 +614,9 @@ int ath6kldev_mask_intrs(struct ath6kl_device *dev) ...@@ -699,21 +614,9 @@ int ath6kldev_mask_intrs(struct ath6kl_device *dev)
int ath6kldev_setup(struct ath6kl_device *dev) int ath6kldev_setup(struct ath6kl_device *dev)
{ {
int status = 0; int status = 0;
int i;
struct htc_packet *packet;
/* initialize our free list of IO packets */
INIT_LIST_HEAD(&dev->reg_io);
spin_lock_init(&dev->lock); spin_lock_init(&dev->lock);
/* carve up register I/O packets (these are for ASYNC register I/O ) */
for (i = 0; i < ATH6KL_MAX_REG_IO_BUFFERS; i++) {
packet = &dev->reg_io_buf[i].packet;
set_htc_rxpkt_info(packet, dev, dev->reg_io_buf[i].buf,
ATH6KL_REG_IO_BUFFER_SIZE, 0);
ath6kl_add_io_pkt(dev, packet);
}
/* /*
* NOTE: we actually get the block size of a mailbox other than 0, * NOTE: we actually get the block size of a mailbox other than 0,
* for SDIO the block size on mailbox 0 is artificially set to 1. * for SDIO the block size on mailbox 0 is artificially set to 1.
......
...@@ -82,8 +82,6 @@ struct ath6kl_device { ...@@ -82,8 +82,6 @@ struct ath6kl_device {
u32 block_sz; u32 block_sz;
u32 block_mask; u32 block_mask;
struct htc_target *htc_cnxt; struct htc_target *htc_cnxt;
struct list_head reg_io;
struct ath6kl_async_reg_io_buffer reg_io_buf[ATH6KL_MAX_REG_IO_BUFFERS];
int (*msg_pending) (struct htc_target *target, u32 lk_ahds[], int (*msg_pending) (struct htc_target *target, u32 lk_ahds[],
int *npkts_fetched); int *npkts_fetched);
struct hif_dev_scat_sup_info hif_scat_info; struct hif_dev_scat_sup_info hif_scat_info;
......
...@@ -244,10 +244,21 @@ static int ath6kl_sdio_scat_rw(struct ath6kl_sdio *ar_sdio, ...@@ -244,10 +244,21 @@ static int ath6kl_sdio_scat_rw(struct ath6kl_sdio *ar_sdio,
struct mmc_data data; struct mmc_data data;
struct hif_scatter_req *scat_req; struct hif_scatter_req *scat_req;
u8 opcode, rw; u8 opcode, rw;
int status; int status, len;
scat_req = req->scat_req; scat_req = req->scat_req;
if (scat_req->virt_scat) {
len = scat_req->len;
if (scat_req->req & HIF_BLOCK_BASIS)
len = round_down(len, HIF_MBOX_BLOCK_SIZE);
status = ath6kl_sdio_io(ar_sdio->func, scat_req->req,
scat_req->addr, scat_req->virt_dma_buf,
len);
goto scat_complete;
}
memset(&mmc_req, 0, sizeof(struct mmc_request)); memset(&mmc_req, 0, sizeof(struct mmc_request));
memset(&cmd, 0, sizeof(struct mmc_command)); memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data)); memset(&data, 0, sizeof(struct mmc_data));
...@@ -284,6 +295,8 @@ static int ath6kl_sdio_scat_rw(struct ath6kl_sdio *ar_sdio, ...@@ -284,6 +295,8 @@ static int ath6kl_sdio_scat_rw(struct ath6kl_sdio *ar_sdio,
mmc_wait_for_req(ar_sdio->func->card->host, &mmc_req); mmc_wait_for_req(ar_sdio->func->card->host, &mmc_req);
status = cmd.error ? cmd.error : data.error; status = cmd.error ? cmd.error : data.error;
scat_complete:
scat_req->status = status; scat_req->status = status;
if (scat_req->status) if (scat_req->status)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册