resources/KernelSource_4_19v/drivers/fpga/fpga-mgr.c
/**
 * fpga_mgr_create - create and initialize a FPGA manager struct
 * @dev:	fpga manager device from pdev
 * @name:	fpga manager name
 * @mops:	pointer to structure of fpga manager ops
 * @priv:	fpga manager private data
 *
 * Return: pointer to struct fpga_manager or NULL
 */
create and initialize a FPGA manager struct
@dev:        fpga manager device from pdev
@name:       fpga manager name
@mops:       pointer to structure of fpga manager ops
@priv:       fpga manager private data

pointer to struct fpga_manager or NULL
create and initialize a FPGA manager struct @dev : fpga manager device from pdev @name : fpga manager name @mops : pointer to structure of fpga manager ops @priv : fpga manager private data pointer to struct fpga_manager or NULL
struct fpga_manager *fpga_mgr_create(struct device *dev, const char *name,
				     const struct fpga_manager_ops *mops,
				     void *priv)
{
	struct fpga_manager *mgr;
	int id, ret;
	if (!mops || !mops->write_complete || !mops->state ||
	    !mops->write_init || (!mops->write && !mops->write_sg) ||
	    (mops->write && mops->write_sg)) {
		dev_err(dev, "Attempt to register without fpga_manager_ops\n");
		return NULL;
	}
	if (!name || !strlen(name)) {
		dev_err(dev, "Attempt to register with no name!\n");
		return NULL;
	}
	mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
	if (!mgr)
		return NULL;
	id = ida_simple_get(&fpga_mgr_ida, 0, 0, GFP_KERNEL);
	if (id < 0) {
		ret = id;
		goto error_kfree;
	}
	mutex_init(&mgr->ref_mutex);
	mgr->name = name;
	mgr->mops = mops;
	mgr->priv = priv;
	device_initialize(&mgr->dev);
	mgr->dev.class = fpga_mgr_class;
	mgr->dev.groups = mops->groups;
	mgr->dev.parent = dev;
	mgr->dev.of_node = dev->of_node;
	mgr->dev.id = id;
	ret = dev_set_name(&mgr->dev, "fpga%d", id);
	if (ret)
		goto error_device;
	return mgr;
error_device:
	ida_simple_remove(&fpga_mgr_ida, id);
error_kfree:
	kfree(mgr);
	return NULL;
}
struct fpga_manager * fpga_mgr_create ( struct device * dev , const char * name , const struct fpga_manager_ops * mops , void * priv ) { struct fpga_manager * mgr ; int id , ret ; if ( ! mops || ! mops -> write_complete || ! mops -> state || ! mops -> write_init || ( ! mops -> write && ! mops -> write_sg ) || ( mops -> write && mops -> write_sg ) ) { dev_err ( dev , " \n " ) ; return NULL ; } if ( ! name || ! strlen ( name ) ) { dev_err ( dev , " \n " ) ; return NULL ; } mgr = kzalloc ( sizeof ( * mgr ) , GFP_KERNEL ) ; if ( ! mgr ) return NULL ; id = ida_simple_get ( & fpga_mgr_ida , 0 , 0 , GFP_KERNEL ) ; if ( id < 0 ) { ret = id ; goto error_kfree ; } mutex_init ( & mgr -> ref_mutex ) ; mgr -> name = name ; mgr -> mops = mops ; mgr -> priv = priv ; device_initialize ( & mgr -> dev ) ; mgr -> dev . class = fpga_mgr_class ; mgr -> dev . groups = mops -> groups ; mgr -> dev . parent = dev ; mgr -> dev . of_node = dev -> of_node ; mgr -> dev . id = id ; ret = dev_set_name ( & mgr -> dev , " " , id ) ; if ( ret ) goto error_device ; return mgr ; error_device : ida_simple_remove ( & fpga_mgr_ida , id ) ; error_kfree : kfree ( mgr ) ; return NULL ; }
fpga_mgr_create - create and initialize a FPGA manager struct
 @dev:        fpga manager device from pdev
 @name:       fpga manager name
 @mops:       pointer to structure of fpga manager ops
 @priv:       fpga manager private data
fpga_mgr_create - create and initialize a FPGA manager struct @dev : fpga manager device from pdev @name : fpga manager name @mops : pointer to structure of fpga manager ops @priv : fpga manager private data