Lines Matching full:cd
32 static int genwqe_open_files(struct genwqe_dev *cd) in genwqe_open_files() argument
37 spin_lock_irqsave(&cd->file_lock, flags); in genwqe_open_files()
38 rc = list_empty(&cd->file_list); in genwqe_open_files()
39 spin_unlock_irqrestore(&cd->file_lock, flags); in genwqe_open_files()
43 static void genwqe_add_file(struct genwqe_dev *cd, struct genwqe_file *cfile) in genwqe_add_file() argument
48 spin_lock_irqsave(&cd->file_lock, flags); in genwqe_add_file()
49 list_add(&cfile->list, &cd->file_list); in genwqe_add_file()
50 spin_unlock_irqrestore(&cd->file_lock, flags); in genwqe_add_file()
53 static int genwqe_del_file(struct genwqe_dev *cd, struct genwqe_file *cfile) in genwqe_del_file() argument
57 spin_lock_irqsave(&cd->file_lock, flags); in genwqe_del_file()
59 spin_unlock_irqrestore(&cd->file_lock, flags); in genwqe_del_file()
158 struct pci_dev *pci_dev = cfile->cd->pci_dev; in __genwqe_search_mapping()
194 struct genwqe_dev *cd = cfile->cd; in genwqe_remove_mappings() local
195 struct pci_dev *pci_dev = cfile->cd->pci_dev; in genwqe_remove_mappings()
217 __genwqe_free_consistent(cd, dma_map->size, in genwqe_remove_mappings()
223 genwqe_user_vunmap(cd, dma_map); in genwqe_remove_mappings()
232 struct genwqe_dev *cd = cfile->cd; in genwqe_remove_pinnings() local
246 genwqe_user_vunmap(cd, dma_map); in genwqe_remove_pinnings()
253 * @cd: GenWQE device information
256 * E.g. genwqe_send_signal(cd, SIGIO);
258 static int genwqe_kill_fasync(struct genwqe_dev *cd, int sig) in genwqe_kill_fasync() argument
264 spin_lock_irqsave(&cd->file_lock, flags); in genwqe_kill_fasync()
265 list_for_each_entry(cfile, &cd->file_list, list) { in genwqe_kill_fasync()
270 spin_unlock_irqrestore(&cd->file_lock, flags); in genwqe_kill_fasync()
274 static int genwqe_terminate(struct genwqe_dev *cd) in genwqe_terminate() argument
280 spin_lock_irqsave(&cd->file_lock, flags); in genwqe_terminate()
281 list_for_each_entry(cfile, &cd->file_list, list) { in genwqe_terminate()
285 spin_unlock_irqrestore(&cd->file_lock, flags); in genwqe_terminate()
301 struct genwqe_dev *cd; in genwqe_open() local
308 cd = container_of(inode->i_cdev, struct genwqe_dev, cdev_genwqe); in genwqe_open()
309 cfile->cd = cd; in genwqe_open()
321 genwqe_add_file(cd, cfile); in genwqe_open()
360 struct genwqe_dev *cd = cfile->cd; in genwqe_release() local
370 * For this to work we must not release cd when this cfile is in genwqe_release()
374 genwqe_del_file(cd, cfile); in genwqe_release()
395 struct genwqe_dev *cd = container_of(inode->i_cdev, struct genwqe_dev, in genwqe_vma_close() local
397 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_vma_close()
411 __genwqe_free_consistent(cd, dma_map->size, dma_map->k_vaddr, in genwqe_vma_close()
440 struct genwqe_dev *cd = cfile->cd; in genwqe_mmap() local
457 dma_map->k_vaddr = __genwqe_alloc_consistent(cd, vsize, in genwqe_mmap()
485 __genwqe_free_consistent(cd, dma_map->size, in genwqe_mmap()
514 struct genwqe_dev *cd = cfile->cd; in do_flash_update() local
516 struct pci_dev *pci_dev = cd->pci_dev; in do_flash_update()
540 xbuf = __genwqe_alloc_consistent(cd, FLASH_BLOCK, &dma_addr); in do_flash_update()
577 if (genwqe_get_slu_id(cd) <= 0x2) { in do_flash_update()
610 rc = __genwqe_execute_raw_ddcb(cd, req, filp->f_flags); in do_flash_update()
635 __genwqe_free_consistent(cd, FLASH_BLOCK, xbuf, dma_addr); in do_flash_update()
649 struct genwqe_dev *cd = cfile->cd; in do_flash_read() local
651 struct pci_dev *pci_dev = cd->pci_dev; in do_flash_read()
676 xbuf = __genwqe_alloc_consistent(cd, FLASH_BLOCK, &dma_addr); in do_flash_read()
703 if (genwqe_get_slu_id(cd) <= 0x2) { in do_flash_read()
728 rc = __genwqe_execute_raw_ddcb(cd, cmd, filp->f_flags); in do_flash_read()
765 __genwqe_free_consistent(cd, FLASH_BLOCK, xbuf, dma_addr); in do_flash_read()
772 struct genwqe_dev *cd = cfile->cd; in genwqe_pin_mem() local
773 struct pci_dev *pci_dev = cfile->cd->pci_dev; in genwqe_pin_mem()
791 rc = genwqe_user_vmap(cd, dma_map, (void *)map_addr, map_size); in genwqe_pin_mem()
805 struct genwqe_dev *cd = cfile->cd; in genwqe_unpin_mem() local
821 genwqe_user_vunmap(cd, dma_map); in genwqe_unpin_mem()
837 struct genwqe_dev *cd = cfile->cd; in ddcb_cmd_cleanup() local
844 genwqe_user_vunmap(cd, dma_map); in ddcb_cmd_cleanup()
847 genwqe_free_sync_sgl(cd, &req->sgls[i]); in ddcb_cmd_cleanup()
866 struct genwqe_dev *cd = cfile->cd; in ddcb_cmd_fixups() local
948 rc = genwqe_user_vmap(cd, m, (void *)u_addr, in ddcb_cmd_fixups()
958 rc = genwqe_alloc_sync_sgl(cd, &req->sgls[i], in ddcb_cmd_fixups()
964 genwqe_setup_sgl(cd, &req->sgls[i], in ddcb_cmd_fixups()
997 struct genwqe_dev *cd = cfile->cd; in genwqe_execute_ddcb() local
1005 rc = __genwqe_execute_raw_ddcb(cd, cmd, filp->f_flags); in genwqe_execute_ddcb()
1015 struct genwqe_dev *cd = cfile->cd; in do_execute_ddcb() local
1030 rc = __genwqe_execute_raw_ddcb(cd, cmd, filp->f_flags); in do_execute_ddcb()
1057 struct genwqe_dev *cd = cfile->cd; in genwqe_ioctl() local
1058 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_ioctl()
1073 put_user(cd->card_state, (enum genwqe_card_state __user *)arg); in genwqe_ioctl()
1083 if ((reg_offs >= cd->mmio_len) || (reg_offs & 0x7)) in genwqe_ioctl()
1086 val = __genwqe_readq(cd, reg_offs); in genwqe_ioctl()
1103 if ((reg_offs >= cd->mmio_len) || (reg_offs & 0x7)) in genwqe_ioctl()
1109 __genwqe_writeq(cd, reg_offs, val); in genwqe_ioctl()
1119 if ((reg_offs >= cd->mmio_len) || (reg_offs & 0x3)) in genwqe_ioctl()
1122 val = __genwqe_readl(cd, reg_offs); in genwqe_ioctl()
1139 if ((reg_offs >= cd->mmio_len) || (reg_offs & 0x3)) in genwqe_ioctl()
1145 __genwqe_writel(cd, reg_offs, val); in genwqe_ioctl()
1153 if (!genwqe_is_privileged(cd)) in genwqe_ioctl()
1174 if (!genwqe_is_privileged(cd)) in genwqe_ioctl()
1177 if (genwqe_flash_readback_fails(cd)) in genwqe_ioctl()
1239 static int genwqe_device_initialized(struct genwqe_dev *cd) in genwqe_device_initialized() argument
1241 return cd->dev != NULL; in genwqe_device_initialized()
1246 * @cd: genwqe device descriptor
1252 int genwqe_device_create(struct genwqe_dev *cd) in genwqe_device_create() argument
1255 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_device_create()
1263 rc = alloc_chrdev_region(&cd->devnum_genwqe, 0, in genwqe_device_create()
1270 cdev_init(&cd->cdev_genwqe, &genwqe_fops); in genwqe_device_create()
1271 cd->cdev_genwqe.owner = THIS_MODULE; in genwqe_device_create()
1273 rc = cdev_add(&cd->cdev_genwqe, cd->devnum_genwqe, 1); in genwqe_device_create()
1283 cd->dev = device_create_with_groups(cd->class_genwqe, in genwqe_device_create()
1284 &cd->pci_dev->dev, in genwqe_device_create()
1285 cd->devnum_genwqe, cd, in genwqe_device_create()
1288 cd->card_idx); in genwqe_device_create()
1289 if (IS_ERR(cd->dev)) { in genwqe_device_create()
1290 rc = PTR_ERR(cd->dev); in genwqe_device_create()
1294 genwqe_init_debugfs(cd); in genwqe_device_create()
1299 cdev_del(&cd->cdev_genwqe); in genwqe_device_create()
1301 unregister_chrdev_region(cd->devnum_genwqe, GENWQE_MAX_MINOR); in genwqe_device_create()
1303 cd->dev = NULL; in genwqe_device_create()
1307 static int genwqe_inform_and_stop_processes(struct genwqe_dev *cd) in genwqe_inform_and_stop_processes() argument
1311 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_inform_and_stop_processes()
1313 if (!genwqe_open_files(cd)) in genwqe_inform_and_stop_processes()
1318 rc = genwqe_kill_fasync(cd, SIGIO); in genwqe_inform_and_stop_processes()
1322 genwqe_open_files(cd); i++) { in genwqe_inform_and_stop_processes()
1330 if (!genwqe_open_files(cd)) in genwqe_inform_and_stop_processes()
1336 rc = genwqe_terminate(cd); in genwqe_inform_and_stop_processes()
1340 genwqe_open_files(cd); i++) { in genwqe_inform_and_stop_processes()
1353 * @cd: GenWQE device information
1361 int genwqe_device_remove(struct genwqe_dev *cd) in genwqe_device_remove() argument
1364 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_device_remove()
1366 if (!genwqe_device_initialized(cd)) in genwqe_device_remove()
1369 genwqe_inform_and_stop_processes(cd); in genwqe_device_remove()
1377 rc = kref_read(&cd->cdev_genwqe.kobj.kref); in genwqe_device_remove()
1384 genqwe_exit_debugfs(cd); in genwqe_device_remove()
1385 device_destroy(cd->class_genwqe, cd->devnum_genwqe); in genwqe_device_remove()
1386 cdev_del(&cd->cdev_genwqe); in genwqe_device_remove()
1387 unregister_chrdev_region(cd->devnum_genwqe, GENWQE_MAX_MINOR); in genwqe_device_remove()
1388 cd->dev = NULL; in genwqe_device_remove()