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

can: c_can: 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: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://patch.msgid.link/20250212-syscon-phandle-args-can-v2-4-ac9a1253396b@linaro.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Krzysztof Kozlowski and committed by
Marc Kleine-Budde
9f0f0345 ab1bc229

+6 -15
+6 -15
drivers/net/can/c_can/c_can_platform.c
··· 317 317 * platforms. Only supported with DT boot. 318 318 */ 319 319 if (np && of_property_present(np, "syscon-raminit")) { 320 + unsigned int args[2]; 320 321 u32 id; 321 322 struct c_can_raminit *raminit = &priv->raminit_sys; 322 323 323 324 ret = -EINVAL; 324 - raminit->syscon = syscon_regmap_lookup_by_phandle(np, 325 - "syscon-raminit"); 325 + raminit->syscon = syscon_regmap_lookup_by_phandle_args(np, 326 + "syscon-raminit", 327 + 2, args); 326 328 if (IS_ERR(raminit->syscon)) { 327 329 ret = PTR_ERR(raminit->syscon); 328 330 goto exit_free_device; 329 331 } 330 332 331 - if (of_property_read_u32_index(np, "syscon-raminit", 1, 332 - &raminit->reg)) { 333 - dev_err(&pdev->dev, 334 - "couldn't get the RAMINIT reg. offset!\n"); 335 - goto exit_free_device; 336 - } 337 - 338 - if (of_property_read_u32_index(np, "syscon-raminit", 2, 339 - &id)) { 340 - dev_err(&pdev->dev, 341 - "couldn't get the CAN instance ID\n"); 342 - goto exit_free_device; 343 - } 333 + raminit->reg = args[0]; 334 + id = args[1]; 344 335 345 336 if (id >= drvdata->raminit_num) { 346 337 dev_err(&pdev->dev,