All of lore.kernel.org
 help / color / mirror / Atom feed
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>
Subject: Re: [PATCH 1/7] scsi: libsas: introduce sas address conversion and comparation helpers
Date: Thu, 22 Sep 2022 15:14:06 +0100	[thread overview]
Message-ID: <650e35b7-9d90-fe03-7d92-48207644536b@huawei.com> (raw)
In-Reply-To: <20220917104311.1878250-2-yanaijie@huawei.com>

On 17/09/2022 11:43, Jason Yan wrote:
> Sas address conversion and comparation is widely used in libsas and
> drivers. 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>
> ---
>   include/scsi/libsas.h | 32 ++++++++++++++++++++++++++++++++
>   1 file changed, 32 insertions(+)
> 
> diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
> index 2dbead74a2af..382aedf31fa4 100644
> --- a/include/scsi/libsas.h
> +++ b/include/scsi/libsas.h
> @@ -648,6 +648,38 @@ static inline bool sas_is_internal_abort(struct sas_task *task)
>   	return task->task_proto == SAS_PROTOCOL_INTERNAL_ABORT;
>   }
>   
> +static inline unsigned long long ex_phy_addr(struct ex_phy *phy)

This is a public header, so I would hope that any function would have 
"sas_" prefix

> +{
> +	return SAS_ADDR(phy->attached_sas_addr);
> +}
> +
> +static inline unsigned long long dev_addr(struct domain_device *dev)
> +{
> +	return SAS_ADDR(dev->sas_addr);
> +}
> +
> +static inline unsigned long long port_addr(struct asd_sas_port *port)
> +{
> +	return SAS_ADDR(port->sas_addr);

As below, I don't really see how these simple functions help much

> +}
> +
> +static inline bool dev_and_phy_addr_same(struct domain_device *dev,
> +					 struct ex_phy *phy)
> +{
> +	return dev_addr(dev) == ex_phy_addr(phy);
> +}
> +
> +static inline bool port_and_phy_addr_same(struct asd_sas_port *port,
> +					  struct ex_phy *phy)

I'd say sas_phy_match_port_addr() could be a better name.

> +{
> +	return port_addr(port) == ex_phy_addr(phy);

I think the following is just as good:

	return SAS_ADDR(port->sas_addr) == SAS_ADDR(phy->attached_sas_addr)

port_addr() is only used once AFAICS, so the code would not be less concise

> +}
> +
> +static inline bool ex_phy_addr_same(struct ex_phy *phy1, struct ex_phy *phy2)
> +{
> +	return  ex_phy_addr(phy1) ==  ex_phy_addr(phy2);

nit: 2x double whitespace

> +}
> +
>   struct sas_domain_function_template {
>   	/* The class calls these to notify the LLDD of an event. */
>   	void (*lldd_port_formed)(struct asd_sas_phy *);

Thanks,
John

  reply	other threads:[~2022-09-22 14:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-17 10:43 [PATCH 0/7] scsi: libsas: sas address comparation refactor Jason Yan
2022-09-17 10:43 ` [PATCH 1/7] scsi: libsas: introduce sas address conversion and comparation helpers Jason Yan
2022-09-22 14:14   ` John Garry [this message]
2022-09-17 10:43 ` [PATCH 2/7] scsi: libsas: use dev_and_phy_addr_same() instead of open coded Jason Yan
2022-09-17 10:43 ` [PATCH 3/7] scsi: libsas: use ex_phy_addr_same() " Jason Yan
2022-09-17 10:43 ` [PATCH 4/7] scsi: libsas: use port_and_phy_addr_same() " Jason Yan
2022-09-17 10:43 ` [PATCH 5/7] scsi: hisi_sas: use dev_and_phy_addr_same() " Jason Yan
2022-09-17 10:43 ` [PATCH 6/7] scsi: pm8001: " Jason Yan
2022-09-22 14:24   ` John Garry
2022-09-23  1:55     ` Jason Yan
2022-09-23  9:44     ` Jason Yan
2022-09-23 10:00       ` John Garry
2022-09-23 10:10         ` Jason Yan
2022-09-23 10:13         ` Jason Yan
2022-09-23 10:30           ` John Garry
2022-09-24  3:22             ` Jason Yan
2022-09-17 10:43 ` [PATCH 7/7] scsi: mvsas: " 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=650e35b7-9d90-fe03-7d92-48207644536b@huawei.com \
    --to=john.garry@huawei.com \
    --cc=bvanassche@acm.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.