Skip to contentSkip to conversation

PCI: dwc: Use {upper,lower}_32_bits() macros for clarity

PATCH Superseded Stephen Boyd 3 participants 4 messages Nov 29, 2017 – Dec 19, 2017 PCI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: dwc: Use {upper,lower}_32_bits() macros for clarity

We have macros for getting the upper or lower 32 bits of a number. Use them here to shave a couple lines off the code.

---
 drivers/pci/dwc/pcie-designware-host.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pci/dwc/pcie-designware-host.c +2 -4
index 157621175147..ae5abfddf8de 100644
@@ -89,10 +89,8 @@ void dw_pcie_msi_init(struct pcie_port *pp)
 	msi_target = virt_to_phys((void *)pp->msi_data);
 
 	/* program the msi_data */
-	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_LO, 4,
-			    (u32)(msi_target & 0xffffffff));
-	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_HI, 4,
-			    (u32)(msi_target >> 32 & 0xffffffff));
+	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_LO, 4, lower_32_bits(msi_target));
+	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_HI, 4, upper_32_bits(msi_target));
 }
 
 static void dw_pcie_msi_clear_irq(struct pcie_port *pp, int irq)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Stephen Boyd

We have macros for getting the upper or lower 32 bits of a number. Use them here to shave a couple lines off the code.

Best regards,
Jingoo Han

Quoted 27 lines
---
 drivers/pci/dwc/pcie-designware-host.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pci/dwc/pcie-designware-host.c +2 -4
index 157621175147..ae5abfddf8de 100644
@@ -89,10 +89,8 @@ void dw_pcie_msi_init(struct pcie_port *pp)
 	msi_target = virt_to_phys((void *)pp->msi_data);
 
 	/* program the msi_data */
-	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_LO, 4,
-			    (u32)(msi_target & 0xffffffff));
-	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_HI, 4,
-			    (u32)(msi_target >> 32 & 0xffffffff));
+	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_LO, 4,
 lower_32_bits(msi_target));
+	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_HI, 4,
 upper_32_bits(msi_target));
 }

static void dw_pcie_msi_clear_irq(struct pcie_port *pp, int irq)
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

#2 lore raw
In reply to Stephen Boyd
Quoted 13 lines · Stephen Boyd

We have macros for getting the upper or lower 32 bits of a number. Use them here to shave a couple lines off the code.

---
 drivers/pci/dwc/pcie-designware-host.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pci/dwc/pcie-designware-host.c +0 -0
index 157621175147..ae5abfddf8de 100644

drivers/pci/dwc/pcie-designware-host.c void dw_pcie_msi_init(struct pcie_port *pp) · line 94

Quoted 10 lines
drivers/pci/dwc/pcie-designware-host.c +2 -4
@@ -89,10 +89,8 @@ void dw_pcie_msi_init(struct pcie_port *pp)
 	msi_target = virt_to_phys((void *)pp->msi_data);
 
 	/* program the msi_data */
-	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_LO, 4,
-			    (u32)(msi_target & 0xffffffff));
-	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_HI, 4,
-			    (u32)(msi_target >> 32 & 0xffffffff));
+	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_LO, 4, lower_32_bits(msi_target));
+	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_HI, 4, upper_32_bits(msi_target));
 }

Hi Stephen,

I was about to apply it but I think that for consistency it would be better to convert to {lower,upper}_32_bits() also code in dw_msi_setup_msg() and slightly reword the log accordingly; if you do not mind sending a v2 with those changes I will apply then.

Thanks,
Lorenzo

#3 lore raw
Quoted 27 lines · Lorenzo Pieralisi
Quoted 13 lines · Stephen Boyd

We have macros for getting the upper or lower 32 bits of a number. Use them here to shave a couple lines off the code.

---
 drivers/pci/dwc/pcie-designware-host.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pci/dwc/pcie-designware-host.c +0 -0
index 157621175147..ae5abfddf8de 100644

drivers/pci/dwc/pcie-designware-host.c void dw_pcie_msi_init(struct pcie_port *pp) · line 94

Quoted 10 lines
drivers/pci/dwc/pcie-designware-host.c +2 -4
@@ -89,10 +89,8 @@ void dw_pcie_msi_init(struct pcie_port *pp)
 	msi_target = virt_to_phys((void *)pp->msi_data);
 
 	/* program the msi_data */
-	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_LO, 4,
-			    (u32)(msi_target & 0xffffffff));
-	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_HI, 4,
-			    (u32)(msi_target >> 32 & 0xffffffff));
+	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_LO, 4, lower_32_bits(msi_target));
+	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_HI, 4, upper_32_bits(msi_target));
 }

Hi Stephen,

Quoted 5 lines

I was about to apply it but I think that for consistency it would be better to convert to {lower,upper}_32_bits() also code in dw_msi_setup_msg() and slightly reword the log accordingly; if you do not mind sending a v2 with those changes I will apply then.

Ok. v2 coming shortly.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project