@@ -625,7 +625,7 @@ int eeh_pci_enable(struct eeh_pe *pe, int function)intpcibios_set_pcie_reset_state(structpci_dev*dev,enumpcie_reset_statestate){structeeh_dev*edev=pci_dev_to_eeh_dev(dev);-structeeh_pe*pe=edev->pe;+structeeh_pe*pe=edev?edev->pe:NULL;if(!pe){pr_err("%s: No PE found on PCI device %s\n",
@@ -625,7 +625,7 @@ int eeh_pci_enable(struct eeh_pe *pe, int function)intpcibios_set_pcie_reset_state(structpci_dev*dev,enumpcie_reset_statestate){structeeh_dev*edev=pci_dev_to_eeh_dev(dev);-structeeh_pe*pe=edev->pe;+structeeh_pe*pe=edev?edev->pe:NULL;if(!pe){pr_err("%s: No PE found on PCI device %s\n",
We seem to do this or something similar in a few places. Is it worth having a
pci_dev_to_eeh_pe() inline?
cheers
@@ -625,7 +625,7 @@ int eeh_pci_enable(struct eeh_pe *pe, int function)intpcibios_set_pcie_reset_state(structpci_dev*dev,enumpcie_reset_statestate){structeeh_dev*edev=pci_dev_to_eeh_dev(dev);-structeeh_pe*pe=edev->pe;+structeeh_pe*pe=edev?edev->pe:NULL;if(!pe){pr_err("%s: No PE found on PCI device %s\n",
We seem to do this or something similar in a few places. Is it worth having a
pci_dev_to_eeh_pe() inline?
Yes, maybe we just need a eeh_dev_to_pe() because converting
pci_dev to eeh_dev is already coverred by pci_dev_to_eeh_dev().
With eeh_dev_to_pe(), it looks like this:
struct pci_dev *pdev;
struct eeh_dev *edev = pci_dev_to_eeh_dev(pdev);
struct eeh_pe *pe = eeh_dev_to_pe(edev);
Or another case:
struct device_node *dn;
struct eeh_dev *edev = of_node_to_eeh_dev(dn);
struct eeh_pe *pe = eeh_dev_to_pe(edev);
Thanks,
Gavin
@@ -625,7 +625,7 @@ int eeh_pci_enable(struct eeh_pe *pe, int function)intpcibios_set_pcie_reset_state(structpci_dev*dev,enumpcie_reset_statestate){structeeh_dev*edev=pci_dev_to_eeh_dev(dev);-structeeh_pe*pe=edev->pe;+structeeh_pe*pe=edev?edev->pe:NULL;if(!pe){pr_err("%s: No PE found on PCI device %s\n",
We seem to do this or something similar in a few places. Is it worth having a
pci_dev_to_eeh_pe() inline?
Yes, maybe we just need a eeh_dev_to_pe() because converting
pci_dev to eeh_dev is already coverred by pci_dev_to_eeh_dev().
With eeh_dev_to_pe(), it looks like this:
struct pci_dev *pdev;
struct eeh_dev *edev = pci_dev_to_eeh_dev(pdev);
struct eeh_pe *pe = eeh_dev_to_pe(edev);
Or another case:
struct device_node *dn;
struct eeh_dev *edev = of_node_to_eeh_dev(dn);
struct eeh_pe *pe = eeh_dev_to_pe(edev);
With these helper, it would be more consolidate to jump between those data.
Gavin,
You would add these helpers? Or would like me to add them?
@@ -625,7 +625,7 @@ int eeh_pci_enable(struct eeh_pe *pe, int function)intpcibios_set_pcie_reset_state(structpci_dev*dev,enumpcie_reset_statestate){structeeh_dev*edev=pci_dev_to_eeh_dev(dev);-structeeh_pe*pe=edev->pe;+structeeh_pe*pe=edev?edev->pe:NULL;if(!pe){pr_err("%s: No PE found on PCI device %s\n",
We seem to do this or something similar in a few places. Is it worth having a
pci_dev_to_eeh_pe() inline?
Yes, maybe we just need a eeh_dev_to_pe() because converting
pci_dev to eeh_dev is already coverred by pci_dev_to_eeh_dev().
With eeh_dev_to_pe(), it looks like this:
struct pci_dev *pdev;
struct eeh_dev *edev = pci_dev_to_eeh_dev(pdev);
struct eeh_pe *pe = eeh_dev_to_pe(edev);
Or another case:
struct device_node *dn;
struct eeh_dev *edev = of_node_to_eeh_dev(dn);
struct eeh_pe *pe = eeh_dev_to_pe(edev);
With these helper, it would be more consolidate to jump between those data.
Gavin,
You would add these helpers? Or would like me to add them?
It would be Richard to help on this :-)
Thanks,
Gavin
@@ -625,7 +625,7 @@ int eeh_pci_enable(struct eeh_pe *pe, int function)intpcibios_set_pcie_reset_state(structpci_dev*dev,enumpcie_reset_statestate){structeeh_dev*edev=pci_dev_to_eeh_dev(dev);-structeeh_pe*pe=edev->pe;+structeeh_pe*pe=edev?edev->pe:NULL;if(!pe){pr_err("%s: No PE found on PCI device %s\n",
We seem to do this or something similar in a few places. Is it worth having a
pci_dev_to_eeh_pe() inline?
Yes, maybe we just need a eeh_dev_to_pe() because converting
pci_dev to eeh_dev is already coverred by pci_dev_to_eeh_dev().
With eeh_dev_to_pe(), it looks like this:
struct pci_dev *pdev;
struct eeh_dev *edev = pci_dev_to_eeh_dev(pdev);
struct eeh_pe *pe = eeh_dev_to_pe(edev);
Or another case:
struct device_node *dn;
struct eeh_dev *edev = of_node_to_eeh_dev(dn);
struct eeh_pe *pe = eeh_dev_to_pe(edev);
Yeah I guess.
I saw a few places where we go from pci_dev to eeh_pe via a eeh_dev but then
don't use the eeh_dev at all. So for those it would make sense to have one
macro that does the full conversion from pci_dev to eeh_pe.
But if you think that's not very common then yeah a macro to do each stage is
fine.
cheers
@@ -410,7 +410,7 @@ int eeh_dev_check_failure(struct eeh_dev *edev)}dn=eeh_dev_to_of_node(edev);dev=eeh_dev_to_pci_dev(edev);-pe=edev->pe;+pe=eeh_dev_to_pe(edev);/* Access to IO BARs might get this far and still not want checking. */if(!pe){
@@ -634,7 +634,7 @@ int eeh_pci_enable(struct eeh_pe *pe, int function)intpcibios_set_pcie_reset_state(structpci_dev*dev,enumpcie_reset_statestate){structeeh_dev*edev=pci_dev_to_eeh_dev(dev);-structeeh_pe*pe=edev->pe;+structeeh_pe*pe=eeh_dev_to_pe(edev);if(!pe){pr_err("%s: No PE found on PCI device %s\n",
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2014-09-16 04:03:57
On Mon, 2014-09-15 at 16:08 +0800, Wei Yang wrote:
This patch introduces a marco to convert eeh_dev to eeh_pe. By doing so, it
will prevent converting with NULL pointer.
Signed-off-by: Wei Yang <redacted>
Acked-by: Gavin Shan <redacted>
V2 -> V3:
1. rebased on 3.17-rc4
2. introduce a marco
3. use this marco in several other places
On Tue, Sep 16, 2014 at 02:03:56PM +1000, Michael Ellerman wrote:
On Mon, 2014-09-15 at 16:08 +0800, Wei Yang wrote:
quoted
This patch introduces a marco to convert eeh_dev to eeh_pe. By doing so, it
will prevent converting with NULL pointer.
Signed-off-by: Wei Yang <redacted>
Acked-by: Gavin Shan <redacted>
V2 -> V3:
1. rebased on 3.17-rc4
2. introduce a marco
3. use this marco in several other places
On Tue, Sep 16, 2014 at 02:02:18PM +0800, Wei Yang wrote:
On Tue, Sep 16, 2014 at 02:03:56PM +1000, Michael Ellerman wrote:
quoted
On Mon, 2014-09-15 at 16:08 +0800, Wei Yang wrote:
quoted
This patch introduces a marco to convert eeh_dev to eeh_pe. By doing so, it
will prevent converting with NULL pointer.
Signed-off-by: Wei Yang <redacted>
Acked-by: Gavin Shan <redacted>
V2 -> V3:
1. rebased on 3.17-rc4
2. introduce a marco
3. use this marco in several other places
@@ -410,7 +410,7 @@ int eeh_dev_check_failure(struct eeh_dev *edev)}dn=eeh_dev_to_of_node(edev);dev=eeh_dev_to_pci_dev(edev);-pe=edev->pe;+pe=eeh_dev_to_pe(edev);/* Access to IO BARs might get this far and still not want checking. */if(!pe){
@@ -634,7 +634,7 @@ int eeh_pci_enable(struct eeh_pe *pe, int function)intpcibios_set_pcie_reset_state(structpci_dev*dev,enumpcie_reset_statestate){structeeh_dev*edev=pci_dev_to_eeh_dev(dev);-structeeh_pe*pe=edev->pe;+structeeh_pe*pe=eeh_dev_to_pe(edev);if(!pe){pr_err("%s: No PE found on PCI device %s\n",