scsi: libsas: Clean up sas_form_port()
authorDamien Le Moal <damien.lemoal@opensource.wdc.com>
Mon, 28 Feb 2022 09:48:57 +0000 (18:48 +0900)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 2 Mar 2022 04:56:27 +0000 (23:56 -0500)
commit32698c955295957d63f042f4bb30e9d613ca8b55
treec58527095ea010eb5cb26f2b76e6bd9d35ce9e15
parent26440303310591e29121964ede0048583cb3126d
scsi: libsas: Clean up sas_form_port()

Sparse throws a warning about context imbalance ("different lock contexts
for basic block") in sas_form_port() as it gets confused with the fact that
a port is locked within one of the two search loops and unlocked afterward
outside of the search loops once the phy is added to the port. Since this
code is not easy to follow, improve it by factoring out the code adding the
phy to the port once the port is locked into the helper function
sas_form_port_add_phy(). This helper can then be called directly within the
port search loops, avoiding confusion and clearing the sparse warning.

Link: https://lore.kernel.org/r/20220228094857.557329-1-damien.lemoal@opensource.wdc.com
Reviewed-by: John Garry <john.garry@huawei.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/libsas/sas_port.c