Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp32213112rwd; Fri, 7 Jul 2023 10:13:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlFwzXoBJbqNDlINb9JFPJ/iKN+hq8BZvMbU7yAkySyhCJoOYdApIZopssfgRgD/6KN3jmCY X-Received: by 2002:a05:6402:2802:b0:51a:4d46:4026 with SMTP id h2-20020a056402280200b0051a4d464026mr5691043ede.0.1688749983551; Fri, 07 Jul 2023 10:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688749983; cv=none; d=google.com; s=arc-20160816; b=VQEQJsWlG1KUHp0HkY6gmS/b5Nfo5vRtTr/QYgZgBycm1sBToBvVLAq5hMks8vSpY+ TRQ4Yhfh+VyIXiuatE2munvYfhT27RpiJ6bLeysXjuCYwuSqenz5SOT6tpyYtHFOY86/ bgUaVbesbNzoMy0T/8wnKXH+dYaVoeKyNiOP6sPk659Pmk9k7jAxq99F/tPnJmOawHR+ uANyJTS8yoQcObf+6DQBmIwoUSN0F3ksefJSjRmwI/9ec/iuXSCH0Km2OiqacDPGmnSf iYENuZaVIuqx9IL8x5SDJVM+7KtxDGlsy2NjW6knFo1haAXJEWi2JxlhsRikNihWR6hl 4yBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=YItiT2tdiA08FS5wAdNJ9fCMv10m//kxWIar2s9I+Kg=; fh=njBx3yFpp0KTAyFgO+wVpqsPYERD5juZ1gCnjrAMS9I=; b=Bs6aCtkFB9j769lLNz+iZkkIwK+6ks0PlRulwPR4YzA7wgDrMdka27CoSiIkwXS5ak 13D1xHqyavo1rwAWrceVjOP4mrrzAeFT3mm4eAYIqhh0zbnW0+66fDcoFECEfEKCOIaw ayFgmspX6qF1vZfmgCLi2xKlq919T+4yK1N9uTUjOabCC20hGJG3fhgfvhyZLc99uzDO q5zWgnv11eXOsjcSyMiMaStUXgm6SgB+WvWnGozmMuO+ji6qtNB2eFOEakyJesA0kkHW rh71fYjmgiPpMprUS7xNg2B8Ktg6gUZ68aQQlWkvfDGjw5DNZDLSHa0qrtltax71Wb68 tZgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b1-20020aa7c901000000b0051de4b6be0esi1123525edt.646.2023.07.07.10.12.33; Fri, 07 Jul 2023 10:13:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229480AbjGGRJZ (ORCPT + 99 others); Fri, 7 Jul 2023 13:09:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbjGGRJY (ORCPT ); Fri, 7 Jul 2023 13:09:24 -0400 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E8071BE8; Fri, 7 Jul 2023 10:09:23 -0700 (PDT) Received: from dslb-188-097-041-027.188.097.pools.vodafone-ip.de ([188.97.41.27] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1qHoxF-0003F4-Su; Fri, 07 Jul 2023 19:09:13 +0200 Received: from martin by martin-debian-2.paytec.ch with local (Exim 4.94.2) (envelope-from ) id 1qHovi-000dvS-4S; Fri, 07 Jul 2023 19:07:38 +0200 Date: Fri, 7 Jul 2023 19:07:38 +0200 From: Martin Kaiser To: Yangtao Li Cc: Olivia Mackall , Herbert Xu , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] hwrng: timeriomem - Use devm_platform_get_and_ioremap_resource() Message-ID: References: <20230705115242.54285-1-frank.li@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230705115242.54285-1-frank.li@vivo.com> Sender: "Martin Kaiser,,," X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Hi, Thus wrote Yangtao Li (frank.li@vivo.com): > Convert platform_get_resource(), devm_ioremap_resource() to a single > call to devm_platform_get_and_ioremap_resource(), as this is exactly > what this function does. > Signed-off-by: Yangtao Li > --- > drivers/char/hw_random/timeriomem-rng.c | 25 ++++++++++--------------- > 1 file changed, 10 insertions(+), 15 deletions(-) > diff --git a/drivers/char/hw_random/timeriomem-rng.c b/drivers/char/hw_random/timeriomem-rng.c > index 26f322d19a88..3db9d868efb1 100644 > --- a/drivers/char/hw_random/timeriomem-rng.c > +++ b/drivers/char/hw_random/timeriomem-rng.c > @@ -113,16 +113,6 @@ static int timeriomem_rng_probe(struct platform_device *pdev) > return -EINVAL; > } > - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > - if (!res) > - return -ENXIO; > - > - if (res->start % 4 != 0 || resource_size(res) < 4) { > - dev_err(&pdev->dev, > - "address must be at least four bytes wide and 32-bit aligned\n"); > - return -EINVAL; > - } > - > /* Allocate memory for the device structure (and zero it) */ > priv = devm_kzalloc(&pdev->dev, > sizeof(struct timeriomem_rng_private), GFP_KERNEL); > @@ -131,6 +121,16 @@ static int timeriomem_rng_probe(struct platform_device *pdev) > platform_set_drvdata(pdev, priv); > + priv->io_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); > + if (IS_ERR(priv->io_base)) > + return PTR_ERR(priv->io_base); > + > + if (res->start % 4 != 0 || resource_size(res) < 4) { > + dev_err(&pdev->dev, > + "address must be at least four bytes wide and 32-bit aligned\n"); > + return -EINVAL; > + } > + > if (pdev->dev.of_node) { > int i; > @@ -158,11 +158,6 @@ static int timeriomem_rng_probe(struct platform_device *pdev) > priv->rng_ops.name = dev_name(&pdev->dev); > priv->rng_ops.read = timeriomem_rng_read; > - priv->io_base = devm_ioremap_resource(&pdev->dev, res); > - if (IS_ERR(priv->io_base)) { > - return PTR_ERR(priv->io_base); > - } > - > /* Assume random data is already available. */ > priv->present = 1; > complete(&priv->completion); > -- > 2.39.0 Looks ok to me. Reviewed-by: Martin Kaiser I was wondering if we really have to check res->start and resource_size(res) that we read from the device tree. Other drivers don't check these settings and use devm_platform_ioremap_resource(pdev, 0). Best regards, Martin