powerpc/eeh: Reduce to one the number of places where edev is allocated

arch/powerpc/kernel/eeh_dev.c:57 is the only legit place where edev
is allocated; other 2 places allocate it on stack and in the heap for
a very short period of time to use eeh_pe_get() as takes edev.

This changes eeh_pe_get() to receive required parameters explicitly.

This removes unnecessary temporary allocation of edev.

This uses the "pe_no" name instead of the "pe_config_addr" name as
it actually is a PE number and not a config space address as it seemed.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Acked-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
Alexey Kardashevskiy
2017-08-29 17:34:00 +10:00
committed by Michael Ellerman
parent 5f600b17d1
commit 8bae6a2319
3 changed files with 25 additions and 25 deletions

View File

@@ -230,10 +230,15 @@ void *eeh_pe_dev_traverse(struct eeh_pe *root,
* Bus/Device/Function number. The extra data referred by flag
* indicates which type of address should be used.
*/
struct eeh_pe_get_flag {
int pe_no;
int config_addr;
};
static void *__eeh_pe_get(void *data, void *flag)
{
struct eeh_pe *pe = (struct eeh_pe *)data;
struct eeh_dev *edev = (struct eeh_dev *)flag;
struct eeh_pe_get_flag *tmp = (struct eeh_pe_get_flag *) flag;
/* Unexpected PHB PE */
if (pe->type & EEH_PE_PHB)
@@ -244,17 +249,17 @@ static void *__eeh_pe_get(void *data, void *flag)
* have non-zero PE address
*/
if (eeh_has_flag(EEH_VALID_PE_ZERO)) {
if (edev->pe_config_addr == pe->addr)
if (tmp->pe_no == pe->addr)
return pe;
} else {
if (edev->pe_config_addr &&
(edev->pe_config_addr == pe->addr))
if (tmp->pe_no &&
(tmp->pe_no == pe->addr))
return pe;
}
/* Try BDF address */
if (edev->config_addr &&
(edev->config_addr == pe->config_addr))
if (tmp->config_addr &&
(tmp->config_addr == pe->config_addr))
return pe;
return NULL;
@@ -262,7 +267,9 @@ static void *__eeh_pe_get(void *data, void *flag)
/**
* eeh_pe_get - Search PE based on the given address
* @edev: EEH device
* @phb: PCI controller
* @pe_no: PE number
* @config_addr: Config address
*
* Search the corresponding PE based on the specified address which
* is included in the eeh device. The function is used to check if
@@ -271,12 +278,14 @@ static void *__eeh_pe_get(void *data, void *flag)
* which is composed of PCI bus/device/function number, or unified
* PE address.
*/
struct eeh_pe *eeh_pe_get(struct eeh_dev *edev)
struct eeh_pe *eeh_pe_get(struct pci_controller *phb,
int pe_no, int config_addr)
{
struct eeh_pe *root = eeh_phb_pe_get(edev->phb);
struct eeh_pe *root = eeh_phb_pe_get(phb);
struct eeh_pe_get_flag tmp = { pe_no, config_addr };
struct eeh_pe *pe;
pe = eeh_pe_traverse(root, __eeh_pe_get, edev);
pe = eeh_pe_traverse(root, __eeh_pe_get, &tmp);
return pe;
}
@@ -344,7 +353,8 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
* PE should be composed of PCI bus and its subordinate
* components.
*/
pe = eeh_pe_get(edev);
pe = eeh_pe_get(edev->pdn->phb, edev->pe_config_addr,
edev->config_addr);
if (pe && !(pe->type & EEH_PE_INVALID)) {
/* Mark the PE as type of PCI bus */
pe->type = EEH_PE_BUS;