From: John Garry <john.garry@huawei.com>
To: Jason Yan <yanaijie@huawei.com>, <martin.petersen@oracle.com>,
<jejb@linux.ibm.com>
Cc: <linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<hare@suse.com>, <hch@lst.de>, <bvanassche@acm.org>,
<jinpu.wang@cloud.ionos.com>, <damien.lemoal@opensource.wdc.com>
Subject: Re: [PATCH v4 1/8] scsi: libsas: introduce sas address comparison helpers
Date: Tue, 27 Sep 2022 09:38:30 +0100 [thread overview]
Message-ID: <dc414029-bf05-7eba-e69f-bce0319bcb53@huawei.com> (raw)
In-Reply-To: <20220927032605.78103-2-yanaijie@huawei.com>
On 27/09/2022 04:25, Jason Yan wrote:
> Sas address comparison is widely used in libsas. However they are all
> opencoded and to avoid the line spill over 80 columns, are mostly split
> into multi-lines. Introduce some helpers to prepare some refactor.
>
> Signed-off-by: Jason Yan <yanaijie@huawei.com>
> Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: John Garry <john.garry@huawei.com>
> ---
> drivers/scsi/libsas/sas_internal.h | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h
> index 8d0ad3abc7b5..3384429b7eb0 100644
> --- a/drivers/scsi/libsas/sas_internal.h
> +++ b/drivers/scsi/libsas/sas_internal.h
> @@ -111,6 +111,23 @@ static inline void sas_smp_host_handler(struct bsg_job *job,
> }
> #endif
>
> +static inline bool sas_phy_match_dev_addr(struct domain_device *dev,
> + struct ex_phy *phy)
> +{
> + return SAS_ADDR(dev->sas_addr) == SAS_ADDR(phy->attached_sas_addr);
> +}
> +
> +static inline bool sas_phy_match_port_addr(struct asd_sas_port *port,
> + struct ex_phy *phy)
> +{
> + return SAS_ADDR(port->sas_addr) == SAS_ADDR(phy->attached_sas_addr);
> +}
> +
> +static inline bool sas_phy_addr_match(struct ex_phy *p1, struct ex_phy *p2)
> +{
> + return SAS_ADDR(p1->attached_sas_addr) == SAS_ADDR(p2->attached_sas_addr);
> +}
> +
note: I did think that we could use a macro as a generic matching API, like:
#define sas_phy_match_addr_common(x, ex_phy) \
({ typeof(x) __dummy; \
if (__builtin_types_compatible_p(typeof(__dummy), struct asd_sas_port))\
sas_phy_match_port_addr(x, ex_phy);\
if (__builtin_types_compatible_p(typeof(__dummy), struct domain_device))\
sas_phy_match_dev_addr(x, ex_phy);\
0; \
})
But I couldn't get it to work after 60 minutes of messing ... indeed,
that latest code doesn't even compile..
Thanks,
John
> static inline void sas_fail_probe(struct domain_device *dev, const char *func, int err)
> {
> pr_warn("%s: for %s device %016llx returned %d\n",
next prev parent reply other threads:[~2022-09-27 8:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-27 3:25 [PATCH v4 0/8] scsi: libsas: sas address comparison refactor Jason Yan
2022-09-27 3:25 ` [PATCH v4 1/8] scsi: libsas: introduce sas address comparison helpers Jason Yan
2022-09-27 8:38 ` John Garry [this message]
2022-09-27 3:25 ` [PATCH v4 2/8] scsi: libsas: introduce sas_find_attached_phy() helper Jason Yan
2022-09-27 8:46 ` John Garry
2022-09-27 3:26 ` [PATCH v4 3/8] scsi: pm8001: use sas_find_attached_phy() instead of open coded Jason Yan
2022-09-27 8:34 ` John Garry
2022-09-27 11:25 ` Jason Yan
2022-09-27 3:26 ` [PATCH v4 4/8] scsi: mvsas: " Jason Yan
2022-09-27 3:26 ` [PATCH v4 5/8] scsi: hisi_sas: use sas_find_attathed_phy() " Jason Yan
2022-09-27 3:26 ` [PATCH v4 6/8] scsi: libsas: use sas_phy_match_dev_addr() " Jason Yan
2022-09-27 4:25 ` Damien Le Moal
2022-09-27 3:26 ` [PATCH v4 7/8] scsi: libsas: use sas_phy_addr_match() " Jason Yan
2022-09-27 3:26 ` [PATCH v4 8/8] scsi: libsas: use sas_phy_match_port_addr() " Jason Yan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dc414029-bf05-7eba-e69f-bce0319bcb53@huawei.com \
--to=john.garry@huawei.com \
--cc=bvanassche@acm.org \
--cc=damien.lemoal@opensource.wdc.com \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=jejb@linux.ibm.com \
--cc=jinpu.wang@cloud.ionos.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=yanaijie@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®