Re: [PATCH v2 1/4] ntb_hw_amd: Style fixes: open code macros that just obfuscate code
On Tue, Jan 10, 2017 at 05:33:36PM -0700, Logan Gunthorpe wrote: > As per a comments in [1] by Greg Kroah-Hartman, the ndev_* macros should > be cleaned up. This makes it more clear what's actually going on when > reading the code. > > [1] http://www.spinics.net/lists/linux-pci/msg56904.html > > Signed-off-by: Logan GunthorpeApplied to my ntb-next branch Thanks, Jon > --- > drivers/ntb/hw/amd/ntb_hw_amd.c | 59 > ++--- > drivers/ntb/hw/amd/ntb_hw_amd.h | 3 --- > 2 files changed, 31 insertions(+), 31 deletions(-) > > diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c > index 019a158..0135fcf 100644 > --- a/drivers/ntb/hw/amd/ntb_hw_amd.c > +++ b/drivers/ntb/hw/amd/ntb_hw_amd.c > @@ -98,10 +98,10 @@ static int amd_ntb_mw_get_range(struct ntb_dev *ntb, int > idx, > return bar; > > if (base) > - *base = pci_resource_start(ndev->ntb.pdev, bar); > + *base = pci_resource_start(ntb->pdev, bar); > > if (size) > - *size = pci_resource_len(ndev->ntb.pdev, bar); > + *size = pci_resource_len(ntb->pdev, bar); > > if (align) > *align = SZ_4K; > @@ -126,7 +126,7 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int > idx, > if (bar < 0) > return bar; > > - mw_size = pci_resource_len(ndev->ntb.pdev, bar); > + mw_size = pci_resource_len(ntb->pdev, bar); > > /* make sure the range fits in the usable mw size */ > if (size > mw_size) > @@ -135,7 +135,7 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int > idx, > mmio = ndev->self_mmio; > peer_mmio = ndev->peer_mmio; > > - base_addr = pci_resource_start(ndev->ntb.pdev, bar); > + base_addr = pci_resource_start(ntb->pdev, bar); > > if (bar != 1) { > xlat_reg = AMD_BAR23XLAT_OFFSET + ((bar - 2) << 2); > @@ -225,7 +225,7 @@ static int amd_ntb_link_is_up(struct ntb_dev *ntb, > if (width) > *width = NTB_LNK_STA_WIDTH(ndev->lnk_sta); > > - dev_dbg(ndev_dev(ndev), "link is up.\n"); > + dev_dbg(>pdev->dev, "link is up.\n"); > > ret = 1; > } else { > @@ -234,7 +234,7 @@ static int amd_ntb_link_is_up(struct ntb_dev *ntb, > if (width) > *width = NTB_WIDTH_NONE; > > - dev_dbg(ndev_dev(ndev), "link is down.\n"); > + dev_dbg(>pdev->dev, "link is down.\n"); > } > > return ret; > @@ -254,7 +254,7 @@ static int amd_ntb_link_enable(struct ntb_dev *ntb, > > if (ndev->ntb.topo == NTB_TOPO_SEC) > return -EINVAL; > - dev_dbg(ndev_dev(ndev), "Enabling Link.\n"); > + dev_dbg(>pdev->dev, "Enabling Link.\n"); > > ntb_ctl = readl(mmio + AMD_CNTL_OFFSET); > ntb_ctl |= (PMM_REG_CTL | SMM_REG_CTL); > @@ -275,7 +275,7 @@ static int amd_ntb_link_disable(struct ntb_dev *ntb) > > if (ndev->ntb.topo == NTB_TOPO_SEC) > return -EINVAL; > - dev_dbg(ndev_dev(ndev), "Enabling Link.\n"); > + dev_dbg(>pdev->dev, "Enabling Link.\n"); > > ntb_ctl = readl(mmio + AMD_CNTL_OFFSET); > ntb_ctl &= ~(PMM_REG_CTL | SMM_REG_CTL); > @@ -466,18 +466,19 @@ static void amd_ack_smu(struct amd_ntb_dev *ndev, u32 > bit) > static void amd_handle_event(struct amd_ntb_dev *ndev, int vec) > { > void __iomem *mmio = ndev->self_mmio; > + struct device *dev = >ntb.pdev->dev; > u32 status; > > status = readl(mmio + AMD_INTSTAT_OFFSET); > if (!(status & AMD_EVENT_INTMASK)) > return; > > - dev_dbg(ndev_dev(ndev), "status = 0x%x and vec = %d\n", status, vec); > + dev_dbg(dev, "status = 0x%x and vec = %d\n", status, vec); > > status &= AMD_EVENT_INTMASK; > switch (status) { > case AMD_PEER_FLUSH_EVENT: > - dev_info(ndev_dev(ndev), "Flush is done.\n"); > + dev_info(dev, "Flush is done.\n"); > break; > case AMD_PEER_RESET_EVENT: > amd_ack_smu(ndev, AMD_PEER_RESET_EVENT); > @@ -503,7 +504,7 @@ static void amd_handle_event(struct amd_ntb_dev *ndev, > int vec) > status = readl(mmio + AMD_PMESTAT_OFFSET); > /* check if this is WAKEUP event */ > if (status & 0x1) > - dev_info(ndev_dev(ndev), "Wakeup is done.\n"); > + dev_info(dev, "Wakeup is done.\n"); > > amd_ack_smu(ndev, AMD_PEER_D0_EVENT); > > @@ -512,14 +513,14 @@ static void amd_handle_event(struct amd_ntb_dev *ndev, > int vec) > AMD_LINK_HB_TIMEOUT); > break; > default: > - dev_info(ndev_dev(ndev), "event status = 0x%x.\n", status); > + dev_info(dev, "event status = 0x%x.\n", status); > break; > } > } > > static irqreturn_t
Re: [PATCH v2 1/4] ntb_hw_amd: Style fixes: open code macros that just obfuscate code
On Tue, Jan 10, 2017 at 05:33:36PM -0700, Logan Gunthorpe wrote: > As per a comments in [1] by Greg Kroah-Hartman, the ndev_* macros should > be cleaned up. This makes it more clear what's actually going on when > reading the code. > > [1] http://www.spinics.net/lists/linux-pci/msg56904.html > > Signed-off-by: Logan Gunthorpe Applied to my ntb-next branch Thanks, Jon > --- > drivers/ntb/hw/amd/ntb_hw_amd.c | 59 > ++--- > drivers/ntb/hw/amd/ntb_hw_amd.h | 3 --- > 2 files changed, 31 insertions(+), 31 deletions(-) > > diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c > index 019a158..0135fcf 100644 > --- a/drivers/ntb/hw/amd/ntb_hw_amd.c > +++ b/drivers/ntb/hw/amd/ntb_hw_amd.c > @@ -98,10 +98,10 @@ static int amd_ntb_mw_get_range(struct ntb_dev *ntb, int > idx, > return bar; > > if (base) > - *base = pci_resource_start(ndev->ntb.pdev, bar); > + *base = pci_resource_start(ntb->pdev, bar); > > if (size) > - *size = pci_resource_len(ndev->ntb.pdev, bar); > + *size = pci_resource_len(ntb->pdev, bar); > > if (align) > *align = SZ_4K; > @@ -126,7 +126,7 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int > idx, > if (bar < 0) > return bar; > > - mw_size = pci_resource_len(ndev->ntb.pdev, bar); > + mw_size = pci_resource_len(ntb->pdev, bar); > > /* make sure the range fits in the usable mw size */ > if (size > mw_size) > @@ -135,7 +135,7 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int > idx, > mmio = ndev->self_mmio; > peer_mmio = ndev->peer_mmio; > > - base_addr = pci_resource_start(ndev->ntb.pdev, bar); > + base_addr = pci_resource_start(ntb->pdev, bar); > > if (bar != 1) { > xlat_reg = AMD_BAR23XLAT_OFFSET + ((bar - 2) << 2); > @@ -225,7 +225,7 @@ static int amd_ntb_link_is_up(struct ntb_dev *ntb, > if (width) > *width = NTB_LNK_STA_WIDTH(ndev->lnk_sta); > > - dev_dbg(ndev_dev(ndev), "link is up.\n"); > + dev_dbg(>pdev->dev, "link is up.\n"); > > ret = 1; > } else { > @@ -234,7 +234,7 @@ static int amd_ntb_link_is_up(struct ntb_dev *ntb, > if (width) > *width = NTB_WIDTH_NONE; > > - dev_dbg(ndev_dev(ndev), "link is down.\n"); > + dev_dbg(>pdev->dev, "link is down.\n"); > } > > return ret; > @@ -254,7 +254,7 @@ static int amd_ntb_link_enable(struct ntb_dev *ntb, > > if (ndev->ntb.topo == NTB_TOPO_SEC) > return -EINVAL; > - dev_dbg(ndev_dev(ndev), "Enabling Link.\n"); > + dev_dbg(>pdev->dev, "Enabling Link.\n"); > > ntb_ctl = readl(mmio + AMD_CNTL_OFFSET); > ntb_ctl |= (PMM_REG_CTL | SMM_REG_CTL); > @@ -275,7 +275,7 @@ static int amd_ntb_link_disable(struct ntb_dev *ntb) > > if (ndev->ntb.topo == NTB_TOPO_SEC) > return -EINVAL; > - dev_dbg(ndev_dev(ndev), "Enabling Link.\n"); > + dev_dbg(>pdev->dev, "Enabling Link.\n"); > > ntb_ctl = readl(mmio + AMD_CNTL_OFFSET); > ntb_ctl &= ~(PMM_REG_CTL | SMM_REG_CTL); > @@ -466,18 +466,19 @@ static void amd_ack_smu(struct amd_ntb_dev *ndev, u32 > bit) > static void amd_handle_event(struct amd_ntb_dev *ndev, int vec) > { > void __iomem *mmio = ndev->self_mmio; > + struct device *dev = >ntb.pdev->dev; > u32 status; > > status = readl(mmio + AMD_INTSTAT_OFFSET); > if (!(status & AMD_EVENT_INTMASK)) > return; > > - dev_dbg(ndev_dev(ndev), "status = 0x%x and vec = %d\n", status, vec); > + dev_dbg(dev, "status = 0x%x and vec = %d\n", status, vec); > > status &= AMD_EVENT_INTMASK; > switch (status) { > case AMD_PEER_FLUSH_EVENT: > - dev_info(ndev_dev(ndev), "Flush is done.\n"); > + dev_info(dev, "Flush is done.\n"); > break; > case AMD_PEER_RESET_EVENT: > amd_ack_smu(ndev, AMD_PEER_RESET_EVENT); > @@ -503,7 +504,7 @@ static void amd_handle_event(struct amd_ntb_dev *ndev, > int vec) > status = readl(mmio + AMD_PMESTAT_OFFSET); > /* check if this is WAKEUP event */ > if (status & 0x1) > - dev_info(ndev_dev(ndev), "Wakeup is done.\n"); > + dev_info(dev, "Wakeup is done.\n"); > > amd_ack_smu(ndev, AMD_PEER_D0_EVENT); > > @@ -512,14 +513,14 @@ static void amd_handle_event(struct amd_ntb_dev *ndev, > int vec) > AMD_LINK_HB_TIMEOUT); > break; > default: > - dev_info(ndev_dev(ndev), "event status = 0x%x.\n", status); > + dev_info(dev, "event status = 0x%x.\n", status); > break; > } > } > > static irqreturn_t ndev_interrupt(struct
[PATCH v2 1/4] ntb_hw_amd: Style fixes: open code macros that just obfuscate code
As per a comments in [1] by Greg Kroah-Hartman, the ndev_* macros should be cleaned up. This makes it more clear what's actually going on when reading the code. [1] http://www.spinics.net/lists/linux-pci/msg56904.html Signed-off-by: Logan Gunthorpe--- drivers/ntb/hw/amd/ntb_hw_amd.c | 59 ++--- drivers/ntb/hw/amd/ntb_hw_amd.h | 3 --- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c index 019a158..0135fcf 100644 --- a/drivers/ntb/hw/amd/ntb_hw_amd.c +++ b/drivers/ntb/hw/amd/ntb_hw_amd.c @@ -98,10 +98,10 @@ static int amd_ntb_mw_get_range(struct ntb_dev *ntb, int idx, return bar; if (base) - *base = pci_resource_start(ndev->ntb.pdev, bar); + *base = pci_resource_start(ntb->pdev, bar); if (size) - *size = pci_resource_len(ndev->ntb.pdev, bar); + *size = pci_resource_len(ntb->pdev, bar); if (align) *align = SZ_4K; @@ -126,7 +126,7 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int idx, if (bar < 0) return bar; - mw_size = pci_resource_len(ndev->ntb.pdev, bar); + mw_size = pci_resource_len(ntb->pdev, bar); /* make sure the range fits in the usable mw size */ if (size > mw_size) @@ -135,7 +135,7 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int idx, mmio = ndev->self_mmio; peer_mmio = ndev->peer_mmio; - base_addr = pci_resource_start(ndev->ntb.pdev, bar); + base_addr = pci_resource_start(ntb->pdev, bar); if (bar != 1) { xlat_reg = AMD_BAR23XLAT_OFFSET + ((bar - 2) << 2); @@ -225,7 +225,7 @@ static int amd_ntb_link_is_up(struct ntb_dev *ntb, if (width) *width = NTB_LNK_STA_WIDTH(ndev->lnk_sta); - dev_dbg(ndev_dev(ndev), "link is up.\n"); + dev_dbg(>pdev->dev, "link is up.\n"); ret = 1; } else { @@ -234,7 +234,7 @@ static int amd_ntb_link_is_up(struct ntb_dev *ntb, if (width) *width = NTB_WIDTH_NONE; - dev_dbg(ndev_dev(ndev), "link is down.\n"); + dev_dbg(>pdev->dev, "link is down.\n"); } return ret; @@ -254,7 +254,7 @@ static int amd_ntb_link_enable(struct ntb_dev *ntb, if (ndev->ntb.topo == NTB_TOPO_SEC) return -EINVAL; - dev_dbg(ndev_dev(ndev), "Enabling Link.\n"); + dev_dbg(>pdev->dev, "Enabling Link.\n"); ntb_ctl = readl(mmio + AMD_CNTL_OFFSET); ntb_ctl |= (PMM_REG_CTL | SMM_REG_CTL); @@ -275,7 +275,7 @@ static int amd_ntb_link_disable(struct ntb_dev *ntb) if (ndev->ntb.topo == NTB_TOPO_SEC) return -EINVAL; - dev_dbg(ndev_dev(ndev), "Enabling Link.\n"); + dev_dbg(>pdev->dev, "Enabling Link.\n"); ntb_ctl = readl(mmio + AMD_CNTL_OFFSET); ntb_ctl &= ~(PMM_REG_CTL | SMM_REG_CTL); @@ -466,18 +466,19 @@ static void amd_ack_smu(struct amd_ntb_dev *ndev, u32 bit) static void amd_handle_event(struct amd_ntb_dev *ndev, int vec) { void __iomem *mmio = ndev->self_mmio; + struct device *dev = >ntb.pdev->dev; u32 status; status = readl(mmio + AMD_INTSTAT_OFFSET); if (!(status & AMD_EVENT_INTMASK)) return; - dev_dbg(ndev_dev(ndev), "status = 0x%x and vec = %d\n", status, vec); + dev_dbg(dev, "status = 0x%x and vec = %d\n", status, vec); status &= AMD_EVENT_INTMASK; switch (status) { case AMD_PEER_FLUSH_EVENT: - dev_info(ndev_dev(ndev), "Flush is done.\n"); + dev_info(dev, "Flush is done.\n"); break; case AMD_PEER_RESET_EVENT: amd_ack_smu(ndev, AMD_PEER_RESET_EVENT); @@ -503,7 +504,7 @@ static void amd_handle_event(struct amd_ntb_dev *ndev, int vec) status = readl(mmio + AMD_PMESTAT_OFFSET); /* check if this is WAKEUP event */ if (status & 0x1) - dev_info(ndev_dev(ndev), "Wakeup is done.\n"); + dev_info(dev, "Wakeup is done.\n"); amd_ack_smu(ndev, AMD_PEER_D0_EVENT); @@ -512,14 +513,14 @@ static void amd_handle_event(struct amd_ntb_dev *ndev, int vec) AMD_LINK_HB_TIMEOUT); break; default: - dev_info(ndev_dev(ndev), "event status = 0x%x.\n", status); + dev_info(dev, "event status = 0x%x.\n", status); break; } } static irqreturn_t ndev_interrupt(struct amd_ntb_dev *ndev, int vec) { - dev_dbg(ndev_dev(ndev), "vec %d\n", vec); + dev_dbg(>ntb.pdev->dev, "vec %d\n", vec); if (vec > (AMD_DB_CNT - 1) || (ndev->msix_vec_count == 1))
[PATCH v2 1/4] ntb_hw_amd: Style fixes: open code macros that just obfuscate code
As per a comments in [1] by Greg Kroah-Hartman, the ndev_* macros should be cleaned up. This makes it more clear what's actually going on when reading the code. [1] http://www.spinics.net/lists/linux-pci/msg56904.html Signed-off-by: Logan Gunthorpe --- drivers/ntb/hw/amd/ntb_hw_amd.c | 59 ++--- drivers/ntb/hw/amd/ntb_hw_amd.h | 3 --- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c index 019a158..0135fcf 100644 --- a/drivers/ntb/hw/amd/ntb_hw_amd.c +++ b/drivers/ntb/hw/amd/ntb_hw_amd.c @@ -98,10 +98,10 @@ static int amd_ntb_mw_get_range(struct ntb_dev *ntb, int idx, return bar; if (base) - *base = pci_resource_start(ndev->ntb.pdev, bar); + *base = pci_resource_start(ntb->pdev, bar); if (size) - *size = pci_resource_len(ndev->ntb.pdev, bar); + *size = pci_resource_len(ntb->pdev, bar); if (align) *align = SZ_4K; @@ -126,7 +126,7 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int idx, if (bar < 0) return bar; - mw_size = pci_resource_len(ndev->ntb.pdev, bar); + mw_size = pci_resource_len(ntb->pdev, bar); /* make sure the range fits in the usable mw size */ if (size > mw_size) @@ -135,7 +135,7 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int idx, mmio = ndev->self_mmio; peer_mmio = ndev->peer_mmio; - base_addr = pci_resource_start(ndev->ntb.pdev, bar); + base_addr = pci_resource_start(ntb->pdev, bar); if (bar != 1) { xlat_reg = AMD_BAR23XLAT_OFFSET + ((bar - 2) << 2); @@ -225,7 +225,7 @@ static int amd_ntb_link_is_up(struct ntb_dev *ntb, if (width) *width = NTB_LNK_STA_WIDTH(ndev->lnk_sta); - dev_dbg(ndev_dev(ndev), "link is up.\n"); + dev_dbg(>pdev->dev, "link is up.\n"); ret = 1; } else { @@ -234,7 +234,7 @@ static int amd_ntb_link_is_up(struct ntb_dev *ntb, if (width) *width = NTB_WIDTH_NONE; - dev_dbg(ndev_dev(ndev), "link is down.\n"); + dev_dbg(>pdev->dev, "link is down.\n"); } return ret; @@ -254,7 +254,7 @@ static int amd_ntb_link_enable(struct ntb_dev *ntb, if (ndev->ntb.topo == NTB_TOPO_SEC) return -EINVAL; - dev_dbg(ndev_dev(ndev), "Enabling Link.\n"); + dev_dbg(>pdev->dev, "Enabling Link.\n"); ntb_ctl = readl(mmio + AMD_CNTL_OFFSET); ntb_ctl |= (PMM_REG_CTL | SMM_REG_CTL); @@ -275,7 +275,7 @@ static int amd_ntb_link_disable(struct ntb_dev *ntb) if (ndev->ntb.topo == NTB_TOPO_SEC) return -EINVAL; - dev_dbg(ndev_dev(ndev), "Enabling Link.\n"); + dev_dbg(>pdev->dev, "Enabling Link.\n"); ntb_ctl = readl(mmio + AMD_CNTL_OFFSET); ntb_ctl &= ~(PMM_REG_CTL | SMM_REG_CTL); @@ -466,18 +466,19 @@ static void amd_ack_smu(struct amd_ntb_dev *ndev, u32 bit) static void amd_handle_event(struct amd_ntb_dev *ndev, int vec) { void __iomem *mmio = ndev->self_mmio; + struct device *dev = >ntb.pdev->dev; u32 status; status = readl(mmio + AMD_INTSTAT_OFFSET); if (!(status & AMD_EVENT_INTMASK)) return; - dev_dbg(ndev_dev(ndev), "status = 0x%x and vec = %d\n", status, vec); + dev_dbg(dev, "status = 0x%x and vec = %d\n", status, vec); status &= AMD_EVENT_INTMASK; switch (status) { case AMD_PEER_FLUSH_EVENT: - dev_info(ndev_dev(ndev), "Flush is done.\n"); + dev_info(dev, "Flush is done.\n"); break; case AMD_PEER_RESET_EVENT: amd_ack_smu(ndev, AMD_PEER_RESET_EVENT); @@ -503,7 +504,7 @@ static void amd_handle_event(struct amd_ntb_dev *ndev, int vec) status = readl(mmio + AMD_PMESTAT_OFFSET); /* check if this is WAKEUP event */ if (status & 0x1) - dev_info(ndev_dev(ndev), "Wakeup is done.\n"); + dev_info(dev, "Wakeup is done.\n"); amd_ack_smu(ndev, AMD_PEER_D0_EVENT); @@ -512,14 +513,14 @@ static void amd_handle_event(struct amd_ntb_dev *ndev, int vec) AMD_LINK_HB_TIMEOUT); break; default: - dev_info(ndev_dev(ndev), "event status = 0x%x.\n", status); + dev_info(dev, "event status = 0x%x.\n", status); break; } } static irqreturn_t ndev_interrupt(struct amd_ntb_dev *ndev, int vec) { - dev_dbg(ndev_dev(ndev), "vec %d\n", vec); + dev_dbg(>ntb.pdev->dev, "vec %d\n", vec); if (vec > (AMD_DB_CNT - 1) || (ndev->msix_vec_count == 1))