reconfig.c (a02001086bbfb4da35d1228bebc2f1b442db455f) | reconfig.c (948ad1acaf456b7213731cd9eb58654930335070) |
---|---|
1/* 2 * pSeries_reconfig.c - support for dynamic reconfiguration (including PCI 3 * Hotplug and Dynamic Logical Partitioning on RPA platforms). 4 * 5 * Copyright (C) 2005 Nathan Lynch 6 * Copyright (C) 2005 IBM Corporation 7 * 8 * --- 8 unchanged lines hidden (view full) --- 17#include <linux/slab.h> 18#include <linux/of.h> 19 20#include <asm/prom.h> 21#include <asm/machdep.h> 22#include <asm/uaccess.h> 23#include <asm/mmu.h> 24 | 1/* 2 * pSeries_reconfig.c - support for dynamic reconfiguration (including PCI 3 * Hotplug and Dynamic Logical Partitioning on RPA platforms). 4 * 5 * Copyright (C) 2005 Nathan Lynch 6 * Copyright (C) 2005 IBM Corporation 7 * 8 * --- 8 unchanged lines hidden (view full) --- 17#include <linux/slab.h> 18#include <linux/of.h> 19 20#include <asm/prom.h> 21#include <asm/machdep.h> 22#include <asm/uaccess.h> 23#include <asm/mmu.h> 24 |
25/** 26 * derive_parent - basically like dirname(1) 27 * @path: the full_name of a node to be added to the tree 28 * 29 * Returns the node which should be the parent of the node 30 * described by path. E.g., for path = "/foo/bar", returns 31 * the node with full_name = "/foo". 32 */ 33static struct device_node *derive_parent(const char *path) 34{ 35 struct device_node *parent = NULL; 36 char *parent_path = "/"; 37 size_t parent_path_len = strrchr(path, '/') - path + 1; | 25#include "of_helpers.h" |
38 | 26 |
39 /* reject if path is "/" */ 40 if (!strcmp(path, "/")) 41 return ERR_PTR(-EINVAL); 42 43 if (strrchr(path, '/') != path) { 44 parent_path = kmalloc(parent_path_len, GFP_KERNEL); 45 if (!parent_path) 46 return ERR_PTR(-ENOMEM); 47 strlcpy(parent_path, path, parent_path_len); 48 } 49 parent = of_find_node_by_path(parent_path); 50 if (!parent) 51 return ERR_PTR(-EINVAL); 52 if (strcmp(parent_path, "/")) 53 kfree(parent_path); 54 return parent; 55} 56 | |
57static int pSeries_reconfig_add_node(const char *path, struct property *proplist) 58{ 59 struct device_node *np; 60 int err = -ENOMEM; 61 62 np = kzalloc(sizeof(*np), GFP_KERNEL); 63 if (!np) 64 goto out_err; 65 66 np->full_name = kstrdup(path, GFP_KERNEL); 67 if (!np->full_name) 68 goto out_err; 69 70 np->properties = proplist; 71 of_node_set_flag(np, OF_DYNAMIC); 72 of_node_init(np); 73 | 27static int pSeries_reconfig_add_node(const char *path, struct property *proplist) 28{ 29 struct device_node *np; 30 int err = -ENOMEM; 31 32 np = kzalloc(sizeof(*np), GFP_KERNEL); 33 if (!np) 34 goto out_err; 35 36 np->full_name = kstrdup(path, GFP_KERNEL); 37 if (!np->full_name) 38 goto out_err; 39 40 np->properties = proplist; 41 of_node_set_flag(np, OF_DYNAMIC); 42 of_node_init(np); 43 |
74 np->parent = derive_parent(path); | 44 np->parent = pseries_of_derive_parent(path); |
75 if (IS_ERR(np->parent)) { 76 err = PTR_ERR(np->parent); 77 goto out_err; 78 } 79 80 err = of_attach_node(np); 81 if (err) { 82 printk(KERN_ERR "Failed to add device node %s\n", path); --- 373 unchanged lines hidden --- | 45 if (IS_ERR(np->parent)) { 46 err = PTR_ERR(np->parent); 47 goto out_err; 48 } 49 50 err = of_attach_node(np); 51 if (err) { 52 printk(KERN_ERR "Failed to add device node %s\n", path); --- 373 unchanged lines hidden --- |