Skip to content

Commit

Permalink
scsi: libsas: Introduce sas_find_attached_phy_id() helper
Browse files Browse the repository at this point in the history
LLDDs are all implementing their own attached phy ID finding code.  Factor
it out to libsas.

Signed-off-by: Jason Yan <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Jack Wang <[email protected]>
Reviewed-by: Damien Le Moal <[email protected]>
Reviewed-by: John Garry <[email protected]>
Reviewed-by: Johannes Thumshirn <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
  • Loading branch information
JasonYanHw authored and martinkpetersen committed Oct 18, 2022
1 parent 773792e commit 2d08f32
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions drivers/scsi/libsas/sas_expander.c
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,22 @@ int sas_ex_revalidate_domain(struct domain_device *port_dev)
return res;
}

int sas_find_attached_phy_id(struct expander_device *ex_dev,
struct domain_device *dev)
{
struct ex_phy *phy;
int phy_id;

for (phy_id = 0; phy_id < ex_dev->num_phys; phy_id++) {
phy = &ex_dev->ex_phy[phy_id];
if (sas_phy_match_dev_addr(dev, phy))
return phy_id;
}

return -ENODEV;
}
EXPORT_SYMBOL_GPL(sas_find_attached_phy_id);

void sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost,
struct sas_rphy *rphy)
{
Expand Down
2 changes: 2 additions & 0 deletions include/scsi/libsas.h
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,8 @@ int sas_clear_task_set(struct domain_device *dev, u8 *lun);
int sas_lu_reset(struct domain_device *dev, u8 *lun);
int sas_query_task(struct sas_task *task, u16 tag);
int sas_abort_task(struct sas_task *task, u16 tag);
int sas_find_attached_phy_id(struct expander_device *ex_dev,
struct domain_device *dev);

void sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event,
gfp_t gfp_flags);
Expand Down

0 comments on commit 2d08f32

Please sign in to comment.