diff mbox series

[v2,2/3] scsi: libsas: Remove an empty branch in sas_check_parent_topology()

Message ID 20230420143339.2769414-3-yanaijie@huawei.com (mailing list archive)
State Superseded
Headers show
Series scsi: libsas: remove empty branches and code simplification | expand

Commit Message

Jason Yan April 20, 2023, 2:33 p.m. UTC
There is an empty "All good" branch in sas_check_parent_topology(). We can
reverse the test statement and remove the empty branch.

Signed-off-by: Jason Yan <yanaijie@huawei.com>
---
 drivers/scsi/libsas/sas_expander.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Christoph Hellwig April 20, 2023, 3:02 p.m. UTC | #1
On Thu, Apr 20, 2023 at 10:33:38PM +0800, Jason Yan wrote:
> There is an empty "All good" branch in sas_check_parent_topology(). We can
> reverse the test statement and remove the empty branch.

Eww, this code is pretty unreadable (as-is and after the change).
Can you move SAS_EDGE_EXPANDER_DEVICE case into a helper to
make it readabke?  That has the extra upside of just being able to
return the error code instead of assigning it to res.
Jason Yan April 21, 2023, 1:57 a.m. UTC | #2
On 2023/4/20 23:02, Christoph Hellwig wrote:
> On Thu, Apr 20, 2023 at 10:33:38PM +0800, Jason Yan wrote:
>> There is an empty "All good" branch in sas_check_parent_topology(). We can
>> reverse the test statement and remove the empty branch.
> 
> Eww, this code is pretty unreadable (as-is and after the change).
> Can you move SAS_EDGE_EXPANDER_DEVICE case into a helper to
> make it readabke?  That has the extra upside of just being able to
> return the error code instead of assigning it to res.

Sure.
diff mbox series

Patch

diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 70fd4f439664..bbf73e74530e 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -1285,11 +1285,9 @@  static int sas_check_parent_topology(struct domain_device *child)
 					res = -ENODEV;
 				}
 			} else if (parent_phy->routing_attr == TABLE_ROUTING) {
-				if (child_phy->routing_attr == SUBTRACTIVE_ROUTING ||
-				    (child_phy->routing_attr == TABLE_ROUTING &&
-				     child_ex->t2t_supp && parent_ex->t2t_supp)) {
-					/* All good */;
-				} else {
+				if (child_phy->routing_attr != SUBTRACTIVE_ROUTING &&
+				    (child_phy->routing_attr != TABLE_ROUTING ||
+				     !child_ex->t2t_supp || !parent_ex->t2t_supp)) {
 					sas_print_parent_topology_bug(child, parent_phy, child_phy);
 					res = -ENODEV;
 				}