Re: [PATCH 6/7] scsi: pm8001: use dev_and_phy_addr_same() instead of open coded

From: Jason Yan
Date: Fri Sep 23 2022 - 23:22:43 EST



On 2022/9/23 18:30, John Garry wrote:
On 23/09/2022 11:13, Jason Yan wrote:

Please explain why.

I would assume that if those helpers were only used in libsas code (and not LLDDs) then they could be put in sas_internal.h and no need for export



Sorry, I did not make it clear. I mean we need to export sas_find_attathed_phy() below. Not the sas address comparation helpers.

That seems fine to me.

About sas_find_attathed_phy() implementation,

> +static inline int sas_find_attathed_phy(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_ADDR(phy->attached_sas_addr)
> +                       == SAS_ADDR(dev->sas_addr))
> +                       return phy_id;
> +       }
> +
> +       return ex_dev->num_phys;

Returning ex_dev->num_phys would seem ok, but then the LLDD needs to check that return against ex_dev->num_phys. It seems ok, but I'm still not 100% comfortable with that. Maybe returning -ENODEV may be better.

Or return boolean and pass phy_id as pointer to be filled in when returning true.


I've been thinking about this for a while too. Thank you for the advise.

Thanks,
Jason

> +}

Thanks,
John

.