Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10844960imu; Thu, 6 Dec 2018 07:40:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/VbU/7PioiwuOqYSfRyNkApRADXOHhrGx1QM/iLwHBESM4C5sgcXWiJLvmtsai6ell0WYza X-Received: by 2002:a17:902:2dc3:: with SMTP id p61mr28012481plb.166.1544110807410; Thu, 06 Dec 2018 07:40:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544110807; cv=none; d=google.com; s=arc-20160816; b=00yoY9tlZeK04m65IAdey6u7DA0B4QGw7Wz3trUx4K+AZIVhe0RRcIXfuo0+LLrGqY 6tFo4cIzTOeHrq1X42ww+iH98styff8oUm9j4k6X+shhjHn4LUYil454IdDq3rpO8u5b VqCNwPDOmJhI5R0BK+kylf1dLgUJCIsRG4FlNXwfU8vu+lx8Ucb8bdI+EJrBxEWjy9No U8E3A3zDdCOFRzW0Ze2TUX4FCdt9CK4SFkgptI5tBsmN1e+19fXl7sjfNT9abGpd+tuP qBfCl4kIbOhXt1VYGN01gFMEKvhwHiYr1n69TuE+VJO2uuPObEZnFgrNoVfslyUlPcTK ZskA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=4KOXmVYGcaO1/iLzYx1QKYEGPPyhjAx+TGC5klDYSoU=; b=UEusB3tXZy8MeA1pRvhsMFX+DpnyMihZu/Eqirm+V45NwhaB2t6+FcZgqblNgc2W53 m2WcC+NARqi0D/OEMRfS2TZa+DbE36Yh77Ug2L76B6xFQIKY7H3WMQC57pdMPwxAayZb fSn7zp0Uj7I3ZKN6ISguFclw2iDFFyQ4Qb4rLEYQrnaoJpn5ZMFhItDLZX0j0ViOxwuk FRVup4yDHDfw4OjVLg0JVFQfWQgeIv4acNffbuI+PKCtGtOjGdlrabHNsMnXKq5ekwy2 /SrOSyRwwMwgqgpr0mxlB5MmrhN6ut+OMHyC7CleH0rNWZmJiTLK57WMOfnWY6R4wy/N GGyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e3si503981pfe.203.2018.12.06.07.39.43; Thu, 06 Dec 2018 07:40:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726230AbeLFPiB (ORCPT + 99 others); Thu, 6 Dec 2018 10:38:01 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:59124 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725936AbeLFPiA (ORCPT ); Thu, 6 Dec 2018 10:38:00 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id C8088F0F1662A; Thu, 6 Dec 2018 23:37:56 +0800 (CST) Received: from [127.0.0.1] (10.202.226.41) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.408.0; Thu, 6 Dec 2018 23:37:51 +0800 Subject: Re: [PATCH v4 2/5] scsi: hisi_sas: Relocate some code to reduce complexity To: Johannes Thumshirn , , References: <1544103284-100497-1-git-send-email-john.garry@huawei.com> <1544103284-100497-3-git-send-email-john.garry@huawei.com> CC: , , , Xiang Chen From: John Garry Message-ID: <2da87e22-1bbc-aff9-c0be-85a3fd8f4393@huawei.com> Date: Thu, 6 Dec 2018 15:37:46 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.226.41] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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