All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhou Wang <wangzhou1@hisilicon.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	Mao Wenan <maowenan@huawei.com>
Cc: herbert@gondor.apana.org.au, davem@davemloft.net,
	tanshukun1@huawei.com, linux-crypto@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH -next] crypto: hisilicon: move label err to #ifdef CONFIG_NUMA
Date: Wed, 06 Nov 2019 00:50:03 +0000	[thread overview]
Message-ID: <5DC218BB.3080001@hisilicon.com> (raw)
In-Reply-To: <20191105145602.GH10409@kadam>

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

WARNING: multiple messages have this Message-ID (diff)
From: Zhou Wang <wangzhou1@hisilicon.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	Mao Wenan <maowenan@huawei.com>
Cc: <herbert@gondor.apana.org.au>, <davem@davemloft.net>,
	<tanshukun1@huawei.com>, <linux-crypto@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH -next] crypto: hisilicon: move label err to #ifdef CONFIG_NUMA
Date: Wed, 6 Nov 2019 08:50:03 +0800	[thread overview]
Message-ID: <5DC218BB.3080001@hisilicon.com> (raw)
In-Reply-To: <20191105145602.GH10409@kadam>

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


  reply	other threads:[~2019-11-06  0:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05 14:33 [PATCH -next] crypto: hisilicon: move label err to #ifdef CONFIG_NUMA Mao Wenan
2019-11-05 14:33 ` Mao Wenan
2019-11-05 14:56 ` Dan Carpenter
2019-11-05 14:56   ` Dan Carpenter
2019-11-06  0:50   ` Zhou Wang [this message]
2019-11-06  0:50     ` Zhou Wang

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=5DC218BB.3080001@hisilicon.com \
    --to=wangzhou1@hisilicon.com \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maowenan@huawei.com \
    --cc=tanshukun1@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.