All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: dwc: ep: Use FIELD_GET()
@ 2025-04-21 11:45 Hans Zhang
  2025-04-24 13:44 ` Niklas Cassel
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Zhang @ 2025-04-21 11:45 UTC (permalink / raw)
  To: lpieralisi, bhelgaas, jingoohan1, manivannan.sadhasivam, kw
  Cc: robh, thomas.richard, linux-pci, linux-kernel, Hans Zhang

Use FIELD_GET() and FIELD_PREP() to remove dependences on the field
position, i.e., the shift value. No functional change intended.

Signed-off-by: Hans Zhang <18255117159@163.com>
---
I referred to Bjorn Helgaas' submitted patch.
https://lore.kernel.org/all/20231010204436.1000644-2-helgaas@kernel.org/
---
 drivers/pci/controller/dwc/pcie-designware-ep.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
index 1a0bf9341542..f3daf46b5e63 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -256,11 +256,11 @@ static unsigned int dw_pcie_ep_get_rebar_offset(struct dw_pcie *pci,
 		return offset;
 
 	reg = dw_pcie_readl_dbi(pci, offset + PCI_REBAR_CTRL);
-	nbars = (reg & PCI_REBAR_CTRL_NBAR_MASK) >> PCI_REBAR_CTRL_NBAR_SHIFT;
+	nbars = FIELD_GET(PCI_REBAR_CTRL_NBAR_MASK, reg);
 
 	for (i = 0; i < nbars; i++, offset += PCI_REBAR_CTRL) {
 		reg = dw_pcie_readl_dbi(pci, offset + PCI_REBAR_CTRL);
-		bar_index = reg & PCI_REBAR_CTRL_BAR_IDX;
+		bar_index = FIELD_GET(PCI_REBAR_CTRL_BAR_IDX, reg);
 		if (bar_index == bar)
 			return offset;
 	}
@@ -875,8 +875,7 @@ static void dw_pcie_ep_init_non_sticky_registers(struct dw_pcie *pci)
 
 	if (offset) {
 		reg = dw_pcie_readl_dbi(pci, offset + PCI_REBAR_CTRL);
-		nbars = (reg & PCI_REBAR_CTRL_NBAR_MASK) >>
-			PCI_REBAR_CTRL_NBAR_SHIFT;
+		nbars = FIELD_GET(PCI_REBAR_CTRL_NBAR_MASK, reg);
 
 		/*
 		 * PCIe r6.0, sec 7.8.6.2 require us to support at least one
@@ -897,7 +896,7 @@ static void dw_pcie_ep_init_non_sticky_registers(struct dw_pcie *pci)
 			 * is why RESBAR_CAP_REG is written here.
 			 */
 			val = dw_pcie_readl_dbi(pci, offset + PCI_REBAR_CTRL);
-			bar = val & PCI_REBAR_CTRL_BAR_IDX;
+			bar = FIELD_GET(PCI_REBAR_CTRL_BAR_IDX, val);
 			if (ep->epf_bar[bar])
 				pci_epc_bar_size_to_rebar_cap(ep->epf_bar[bar]->size, &val);
 			else

base-commit: 9d7a0577c9db35c4cc52db90bc415ea248446472
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI: dwc: ep: Use FIELD_GET()
  2025-04-21 11:45 [PATCH] PCI: dwc: ep: Use FIELD_GET() Hans Zhang
@ 2025-04-24 13:44 ` Niklas Cassel
  2025-04-24 14:39   ` Hans Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Niklas Cassel @ 2025-04-24 13:44 UTC (permalink / raw)
  To: Hans Zhang
  Cc: lpieralisi, bhelgaas, jingoohan1, manivannan.sadhasivam, kw, robh,
	thomas.richard, linux-pci, linux-kernel

On Mon, Apr 21, 2025 at 07:45:48PM +0800, Hans Zhang wrote:
> Use FIELD_GET() and FIELD_PREP() to remove dependences on the field
> position, i.e., the shift value. No functional change intended.

Nit: It is a little bit misleading to write "Use ... FIELD_PREP()"
since this patch actually never uses FIELD_PREP().

Reviewed-by: Niklas Cassel <cassel@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI: dwc: ep: Use FIELD_GET()
  2025-04-24 13:44 ` Niklas Cassel
@ 2025-04-24 14:39   ` Hans Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Hans Zhang @ 2025-04-24 14:39 UTC (permalink / raw)
  To: Niklas Cassel
  Cc: lpieralisi, bhelgaas, jingoohan1, manivannan.sadhasivam, kw, robh,
	thomas.richard, linux-pci, linux-kernel



On 2025/4/24 21:44, Niklas Cassel wrote:
> On Mon, Apr 21, 2025 at 07:45:48PM +0800, Hans Zhang wrote:
>> Use FIELD_GET() and FIELD_PREP() to remove dependences on the field
>> position, i.e., the shift value. No functional change intended.
> 
> Nit: It is a little bit misleading to write "Use ... FIELD_PREP()"
> since this patch actually never uses FIELD_PREP().
> 
> Reviewed-by: Niklas Cassel <cassel@kernel.org>

Hi Niklas,

Thank you very much for your review. I think Mani can help me modify it 
when merging to the temporary branch.

Best regards,
Hans


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-24 14:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-21 11:45 [PATCH] PCI: dwc: ep: Use FIELD_GET() Hans Zhang
2025-04-24 13:44 ` Niklas Cassel
2025-04-24 14:39   ` Hans Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.