Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1462781ybx; Tue, 5 Nov 2019 16:50:54 -0800 (PST) X-Google-Smtp-Source: APXvYqwjqJt3ws11sKkt8x3idm4AYgfdVwoLhAfkzCni0hY72CLic6T/z67Zy/CUFW7NsP3bypvu X-Received: by 2002:a17:906:66d2:: with SMTP id k18mr31906388ejp.278.1573001454097; Tue, 05 Nov 2019 16:50:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573001454; cv=none; d=google.com; s=arc-20160816; b=uNh4/pe0Qr0zSZMwu9kwjMMoQFx9qZmMMje4cSpMYYJcuGCESsdWsZQ5tLHKSz9lfn TxafHJJ55/VEFFDbDsAUQkfag0JKpuh8v2bFqKb2+ArUB2IDKhbbgzpWPBK7fH4QuHgI vz0jeYlMWwi+5UZzhPmcfp6r667hBTdl3UoucNRQH3jtWLP5zJ34zcDiMFJumyOO78eC I+5rQRSF95M9IU850+FP/ctigxbkXn/f6eKev/dlOKE4obft5hw4qopENNIKkwzLPlZy WqfApOaKHf1ZPj9w+Cftf5FNmNg7EP19YMhgG1CShJTPFGZ0ZypB52mwStyQnlNiS4ve Q2Xw== 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=5AAjGuNh2DyqNBNtbAAYDkYQpHFQjJSxYAfMwHcrsOc=; b=kY48ld0H4yE2vrUKmeZ5cpFasdJm0sfHOYzHvQZEh3R7PxM3Os08Vwhl2I4FujEBrB rgJMqkq9xVnQGmAy/FdXhuAR02DNUHzGGPcEmy27VKvorXcyKpty1A+IT6tsDYvHa4vt lmVo/TY6j8PbWwHDrsTIoaX+gGeONwOyTjTUl2ozoN/qqa2qHTk/ozeVTBwF+mn5uupH 29LOr9mEGjdSlqX4ltMkwRTjkFPPa3B16kEihNTHl2WSGym7EsSYJAgf7aSnhhGnHWNm 7z/11W8zQJJAwCqo0nZN/DgEr/6fCq0X3qRWchVke459wtyg7vH+962PIuJ9E825KyfZ NpSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 h2si3846209ejy.259.2019.11.05.16.50.20; Tue, 05 Nov 2019 16:50:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727132AbfKFAuM (ORCPT + 99 others); Tue, 5 Nov 2019 19:50:12 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:50336 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727046AbfKFAuM (ORCPT ); Tue, 5 Nov 2019 19:50:12 -0500 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 13411F21071883A3EAD7; Wed, 6 Nov 2019 08:50:10 +0800 (CST) Received: from [127.0.0.1] (10.63.139.185) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Wed, 6 Nov 2019 08:50:04 +0800 Subject: Re: [PATCH -next] crypto: hisilicon: move label err to #ifdef CONFIG_NUMA To: Dan Carpenter , Mao Wenan References: <20191105143340.32950-1-maowenan@huawei.com> <20191105145602.GH10409@kadam> CC: , , , , , From: Zhou Wang Message-ID: <5DC218BB.3080001@hisilicon.com> Date: Wed, 6 Nov 2019 08:50:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20191105145602.GH10409@kadam> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.63.139.185] X-CFilter-Loop: Reflected Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 2019/11/5 22:56, Dan Carpenter wrote: > The ifdefs in this function were pretty ugly before but this makes it > super extra ugly... :/ There are bunch of ways to fix this nicely > but my favourite is this: > > Feel free to give me a Suggested-by tag. > > diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisilicon/zip/zip_main.c > index 255b63cfbe1d..1b22f0ead56e 100644 > --- a/drivers/crypto/hisilicon/zip/zip_main.c > +++ b/drivers/crypto/hisilicon/zip/zip_main.c > @@ -105,20 +105,27 @@ static void free_list(struct list_head *head) > struct hisi_zip *find_zip_device(int node) > { > struct hisi_zip *ret = NULL; > -#ifdef CONFIG_NUMA > struct hisi_zip_resource *res, *tmp; > struct hisi_zip *hisi_zip; > struct list_head *n; > struct device *dev; > LIST_HEAD(head); > > + if (!IS_ENABLED(CONFIG_NUMA)) { > + mutex_lock(&hisi_zip_list_lock); > + ret = list_first_entry(&hisi_zip_list, struct hisi_zip, list); > + mutex_unlock(&hisi_zip_list_lock); > + return ret; > + } > + > mutex_lock(&hisi_zip_list_lock); > > list_for_each_entry(hisi_zip, &hisi_zip_list, list) { > res = kzalloc(sizeof(*res), GFP_KERNEL); > - if (!res) > - goto err; > - > + if (!res) { > + ret = NULL; > + goto done; > + } > dev = &hisi_zip->qm.pdev->dev; > res->hzip = hisi_zip; > res->distance = node_distance(dev->numa_node, node); > @@ -140,20 +147,10 @@ struct hisi_zip *find_zip_device(int node) > } > } > > +done: > free_list(&head); > -#else > - mutex_lock(&hisi_zip_list_lock); > - > - ret = list_first_entry(&hisi_zip_list, struct hisi_zip, list); > -#endif > mutex_unlock(&hisi_zip_list_lock); > - > return ret; > - > -err: > - free_list(&head); > - mutex_unlock(&hisi_zip_list_lock); > - return NULL; > } > > struct hisi_zip_hw_error { > > > . > Hi Mao and Dan, I already posted a patch to fix this problem: [PATCH] crypto: hisilicon - replace #ifdef with IS_ENABLED for CONFIG_NUMA Many thanks for your help, Zhou