mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Garry <john.garry@huawei.com>
To: Johannes Thumshirn <jthumshirn@suse.de>,
	<jejb@linux.vnet.ibm.com>, <martin.petersen@oracle.com>
Cc: <linuxarm@huawei.com>, <linux-kernel@vger.kernel.org>,
	<linux-scsi@vger.kernel.org>,
	Xiang Chen <chenxiang66@hisilicon.com>
Subject: Re: [PATCH v4 2/5] scsi: hisi_sas: Relocate some code to reduce complexity
Date: Thu, 6 Dec 2018 15:37:46 +0000	[thread overview]
Message-ID: <2da87e22-1bbc-aff9-c0be-85a3fd8f4393@huawei.com> (raw)
In-Reply-To: <c7ec9e23-6da8-35e0-1996-02db3d640f4b@suse.de>

On 06/12/2018 14:17, Johannes Thumshirn wrote:
> On 06/12/2018 14:34, John Garry wrote:
> [...]
>> +static void hisi_sas_dma_unmap(struct hisi_hba *hisi_hba,
>> +			       struct sas_task *task, int n_elem,
>> +			       int n_elem_req, int n_elem_resp)
>> +{
>> +	struct device *dev = hisi_hba->dev;
>> +
>> +	if (!sas_protocol_ata(task->task_proto)) {
>> +		if (task->num_scatter) {
>> +			if (n_elem)
>> +				dma_unmap_sg(dev, task->scatter,
>> +					     task->num_scatter,
>> +					     task->data_dir);
>> +		} else if (task->task_proto & SAS_PROTOCOL_SMP) {
>> +			if (n_elem_req)
>> +				dma_unmap_sg(dev, &task->smp_task.smp_req,
>> +					     1, DMA_TO_DEVICE);
>> +			if (n_elem_resp)
>> +				dma_unmap_sg(dev, &task->smp_task.smp_resp,
>> +					     1, DMA_FROM_DEVICE);
>> +		}
>> +	}
>
> 	if (sas_protocol_ata(task->task_proto))
> 		return;
>
> Would save you a level of indentation and make the above more readable.
>
>

Hi Johannes,

Whilst I agree with the idea, the current approach makes the function 
more symmetic with its mapping buddy, hisi_sas_dma_map():

static void hisi_sas_dma_unmap(struct hisi_hba *hisi_hba,
                    struct sas_task *task, int n_elem,
                    int n_elem_req, int n_elem_resp)
{
     struct device *dev = hisi_hba->dev;

     if (!sas_protocol_ata(task->task_proto)) {
         if (task->num_scatter) {
             if (n_elem)
                 dma_unmap_sg(dev, task->scatter,

	...
}

static int hisi_sas_dma_map(struct hisi_hba *hisi_hba,
                 struct sas_task *task, int *n_elem,
                 int *n_elem_req, int *n_elem_resp)
{
     struct device *dev = hisi_hba->dev;
     int rc;

     if (sas_protocol_ata(task->task_proto)) {
         *n_elem = task->num_scatter;
     } else {
         unsigned int req_len, resp_len;

         if (task->num_scatter) {
             *n_elem = dma_map_sg(dev, task->scatter,
                          task->num_scatter, task->data_dir);
    		...

}

which is important. Let me know if you disagree and I can change it.

Thanks,
John



  reply	other threads:[~2018-12-06 15:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-06 13:34 [PATCH v4 0/5] hisi_sas: DIF support John Garry
2018-12-06 13:34 ` [PATCH v4 1/5] scsi: hisi_sas: Fix warnings detected by sparse John Garry
2018-12-06 13:34 ` [PATCH v4 2/5] scsi: hisi_sas: Relocate some code to reduce complexity John Garry
2018-12-06 14:17   ` Johannes Thumshirn
2018-12-06 15:37     ` John Garry [this message]
2018-12-06 16:20       ` Johannes Thumshirn
2018-12-07 10:07         ` John Garry
2018-12-07 10:53           ` Johannes Thumshirn
2018-12-06 13:34 ` [PATCH v4 3/5] scsi: hisi_sas: Make sg_tablesize consistent value John Garry
2018-12-06 13:34 ` [PATCH v4 4/5] scsi: hisi_sas: Add support for DIF feature for v3 hw John Garry
2018-12-13  2:20   ` Martin K. Petersen
2018-12-13 13:35     ` John Garry
2018-12-17 14:51       ` John Garry
2018-12-18  3:31         ` Martin K. Petersen
2018-12-06 13:34 ` [RFC PATCH v4 5/5] scsi: hisi_sas: Add support for DIX feature for v3 hw as experimental John Garry
2018-12-13  2:23 ` [PATCH v4 0/5] hisi_sas: DIF support Martin K. Petersen

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=2da87e22-1bbc-aff9-c0be-85a3fd8f4393@huawei.com \
    --to=john.garry@huawei.com \
    --cc=chenxiang66@hisilicon.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=jthumshirn@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=martin.petersen@oracle.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®