Skip to content

Commit ad9afd7

Browse files
krzkbjorn-helgaas
authored andcommitted
PCI: dra7xx: Use syscon_regmap_lookup_by_phandle_args
Use syscon_regmap_lookup_by_phandle_args() which is a wrapper over syscon_regmap_lookup_by_phandle() combined with getting the syscon argument. Except simpler code this annotates within one line that given phandle has arguments, so grepping for code would be easier. There is also no real benefit in printing errors on missing syscon argument, because this is done just too late: runtime check on static/build-time data. Dtschema and Devicetree bindings offer the static/build-time check for this already. Link: https://lore.kernel.org/r/20250112-syscon-phandle-args-pci-v1-1-fcb6ebcc0afc@linaro.org Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
1 parent 40384c8 commit ad9afd7

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

drivers/pci/controller/dwc/pci-dra7xx.c

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -635,30 +635,20 @@ static int dra7xx_pcie_unaligned_memaccess(struct device *dev)
635635
{
636636
int ret;
637637
struct device_node *np = dev->of_node;
638-
struct of_phandle_args args;
638+
unsigned int args[2];
639639
struct regmap *regmap;
640640

641-
regmap = syscon_regmap_lookup_by_phandle(np,
642-
"ti,syscon-unaligned-access");
641+
regmap = syscon_regmap_lookup_by_phandle_args(np, "ti,syscon-unaligned-access",
642+
2, args);
643643
if (IS_ERR(regmap)) {
644644
dev_dbg(dev, "can't get ti,syscon-unaligned-access\n");
645645
return -EINVAL;
646646
}
647647

648-
ret = of_parse_phandle_with_fixed_args(np, "ti,syscon-unaligned-access",
649-
2, 0, &args);
650-
if (ret) {
651-
dev_err(dev, "failed to parse ti,syscon-unaligned-access\n");
652-
return ret;
653-
}
654-
655-
ret = regmap_update_bits(regmap, args.args[0], args.args[1],
656-
args.args[1]);
648+
ret = regmap_update_bits(regmap, args[0], args[1], args[1]);
657649
if (ret)
658650
dev_err(dev, "failed to enable unaligned access\n");
659651

660-
of_node_put(args.np);
661-
662652
return ret;
663653
}
664654

@@ -671,18 +661,13 @@ static int dra7xx_pcie_configure_two_lane(struct device *dev,
671661
u32 mask;
672662
u32 val;
673663

674-
pcie_syscon = syscon_regmap_lookup_by_phandle(np, "ti,syscon-lane-sel");
664+
pcie_syscon = syscon_regmap_lookup_by_phandle_args(np, "ti,syscon-lane-sel",
665+
1, &pcie_reg);
675666
if (IS_ERR(pcie_syscon)) {
676667
dev_err(dev, "unable to get ti,syscon-lane-sel\n");
677668
return -EINVAL;
678669
}
679670

680-
if (of_property_read_u32_index(np, "ti,syscon-lane-sel", 1,
681-
&pcie_reg)) {
682-
dev_err(dev, "couldn't get lane selection reg offset\n");
683-
return -EINVAL;
684-
}
685-
686671
mask = b1co_mode_sel_mask | PCIE_B0_B1_TSYNCEN;
687672
val = PCIE_B1C0_MODE_SEL | PCIE_B0_B1_TSYNCEN;
688673
regmap_update_bits(pcie_syscon, pcie_reg, mask, val);

0 commit comments

Comments
 (0)