Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3218176imu; Mon, 19 Nov 2018 12:28:19 -0800 (PST) X-Google-Smtp-Source: AJdET5eq0DuxSd0Xj/uwMiwYdpKbSOS+j7IQKYz3JvpWMzP/WLAg2ucI30bY79IAAoK55JXovMis X-Received: by 2002:a65:520a:: with SMTP id o10mr22230043pgp.276.1542659299033; Mon, 19 Nov 2018 12:28:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542659298; cv=none; d=google.com; s=arc-20160816; b=VLS3XzXliYV6PbLjymclU6kCNId6G/xDB1/Ziu5cFyVf5hzKy93SQJ8qM9aC8Ujo/k v6JKL9dj5OM/8mnD9GRhikfVQXAr4c0U4cU+GpngAxcxD/Bfm60qo6hzYegEUrA2sckN tBi3s96Kjvi7pQQftcj9ySs7ToNx5spzeWdRN0jFYxzANN5y+N06xW5RR0xRCQL1FUum jd4vm+eZp2/W9+zaLe5gdwpr8xElO5g/1ngVI62s6ISLAcWw5XMsEoy8Syg5bF5xmU3i BZyLWVf3aGT+UCJpq37IF0kkcyWrTnBfVEQIPG3/lu92OiK6ahkf18lEO5sxeohM56ZA TJhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=SW76frBgmIxnQj6FbUvYe17VUf1Wc2R/AGi8b/6ZdH8=; b=ca9jqg3uMx3i8GWCFIZ/+ywr84ojIIwblk9jYPA0dcDertRN1QUcXeMub27oGiyfMh yCYAmNk7355+Ml85KurvEuU3eGZCUUPz3CfBBaAQnI0i4VshdFR2LxzL57iIsg5FW0eg KKGvDt6/nrjhw5bzeRnLjkIixrAJ3CU2ONQMw9l6bdJ6Pfv7KBxsmVLi1QAmpnN/ia7O bggZaIV7CyaoeE5tbgiA1kLKsdWfg7gU6LIIJ3FFLa1gmR8ki+LrunVtGYIZR6aQbEy3 /EUhxUOYi5uiSkRlp7fn1YrBaXJeYIDmiYW4ub6eItFRL7dhtWcUCQvdHCCEmXKu7M0Y wZdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IrCmBPng; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q128si29538043pfc.179.2018.11.19.12.28.03; Mon, 19 Nov 2018 12:28:18 -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; dkim=pass header.i=@linaro.org header.s=google header.b=IrCmBPng; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730604AbeKTGuk (ORCPT + 99 others); Tue, 20 Nov 2018 01:50:40 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:41065 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728938AbeKTGuj (ORCPT ); Tue, 20 Nov 2018 01:50:39 -0500 Received: by mail-io1-f67.google.com with SMTP id s22so11349630ioc.8 for ; Mon, 19 Nov 2018 12:25:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SW76frBgmIxnQj6FbUvYe17VUf1Wc2R/AGi8b/6ZdH8=; b=IrCmBPnglmOh5pNgVx60lJyzAq2HMCcFXS+SR8ReDkal7sRcyoaIv+T/Txzug6le/H w+8HNdvSup6SrvMzUs/5r9gIvZ+s5Z6EcFwUH9FYVNW3Eae333JL+PGjRsbMZ8F6gLWi 96+PpdaGcklwMVpjIv9SzGf4TJumcDPkmOr1c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SW76frBgmIxnQj6FbUvYe17VUf1Wc2R/AGi8b/6ZdH8=; b=ZXqttJJjzEYjPKipyfUpKsCkbeq3mJ6tbCnZtHlPY3w/N5yeu/uoOLId00UTU8/SPe iKuw75wsDvFcr/NawXkyvbxKpLeZhhPB3WtVPCG1X1bfxtPZ+Yv5y1Xoxn1AiyxMaiox uht3Srp9hxDsYlcJiNMQBSqd1Hfwld7JuR3Mcno+z5dQwtTEilBzSIGUkkexdz7ep3G4 37KTzrEmwmQVda4v3oMXMr8MlaKcV+aV9w/c79wYCKtE4OqBNNR/RLdVsxIPA98gUbp3 BwW6EbDn2nTKeufNmd4ZFEJ3IFkIkhPQtZ/9uGbHpw7HtABtvUqFUdfT3oaWU4JdEma6 Bk1Q== X-Gm-Message-State: AA+aEWZzDLjTS9AYNMWeAyfTMS3bLGLrDwY9WmiR+bzK5ivGVv8tfEFA jPg8zqV7DnYaej4YXH9I0glsUu68ObBtuM8Oe5AmAg== X-Received: by 2002:a6b:7a46:: with SMTP id k6mr16560434iop.60.1542659121003; Mon, 19 Nov 2018 12:25:21 -0800 (PST) MIME-Version: 1.0 References: <1542657210-37739-1-git-send-email-clabbe@baylibre.com> <1542657210-37739-2-git-send-email-clabbe@baylibre.com> In-Reply-To: <1542657210-37739-2-git-send-email-clabbe@baylibre.com> From: Ard Biesheuvel Date: Mon, 19 Nov 2018 12:25:10 -0800 Message-ID: Subject: Re: [PATCH v2 01/11] crypto: move crypto_alg_get/crypto_alg_put to linux/crypto.h To: Corentin Labbe Cc: "David S. Miller" , Eric Biggers , Herbert Xu , nhorman@tuxdriver.com, "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 19 Nov 2018 at 11:53, Corentin Labbe wrote: > > Since we will need crypto_alg_get/crypto_alg_put for "locking" > crypto_alg when updating stats, we need it to be via linux/crypto.h > This seems backwards to me. Surely, crypto stats are permitted to use the internal crypto API? > Signed-off-by: Corentin Labbe > --- > crypto/internal.h | 12 ------------ > include/linux/crypto.h | 12 ++++++++++++ > 2 files changed, 12 insertions(+), 12 deletions(-) > > diff --git a/crypto/internal.h b/crypto/internal.h > index ef769b5e8ad3..d81f033aeb5c 100644 > --- a/crypto/internal.h > +++ b/crypto/internal.h > @@ -91,18 +91,6 @@ unsigned int crypto_alg_extsize(struct crypto_alg *alg); > int crypto_type_has_alg(const char *name, const struct crypto_type *frontend, > u32 type, u32 mask); > > -static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg) > -{ > - refcount_inc(&alg->cra_refcnt); > - return alg; > -} > - > -static inline void crypto_alg_put(struct crypto_alg *alg) > -{ > - if (refcount_dec_and_test(&alg->cra_refcnt) && alg->cra_destroy) > - alg->cra_destroy(alg); > -} > - > static inline int crypto_tmpl_get(struct crypto_template *tmpl) > { > return try_module_get(tmpl->module); > diff --git a/include/linux/crypto.h b/include/linux/crypto.h > index 3634ad6fe202..ac8f4168a831 100644 > --- a/include/linux/crypto.h > +++ b/include/linux/crypto.h > @@ -607,6 +607,18 @@ int crypto_unregister_algs(struct crypto_alg *algs, int count); > */ > int crypto_has_alg(const char *name, u32 type, u32 mask); > > +static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg) > +{ > + refcount_inc(&alg->cra_refcnt); > + return alg; > +} > + > +static inline void crypto_alg_put(struct crypto_alg *alg) > +{ > + if (refcount_dec_and_test(&alg->cra_refcnt) && alg->cra_destroy) > + alg->cra_destroy(alg); > +} > + > /* > * Transforms: user-instantiated objects which encapsulate algorithms > * and core processing logic. Managed via crypto_alloc_*() and > -- > 2.18.1 >