* [PATCH] i2c: i2c-mux-reg: wrong condition checked for of_address_to_resource return value
@ 2016-06-27 9:21 Lukasz Gemborowski
2016-06-27 9:26 ` Wolfram Sang
0 siblings, 1 reply; 4+ messages in thread
From: Lukasz Gemborowski @ 2016-06-27 9:21 UTC (permalink / raw)
To: wsa, peda, linux-i2c; +Cc: alexander.sverdlin
of_address_to_resource return 0 on successful call but
devm_ioremap_resource is called only if it returns non-zero value
Signed-off-by: Lukasz Gemborowski <lukasz.gemborowski@nokia.com>
Reviewed-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
---
drivers/i2c/muxes/i2c-mux-reg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/muxes/i2c-mux-reg.c b/drivers/i2c/muxes/i2c-mux-reg.c
index 26e7c51..012a7ab 100644
--- a/drivers/i2c/muxes/i2c-mux-reg.c
+++ b/drivers/i2c/muxes/i2c-mux-reg.c
@@ -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))
--
2.5.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] i2c: i2c-mux-reg: wrong condition checked for of_address_to_resource return value
2016-06-27 9:21 [PATCH] i2c: i2c-mux-reg: wrong condition checked for of_address_to_resource return value Lukasz Gemborowski
@ 2016-06-27 9:26 ` Wolfram Sang
2016-06-27 10:57 ` [PATCH v2] " Lukasz Gemborowski
0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2016-06-27 9:26 UTC (permalink / raw)
To: Lukasz Gemborowski; +Cc: peda, linux-i2c, alexander.sverdlin
[-- Attachment #1: Type: text/plain, Size: 1052 bytes --]
On Mon, Jun 27, 2016 at 11:21:48AM +0200, Lukasz Gemborowski wrote:
> of_address_to_resource return 0 on successful call but
> devm_ioremap_resource is called only if it returns non-zero value
>
> Signed-off-by: Lukasz Gemborowski <lukasz.gemborowski@nokia.com>
> Reviewed-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
> ---
> drivers/i2c/muxes/i2c-mux-reg.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/muxes/i2c-mux-reg.c b/drivers/i2c/muxes/i2c-mux-reg.c
> index 26e7c51..012a7ab 100644
> --- a/drivers/i2c/muxes/i2c-mux-reg.c
> +++ b/drivers/i2c/muxes/i2c-mux-reg.c
> @@ -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'.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] i2c: i2c-mux-reg: wrong condition checked for of_address_to_resource return value
2016-06-27 9:26 ` Wolfram Sang
@ 2016-06-27 10:57 ` Lukasz Gemborowski
2016-07-05 15:32 ` Wolfram Sang
0 siblings, 1 reply; 4+ messages in thread
From: Lukasz Gemborowski @ 2016-06-27 10:57 UTC (permalink / raw)
To: Wolfram Sang, peda, linux-i2c; +Cc: alexander.sverdlin
of_address_to_resource return 0 on successful call but
devm_ioremap_resource is called only if it returns non-zero value
Signed-off-by: Lukasz Gemborowski <lukasz.gemborowski@nokia.com>
Reviewed-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
---
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(-)
diff --git a/drivers/i2c/muxes/i2c-mux-reg.c b/drivers/i2c/muxes/i2c-mux-reg.c
index 26e7c51..c6a90b4 100644
--- a/drivers/i2c/muxes/i2c-mux-reg.c
+++ b/drivers/i2c/muxes/i2c-mux-reg.c
@@ -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))
--
2.5.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] i2c: i2c-mux-reg: wrong condition checked for of_address_to_resource return value
2016-06-27 10:57 ` [PATCH v2] " Lukasz Gemborowski
@ 2016-07-05 15:32 ` Wolfram Sang
0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2016-07-05 15:32 UTC (permalink / raw)
To: Lukasz Gemborowski; +Cc: peda, linux-i2c, alexander.sverdlin
[-- Attachment #1: Type: text/plain, Size: 371 bytes --]
On Mon, Jun 27, 2016 at 12:57:47PM +0200, Lukasz Gemborowski wrote:
> of_address_to_resource return 0 on successful call but
> devm_ioremap_resource is called only if it returns non-zero value
>
> Signed-off-by: Lukasz Gemborowski <lukasz.gemborowski@nokia.com>
> Reviewed-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Applied to for-current, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-07-05 15:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-27 9:21 [PATCH] i2c: i2c-mux-reg: wrong condition checked for of_address_to_resource return value Lukasz Gemborowski
2016-06-27 9:26 ` Wolfram Sang
2016-06-27 10:57 ` [PATCH v2] " Lukasz Gemborowski
2016-07-05 15:32 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).