From: Niklas Cassel Date: Thu, 14 Aug 2025 17:32:25 +0000 (+0200) Subject: scsi: pm80xx: Use pm80xx_get_local_phy_id() to access phy array X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=03f69351b63ea9583bd91c60a83d0a8573ea29fb;p=users%2Fhch%2Fmisc.git scsi: pm80xx: Use pm80xx_get_local_phy_id() to access phy array While the current code is perfectly fine (because we verify that the device is directly attached before using attached_phy to index the pm8001_ha->phy array), let's use the pm80xx_get_local_phy_id() helper anyway, to reduce the chance that someone will copy paste this pattern to other parts of the driver. Note that in this specific case, we still need to keep the check that the device is not behind an expander, because we do not want to clear attached_phy of the expander if a device behind the expander disappears (as that would disable all the other devices behind the expander). However, if it is the expander itself that disappears, attached_phy will be cleared, just like it would for any other directly attached device. Signed-off-by: Niklas Cassel Link: https://lore.kernel.org/r/20250814173215.1765055-22-cassel@kernel.org Reviewed-by: Damien Le Moal Reviewed-by: Igor Pylypiv Acked-by: Jack Wang Signed-off-by: Martin K. Petersen --- diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index c5354263b45e..6a8d35aea93a 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -780,8 +780,11 @@ static void pm8001_dev_gone_notify(struct domain_device *dev) * The phy array only contains local phys. Thus, we cannot clear * phy_attached for a device behind an expander. */ - if (!dev_parent_is_expander(dev)) - pm8001_ha->phy[pm8001_dev->attached_phy].phy_attached = 0; + if (!dev_parent_is_expander(dev)) { + u32 phy_id = pm80xx_get_local_phy_id(dev); + + pm8001_ha->phy[phy_id].phy_attached = 0; + } pm8001_free_dev(pm8001_dev); } else { pm8001_dbg(pm8001_ha, DISC, "Found dev has gone.\n");