FreeBSD/sys/dev/extres/clk/clk.c
/*
 * Create and initialize clock object, but do not register it.
 */
Create and initialize clock object, but do not register it.
Create and initialize clock object but do not register it .
struct clknode *
clknode_create(struct clkdom * clkdom, clknode_class_t clknode_class,
    const struct clknode_init_def *def)
{
	struct clknode *clknode;
	KASSERT(def->name != NULL, ("clock name is NULL"));
	KASSERT(def->name[0] != '\0', ("clock name is empty"));
#ifdef   INVARIANTS
	CLK_TOPO_SLOCK();
	if (clknode_find_by_name(def->name) != NULL)
		panic("Duplicated clock registration: %s\n", def->name);
	CLK_TOPO_UNLOCK();
#endif
	clknode = malloc(sizeof(struct clknode), M_CLOCK, M_WAITOK | M_ZERO);
	kobj_init((kobj_t)clknode, (kobj_class_t)clknode_class);
	sx_init(&clknode->lock, "Clocknode lock");
	if (clknode_class->size > 0) {
		clknode->softc = malloc(clknode_class->size,
		    M_CLOCK, M_WAITOK | M_ZERO);
	}
	clknode->parents = malloc(sizeof(struct clknode *) * def->parent_cnt,
	    M_CLOCK, M_WAITOK | M_ZERO);
	if (def->flags & CLK_NODE_STATIC_STRINGS) {
		clknode->name = def->name;
		clknode->parent_names = def->parent_names;
	} else {
		clknode->name = strdup(def->name, M_CLOCK);
		clknode->parent_names =
		    strdup_list(def->parent_names, def->parent_cnt);
	}
	clknode->id = def->id;
	clknode->clkdom = clkdom;
	clknode->flags = def->flags;
	clknode->parent_cnt = def->parent_cnt;
	clknode->parent = NULL;
	clknode->parent_idx = CLKNODE_IDX_NONE;
	TAILQ_INIT(&clknode->children);
	return (clknode);
}
struct clknode * clknode_create ( struct clkdom * clkdom , clknode_class_t clknode_class , const struct clknode_init_def * def ) { struct clknode * clknode ; KASSERT ( def -> name != NULL , ( " " ) ) ; KASSERT ( def -> name [ 0 ] != ' \0 ' , ( " " ) ) ; #ifdef INVARIANTS CLK_TOPO_SLOCK ( ) ; if ( clknode_find_by_name ( def -> name ) != NULL ) panic ( " \n " , def -> name ) ; CLK_TOPO_UNLOCK ( ) ; #endif clknode = malloc ( sizeof ( struct clknode ) , M_CLOCK , M_WAITOK | M_ZERO ) ; kobj_init ( ( kobj_t ) clknode , ( kobj_class_t ) clknode_class ) ; sx_init ( & clknode -> lock , " " ) ; if ( clknode_class -> size > 0 ) { clknode -> softc = malloc ( clknode_class -> size , M_CLOCK , M_WAITOK | M_ZERO ) ; } clknode -> parents = malloc ( sizeof ( struct clknode * ) * def -> parent_cnt , M_CLOCK , M_WAITOK | M_ZERO ) ; if ( def -> flags & CLK_NODE_STATIC_STRINGS ) { clknode -> name = def -> name ; clknode -> parent_names = def -> parent_names ; } else { clknode -> name = strdup ( def -> name , M_CLOCK ) ; clknode -> parent_names = strdup_list ( def -> parent_names , def -> parent_cnt ) ; } clknode -> id = def -> id ; clknode -> clkdom = clkdom ; clknode -> flags = def -> flags ; clknode -> parent_cnt = def -> parent_cnt ; clknode -> parent = NULL ; clknode -> parent_idx = CLKNODE_IDX_NONE ; TAILQ_INIT ( & clknode -> children ) ; return ( clknode ) ; }
Create and initialize clock object, but do not register it.
Create and initialize clock object but do not register it .
/* Create object and initialize it. */ /* Allocate softc if required. */ /* Prepare array for ptrs to parent clocks. */ /* Copy all strings unless they're flagged as static. */ /* Rest of init. */