Re: [PATCH v2 2/4] ntb_hw_intel: Style fixes: open code macros that just obfuscate code
On Tue, Jan 10, 2017 at 05:33:37PM -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/intel/ntb_hw_intel.c | 192 > ++-- > drivers/ntb/hw/intel/ntb_hw_intel.h | 3 - > 2 files changed, 95 insertions(+), 100 deletions(-) > > diff --git a/drivers/ntb/hw/intel/ntb_hw_intel.c > b/drivers/ntb/hw/intel/ntb_hw_intel.c > index eca9688..6456f54 100644 > --- a/drivers/ntb/hw/intel/ntb_hw_intel.c > +++ b/drivers/ntb/hw/intel/ntb_hw_intel.c > @@ -270,12 +270,12 @@ static inline int ndev_db_addr(struct intel_ntb_dev > *ndev, > > if (db_addr) { > *db_addr = reg_addr + reg; > - dev_dbg(ndev_dev(ndev), "Peer db addr %llx\n", *db_addr); > + dev_dbg(>ntb.pdev->dev, "Peer db addr %llx\n", *db_addr); > } > > if (db_size) { > *db_size = ndev->reg->db_size; > - dev_dbg(ndev_dev(ndev), "Peer db size %llx\n", *db_size); > + dev_dbg(>ntb.pdev->dev, "Peer db size %llx\n", *db_size); > } > > return 0; > @@ -368,7 +368,8 @@ static inline int ndev_spad_addr(struct intel_ntb_dev > *ndev, int idx, > > if (spad_addr) { > *spad_addr = reg_addr + reg + (idx << 2); > - dev_dbg(ndev_dev(ndev), "Peer spad addr %llx\n", *spad_addr); > + dev_dbg(>ntb.pdev->dev, "Peer spad addr %llx\n", > + *spad_addr); > } > > return 0; > @@ -409,7 +410,7 @@ static irqreturn_t ndev_interrupt(struct intel_ntb_dev > *ndev, int vec) > if ((ndev->hwerr_flags & NTB_HWERR_MSIX_VECTOR32_BAD) && (vec == 31)) > vec_mask |= ndev->db_link_mask; > > - dev_dbg(ndev_dev(ndev), "vec %d vec_mask %llx\n", vec, vec_mask); > + dev_dbg(>ntb.pdev->dev, "vec %d vec_mask %llx\n", vec, vec_mask); > > ndev->last_ts = jiffies; > > @@ -428,7 +429,7 @@ static irqreturn_t ndev_vec_isr(int irq, void *dev) > { > struct intel_ntb_vec *nvec = dev; > > - dev_dbg(ndev_dev(nvec->ndev), "irq: %d nvec->num: %d\n", > + dev_dbg(>ndev->ntb.pdev->dev, "irq: %d nvec->num: %d\n", > irq, nvec->num); > > return ndev_interrupt(nvec->ndev, nvec->num); > @@ -438,7 +439,7 @@ static irqreturn_t ndev_irq_isr(int irq, void *dev) > { > struct intel_ntb_dev *ndev = dev; > > - return ndev_interrupt(ndev, irq - ndev_pdev(ndev)->irq); > + return ndev_interrupt(ndev, irq - ndev->ntb.pdev->irq); > } > > static int ndev_init_isr(struct intel_ntb_dev *ndev, > @@ -448,7 +449,7 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev, > struct pci_dev *pdev; > int rc, i, msix_count, node; > > - pdev = ndev_pdev(ndev); > + pdev = ndev->ntb.pdev; > > node = dev_to_node(>dev); > > @@ -487,7 +488,7 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev, > goto err_msix_request; > } > > - dev_dbg(ndev_dev(ndev), "Using %d msix interrupts\n", msix_count); > + dev_dbg(>dev, "Using %d msix interrupts\n", msix_count); > ndev->db_vec_count = msix_count; > ndev->db_vec_shift = msix_shift; > return 0; > @@ -515,7 +516,7 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev, > if (rc) > goto err_msi_request; > > - dev_dbg(ndev_dev(ndev), "Using msi interrupts\n"); > + dev_dbg(>dev, "Using msi interrupts\n"); > ndev->db_vec_count = 1; > ndev->db_vec_shift = total_shift; > return 0; > @@ -533,7 +534,7 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev, > if (rc) > goto err_intx_request; > > - dev_dbg(ndev_dev(ndev), "Using intx interrupts\n"); > + dev_dbg(>dev, "Using intx interrupts\n"); > ndev->db_vec_count = 1; > ndev->db_vec_shift = total_shift; > return 0; > @@ -547,7 +548,7 @@ static void ndev_deinit_isr(struct intel_ntb_dev *ndev) > struct pci_dev *pdev; > int i; > > - pdev = ndev_pdev(ndev); > + pdev = ndev->ntb.pdev; > > /* Mask all doorbell interrupts */ > ndev->db_mask = ndev->db_valid_mask; > @@ -744,7 +745,7 @@ static ssize_t ndev_ntb_debugfs_read(struct file *filp, > char __user *ubuf, > union { u64 v64; u32 v32; u16 v16; u8 v8; } u; > > ndev = filp->private_data; > - pdev = ndev_pdev(ndev); > + pdev = ndev->ntb.pdev; > mmio = ndev->self_mmio; > > buf_size = min(count, 0x800ul); > @@ -1019,7 +1020,8 @@ static void ndev_init_debugfs(struct intel_ntb_dev > *ndev) > ndev->debugfs_info = NULL; > } else { > ndev->debugfs_dir = > -
Re: [PATCH v2 2/4] ntb_hw_intel: Style fixes: open code macros that just obfuscate code
On Tue, Jan 10, 2017 at 05:33:37PM -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/intel/ntb_hw_intel.c | 192 > ++-- > drivers/ntb/hw/intel/ntb_hw_intel.h | 3 - > 2 files changed, 95 insertions(+), 100 deletions(-) > > diff --git a/drivers/ntb/hw/intel/ntb_hw_intel.c > b/drivers/ntb/hw/intel/ntb_hw_intel.c > index eca9688..6456f54 100644 > --- a/drivers/ntb/hw/intel/ntb_hw_intel.c > +++ b/drivers/ntb/hw/intel/ntb_hw_intel.c > @@ -270,12 +270,12 @@ static inline int ndev_db_addr(struct intel_ntb_dev > *ndev, > > if (db_addr) { > *db_addr = reg_addr + reg; > - dev_dbg(ndev_dev(ndev), "Peer db addr %llx\n", *db_addr); > + dev_dbg(>ntb.pdev->dev, "Peer db addr %llx\n", *db_addr); > } > > if (db_size) { > *db_size = ndev->reg->db_size; > - dev_dbg(ndev_dev(ndev), "Peer db size %llx\n", *db_size); > + dev_dbg(>ntb.pdev->dev, "Peer db size %llx\n", *db_size); > } > > return 0; > @@ -368,7 +368,8 @@ static inline int ndev_spad_addr(struct intel_ntb_dev > *ndev, int idx, > > if (spad_addr) { > *spad_addr = reg_addr + reg + (idx << 2); > - dev_dbg(ndev_dev(ndev), "Peer spad addr %llx\n", *spad_addr); > + dev_dbg(>ntb.pdev->dev, "Peer spad addr %llx\n", > + *spad_addr); > } > > return 0; > @@ -409,7 +410,7 @@ static irqreturn_t ndev_interrupt(struct intel_ntb_dev > *ndev, int vec) > if ((ndev->hwerr_flags & NTB_HWERR_MSIX_VECTOR32_BAD) && (vec == 31)) > vec_mask |= ndev->db_link_mask; > > - dev_dbg(ndev_dev(ndev), "vec %d vec_mask %llx\n", vec, vec_mask); > + dev_dbg(>ntb.pdev->dev, "vec %d vec_mask %llx\n", vec, vec_mask); > > ndev->last_ts = jiffies; > > @@ -428,7 +429,7 @@ static irqreturn_t ndev_vec_isr(int irq, void *dev) > { > struct intel_ntb_vec *nvec = dev; > > - dev_dbg(ndev_dev(nvec->ndev), "irq: %d nvec->num: %d\n", > + dev_dbg(>ndev->ntb.pdev->dev, "irq: %d nvec->num: %d\n", > irq, nvec->num); > > return ndev_interrupt(nvec->ndev, nvec->num); > @@ -438,7 +439,7 @@ static irqreturn_t ndev_irq_isr(int irq, void *dev) > { > struct intel_ntb_dev *ndev = dev; > > - return ndev_interrupt(ndev, irq - ndev_pdev(ndev)->irq); > + return ndev_interrupt(ndev, irq - ndev->ntb.pdev->irq); > } > > static int ndev_init_isr(struct intel_ntb_dev *ndev, > @@ -448,7 +449,7 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev, > struct pci_dev *pdev; > int rc, i, msix_count, node; > > - pdev = ndev_pdev(ndev); > + pdev = ndev->ntb.pdev; > > node = dev_to_node(>dev); > > @@ -487,7 +488,7 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev, > goto err_msix_request; > } > > - dev_dbg(ndev_dev(ndev), "Using %d msix interrupts\n", msix_count); > + dev_dbg(>dev, "Using %d msix interrupts\n", msix_count); > ndev->db_vec_count = msix_count; > ndev->db_vec_shift = msix_shift; > return 0; > @@ -515,7 +516,7 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev, > if (rc) > goto err_msi_request; > > - dev_dbg(ndev_dev(ndev), "Using msi interrupts\n"); > + dev_dbg(>dev, "Using msi interrupts\n"); > ndev->db_vec_count = 1; > ndev->db_vec_shift = total_shift; > return 0; > @@ -533,7 +534,7 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev, > if (rc) > goto err_intx_request; > > - dev_dbg(ndev_dev(ndev), "Using intx interrupts\n"); > + dev_dbg(>dev, "Using intx interrupts\n"); > ndev->db_vec_count = 1; > ndev->db_vec_shift = total_shift; > return 0; > @@ -547,7 +548,7 @@ static void ndev_deinit_isr(struct intel_ntb_dev *ndev) > struct pci_dev *pdev; > int i; > > - pdev = ndev_pdev(ndev); > + pdev = ndev->ntb.pdev; > > /* Mask all doorbell interrupts */ > ndev->db_mask = ndev->db_valid_mask; > @@ -744,7 +745,7 @@ static ssize_t ndev_ntb_debugfs_read(struct file *filp, > char __user *ubuf, > union { u64 v64; u32 v32; u16 v16; u8 v8; } u; > > ndev = filp->private_data; > - pdev = ndev_pdev(ndev); > + pdev = ndev->ntb.pdev; > mmio = ndev->self_mmio; > > buf_size = min(count, 0x800ul); > @@ -1019,7 +1020,8 @@ static void ndev_init_debugfs(struct intel_ntb_dev > *ndev) > ndev->debugfs_info = NULL; > } else { > ndev->debugfs_dir = > - debugfs_create_dir(ndev_name(ndev), debugfs_dir); > +
[PATCH v2 2/4] ntb_hw_intel: 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/intel/ntb_hw_intel.c | 192 ++-- drivers/ntb/hw/intel/ntb_hw_intel.h | 3 - 2 files changed, 95 insertions(+), 100 deletions(-) diff --git a/drivers/ntb/hw/intel/ntb_hw_intel.c b/drivers/ntb/hw/intel/ntb_hw_intel.c index eca9688..6456f54 100644 --- a/drivers/ntb/hw/intel/ntb_hw_intel.c +++ b/drivers/ntb/hw/intel/ntb_hw_intel.c @@ -270,12 +270,12 @@ static inline int ndev_db_addr(struct intel_ntb_dev *ndev, if (db_addr) { *db_addr = reg_addr + reg; - dev_dbg(ndev_dev(ndev), "Peer db addr %llx\n", *db_addr); + dev_dbg(>ntb.pdev->dev, "Peer db addr %llx\n", *db_addr); } if (db_size) { *db_size = ndev->reg->db_size; - dev_dbg(ndev_dev(ndev), "Peer db size %llx\n", *db_size); + dev_dbg(>ntb.pdev->dev, "Peer db size %llx\n", *db_size); } return 0; @@ -368,7 +368,8 @@ static inline int ndev_spad_addr(struct intel_ntb_dev *ndev, int idx, if (spad_addr) { *spad_addr = reg_addr + reg + (idx << 2); - dev_dbg(ndev_dev(ndev), "Peer spad addr %llx\n", *spad_addr); + dev_dbg(>ntb.pdev->dev, "Peer spad addr %llx\n", + *spad_addr); } return 0; @@ -409,7 +410,7 @@ static irqreturn_t ndev_interrupt(struct intel_ntb_dev *ndev, int vec) if ((ndev->hwerr_flags & NTB_HWERR_MSIX_VECTOR32_BAD) && (vec == 31)) vec_mask |= ndev->db_link_mask; - dev_dbg(ndev_dev(ndev), "vec %d vec_mask %llx\n", vec, vec_mask); + dev_dbg(>ntb.pdev->dev, "vec %d vec_mask %llx\n", vec, vec_mask); ndev->last_ts = jiffies; @@ -428,7 +429,7 @@ static irqreturn_t ndev_vec_isr(int irq, void *dev) { struct intel_ntb_vec *nvec = dev; - dev_dbg(ndev_dev(nvec->ndev), "irq: %d nvec->num: %d\n", + dev_dbg(>ndev->ntb.pdev->dev, "irq: %d nvec->num: %d\n", irq, nvec->num); return ndev_interrupt(nvec->ndev, nvec->num); @@ -438,7 +439,7 @@ static irqreturn_t ndev_irq_isr(int irq, void *dev) { struct intel_ntb_dev *ndev = dev; - return ndev_interrupt(ndev, irq - ndev_pdev(ndev)->irq); + return ndev_interrupt(ndev, irq - ndev->ntb.pdev->irq); } static int ndev_init_isr(struct intel_ntb_dev *ndev, @@ -448,7 +449,7 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev, struct pci_dev *pdev; int rc, i, msix_count, node; - pdev = ndev_pdev(ndev); + pdev = ndev->ntb.pdev; node = dev_to_node(>dev); @@ -487,7 +488,7 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev, goto err_msix_request; } - dev_dbg(ndev_dev(ndev), "Using %d msix interrupts\n", msix_count); + dev_dbg(>dev, "Using %d msix interrupts\n", msix_count); ndev->db_vec_count = msix_count; ndev->db_vec_shift = msix_shift; return 0; @@ -515,7 +516,7 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev, if (rc) goto err_msi_request; - dev_dbg(ndev_dev(ndev), "Using msi interrupts\n"); + dev_dbg(>dev, "Using msi interrupts\n"); ndev->db_vec_count = 1; ndev->db_vec_shift = total_shift; return 0; @@ -533,7 +534,7 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev, if (rc) goto err_intx_request; - dev_dbg(ndev_dev(ndev), "Using intx interrupts\n"); + dev_dbg(>dev, "Using intx interrupts\n"); ndev->db_vec_count = 1; ndev->db_vec_shift = total_shift; return 0; @@ -547,7 +548,7 @@ static void ndev_deinit_isr(struct intel_ntb_dev *ndev) struct pci_dev *pdev; int i; - pdev = ndev_pdev(ndev); + pdev = ndev->ntb.pdev; /* Mask all doorbell interrupts */ ndev->db_mask = ndev->db_valid_mask; @@ -744,7 +745,7 @@ static ssize_t ndev_ntb_debugfs_read(struct file *filp, char __user *ubuf, union { u64 v64; u32 v32; u16 v16; u8 v8; } u; ndev = filp->private_data; - pdev = ndev_pdev(ndev); + pdev = ndev->ntb.pdev; mmio = ndev->self_mmio; buf_size = min(count, 0x800ul); @@ -1019,7 +1020,8 @@ static void ndev_init_debugfs(struct intel_ntb_dev *ndev) ndev->debugfs_info = NULL; } else { ndev->debugfs_dir = - debugfs_create_dir(ndev_name(ndev), debugfs_dir); + debugfs_create_dir(pci_name(ndev->ntb.pdev), + debugfs_dir); if (!ndev->debugfs_dir) ndev->debugfs_info = NULL;
[PATCH v2 2/4] ntb_hw_intel: 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/intel/ntb_hw_intel.c | 192 ++-- drivers/ntb/hw/intel/ntb_hw_intel.h | 3 - 2 files changed, 95 insertions(+), 100 deletions(-) diff --git a/drivers/ntb/hw/intel/ntb_hw_intel.c b/drivers/ntb/hw/intel/ntb_hw_intel.c index eca9688..6456f54 100644 --- a/drivers/ntb/hw/intel/ntb_hw_intel.c +++ b/drivers/ntb/hw/intel/ntb_hw_intel.c @@ -270,12 +270,12 @@ static inline int ndev_db_addr(struct intel_ntb_dev *ndev, if (db_addr) { *db_addr = reg_addr + reg; - dev_dbg(ndev_dev(ndev), "Peer db addr %llx\n", *db_addr); + dev_dbg(>ntb.pdev->dev, "Peer db addr %llx\n", *db_addr); } if (db_size) { *db_size = ndev->reg->db_size; - dev_dbg(ndev_dev(ndev), "Peer db size %llx\n", *db_size); + dev_dbg(>ntb.pdev->dev, "Peer db size %llx\n", *db_size); } return 0; @@ -368,7 +368,8 @@ static inline int ndev_spad_addr(struct intel_ntb_dev *ndev, int idx, if (spad_addr) { *spad_addr = reg_addr + reg + (idx << 2); - dev_dbg(ndev_dev(ndev), "Peer spad addr %llx\n", *spad_addr); + dev_dbg(>ntb.pdev->dev, "Peer spad addr %llx\n", + *spad_addr); } return 0; @@ -409,7 +410,7 @@ static irqreturn_t ndev_interrupt(struct intel_ntb_dev *ndev, int vec) if ((ndev->hwerr_flags & NTB_HWERR_MSIX_VECTOR32_BAD) && (vec == 31)) vec_mask |= ndev->db_link_mask; - dev_dbg(ndev_dev(ndev), "vec %d vec_mask %llx\n", vec, vec_mask); + dev_dbg(>ntb.pdev->dev, "vec %d vec_mask %llx\n", vec, vec_mask); ndev->last_ts = jiffies; @@ -428,7 +429,7 @@ static irqreturn_t ndev_vec_isr(int irq, void *dev) { struct intel_ntb_vec *nvec = dev; - dev_dbg(ndev_dev(nvec->ndev), "irq: %d nvec->num: %d\n", + dev_dbg(>ndev->ntb.pdev->dev, "irq: %d nvec->num: %d\n", irq, nvec->num); return ndev_interrupt(nvec->ndev, nvec->num); @@ -438,7 +439,7 @@ static irqreturn_t ndev_irq_isr(int irq, void *dev) { struct intel_ntb_dev *ndev = dev; - return ndev_interrupt(ndev, irq - ndev_pdev(ndev)->irq); + return ndev_interrupt(ndev, irq - ndev->ntb.pdev->irq); } static int ndev_init_isr(struct intel_ntb_dev *ndev, @@ -448,7 +449,7 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev, struct pci_dev *pdev; int rc, i, msix_count, node; - pdev = ndev_pdev(ndev); + pdev = ndev->ntb.pdev; node = dev_to_node(>dev); @@ -487,7 +488,7 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev, goto err_msix_request; } - dev_dbg(ndev_dev(ndev), "Using %d msix interrupts\n", msix_count); + dev_dbg(>dev, "Using %d msix interrupts\n", msix_count); ndev->db_vec_count = msix_count; ndev->db_vec_shift = msix_shift; return 0; @@ -515,7 +516,7 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev, if (rc) goto err_msi_request; - dev_dbg(ndev_dev(ndev), "Using msi interrupts\n"); + dev_dbg(>dev, "Using msi interrupts\n"); ndev->db_vec_count = 1; ndev->db_vec_shift = total_shift; return 0; @@ -533,7 +534,7 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev, if (rc) goto err_intx_request; - dev_dbg(ndev_dev(ndev), "Using intx interrupts\n"); + dev_dbg(>dev, "Using intx interrupts\n"); ndev->db_vec_count = 1; ndev->db_vec_shift = total_shift; return 0; @@ -547,7 +548,7 @@ static void ndev_deinit_isr(struct intel_ntb_dev *ndev) struct pci_dev *pdev; int i; - pdev = ndev_pdev(ndev); + pdev = ndev->ntb.pdev; /* Mask all doorbell interrupts */ ndev->db_mask = ndev->db_valid_mask; @@ -744,7 +745,7 @@ static ssize_t ndev_ntb_debugfs_read(struct file *filp, char __user *ubuf, union { u64 v64; u32 v32; u16 v16; u8 v8; } u; ndev = filp->private_data; - pdev = ndev_pdev(ndev); + pdev = ndev->ntb.pdev; mmio = ndev->self_mmio; buf_size = min(count, 0x800ul); @@ -1019,7 +1020,8 @@ static void ndev_init_debugfs(struct intel_ntb_dev *ndev) ndev->debugfs_info = NULL; } else { ndev->debugfs_dir = - debugfs_create_dir(ndev_name(ndev), debugfs_dir); + debugfs_create_dir(pci_name(ndev->ntb.pdev), + debugfs_dir); if (!ndev->debugfs_dir) ndev->debugfs_info = NULL; else