• Home
  • Raw
  • Download

Lines Matching refs:mgr

74 static int fpga_mgr_write_init_buf(struct fpga_manager *mgr,  in fpga_mgr_write_init_buf()  argument
80 mgr->state = FPGA_MGR_STATE_WRITE_INIT; in fpga_mgr_write_init_buf()
81 if (!mgr->mops->initial_header_size) in fpga_mgr_write_init_buf()
82 ret = mgr->mops->write_init(mgr, info, NULL, 0); in fpga_mgr_write_init_buf()
84 ret = mgr->mops->write_init( in fpga_mgr_write_init_buf()
85 mgr, info, buf, min(mgr->mops->initial_header_size, count)); in fpga_mgr_write_init_buf()
88 dev_err(&mgr->dev, "Error preparing FPGA for writing\n"); in fpga_mgr_write_init_buf()
89 mgr->state = FPGA_MGR_STATE_WRITE_INIT_ERR; in fpga_mgr_write_init_buf()
96 static int fpga_mgr_write_init_sg(struct fpga_manager *mgr, in fpga_mgr_write_init_sg() argument
105 if (!mgr->mops->initial_header_size) in fpga_mgr_write_init_sg()
106 return fpga_mgr_write_init_buf(mgr, info, NULL, 0); in fpga_mgr_write_init_sg()
114 miter.length >= mgr->mops->initial_header_size) { in fpga_mgr_write_init_sg()
115 ret = fpga_mgr_write_init_buf(mgr, info, miter.addr, in fpga_mgr_write_init_sg()
123 buf = kmalloc(mgr->mops->initial_header_size, GFP_KERNEL); in fpga_mgr_write_init_sg()
128 mgr->mops->initial_header_size); in fpga_mgr_write_init_sg()
129 ret = fpga_mgr_write_init_buf(mgr, info, buf, len); in fpga_mgr_write_init_sg()
140 static int fpga_mgr_write_complete(struct fpga_manager *mgr, in fpga_mgr_write_complete() argument
145 mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE; in fpga_mgr_write_complete()
146 ret = mgr->mops->write_complete(mgr, info); in fpga_mgr_write_complete()
148 dev_err(&mgr->dev, "Error after writing image data to FPGA\n"); in fpga_mgr_write_complete()
149 mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE_ERR; in fpga_mgr_write_complete()
152 mgr->state = FPGA_MGR_STATE_OPERATING; in fpga_mgr_write_complete()
174 static int fpga_mgr_buf_load_sg(struct fpga_manager *mgr, in fpga_mgr_buf_load_sg() argument
180 ret = fpga_mgr_write_init_sg(mgr, info, sgt); in fpga_mgr_buf_load_sg()
185 mgr->state = FPGA_MGR_STATE_WRITE; in fpga_mgr_buf_load_sg()
186 if (mgr->mops->write_sg) { in fpga_mgr_buf_load_sg()
187 ret = mgr->mops->write_sg(mgr, sgt); in fpga_mgr_buf_load_sg()
193 ret = mgr->mops->write(mgr, miter.addr, miter.length); in fpga_mgr_buf_load_sg()
201 dev_err(&mgr->dev, "Error while writing image data to FPGA\n"); in fpga_mgr_buf_load_sg()
202 mgr->state = FPGA_MGR_STATE_WRITE_ERR; in fpga_mgr_buf_load_sg()
206 return fpga_mgr_write_complete(mgr, info); in fpga_mgr_buf_load_sg()
209 static int fpga_mgr_buf_load_mapped(struct fpga_manager *mgr, in fpga_mgr_buf_load_mapped() argument
215 ret = fpga_mgr_write_init_buf(mgr, info, buf, count); in fpga_mgr_buf_load_mapped()
222 mgr->state = FPGA_MGR_STATE_WRITE; in fpga_mgr_buf_load_mapped()
223 ret = mgr->mops->write(mgr, buf, count); in fpga_mgr_buf_load_mapped()
225 dev_err(&mgr->dev, "Error while writing image data to FPGA\n"); in fpga_mgr_buf_load_mapped()
226 mgr->state = FPGA_MGR_STATE_WRITE_ERR; in fpga_mgr_buf_load_mapped()
230 return fpga_mgr_write_complete(mgr, info); in fpga_mgr_buf_load_mapped()
247 static int fpga_mgr_buf_load(struct fpga_manager *mgr, in fpga_mgr_buf_load() argument
263 if (mgr->mops->write) in fpga_mgr_buf_load()
264 return fpga_mgr_buf_load_mapped(mgr, info, buf, count); in fpga_mgr_buf_load()
299 rc = fpga_mgr_buf_load_sg(mgr, info, &sgt); in fpga_mgr_buf_load()
319 static int fpga_mgr_firmware_load(struct fpga_manager *mgr, in fpga_mgr_firmware_load() argument
323 struct device *dev = &mgr->dev; in fpga_mgr_firmware_load()
327 dev_info(dev, "writing %s to %s\n", image_name, mgr->name); in fpga_mgr_firmware_load()
329 mgr->state = FPGA_MGR_STATE_FIRMWARE_REQ; in fpga_mgr_firmware_load()
333 mgr->state = FPGA_MGR_STATE_FIRMWARE_REQ_ERR; in fpga_mgr_firmware_load()
338 ret = fpga_mgr_buf_load(mgr, info, fw->data, fw->size); in fpga_mgr_firmware_load()
355 int fpga_mgr_load(struct fpga_manager *mgr, struct fpga_image_info *info) in fpga_mgr_load() argument
358 return fpga_mgr_buf_load_sg(mgr, info, info->sgt); in fpga_mgr_load()
360 return fpga_mgr_buf_load(mgr, info, info->buf, info->count); in fpga_mgr_load()
362 return fpga_mgr_firmware_load(mgr, info, info->firmware_name); in fpga_mgr_load()
396 struct fpga_manager *mgr = to_fpga_manager(dev); in name_show() local
398 return sprintf(buf, "%s\n", mgr->name); in name_show()
404 struct fpga_manager *mgr = to_fpga_manager(dev); in state_show() local
406 return sprintf(buf, "%s\n", state_str[mgr->state]); in state_show()
412 struct fpga_manager *mgr = to_fpga_manager(dev); in status_show() local
416 if (!mgr->mops->status) in status_show()
419 status = mgr->mops->status(mgr); in status_show()
449 struct fpga_manager *mgr; in __fpga_mgr_get() local
451 mgr = to_fpga_manager(dev); in __fpga_mgr_get()
456 return mgr; in __fpga_mgr_get()
508 void fpga_mgr_put(struct fpga_manager *mgr) in fpga_mgr_put() argument
510 module_put(mgr->dev.parent->driver->owner); in fpga_mgr_put()
511 put_device(&mgr->dev); in fpga_mgr_put()
527 int fpga_mgr_lock(struct fpga_manager *mgr) in fpga_mgr_lock() argument
529 if (!mutex_trylock(&mgr->ref_mutex)) { in fpga_mgr_lock()
530 dev_err(&mgr->dev, "FPGA manager is in use.\n"); in fpga_mgr_lock()
542 void fpga_mgr_unlock(struct fpga_manager *mgr) in fpga_mgr_unlock() argument
544 mutex_unlock(&mgr->ref_mutex); in fpga_mgr_unlock()
564 struct fpga_manager *mgr; in fpga_mgr_create() local
579 mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); in fpga_mgr_create()
580 if (!mgr) in fpga_mgr_create()
587 mutex_init(&mgr->ref_mutex); in fpga_mgr_create()
589 mgr->name = name; in fpga_mgr_create()
590 mgr->mops = mops; in fpga_mgr_create()
591 mgr->priv = priv; in fpga_mgr_create()
593 device_initialize(&mgr->dev); in fpga_mgr_create()
594 mgr->dev.class = fpga_mgr_class; in fpga_mgr_create()
595 mgr->dev.groups = mops->groups; in fpga_mgr_create()
596 mgr->dev.parent = dev; in fpga_mgr_create()
597 mgr->dev.of_node = dev->of_node; in fpga_mgr_create()
598 mgr->dev.id = id; in fpga_mgr_create()
600 ret = dev_set_name(&mgr->dev, "fpga%d", id); in fpga_mgr_create()
604 return mgr; in fpga_mgr_create()
609 kfree(mgr); in fpga_mgr_create()
619 void fpga_mgr_free(struct fpga_manager *mgr) in fpga_mgr_free() argument
621 ida_simple_remove(&fpga_mgr_ida, mgr->dev.id); in fpga_mgr_free()
622 kfree(mgr); in fpga_mgr_free()
628 struct fpga_manager *mgr = *(struct fpga_manager **)res; in devm_fpga_mgr_release() local
630 fpga_mgr_free(mgr); in devm_fpga_mgr_release()
654 struct fpga_manager **ptr, *mgr; in devm_fpga_mgr_create() local
660 mgr = fpga_mgr_create(dev, name, mops, priv); in devm_fpga_mgr_create()
661 if (!mgr) { in devm_fpga_mgr_create()
664 *ptr = mgr; in devm_fpga_mgr_create()
668 return mgr; in devm_fpga_mgr_create()
678 int fpga_mgr_register(struct fpga_manager *mgr) in fpga_mgr_register() argument
687 mgr->state = mgr->mops->state(mgr); in fpga_mgr_register()
689 ret = device_add(&mgr->dev); in fpga_mgr_register()
693 dev_info(&mgr->dev, "%s registered\n", mgr->name); in fpga_mgr_register()
698 ida_simple_remove(&fpga_mgr_ida, mgr->dev.id); in fpga_mgr_register()
710 void fpga_mgr_unregister(struct fpga_manager *mgr) in fpga_mgr_unregister() argument
712 dev_info(&mgr->dev, "%s %s\n", __func__, mgr->name); in fpga_mgr_unregister()
718 if (mgr->mops->fpga_remove) in fpga_mgr_unregister()
719 mgr->mops->fpga_remove(mgr); in fpga_mgr_unregister()
721 device_unregister(&mgr->dev); in fpga_mgr_unregister()