Skip to contentSkip to conversation

bus: ti-sysc: Remove if-block in sysc_check_children()

PATCH In review Nishka Dasgupta 3 participants 6 messages Aug 8, 2019 – Aug 13, 2019 OMAP2+ support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bus: ti-sysc: Remove if-block in sysc_check_children()

In function sysc_check_children, there is an if-statement checking whether the value returned by function sysc_check_one_child is non-zero. However, sysc_check_one_child always returns 0, and hence this check is not needed. Hence remove this if-block.

---
 drivers/bus/ti-sysc.c | 2 --
 1 file changed, 2 deletions(-)
drivers/bus/ti-sysc.c +0 -2
index e6deabd8305d..bc8082ae7cb5 100644
@@ -637,8 +637,6 @@ static int sysc_check_children(struct sysc *ddata)
 
 	for_each_child_of_node(ddata->dev->of_node, child) {
 		error = sysc_check_one_child(ddata, child);
-		if (error)
-			return error;
 	}
 
 	return 0;
Signature · 1 line
2.19.1
#1 lore raw

Nishka,

Quoted 15 lines · Nishka Dasgupta

In function sysc_check_children, there is an if-statement checking whether the value returned by function sysc_check_one_child is non-zero. However, sysc_check_one_child always returns 0, and hence this check is not needed. Hence remove this if-block.

---
 drivers/bus/ti-sysc.c | 2 --
 1 file changed, 2 deletions(-)
drivers/bus/ti-sysc.c +0 -0
index e6deabd8305d..bc8082ae7cb5 100644

drivers/bus/ti-sysc.c static int sysc_check_children(struct sysc *ddata) · line 641

Quoted 5 lines
drivers/bus/ti-sysc.c +0 -2
@@ -637,8 +637,6 @@ static int sysc_check_children(struct sysc *ddata)
 
 	for_each_child_of_node(ddata->dev->of_node, child) {
 		error = sysc_check_one_child(ddata, child);
-		if (error)
-			return error;

We cannot assume that sysc_check_one_child() will never return error in the future. If it can never return an error then why does it have an int return type?

drivers/bus/ti-sysc.c static int sysc_check_children(struct sysc *ddata) · line 642

Quoted 4 lines
drivers/bus/ti-sysc.c +0 -0
 	}
 
 	return 0;

cheers,
-roger

Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#2 lore raw
Quoted 19 lines · Roger Quadros

Nishka,

Quoted 16 lines · Nishka Dasgupta

In function sysc_check_children, there is an if-statement checking whether the value returned by function sysc_check_one_child is non-zero. However, sysc_check_one_child always returns 0, and hence this check is not needed. Hence remove this if-block.

---
  drivers/bus/ti-sysc.c | 2 --
  1 file changed, 2 deletions(-)
drivers/bus/ti-sysc.c +0 -0
index e6deabd8305d..bc8082ae7cb5 100644
@@ -637,8 +637,6 @@ static int sysc_check_children(struct sysc *ddata)
 
Quoted 7 lines

drivers/bus/ti-sysc.c static int sysc_check_children(struct sysc *ddata) · line 641

Quoted 4 lines
drivers/bus/ti-sysc.c +0 -2
  	for_each_child_of_node(ddata->dev->of_node, child) {
  		error = sysc_check_one_child(ddata, child);
-		if (error)
-			return error;

We cannot assume that sysc_check_one_child() will never return error in the future. If it can never return an error then why does it have an int return type?

I'm not sure why it has an int return type, unfortunately. This is the function in its entirety:

static int sysc_check_one_child(struct sysc *ddata,
struct device_node *np)

{
	const char *name;

	name = of_get_property(np, "ti,hwmods", NULL);
	if (name)
		dev_warn(ddata->dev, "really a child ti,hwmods property?");

	sysc_check_quirk_stdout(ddata, np);
	sysc_parse_dts_quirks(ddata, np, true);

	return 0;
}

I'm not sure how to understand this function. Do dev_warn() or sysc_check_quirk_stdout() or sysc_parse_dts_quirks() cause a non-zero return from sysc_check_one_child()? Should I drop my patch?

Thanking you,
Nishka

Quoted 9 lines

drivers/bus/ti-sysc.c static int sysc_check_children(struct sysc *ddata) · line 642

Quoted 5 lines
drivers/bus/ti-sysc.c +0 -0
  	}
 
  	return 0;

cheers,
-roger

#3 lore raw
Quoted 38 lines · Nishka Dasgupta
Quoted 13 lines · Roger Quadros

Nishka,

Quoted 10 lines · Nishka Dasgupta

In function sysc_check_children, there is an if-statement checking whether the value returned by function sysc_check_one_child is non-zero. However, sysc_check_one_child always returns 0, and hence this check is not needed. Hence remove this if-block.

---
  drivers/bus/ti-sysc.c | 2 --

  1 file changed, 2 deletions(-)
Quoted 12 lines

drivers/bus/ti-sysc.c static int sysc_check_children(struct sysc *ddata) · line 640

Quoted 9 lines
drivers/bus/ti-sysc.c +0 -2
index e6deabd8305d..bc8082ae7cb5 100644
@@ -637,8 +637,6 @@ static int sysc_check_children(struct sysc *ddata)
         for_each_child_of_node(ddata->dev->of_node, child) {
           error = sysc_check_one_child(ddata, child);
-        if (error)
-            return error;

We cannot assume that sysc_check_one_child() will never return error in the future. If it can never return an error then why does it have an int return type?

I'm not sure why it has an int return type, unfortunately. This is the function in its entirety:

static int sysc_check_one_child(struct sysc *ddata, struct device_node *np)
{
    const char *name;

    name = of_get_property(np, "ti,hwmods", NULL);
    if (name)
        dev_warn(ddata->dev, "really a child ti,hwmods property?");

Quoted 7 lines

    sysc_check_quirk_stdout(ddata, np);
    sysc_parse_dts_quirks(ddata, np, true);

    return 0;
}

I'm not sure how to understand this function. Do dev_warn() or sysc_check_quirk_stdout() or sysc_parse_dts_quirks() cause a non-zero return from sysc_check_one_child()? Should I drop my patch?

None of those functions return anything.
Maybe you can fix sysc_check_one_child() to return void? I think you can retain your patch but get rid of error variable.

Quoted 8 lines

Thanking you,
Nishka

Quoted 5 lines
Quoted 4 lines
drivers/bus/ti-sysc.c +0 -0
       }
         return 0;
 
Signature · 4 lines
cheers,
-roger
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
maintainer
#4 lore raw
Quoted 3 lines · Roger Quadros

None of those functions return anything.
Maybe you can fix sysc_check_one_child() to return void? I think you can retain your patch but get rid of error variable.

Makes sense to me.

Regards,

Tony

#5 lore raw
In reply to Roger Quadros
Quoted 44 lines · Roger Quadros
Quoted 41 lines · Nishka Dasgupta
Quoted 13 lines · Roger Quadros

Nishka,

Quoted 10 lines · Nishka Dasgupta

In function sysc_check_children, there is an if-statement checking whether the value returned by function sysc_check_one_child is non-zero. However, sysc_check_one_child always returns 0, and hence this check is not needed. Hence remove this if-block.

---
   drivers/bus/ti-sysc.c | 2 --
   1 file changed, 2 deletions(-)
Quoted 12 lines

drivers/bus/ti-sysc.c static int sysc_check_children(struct sysc *ddata) · line 640

Quoted 9 lines
drivers/bus/ti-sysc.c +0 -2
index e6deabd8305d..bc8082ae7cb5 100644
@@ -637,8 +637,6 @@ static int sysc_check_children(struct sysc *ddata)
         for_each_child_of_node(ddata->dev->of_node, child) {
           error = sysc_check_one_child(ddata, child);
-        if (error)
-            return error;

We cannot assume that sysc_check_one_child() will never return error in the future. If it can never return an error then why does it have an int return type?

I'm not sure why it has an int return type, unfortunately. This is the function in its entirety:

static int sysc_check_one_child(struct sysc *ddata,
                struct device_node *np)
{
    const char *name;

    name = of_get_property(np, "ti,hwmods", NULL);
    if (name)
        dev_warn(ddata->dev, "really a child ti,hwmods property?");

    sysc_check_quirk_stdout(ddata, np);
    sysc_parse_dts_quirks(ddata, np, true);

Quoted 8 lines
Quoted 4 lines

    return 0;
}

I'm not sure how to understand this function. Do dev_warn() or sysc_check_quirk_stdout() or sysc_parse_dts_quirks() cause a non-zero return from sysc_check_one_child()? Should I drop my patch?

None of those functions return anything.
Maybe you can fix sysc_check_one_child() to return void? I think you can retain your patch but get rid of error variable.

Okay, I'll fixup and send v2. What about sysc_check_children()? If error variable is removed then sysc_check_children also only returns 0. Thanking you,
Nishka

Quoted 10 lines
Quoted 9 lines

Thanking you,
Nishka

Quoted 5 lines
Quoted 4 lines
drivers/bus/ti-sysc.c +0 -0
       }
         return 0;