From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99561C2B9FB for ; Sat, 22 May 2021 17:03:20 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 13B98611AB for ; Sat, 22 May 2021 17:03:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13B98611AB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=3n4K2+5aSlvuS87tF3LwWCTHsCWuEDWZJEohkr/BqwM=; b=jYHIyCOeOB8KcYSdzOVAmlkpru Z0CBQA2uUW248e6RN79MTUOf83rkPR/LppqX7yO5MR/AOT4xdVLcjFeTeDz+udFdB2IMt6q/9e7eD Z8Gqdl+FuQ0bNS4AJSF0H3kVNCulOCnCC2eyOE2y4kK2NqpFHxlTVt/B7TCazv23eF+fRirK3039m cmTdoUvL38dHm0Ruk0m8kZ0JM//jhjDlsHhzapSz9Ow4KGgtUA4KjiknuPpdZOo73U6NcBRdq4UNq AIY0VZrwjzTKciuTTfwW6/kvTZGWnlKmhjUUadjwqv4NcabPrvLEcaKVoSDYGh4Xq3kzsqSLBDHct kJlmiJzw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lkV0D-002pE0-NJ; Sat, 22 May 2021 17:01:33 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lkV09-002pDd-Fo for linux-arm-kernel@desiato.infradead.org; Sat, 22 May 2021 17:01:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=cq6+ozOHxatifJxmjJnhjKtut+46PPMCogrnEz7m7b0=; b=kFkX9cu3DgvUk17AqJHx7ZXnIB 5DQerbLHeNepnivyIdKr97O/1/7IL5WbsKEGbd8Nl6eV5s/FQu2qr89W2nMkxCs7rNlTu34KUQ6Me E3DTCdDrTcLW7pOAnPxwKvpVuDyOLzHthpdE4QsOxzmcvsQFB08xLTTT0dalwBpHCbenD0f8DyY7u 8aVXVt7mqcxpiSrzSzmktVlCKGzF1ly9wHETIh7LWh6Q8FpnRDhapFWogYIFU+pcWw6fGY0DD81Vl vJJhnmVgV8j805cdrvmsbC27ZBH5/MSa+NWVzwCBM/16pF07aoLpJbJlKMmHaOYX9GB1A3VK8xWS5 0ZFflhPg==; Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lkV04-0009dl-VS for linux-arm-kernel@lists.infradead.org; Sat, 22 May 2021 17:01:22 +0000 Received: by mail-lf1-x131.google.com with SMTP id j6so31648170lfr.11 for ; Sat, 22 May 2021 10:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cq6+ozOHxatifJxmjJnhjKtut+46PPMCogrnEz7m7b0=; b=UAVFWis8oSSM6tsabuur7WglLQPrnLt2nHbWJlJ5cssnDGXqj8Z5Yg0krfCbVG1aJe B6bxsqQxP4v+Er2ucGNFdE0z2ettZZlrWu+7k6kJH+P5pkcFErF3JP6fPhQQyXQtlqrV o3QmEKAFAWYJcSd0Qj331nOVS7xOORhqRH1xRtiUXn3DriCx3wckNnuC6rER1iqVocDu DAZFbrlK9hyyfEOT/zRu9CYGy4JrIy0vZPhbkY/24SWDTWo3m5L7CDlIpp6Fpaq6ztcp QkV0TjwWE4IRZuKAd8cAXBgqajoiOV9Oz6qWDKD49LcHcVarnFc0cKwiKyxHUkQVGEi1 vuqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cq6+ozOHxatifJxmjJnhjKtut+46PPMCogrnEz7m7b0=; b=kcGbPzPVuxWwT8StSMZXIu+KQdOh3/fbNbj3EQxYIckEQUV8LCsNSSSileb8U5+YmE EW9xEvwPPvXzrl6gFumylinr8rSkrCRb4HLZVOSwGqrzwI7TMUdvKbyhyLNIFDGZmFhK tnl+iMISqN1tSGdZYKj7Oh5/dwGoB89Br9SFCMgfzaAsfA+351FN67IbxgU5ojaNi0mK YiZvAKjSPaJcwW2A/BRvBK+mV/aX96nqAk2xFt08UirzS1AdVGg2JqCJQCZslrTWHIuS f3Ao4qZcvfDDU0+lqL1EjPzw4XihHs45/Z3LcyWK5Nex3OlSQyYgdMMwiO2mtvoH/8Ws UjuQ== X-Gm-Message-State: AOAM532yDdTGeVuPbSWNbw/kxIQ7zwY5hh2g2ZPgLX2FP0KunQTP4RzQ 12MGw0DuqvtpDmyVjCt9b7X0Mg== X-Google-Smtp-Source: ABdhPJzG+z9Qjdc+9D2ks76dCLD7hvXbetW6b0VU5Zkz3/r4fD/i3Mllb2JarGZwVahNNNkx1jnVqA== X-Received: by 2002:a05:6512:a83:: with SMTP id m3mr5545501lfu.44.1621702878939; Sat, 22 May 2021 10:01:18 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id u15sm958870lfs.67.2021.05.22.10.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 May 2021 10:01:18 -0700 (PDT) From: Linus Walleij To: linux-crypto@vger.kernel.org, Herbert Xu , "David S . Miller" , Corentin Labbe Cc: linux-arm-kernel@lists.infradead.org, Imre Kaloz , Krzysztof Halasa , Arnd Bergmann , Linus Walleij Subject: [PATCH 1/3 v3] crypto: ixp4xx: convert to platform driver Date: Sat, 22 May 2021 18:59:11 +0200 Message-Id: <20210522165913.915100-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210522_100121_070516_02C58FD1 X-CRM114-Status: GOOD ( 25.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann The ixp4xx_crypto driver traditionally registers a bare platform device without attaching it to a driver, and detects the hardware at module init time by reading an SoC specific hardware register. Change this to the conventional method of registering the platform device from the platform code itself when the device is present, turning the module_init/module_exit functions into probe/release driver callbacks. This enables compile-testing as well as potentially having ixp4xx coexist with other ARMv5 platforms in the same kernel in the future. Cc: Corentin Labbe Tested-by: Corentin Labbe Signed-off-by: Arnd Bergmann Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - No changes, just resending with the other patches. ChangeLog v1->v2: - Rebase on Corentin's patches in the cryptodev tree - Drop the compile test Kconfig, it will not compile for anything not IXP4xx anyway because it needs the NPE and QMGR to be compiled in and those only exist on IXP4xx. --- arch/arm/mach-ixp4xx/common.c | 26 ++++++++++++++++++++++++ drivers/crypto/ixp4xx_crypto.c | 37 ++++++++++++---------------------- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c index 000f672a94c9..007a44412e24 100644 --- a/arch/arm/mach-ixp4xx/common.c +++ b/arch/arm/mach-ixp4xx/common.c @@ -233,12 +233,38 @@ static struct platform_device *ixp46x_devices[] __initdata = { unsigned long ixp4xx_exp_bus_size; EXPORT_SYMBOL(ixp4xx_exp_bus_size); +static struct platform_device_info ixp_dev_info __initdata = { + .name = "ixp4xx_crypto", + .id = 0, + .dma_mask = DMA_BIT_MASK(32), +}; + +static int __init ixp_crypto_register(void) +{ + struct platform_device *pdev; + + if (!(~(*IXP4XX_EXP_CFG2) & (IXP4XX_FEATURE_HASH | + IXP4XX_FEATURE_AES | IXP4XX_FEATURE_DES))) { + printk(KERN_ERR "ixp_crypto: No HW crypto available\n"); + return -ENODEV; + } + + pdev = platform_device_register_full(&ixp_dev_info); + if (IS_ERR(pdev)) + return PTR_ERR(pdev); + + return 0; +} + void __init ixp4xx_sys_init(void) { ixp4xx_exp_bus_size = SZ_16M; platform_add_devices(ixp4xx_devices, ARRAY_SIZE(ixp4xx_devices)); + if (IS_ENABLED(CONFIG_CRYPTO_DEV_IXP4XX)) + ixp_crypto_register(); + if (cpu_is_ixp46x()) { int region; diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c index b38650b0fea1..76099d6cfff9 100644 --- a/drivers/crypto/ixp4xx_crypto.c +++ b/drivers/crypto/ixp4xx_crypto.c @@ -229,8 +229,6 @@ static dma_addr_t crypt_phys; static int support_aes = 1; -#define DRIVER_NAME "ixp4xx_crypto" - static struct platform_device *pdev; static inline dma_addr_t crypt_virt2phys(struct crypt_ctl *virt) @@ -453,11 +451,6 @@ static int init_ixp_crypto(struct device *dev) int ret = -ENODEV; u32 msg[2] = { 0, 0 }; - if (! ( ~(*IXP4XX_EXP_CFG2) & (IXP4XX_FEATURE_HASH | - IXP4XX_FEATURE_AES | IXP4XX_FEATURE_DES))) { - dev_err(dev, "ixp_crypto: No HW crypto available\n"); - return ret; - } npe_c = npe_request(NPE_ID); if (!npe_c) return ret; @@ -1441,26 +1434,17 @@ static struct ixp_aead_alg ixp4xx_aeads[] = { #define IXP_POSTFIX "-ixp4xx" -static const struct platform_device_info ixp_dev_info __initdata = { - .name = DRIVER_NAME, - .id = 0, - .dma_mask = DMA_BIT_MASK(32), -}; - -static int __init ixp_module_init(void) +static int ixp_crypto_probe(struct platform_device *_pdev) { int num = ARRAY_SIZE(ixp4xx_algos); int i, err; - pdev = platform_device_register_full(&ixp_dev_info); - if (IS_ERR(pdev)) - return PTR_ERR(pdev); + pdev = _pdev; err = init_ixp_crypto(&pdev->dev); - if (err) { - platform_device_unregister(pdev); + if (err) return err; - } + for (i = 0; i < num; i++) { struct skcipher_alg *cra = &ixp4xx_algos[i].crypto; @@ -1531,7 +1515,7 @@ static int __init ixp_module_init(void) return 0; } -static void __exit ixp_module_exit(void) +static int ixp_crypto_remove(struct platform_device *pdev) { int num = ARRAY_SIZE(ixp4xx_algos); int i; @@ -1546,11 +1530,16 @@ static void __exit ixp_module_exit(void) crypto_unregister_skcipher(&ixp4xx_algos[i].crypto); } release_ixp_crypto(&pdev->dev); - platform_device_unregister(pdev); + + return 0; } -module_init(ixp_module_init); -module_exit(ixp_module_exit); +static struct platform_driver ixp_crypto_driver = { + .probe = ixp_crypto_probe, + .remove = ixp_crypto_remove, + .driver = { .name = "ixp4xx_crypto" }, +}; +module_platform_driver(ixp_crypto_driver); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Christian Hohnstaedt "); -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel