mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: David Yang <mmyangfl@gmail.com>, linux-crypto@vger.kernel.org
Cc: Weili Qian <qianweili@huawei.com>,
	Zhou Wang <wangzhou1@hisilicon.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] crypto: hisilicon - Add HiSilicon ADVCA Subsystem
Date: Wed, 24 May 2023 12:45:04 +0200	[thread overview]
Message-ID: <b33cf92691afaa158c6282703128dfb8da4fe242.camel@pengutronix.de> (raw)
In-Reply-To: <20230513074339.266879-2-mmyangfl@gmail.com>

Hi David,

On Sa, 2023-05-13 at 15:43 +0800, David Yang wrote:
> HiSilicon ADVCA Subsystem contains various cryptographic devices, including
> symmetric key ciphers, hash functions, RSA algorithms, as well as key
> ladder and OTP memory.
> 
> This patch adds symmetric key cipher driver.
> 
> Signed-off-by: David Yang <mmyangfl@gmail.com>
> ---
>  drivers/crypto/hisilicon/Kconfig              |    8 +
>  drivers/crypto/hisilicon/Makefile             |    1 +
>  drivers/crypto/hisilicon/advca/Makefile       |    1 +
>  .../crypto/hisilicon/advca/hisi-advca-muc.c   | 1527 +++++++++++++++++
>  4 files changed, 1537 insertions(+)
>  create mode 100644 drivers/crypto/hisilicon/advca/Makefile
>  create mode 100644 drivers/crypto/hisilicon/advca/hisi-advca-muc.c
> 
[...]
> diff --git a/drivers/crypto/hisilicon/advca/hisi-advca-muc.c b/drivers/crypto/hisilicon/advca/hisi-advca-muc.c
> new file mode 100644
> index 000000000000..362596a91e19
> --- /dev/null
> +++ b/drivers/crypto/hisilicon/advca/hisi-advca-muc.c
> @@ -0,0 +1,1527 @@
[...]
> +static int hica_muc_probe(struct platform_device *pdev)
> +{
[...]
> +	priv->rst = devm_reset_control_get_optional(dev, NULL);

Please use devm_reset_control_get_optional_exclusive() directly.

Since priv->rst is only ever used in hica_muc_probe(), it could be
stored in a local variable instead.

> +	if (IS_ERR(priv->rst))
> +		return PTR_ERR(priv->rst);
> +
> +	ret = platform_get_irq(pdev, 0);
> +	if (ret < 0)
> +		return ret;
> +	priv->irqs[0] = ret;
> +	priv->irqs[1] = platform_get_irq_optional(pdev, 1);
> +
> +	priv->algs_num = ARRAY_SIZE(hica_muc_tmpls);
> +	priv->algs = devm_kmalloc_array(dev, priv->algs_num,
> +					sizeof(priv->algs[0]), GFP_KERNEL);
> +	if (!priv->algs)
> +		return -ENOMEM;
> +
> +	init_completion(&priv->cond);
> +
> +	priv->dev = dev;
> +	platform_set_drvdata(pdev, priv);
> +	dev_set_drvdata(dev, priv);
> +
> +	/* bring up device */
> +	ret = reset_control_assert(priv->rst) ?:
> +	      clk_bulk_prepare_enable(priv->clks_num, priv->clks) ?:
> +	      reset_control_deassert(priv->rst);

Using the ternary operator like this is a bit unconventional. Here, the
clocks are kept enabled if the reset_control_deassert() fails.

It would be good to add an error path that disables the clocks.

> +	if (ret)
> +		return ret;
> +
> +	if (!(readl(priv->base + MUC_RST_STATUS) & MUC_STATE_VALID)) {
> +		msleep(20);
> +		if (!(readl(priv->base + MUC_RST_STATUS) & MUC_STATE_VALID)) {
> +			dev_err(dev, "cannot bring up device\n");
> +			return -ENODEV;

This also leaves the clocks enabled. There are some more return
statements with the same issue below.

regards
Philipp

  parent reply	other threads:[~2023-05-24 10:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-13  7:43 [PATCH v2 0/2] " David Yang
2023-05-13  7:43 ` [PATCH v2 1/2] " David Yang
2023-05-13  8:42   ` kernel test robot
2023-05-24 10:45   ` Philipp Zabel [this message]
2023-05-13  7:43 ` [PATCH v2 2/2] crypto: hisilicon/advca - Add SHA support David Yang
2023-05-13  9:05   ` kernel test robot
2023-05-19  8:43   ` Herbert Xu
2023-05-19 19:03     ` Yangfl
2023-05-24 10:15       ` Herbert Xu

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=b33cf92691afaa158c6282703128dfb8da4fe242.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmyangfl@gmail.com \
    --cc=qianweili@huawei.com \
    --cc=wangzhou1@hisilicon.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®