Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

phy: stih407-usb: 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.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Link: https://lore.kernel.org/r/20250111185407.183855-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Vinod Koul
13c1eb1b f4fb9c4d

+7 -17
+7 -17
drivers/phy/st/phy-stih407-usb.c
··· 18 18 #include <linux/mfd/syscon.h> 19 19 #include <linux/phy/phy.h> 20 20 21 - #define PHYPARAM_REG 1 22 - #define PHYCTRL_REG 2 21 + #define PHYPARAM_REG 0 22 + #define PHYCTRL_REG 1 23 23 24 24 /* Default PHY_SEL and REFCLKSEL configuration */ 25 25 #define STIH407_USB_PICOPHY_CTRL_PORT_CONF 0x6 ··· 91 91 struct device *dev = &pdev->dev; 92 92 struct device_node *np = dev->of_node; 93 93 struct phy_provider *phy_provider; 94 + unsigned int syscon_args[2]; 94 95 struct phy *phy; 95 - int ret; 96 96 97 97 phy_dev = devm_kzalloc(dev, sizeof(*phy_dev), GFP_KERNEL); 98 98 if (!phy_dev) ··· 116 116 /* Reset port by default: only deassert it in phy init */ 117 117 reset_control_assert(phy_dev->rstport); 118 118 119 - phy_dev->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg"); 119 + phy_dev->regmap = syscon_regmap_lookup_by_phandle_args(np, "st,syscfg", 120 + 2, syscon_args); 120 121 if (IS_ERR(phy_dev->regmap)) { 121 122 dev_err(dev, "No syscfg phandle specified\n"); 122 123 return PTR_ERR(phy_dev->regmap); 123 124 } 124 125 125 - ret = of_property_read_u32_index(np, "st,syscfg", PHYPARAM_REG, 126 - &phy_dev->param); 127 - if (ret) { 128 - dev_err(dev, "can't get phyparam offset (%d)\n", ret); 129 - return ret; 130 - } 131 - 132 - ret = of_property_read_u32_index(np, "st,syscfg", PHYCTRL_REG, 133 - &phy_dev->ctrl); 134 - if (ret) { 135 - dev_err(dev, "can't get phyctrl offset (%d)\n", ret); 136 - return ret; 137 - } 126 + phy_dev->param = syscon_args[PHYPARAM_REG]; 127 + phy_dev->ctrl = syscon_args[PHYCTRL_REG]; 138 128 139 129 phy = devm_phy_create(dev, NULL, &stih407_usb2_picophy_data); 140 130 if (IS_ERR(phy)) {