i2c: i2c-mux-reg: wrong condition checked for of_address_to_resource return value
Subsystems (2)
PATCH 1/1 i2c: i2c-mux-reg: wrong condition checked for of_address_to_resource return value
of_address_to_resource return 0 on successful call but devm_ioremap_resource is called only if it returns non-zero value
--- drivers/i2c/muxes/i2c-mux-reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/muxes/i2c-mux-reg.c +1 -1
@@ -145,7 +145,7 @@ static int i2c_mux_reg_probe_dt(struct regmux *mux, mux->data.idle_in_use = true;/* map address from "reg" if exists */ -if (of_address_to_resource (np,0 , &res)) { +if (!of_address_to_resource (np,0 , &res)) { mux->data.reg_size =resource_size (&res); mux->data.reg =devm_ioremap_resource (&pdev->dev, &res);if (IS_ERR (mux->data.reg))
Signature · 1 line
2.5.0
Quoted 14 lines · Lukasz Gemborowski
of_address_to_resourcereturn 0 on successful call butdevm_ioremap_resourceis called only if it returns non-zero valueSigned-off-by Lukasz Gemborowski <[email protected]>Reviewed-by Alexander Sverdlin <[email protected]>--- drivers/i2c/muxes/i2c-mux-reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/i2c/muxes/i2c-mux-reg.c +0
-0
drivers/i2c/muxes/i2c-mux-reg.c static int i2c_mux_reg_probe_dt(struct regmux *mux, · line 148
Quoted 5 lines
drivers/i2c/muxes/i2c-mux-reg.c +1
-1@@ -145,7 +145,7 @@ static int i2c_mux_reg_probe_dt(struct regmux *mux, mux->data.idle_in_use = true;/* map address from "reg" if exists */ -if (of_address_to_resource (np,0 , &res)) { +if (!of_address_to_resource (np,0 , &res)) {
Minor nit: I prefer '== 0' in those cases to prevent the misleading reading of "if not of_address_to_resource...". '== 0' can be easier read as 'is OK'.
PATCH v2 1/1 i2c: i2c-mux-reg: wrong condition checked for of_address_to_resource return value
of_address_to_resource return 0 on successful call but devm_ioremap_resource is called only if it returns non-zero value
---
Changelog:
v2:
Changed style of conditional expression as suggested by Wolfram.
drivers/i2c/muxes/i2c-mux-reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/muxes/i2c-mux-reg.c +1 -1
@@ -145,7 +145,7 @@ static int i2c_mux_reg_probe_dt(struct regmux *mux, mux->data.idle_in_use = true;/* map address from "reg" if exists */ -if (of_address_to_resource (np,0 , &res)) { +if (of_address_to_resource (np,0 , &res) ==0 ) { mux->data.reg_size =resource_size (&res); mux->data.reg =devm_ioremap_resource (&pdev->dev, &res);if (IS_ERR (mux->data.reg))
Signature · 1 line
2.5.0
Wolfram Sang
AppliedQuoted 5 lines · Lukasz Gemborowski
of_address_to_resourcereturn 0 on successful call butdevm_ioremap_resourceis called only if it returns non-zero valueSigned-off-by Lukasz Gemborowski <[email protected]>Reviewed-by Alexander Sverdlin <[email protected]>
Applied to for-current, thanks!