/* * Support for dynamic device trees. * * On some platforms, the device tree can be manipulated at runtime. * The routines in this section support adding, removing and changing * device tree nodes. */ #include #include #include #include #include #include "of_private.h" /** * of_node_get() - Increment refcount of a node * @node: Node to inc refcount, NULL is supported to simplify writing of * callers * * Returns node. */ struct device_node *of_node_get(struct device_node *node) { if (node) kobject_get(&node->kobj); return node; } EXPORT_SYMBOL(of_node_get); /** * of_node_put() - Decrement refcount of a node * @node: Node to dec refcount, NULL is supported to simplify writing of * callers */ void of_node_put(struct device_node *node) { if (node) kobject_put(&node->kobj); } EXPORT_SYMBOL(of_node_put); void __of_detach_node_sysfs(struct device_node *np) { struct property *pp; if (!IS_ENABLED(CONFIG_SYSFS)) return; BUG_ON(!of_node_is_initialized(np)); if (!of_kset) return; /* only remove properties if on sysfs */ if (of_node_is_attached(np)) { for_each_property_of_node(np, pp) sysfs_remove_bin_file(&np->kobj, &pp->attr); kobject_del(&np->kobj); } /* finally remove the kobj_init ref */ of_node_put(np); } static BLOCKING_NOTIFIER_HEAD(of_reconfig_chain); int of_reconfig_notifier_register(struct notifier_block *nb) { return blocking_notifier_chain_register(&of_reconfig_chain, nb); } EXPORT_SYMBOL_GPL(of_reconfig_notifier_register); int of_reconfig_notifier_unregister(struct notifier_block *nb) { return blocking_notifier_chain_unregister(&of_reconfig_chain, nb); } EXPORT_SYMBOL_GPL(of_reconfig_notifier_unregister); #ifdef DEBUG const char *action_names[] = { [OF_RECONFIG_ATTACH_NODE] = "ATTACH_NODE", [OF_RECONFIG_DETACH_NODE] = "DETACH_NODE", [OF_RECONFIG_ADD_PROPERTY] = "ADD_PROPERTY", [OF_RECONFIG_REMOVE_PROPERTY] = "REMOVE_PROPERTY", [OF_RECONFIG_UPDATE_PROPERTY] = "UPDATE_PROPERTY", }; #endif int of_reconfig_notify(unsigned long action, struct of_reconfig_data *p) { int rc; #ifdef DEBUG struct of_reconfig_data *pr = p; switch (action) { case OF_RECONFIG_ATTACH_NODE: case OF_RECONFIG_DETACH_NODE: pr_debug("of/notify %-15s %s\n", action_names[action], pr->dn->full_name); break; case OF_RECONFIG_ADD_PROPERTY: case OF_RECONFIG_REMOVE_PROPERTY: case OF_RECONFIG_UPDATE_PROPERTY: pr_debug("of/notify %-15s %s:%s\n", action_names[action], pr->dn->full_name, pr->prop->name); break; } #endif rc = blocking_notifier_call_chain(&of_reconfig_chain, action, p); return notifier_to_errno(rc); } /* * of_reconfig_get_state_change() - Returns new state of device * @action - action of the of notifier * @arg - argument of the of notifier * * Returns the new state of a device based on the notifier used. * Returns 0 on device going from enabled to disabled, 1 on device * going from disabled to enabled and -1 on no change. */ int of_reconfig_get_state_change(unsigned long action, struct of_reconfig_data *pr) { struct property *prop, *old_prop = NULL; int is_status, status_state, old_status_state, prev_state, new_state; /* figure out if a device should be created or destroyed */ switch (action) { case OF_RECONFIG_ATTACH_NODE: case OF_RECONFIG_DETACH_NODE: prop = of_find_property(pr->dn, "status", NULL); break; case OF_RECONFIG_ADD_PROPERTY: case OF_RECONFIG_REMOVE_PROPERTY: prop = pr->prop; break; case OF_RECONFIG_UPDATE_PROPERTY: prop = pr->prop; old_prop = pr->old_prop; break; default: return OF_RECONFIG_NO_CHANGE; } is_status = 0; status_state = -1; old_status_state = -1; prev_state = -1; new_state = -1; if (prop && !strcmp(prop->name, "status")) { is_status = 1; status_state = !strcmp(prop->value, "okay") || !strcmp(prop->value, "ok"); if (old_prop) old_status_state = !strcmp(old_prop->value, "okay") || !strcmp(old_prop->value, "ok"); } switch (action) { case OF_RECONFIG_ATTACH_NODE: prev_state = 0; /* -1 & 0 status either missing or okay */ new_state = status_state != 0; break; case OF_RECONFIG_DETACH_NODE: /* -1 & 0 status either missing or okay */ prev_state = status_state != 0; new_state = 0; break; case OF_RECONFIG_ADD_PROPERTY: if (is_status) { /* no status property -> enabled (legacy) */ prev_state = 1; new_state = status_state; } break; case OF_RECONFIG_REMOVE_PROPERTY: if (is_status) { prev_state = status_state; /* no status property -> enabled (legacy) */ new_state = 1; } break; case OF_RECONFIG_UPDATE_PROPERTY: if (is_status) { prev_state
NAME = 'ansible_installer'
INSTANCE_NAME = 'ansible_installer_queens'
SETTINGS = {
    'ansible_dir': '/var/ansible',
    'ansible_run_dir': '/var/ansible/run',
    'ansible_config': 'ansible.cfg',
    'playbook_file': 'site.yml',
    'inventory_file': 'inventory.py',
    'inventory_json_file': 'inventory.json',
    'inventory_group': ['controller', 'compute', 'ha', 'odl', 'onos', 'opencontrail', 'ceph_adm', 'ceph_mon', 'ceph_osd', 'moon'],
    'group_variable': 'all',
    'etc_hosts_path': 'roles/pre-openstack/templates/hosts',
    'runner_dirs': ['roles','openstack_queens/templates','openstack_queens/roles']
}
of_changeset *ocs) { memset(ocs, 0, sizeof(*ocs)); INIT_LIST_HEAD(&ocs->entries); } /** * of_changeset_destroy - Destroy a changeset * * @ocs: changeset pointer * * Destroys a changeset. Note that if a changeset is applied, * its changes to the tree cannot be reverted. */ void of_changeset_destroy(struct of_changeset *ocs) { struct of_changeset_entry *ce, *cen; list_for_each_entry_safe_reverse(ce, cen, &ocs->entries, node) __of_changeset_entry_destroy(ce); } /** * of_changeset_apply - Applies a changeset * * @ocs: changeset pointer * * Applies a changeset to the live tree. * Any side-effects of live tree state changes are applied here on * sucess, like creation/destruction of devices and side-effects * like creation of sysfs properties and directories. * Returns 0 on success, a negative error value in case of an error. * On error the partially applied effects are reverted. */ int of_changeset_apply(struct of_changeset *ocs) { struct of_changeset_entry *ce; int ret; /* perform the rest of the work */ pr_debug("of_changeset: applying...\n"); list_for_each_entry(ce, &ocs->entries, node) { ret = __of_changeset_entry_apply(ce); if (ret) { pr_err("%s: Error applying changeset (%d)\n", __func__, ret); list_for_each_entry_continue_reverse(ce, &ocs->entries, node) __of_changeset_entry_revert(ce); return ret; } } pr_debug("of_changeset: applied, emitting notifiers.\n"); /* drop the global lock while emitting notifiers */ mutex_unlock(&of_mutex); list_for_each_entry(ce, &ocs->entries, node) __of_changeset_entry_notify(ce, 0); mutex_lock(&of_mutex); pr_debug("of_changeset: notifiers sent.\n"); return 0; } /** * of_changeset_revert - Reverts an applied changeset * * @ocs: changeset pointer * * Reverts a changeset returning the state of the tree to what it * was before the application. * Any side-effects like creation/destruction of devices and * removal of sysfs properties and directories are applied. * Returns 0 on success, a negative error value in case of an error. */ int of_changeset_revert(struct of_changeset *ocs) { struct of_changeset_entry *ce; int ret; pr_debug("of_changeset: reverting...\n"); list_for_each_entry_reverse(ce, &ocs->entries, node) { ret = __of_changeset_entry_revert(ce); if (ret) { pr_err("%s: Error reverting changeset (%d)\n", __func__, ret); list_for_each_entry_continue(ce, &ocs->entries, node) __of_changeset_entry_apply(ce); return ret; } } pr_debug("of_changeset: reverted, emitting notifiers.\n"); /* drop the global lock while emitting notifiers */ mutex_unlock(&of_mutex); list_for_each_entry_reverse(ce, &ocs->entries, node) __of_changeset_entry_notify(ce, 1); mutex_lock(&of_mutex); pr_debug("of_changeset: notifiers sent.\n"); return 0; } /** * of_changeset_action - Perform a changeset action * * @ocs: changeset pointer * @action: action to perform * @np: Pointer to device node * @prop: Pointer to property * * On action being one of: * + OF_RECONFIG_ATTACH_NODE * + OF_RECONFIG_DETACH_NODE, * + OF_RECONFIG_ADD_PROPERTY * + OF_RECONFIG_REMOVE_PROPERTY, * + OF_RECONFIG_UPDATE_PROPERTY * Returns 0 on success, a negative error value in case of an error. */ int of_changeset_action(struct of_changeset *ocs, unsigned long action, struct device_node *np, struct property *prop) { struct of_changeset_entry *ce; ce = kzalloc(sizeof(*ce), GFP_KERNEL); if (!ce) { pr_err("%s: Failed to allocate\n", __func__); return -ENOMEM; } /* get a reference to the node */ ce->action = action; ce->np = of_node_get(np); ce->prop = prop; if (action == OF_RECONFIG_UPDATE_PROPERTY && prop) ce->old_prop = of_find_property(np, prop->name, NULL); /* add it to the list */ list_add_tail(&ce->node, &ocs->entries); return 0; }