diff options
author | Gavin Shan <gwshan@linux.vnet.ibm.com> | 2015-08-27 00:12:37 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2015-08-27 21:33:51 -0400 |
commit | ea0f8acf4d44727f7d3a38072566029bf5e17b44 (patch) | |
tree | 64fe0ca1aa0a362ec0ddd9f88a0a1efece983b51 | |
parent | 590c7567a2895f939525ead57b0334c6d47986f0 (diff) |
powerpc/pseries: Cleanup on pci_dn_reconfig_notifier()
This applies cleanup on pci_dn_reconfig_notifier(), no functional
changes:
* Rename variable "pci" to "pdn" to indicate its purpose clearly.
* The parent node can be released at any time. So it should be
hold with of_get_parent() before accessing it.
* The device node doesn't have to have parent node in theory.
More check on this.
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r-- | arch/powerpc/platforms/pseries/setup.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c index e6e8b241d717..39a74fad3e04 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c | |||
@@ -254,24 +254,26 @@ static void __init pseries_discover_pic(void) | |||
254 | static int pci_dn_reconfig_notifier(struct notifier_block *nb, unsigned long action, void *data) | 254 | static int pci_dn_reconfig_notifier(struct notifier_block *nb, unsigned long action, void *data) |
255 | { | 255 | { |
256 | struct of_reconfig_data *rd = data; | 256 | struct of_reconfig_data *rd = data; |
257 | struct device_node *np = rd->dn; | 257 | struct device_node *parent, *np = rd->dn; |
258 | struct pci_dn *pci = NULL; | 258 | struct pci_dn *pdn; |
259 | int err = NOTIFY_OK; | 259 | int err = NOTIFY_OK; |
260 | 260 | ||
261 | switch (action) { | 261 | switch (action) { |
262 | case OF_RECONFIG_ATTACH_NODE: | 262 | case OF_RECONFIG_ATTACH_NODE: |
263 | pci = np->parent->data; | 263 | parent = of_get_parent(np); |
264 | if (pci) { | 264 | pdn = parent ? PCI_DN(parent) : NULL; |
265 | update_dn_pci_info(np, pci->phb); | 265 | if (pdn) { |
266 | 266 | /* Create pdn and EEH device */ | |
267 | /* Create EEH device for the OF node */ | 267 | update_dn_pci_info(np, pdn->phb); |
268 | eeh_dev_init(PCI_DN(np), pci->phb); | 268 | eeh_dev_init(PCI_DN(np), pdn->phb); |
269 | } | 269 | } |
270 | |||
271 | of_node_put(parent); | ||
270 | break; | 272 | break; |
271 | case OF_RECONFIG_DETACH_NODE: | 273 | case OF_RECONFIG_DETACH_NODE: |
272 | pci = PCI_DN(np); | 274 | pdn = PCI_DN(np); |
273 | if (pci) | 275 | if (pdn) |
274 | list_del(&pci->list); | 276 | list_del(&pdn->list); |
275 | break; | 277 | break; |
276 | default: | 278 | default: |
277 | err = NOTIFY_DONE; | 279 | err = NOTIFY_DONE; |