예제 #1
0
/* Lookup function from function ID and call it using given arguments */
int drvmgr_func_call(void *obj, int funcid, void *a, void *b, void *c, void *d)
{
	int (*func)(void *arg1, void *arg2, void *arg3, void *arg4) = NULL;

	if (drvmgr_func_get(obj, funcid, (void *)&func) != DRVMGR_OK)
		return DRVMGR_FAIL;
	return func(a, b, c, d);
}
static int grtm_init2(struct drvmgr_dev *dev)
{
	struct grtm_priv *priv;

	DBG("GRTM[%d] on bus %s\n", dev->minor_drv, dev->parent->dev->name);
	priv = dev->priv = malloc(sizeof(struct grtm_priv));
	if ( !priv )
		return DRVMGR_NOMEM;
	memset(priv, 0, sizeof(*priv));
	priv->dev = dev;

	/* Get Read/Write operations for bus */
	priv->rw_arg.dev = dev;
	priv->rw_arg.arg = drvmgr_func_call(dev->parent, AMBAPP_RMAP_RW_ARG, dev, NULL, NULL, NULL);
	drvmgr_func_get(dev->parent, AMBAPP_RMAP_R32, (void **)&priv->rw_r32);
	drvmgr_func_get(dev->parent, AMBAPP_RMAP_W32, (void **)&priv->rw_w32);
	drvmgr_func_get(dev->parent, AMBAPP_RMAP_WMEM, (void **)&priv->rw_wmem);
	drvmgr_func_get(dev->parent, AMBAPP_RMAP_MEMSET,
			(void **)&priv->rw_memset);

	/* This core will not find other cores, so we wait for init2() */

	return DRVMGR_OK;
}