scsi: pm80xx: Set phy_attached to zero when device is gone

Message ID 20230516175737.1831575-1-pranavpp@google.com
State New
Headers
Series scsi: pm80xx: Set phy_attached to zero when device is gone |

Commit Message

Pranav Prasad May 16, 2023, 5:57 p.m. UTC
  From: Igor Pylypiv <ipylypiv@google.com>

Set phy_attached to zero when device is gone.

Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
Signed-off-by: Pranav Prasad <pranavpp@google.com>
---
 drivers/scsi/pm8001/pm8001_sas.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

John Garry May 17, 2023, 1:21 p.m. UTC | #1
On 16/05/2023 18:57, Pranav Prasad wrote:
> From: Igor Pylypiv <ipylypiv@google.com>
> 
> Set phy_attached to zero when device is gone.
> 
> Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
> Signed-off-by: Pranav Prasad <pranavpp@google.com>
> ---
>   drivers/scsi/pm8001/pm8001_sas.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
> index e5673c774f66..c57fc671509d 100644
> --- a/drivers/scsi/pm8001/pm8001_sas.c
> +++ b/drivers/scsi/pm8001/pm8001_sas.c
> @@ -706,6 +706,7 @@ static void pm8001_dev_gone_notify(struct domain_device *dev)
>   			spin_lock_irqsave(&pm8001_ha->lock, flags);
>   		}
>   		PM8001_CHIP_DISP->dereg_dev_req(pm8001_ha, device_id);
> +		pm8001_ha->phy[pm8001_dev->attached_phy].phy_attached = 0;

Can you factor stuff like this out, so that maintaining these values is 
easier and less error prone?

Check this:
~/linux/drivers/scsi/pm8001> git grep "phy_attached = 0" | wc -l
21


>   		pm8001_free_dev(pm8001_dev);
>   	} else {
>   		pm8001_dbg(pm8001_ha, DISC, "Found dev has gone.\n");
  

Patch

diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index e5673c774f66..c57fc671509d 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -706,6 +706,7 @@  static void pm8001_dev_gone_notify(struct domain_device *dev)
 			spin_lock_irqsave(&pm8001_ha->lock, flags);
 		}
 		PM8001_CHIP_DISP->dereg_dev_req(pm8001_ha, device_id);
+		pm8001_ha->phy[pm8001_dev->attached_phy].phy_attached = 0;
 		pm8001_free_dev(pm8001_dev);
 	} else {
 		pm8001_dbg(pm8001_ha, DISC, "Found dev has gone.\n");