Lines Matching defs:dev

13 #include "ishtp-dev.h"
18 * @dev: ishtp device
24 void ishtp_cl_alloc_dma_buf(struct ishtp_device *dev)
28 if (dev->ishtp_host_dma_tx_buf)
31 dev->ishtp_host_dma_tx_buf_size = 1024*1024;
32 dev->ishtp_host_dma_rx_buf_size = 1024*1024;
35 dev->ishtp_host_dma_tx_buf = dma_alloc_coherent(dev->devc,
36 dev->ishtp_host_dma_tx_buf_size,
38 if (dev->ishtp_host_dma_tx_buf)
39 dev->ishtp_host_dma_tx_buf_phys = h;
41 dev->ishtp_dma_num_slots = dev->ishtp_host_dma_tx_buf_size /
44 dev->ishtp_dma_tx_map = kcalloc(dev->ishtp_dma_num_slots,
47 spin_lock_init(&dev->ishtp_dma_tx_lock);
50 dev->ishtp_host_dma_rx_buf = dma_alloc_coherent(dev->devc,
51 dev->ishtp_host_dma_rx_buf_size,
54 if (dev->ishtp_host_dma_rx_buf)
55 dev->ishtp_host_dma_rx_buf_phys = h;
60 * @dev: ishtp device
66 void ishtp_cl_free_dma_buf(struct ishtp_device *dev)
70 if (dev->ishtp_host_dma_tx_buf) {
71 h = dev->ishtp_host_dma_tx_buf_phys;
72 dma_free_coherent(dev->devc, dev->ishtp_host_dma_tx_buf_size,
73 dev->ishtp_host_dma_tx_buf, h);
76 if (dev->ishtp_host_dma_rx_buf) {
77 h = dev->ishtp_host_dma_rx_buf_phys;
78 dma_free_coherent(dev->devc, dev->ishtp_host_dma_rx_buf_size,
79 dev->ishtp_host_dma_rx_buf, h);
82 kfree(dev->ishtp_dma_tx_map);
83 dev->ishtp_host_dma_tx_buf = NULL;
84 dev->ishtp_host_dma_rx_buf = NULL;
85 dev->ishtp_dma_tx_map = NULL;
90 * @dev: ishtp device
98 void *ishtp_cl_get_dma_send_buf(struct ishtp_device *dev,
107 if (!dev->ishtp_dma_tx_map) {
108 dev_err(dev->devc, "Fail to allocate Tx map\n");
112 spin_lock_irqsave(&dev->ishtp_dma_tx_lock, flags);
113 for (i = 0; i <= (dev->ishtp_dma_num_slots - required_slots); i++) {
116 if (dev->ishtp_dma_tx_map[i+j]) {
124 dev->ishtp_dma_tx_map[i+j] = 1;
125 spin_unlock_irqrestore(&dev->ishtp_dma_tx_lock, flags);
127 (unsigned char *)dev->ishtp_host_dma_tx_buf;
130 spin_unlock_irqrestore(&dev->ishtp_dma_tx_lock, flags);
131 dev_err(dev->devc, "No free DMA buffer to send msg\n");
137 * @dev: ishtp device
144 void ishtp_cl_release_dma_acked_mem(struct ishtp_device *dev,
153 if ((msg_addr - dev->ishtp_host_dma_tx_buf) % DMA_SLOT_SIZE) {
154 dev_err(dev->devc, "Bad DMA Tx ack address\n");
158 if (!dev->ishtp_dma_tx_map) {
159 dev_err(dev->devc, "Fail to allocate Tx map\n");
163 i = (msg_addr - dev->ishtp_host_dma_tx_buf) / DMA_SLOT_SIZE;
164 spin_lock_irqsave(&dev->ishtp_dma_tx_lock, flags);
166 if ((i + j) >= dev->ishtp_dma_num_slots ||
167 !dev->ishtp_dma_tx_map[i+j]) {
169 spin_unlock_irqrestore(&dev->ishtp_dma_tx_lock, flags);
170 dev_err(dev->devc, "Bad DMA Tx ack address\n");
173 dev->ishtp_dma_tx_map[i+j] = 0;
175 spin_unlock_irqrestore(&dev->ishtp_dma_tx_lock, flags);