* [PATCH 1/2] powerpc/powernv: Simplify definitions of EEH debugfs handlers
@ 2016-02-08 5:35 Gavin Shan
2016-02-08 5:35 ` [PATCH 2/2] powerpc/eeh: Reworked eeh_pe_bus_get() Gavin Shan
0 siblings, 1 reply; 4+ messages in thread
From: Gavin Shan @ 2016-02-08 5:35 UTC (permalink / raw)
To: linuxppc-dev; +Cc: mpe, Gavin Shan
The EEH debugfs handlers have same prototype. This introduces
a macro to define them, then to simplify the code. No logical
changes.
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
arch/powerpc/platforms/powernv/eeh-powernv.c | 60 ++++++++++------------------
1 file changed, 22 insertions(+), 38 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/powerpc/platforms/powernv/eeh-powernv.c
index 5f152b9..3f1cb35 100644
--- a/arch/powerpc/platforms/powernv/eeh-powernv.c
+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c
@@ -167,42 +167,26 @@ static int pnv_eeh_dbgfs_get(void *data, int offset, u64 *val)
return 0;
}
-static int pnv_eeh_outb_dbgfs_set(void *data, u64 val)
-{
- return pnv_eeh_dbgfs_set(data, 0xD10, val);
-}
-
-static int pnv_eeh_outb_dbgfs_get(void *data, u64 *val)
-{
- return pnv_eeh_dbgfs_get(data, 0xD10, val);
-}
-
-static int pnv_eeh_inbA_dbgfs_set(void *data, u64 val)
-{
- return pnv_eeh_dbgfs_set(data, 0xD90, val);
-}
-
-static int pnv_eeh_inbA_dbgfs_get(void *data, u64 *val)
-{
- return pnv_eeh_dbgfs_get(data, 0xD90, val);
-}
-
-static int pnv_eeh_inbB_dbgfs_set(void *data, u64 val)
-{
- return pnv_eeh_dbgfs_set(data, 0xE10, val);
-}
-
-static int pnv_eeh_inbB_dbgfs_get(void *data, u64 *val)
-{
- return pnv_eeh_dbgfs_get(data, 0xE10, val);
-}
+#define PNV_EEH_DBGFS_ENTRY(name, reg) \
+static int pnv_eeh_dbgfs_set_##name(void *data, u64 val) \
+{ \
+ return pnv_eeh_dbgfs_set(data, reg, val); \
+} \
+ \
+static int pnv_eeh_dbgfs_get_##name(void *data, u64 *val) \
+{ \
+ return pnv_eeh_dbgfs_get(data, reg, val); \
+} \
+ \
+DEFINE_SIMPLE_ATTRIBUTE(pnv_eeh_dbgfs_ops_##name, \
+ pnv_eeh_dbgfs_get_##name, \
+ pnv_eeh_dbgfs_set_##name, \
+ "0x%llx\n")
+
+PNV_EEH_DBGFS_ENTRY(outb, 0xD10);
+PNV_EEH_DBGFS_ENTRY(inbA, 0xD90);
+PNV_EEH_DBGFS_ENTRY(inbB, 0xE10);
-DEFINE_SIMPLE_ATTRIBUTE(pnv_eeh_outb_dbgfs_ops, pnv_eeh_outb_dbgfs_get,
- pnv_eeh_outb_dbgfs_set, "0x%llx\n");
-DEFINE_SIMPLE_ATTRIBUTE(pnv_eeh_inbA_dbgfs_ops, pnv_eeh_inbA_dbgfs_get,
- pnv_eeh_inbA_dbgfs_set, "0x%llx\n");
-DEFINE_SIMPLE_ATTRIBUTE(pnv_eeh_inbB_dbgfs_ops, pnv_eeh_inbB_dbgfs_get,
- pnv_eeh_inbB_dbgfs_set, "0x%llx\n");
#endif /* CONFIG_DEBUG_FS */
/**
@@ -268,13 +252,13 @@ static int pnv_eeh_post_init(void)
debugfs_create_file("err_injct_outbound", 0600,
phb->dbgfs, hose,
- &pnv_eeh_outb_dbgfs_ops);
+ &pnv_eeh_dbgfs_ops_outb);
debugfs_create_file("err_injct_inboundA", 0600,
phb->dbgfs, hose,
- &pnv_eeh_inbA_dbgfs_ops);
+ &pnv_eeh_dbgfs_ops_inbA);
debugfs_create_file("err_injct_inboundB", 0600,
phb->dbgfs, hose,
- &pnv_eeh_inbB_dbgfs_ops);
+ &pnv_eeh_dbgfs_ops_inbB);
#endif /* CONFIG_DEBUG_FS */
}
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] powerpc/eeh: Reworked eeh_pe_bus_get()
2016-02-08 5:35 [PATCH 1/2] powerpc/powernv: Simplify definitions of EEH debugfs handlers Gavin Shan
@ 2016-02-08 5:35 ` Gavin Shan
2016-02-08 5:55 ` Andrew Donnellan
2016-02-08 22:40 ` Gavin Shan
0 siblings, 2 replies; 4+ messages in thread
From: Gavin Shan @ 2016-02-08 5:35 UTC (permalink / raw)
To: linuxppc-dev; +Cc: mpe, Gavin Shan
The original implementation is ugly: unnecessary if statements and
"out" tag. This reworks the function to avoid above weaknesses. No
functional changes introduced.
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
arch/powerpc/kernel/eeh_pe.c | 28 ++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
index 8654cb1..1d64e60 100644
--- a/arch/powerpc/kernel/eeh_pe.c
+++ b/arch/powerpc/kernel/eeh_pe.c
@@ -923,25 +923,21 @@ out:
*/
struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe)
{
- struct pci_bus *bus = NULL;
struct eeh_dev *edev;
struct pci_dev *pdev;
- if (pe->type & EEH_PE_PHB) {
- bus = pe->phb->bus;
- } else if (pe->type & EEH_PE_BUS ||
- pe->type & EEH_PE_DEVICE) {
- if (pe->bus) {
- bus = pe->bus;
- goto out;
- }
+ if (pe->type & EEH_PE_PHB)
+ return pe->phb->bus;
- edev = list_first_entry(&pe->edevs, struct eeh_dev, list);
- pdev = eeh_dev_to_pci_dev(edev);
- if (pdev)
- bus = pdev->bus;
- }
+ /* The primary bus might be cached during probe time */
+ if (pe->bus)
+ return pe->bus;
-out:
- return bus;
+ /* Retrieve the parent PCI bus of first (top) PCI device */
+ edev = list_first_entry_or_null(&pe->edevs, struct eeh_dev, list);
+ pdev = eeh_dev_to_pci_dev(edev);
+ if (pdev)
+ return pdev->bus;
+
+ return NULL;
}
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] powerpc/eeh: Reworked eeh_pe_bus_get()
2016-02-08 5:35 ` [PATCH 2/2] powerpc/eeh: Reworked eeh_pe_bus_get() Gavin Shan
@ 2016-02-08 5:55 ` Andrew Donnellan
2016-02-08 22:40 ` Gavin Shan
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Donnellan @ 2016-02-08 5:55 UTC (permalink / raw)
To: Gavin Shan, linuxppc-dev
On 08/02/16 16:35, Gavin Shan wrote:
> The original implementation is ugly: unnecessary if statements and
> "out" tag. This reworks the function to avoid above weaknesses. No
> functional changes introduced.
>
> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
This is definitely a lot nicer to read and doesn't appear to have any
functional changes.
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
--
Andrew Donnellan Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com Australia Development Lab, Canberra
+61 2 6201 8874 (work) IBM Australia Limited
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] powerpc/eeh: Reworked eeh_pe_bus_get()
2016-02-08 5:35 ` [PATCH 2/2] powerpc/eeh: Reworked eeh_pe_bus_get() Gavin Shan
2016-02-08 5:55 ` Andrew Donnellan
@ 2016-02-08 22:40 ` Gavin Shan
1 sibling, 0 replies; 4+ messages in thread
From: Gavin Shan @ 2016-02-08 22:40 UTC (permalink / raw)
To: Gavin Shan; +Cc: linuxppc-dev, mpe
On Mon, Feb 08, 2016 at 04:35:19PM +1100, Gavin Shan wrote:
>The original implementation is ugly: unnecessary if statements and
>"out" tag. This reworks the function to avoid above weaknesses. No
>functional changes introduced.
>
>Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Michael, please ignore this one now because it conflicts with another
patch which needs to be ported to stable. I'll repost all of them
later.
Thanks,
Gavin
>---
> arch/powerpc/kernel/eeh_pe.c | 28 ++++++++++++----------------
> 1 file changed, 12 insertions(+), 16 deletions(-)
>
>diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
>index 8654cb1..1d64e60 100644
>--- a/arch/powerpc/kernel/eeh_pe.c
>+++ b/arch/powerpc/kernel/eeh_pe.c
>@@ -923,25 +923,21 @@ out:
> */
> struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe)
> {
>- struct pci_bus *bus = NULL;
> struct eeh_dev *edev;
> struct pci_dev *pdev;
>
>- if (pe->type & EEH_PE_PHB) {
>- bus = pe->phb->bus;
>- } else if (pe->type & EEH_PE_BUS ||
>- pe->type & EEH_PE_DEVICE) {
>- if (pe->bus) {
>- bus = pe->bus;
>- goto out;
>- }
>+ if (pe->type & EEH_PE_PHB)
>+ return pe->phb->bus;
>
>- edev = list_first_entry(&pe->edevs, struct eeh_dev, list);
>- pdev = eeh_dev_to_pci_dev(edev);
>- if (pdev)
>- bus = pdev->bus;
>- }
>+ /* The primary bus might be cached during probe time */
>+ if (pe->bus)
>+ return pe->bus;
>
>-out:
>- return bus;
>+ /* Retrieve the parent PCI bus of first (top) PCI device */
>+ edev = list_first_entry_or_null(&pe->edevs, struct eeh_dev, list);
>+ pdev = eeh_dev_to_pci_dev(edev);
>+ if (pdev)
>+ return pdev->bus;
>+
>+ return NULL;
> }
>--
>2.1.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-08 22:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-08 5:35 [PATCH 1/2] powerpc/powernv: Simplify definitions of EEH debugfs handlers Gavin Shan
2016-02-08 5:35 ` [PATCH 2/2] powerpc/eeh: Reworked eeh_pe_bus_get() Gavin Shan
2016-02-08 5:55 ` Andrew Donnellan
2016-02-08 22:40 ` Gavin Shan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).