Re: [PATCH v3 1/2] PCI: tegra194: Use FIELD_*() for register fields
From: David Laight
Date: Tue Nov 17 2026 - 17:15:38 EST
On Mon, 2 Nov 2026 14:52:37 +0530
Manikanta Maddireddy <mmaddireddy@xxxxxxxxxx> wrote:
> Several Tegra194 APPL and DesignWare register fields are programmed
> with open-coded shifts, which makes the register programming more
> verbose than necessary.
>
> Use FIELD_PREP(), FIELD_MODIFY() and FIELD_GET() at the Tegra call
> sites where values are shifted into fields. The LTSSM state constants
> are converted from pre-shifted register values to unshifted field
> values for FIELD_GET().
>
> Suggested-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
> Link: https://lore.kernel.org/r/20260515070753.3852840-2-mmaddireddy@xxxxxxxxxx
> Signed-off-by: Manikanta Maddireddy <mmaddireddy@xxxxxxxxxx>
> ---
> drivers/pci/controller/dwc/pcie-tegra194.c | 137 ++++++++++-----------
> 1 file changed, 67 insertions(+), 70 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c
> index 26e2ac5c5869..62bbfcefe6fe 100644
> --- a/drivers/pci/controller/dwc/pcie-tegra194.c
> +++ b/drivers/pci/controller/dwc/pcie-tegra194.c
> @@ -51,8 +51,7 @@
> #define APPL_CTRL_SYS_PRE_DET_STATE BIT(6)
> #define APPL_CTRL_LTSSM_EN BIT(7)
> #define APPL_CTRL_HW_HOT_RST_EN BIT(20)
> -#define APPL_CTRL_HW_HOT_RST_MODE_MASK GENMASK(1, 0)
> -#define APPL_CTRL_HW_HOT_RST_MODE_SHIFT 22
> +#define APPL_CTRL_HW_HOT_RST_MODE_MASK GENMASK(23, 22)
Changing the value of a constant without changing its name
is heading in the direction of a a recipe for disaster.
It doesn't take much (eg a partial backport) for things to go awry.
David