Skip to content

Commit 0f9bfb9

Browse files
lsgunthjonmason
authored andcommitted
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 <logang@deltatee.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
1 parent 3c69f5d commit 0f9bfb9

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

drivers/ntb/hw/amd/ntb_hw_amd.c

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int idx,
133133
if (bar < 0)
134134
return bar;
135135

136-
mw_size = pci_resource_len(ndev->ntb.pdev, bar);
136+
mw_size = pci_resource_len(ntb->pdev, bar);
137137

138138
/* make sure the range fits in the usable mw size */
139139
if (size > mw_size)
@@ -142,7 +142,7 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int idx,
142142
mmio = ndev->self_mmio;
143143
peer_mmio = ndev->peer_mmio;
144144

145-
base_addr = pci_resource_start(ndev->ntb.pdev, bar);
145+
base_addr = pci_resource_start(ntb->pdev, bar);
146146

147147
if (bar != 1) {
148148
xlat_reg = AMD_BAR23XLAT_OFFSET + ((bar - 2) << 2);
@@ -232,7 +232,7 @@ static u64 amd_ntb_link_is_up(struct ntb_dev *ntb,
232232
if (width)
233233
*width = NTB_LNK_STA_WIDTH(ndev->lnk_sta);
234234

235-
dev_dbg(ndev_dev(ndev), "link is up.\n");
235+
dev_dbg(&ntb->pdev->dev, "link is up.\n");
236236

237237
ret = 1;
238238
} else {
@@ -241,7 +241,7 @@ static u64 amd_ntb_link_is_up(struct ntb_dev *ntb,
241241
if (width)
242242
*width = NTB_WIDTH_NONE;
243243

244-
dev_dbg(ndev_dev(ndev), "link is down.\n");
244+
dev_dbg(&ntb->pdev->dev, "link is down.\n");
245245
}
246246

247247
return ret;
@@ -261,7 +261,7 @@ static int amd_ntb_link_enable(struct ntb_dev *ntb,
261261

262262
if (ndev->ntb.topo == NTB_TOPO_SEC)
263263
return -EINVAL;
264-
dev_dbg(ndev_dev(ndev), "Enabling Link.\n");
264+
dev_dbg(&ntb->pdev->dev, "Enabling Link.\n");
265265

266266
ntb_ctl = readl(mmio + AMD_CNTL_OFFSET);
267267
ntb_ctl |= (PMM_REG_CTL | SMM_REG_CTL);
@@ -282,7 +282,7 @@ static int amd_ntb_link_disable(struct ntb_dev *ntb)
282282

283283
if (ndev->ntb.topo == NTB_TOPO_SEC)
284284
return -EINVAL;
285-
dev_dbg(ndev_dev(ndev), "Enabling Link.\n");
285+
dev_dbg(&ntb->pdev->dev, "Enabling Link.\n");
286286

287287
ntb_ctl = readl(mmio + AMD_CNTL_OFFSET);
288288
ntb_ctl &= ~(PMM_REG_CTL | SMM_REG_CTL);
@@ -500,18 +500,19 @@ static void amd_ack_smu(struct amd_ntb_dev *ndev, u32 bit)
500500
static void amd_handle_event(struct amd_ntb_dev *ndev, int vec)
501501
{
502502
void __iomem *mmio = ndev->self_mmio;
503+
struct device *dev = &ndev->ntb.pdev->dev;
503504
u32 status;
504505

505506
status = readl(mmio + AMD_INTSTAT_OFFSET);
506507
if (!(status & AMD_EVENT_INTMASK))
507508
return;
508509

509-
dev_dbg(ndev_dev(ndev), "status = 0x%x and vec = %d\n", status, vec);
510+
dev_dbg(dev, "status = 0x%x and vec = %d\n", status, vec);
510511

511512
status &= AMD_EVENT_INTMASK;
512513
switch (status) {
513514
case AMD_PEER_FLUSH_EVENT:
514-
dev_info(ndev_dev(ndev), "Flush is done.\n");
515+
dev_info(dev, "Flush is done.\n");
515516
break;
516517
case AMD_PEER_RESET_EVENT:
517518
amd_ack_smu(ndev, AMD_PEER_RESET_EVENT);
@@ -537,7 +538,7 @@ static void amd_handle_event(struct amd_ntb_dev *ndev, int vec)
537538
status = readl(mmio + AMD_PMESTAT_OFFSET);
538539
/* check if this is WAKEUP event */
539540
if (status & 0x1)
540-
dev_info(ndev_dev(ndev), "Wakeup is done.\n");
541+
dev_info(dev, "Wakeup is done.\n");
541542

542543
amd_ack_smu(ndev, AMD_PEER_D0_EVENT);
543544

@@ -546,14 +547,14 @@ static void amd_handle_event(struct amd_ntb_dev *ndev, int vec)
546547
AMD_LINK_HB_TIMEOUT);
547548
break;
548549
default:
549-
dev_info(ndev_dev(ndev), "event status = 0x%x.\n", status);
550+
dev_info(dev, "event status = 0x%x.\n", status);
550551
break;
551552
}
552553
}
553554

554555
static irqreturn_t ndev_interrupt(struct amd_ntb_dev *ndev, int vec)
555556
{
556-
dev_dbg(ndev_dev(ndev), "vec %d\n", vec);
557+
dev_dbg(&ndev->ntb.pdev->dev, "vec %d\n", vec);
557558

558559
if (vec > (AMD_DB_CNT - 1) || (ndev->msix_vec_count == 1))
559560
amd_handle_event(ndev, vec);
@@ -575,7 +576,7 @@ static irqreturn_t ndev_irq_isr(int irq, void *dev)
575576
{
576577
struct amd_ntb_dev *ndev = dev;
577578

578-
return ndev_interrupt(ndev, irq - ndev_pdev(ndev)->irq);
579+
return ndev_interrupt(ndev, irq - ndev->ntb.pdev->irq);
579580
}
580581

581582
static int ndev_init_isr(struct amd_ntb_dev *ndev,
@@ -584,7 +585,7 @@ static int ndev_init_isr(struct amd_ntb_dev *ndev,
584585
struct pci_dev *pdev;
585586
int rc, i, msix_count, node;
586587

587-
pdev = ndev_pdev(ndev);
588+
pdev = ndev->ntb.pdev;
588589

589590
node = dev_to_node(&pdev->dev);
590591

@@ -626,7 +627,7 @@ static int ndev_init_isr(struct amd_ntb_dev *ndev,
626627
goto err_msix_request;
627628
}
628629

629-
dev_dbg(ndev_dev(ndev), "Using msix interrupts\n");
630+
dev_dbg(&pdev->dev, "Using msix interrupts\n");
630631
ndev->db_count = msix_min;
631632
ndev->msix_vec_count = msix_max;
632633
return 0;
@@ -653,7 +654,7 @@ static int ndev_init_isr(struct amd_ntb_dev *ndev,
653654
if (rc)
654655
goto err_msi_request;
655656

656-
dev_dbg(ndev_dev(ndev), "Using msi interrupts\n");
657+
dev_dbg(&pdev->dev, "Using msi interrupts\n");
657658
ndev->db_count = 1;
658659
ndev->msix_vec_count = 1;
659660
return 0;
@@ -670,7 +671,7 @@ static int ndev_init_isr(struct amd_ntb_dev *ndev,
670671
if (rc)
671672
goto err_intx_request;
672673

673-
dev_dbg(ndev_dev(ndev), "Using intx interrupts\n");
674+
dev_dbg(&pdev->dev, "Using intx interrupts\n");
674675
ndev->db_count = 1;
675676
ndev->msix_vec_count = 1;
676677
return 0;
@@ -685,7 +686,7 @@ static void ndev_deinit_isr(struct amd_ntb_dev *ndev)
685686
void __iomem *mmio = ndev->self_mmio;
686687
int i;
687688

688-
pdev = ndev_pdev(ndev);
689+
pdev = ndev->ntb.pdev;
689690

690691
/* Mask all doorbell interrupts */
691692
ndev->db_mask = ndev->db_valid_mask;
@@ -811,7 +812,8 @@ static void ndev_init_debugfs(struct amd_ntb_dev *ndev)
811812
ndev->debugfs_info = NULL;
812813
} else {
813814
ndev->debugfs_dir =
814-
debugfs_create_dir(ndev_name(ndev), debugfs_dir);
815+
debugfs_create_dir(pci_name(ndev->ntb.pdev),
816+
debugfs_dir);
815817
if (!ndev->debugfs_dir)
816818
ndev->debugfs_info = NULL;
817819
else
@@ -846,7 +848,7 @@ static int amd_poll_link(struct amd_ntb_dev *ndev)
846848
reg = readl(mmio + AMD_SIDEINFO_OFFSET);
847849
reg &= NTB_LIN_STA_ACTIVE_BIT;
848850

849-
dev_dbg(ndev_dev(ndev), "%s: reg_val = 0x%x.\n", __func__, reg);
851+
dev_dbg(&ndev->ntb.pdev->dev, "%s: reg_val = 0x%x.\n", __func__, reg);
850852

851853
if (reg == ndev->cntl_sta)
852854
return 0;
@@ -928,7 +930,8 @@ static int amd_init_ntb(struct amd_ntb_dev *ndev)
928930

929931
break;
930932
default:
931-
dev_err(ndev_dev(ndev), "AMD NTB does not support B2B mode.\n");
933+
dev_err(&ndev->ntb.pdev->dev,
934+
"AMD NTB does not support B2B mode.\n");
932935
return -EINVAL;
933936
}
934937

@@ -957,10 +960,10 @@ static int amd_init_dev(struct amd_ntb_dev *ndev)
957960
struct pci_dev *pdev;
958961
int rc = 0;
959962

960-
pdev = ndev_pdev(ndev);
963+
pdev = ndev->ntb.pdev;
961964

962965
ndev->ntb.topo = amd_get_topo(ndev);
963-
dev_dbg(ndev_dev(ndev), "AMD NTB topo is %s\n",
966+
dev_dbg(&pdev->dev, "AMD NTB topo is %s\n",
964967
ntb_topo_string(ndev->ntb.topo));
965968

966969
rc = amd_init_ntb(ndev);
@@ -969,7 +972,7 @@ static int amd_init_dev(struct amd_ntb_dev *ndev)
969972

970973
rc = amd_init_isr(ndev);
971974
if (rc) {
972-
dev_err(ndev_dev(ndev), "fail to init isr.\n");
975+
dev_err(&pdev->dev, "fail to init isr.\n");
973976
return rc;
974977
}
975978

@@ -1007,15 +1010,15 @@ static int amd_ntb_init_pci(struct amd_ntb_dev *ndev,
10071010
rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
10081011
if (rc)
10091012
goto err_dma_mask;
1010-
dev_warn(ndev_dev(ndev), "Cannot DMA highmem\n");
1013+
dev_warn(&pdev->dev, "Cannot DMA highmem\n");
10111014
}
10121015

10131016
rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
10141017
if (rc) {
10151018
rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
10161019
if (rc)
10171020
goto err_dma_mask;
1018-
dev_warn(ndev_dev(ndev), "Cannot DMA consistent highmem\n");
1021+
dev_warn(&pdev->dev, "Cannot DMA consistent highmem\n");
10191022
}
10201023

10211024
ndev->self_mmio = pci_iomap(pdev, 0, 0);
@@ -1038,7 +1041,7 @@ static int amd_ntb_init_pci(struct amd_ntb_dev *ndev,
10381041

10391042
static void amd_ntb_deinit_pci(struct amd_ntb_dev *ndev)
10401043
{
1041-
struct pci_dev *pdev = ndev_pdev(ndev);
1044+
struct pci_dev *pdev = ndev->ntb.pdev;
10421045

10431046
pci_iounmap(pdev, ndev->self_mmio);
10441047

drivers/ntb/hw/amd/ntb_hw_amd.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,6 @@ struct amd_ntb_dev {
211211
struct dentry *debugfs_info;
212212
};
213213

214-
#define ndev_pdev(ndev) ((ndev)->ntb.pdev)
215-
#define ndev_name(ndev) pci_name(ndev_pdev(ndev))
216-
#define ndev_dev(ndev) (&ndev_pdev(ndev)->dev)
217214
#define ntb_ndev(__ntb) container_of(__ntb, struct amd_ntb_dev, ntb)
218215
#define hb_ndev(__work) container_of(__work, struct amd_ntb_dev, hb_timer.work)
219216

0 commit comments

Comments
 (0)