From patchwork Thu Aug 25 11:34:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: PrasannaKumar Muralidharan X-Patchwork-Id: 9299263 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5ADDD60459 for ; Thu, 25 Aug 2016 11:34:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C8B429282 for ; Thu, 25 Aug 2016 11:34:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 411AC29287; Thu, 25 Aug 2016 11:34:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D511629282 for ; Thu, 25 Aug 2016 11:34:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933191AbcHYLef (ORCPT ); Thu, 25 Aug 2016 07:34:35 -0400 Received: from mail-pa0-f67.google.com ([209.85.220.67]:35679 "EHLO mail-pa0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933184AbcHYLee (ORCPT ); Thu, 25 Aug 2016 07:34:34 -0400 Received: by mail-pa0-f67.google.com with SMTP id cf3so2971924pad.2; Thu, 25 Aug 2016 04:34:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=uxkq6vY/tmBBXUpkQtKZSp3v11KE3wRg+q4Q1ttPd40=; b=Zot7gToeD8PbytR/1C62fVgBR54v6ETkU9JUkbRQaJtdOdYJagXqdPwj7HlIaoF9de gtvoZ4dHZ/jVo5+Hz7E/KC7G/yKGyDOMJSEQLNACFcRJvpev8F5qSfDIO1gVUVEk9+cm OHf9mJ1j6lsY/pRhbjkeuoqCHcShEdwhIFYIg2RZ2yEtwiBO2uLrbAex6I1OcKAj70nh LrnGJFDRQglWezKNYn7EZRV18hnMjM6fnNbreBGjc0I6sFQB36FCApuqvkC1iXJjpXYN 8qTUlyoWIPsDOy4aq19M5gB1eZ0nAUkuuNVHGc+A4gheXTOYgjhXclfIgyogeAObAj4M mKKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uxkq6vY/tmBBXUpkQtKZSp3v11KE3wRg+q4Q1ttPd40=; b=cfXAGCiaLqj/Uxj6RyUbkrCoOyIHiXgKfmGFz7gnodVwiYnYDHGVKdkoIaJwv89Pzl 9IdMbWo2GvkkrNs/j1ZExVsnvISnefCanic1sOF/O4aMOyqOmBy88j9zZzV4iMbe8Njz 4/I/n/LGCMcFtGvuitvH8Gi1QR4+kxr+Oq/HwJVBw1s5j14rOH1it2Lco2+MCc/fa8Kj dK9XDvud2PfOqJEJZ1CYBR/9nTce1CAjR643XlwCE9Yr9WJujZir0Kq+7t/Liyt1QSm0 L3KPoNoUET7E3A9z+Fb6P2p5a5RtoM2875tyUKWA3iFA/D6I36qkm3wdpE9y/LIrNAxI ELng== X-Gm-Message-State: AE9vXwOQ3DF5NsDzFoKXgNSlNnEN5dnnyllw3r8UEV+pGhTuV9jb2NwThy/laJ97BQGiHQ== X-Received: by 10.66.86.1 with SMTP id l1mr15161082paz.106.1472124873574; Thu, 25 Aug 2016 04:34:33 -0700 (PDT) Received: from localhost.localdomain ([180.151.32.106]) by smtp.gmail.com with ESMTPSA id e2sm20353144pfd.45.2016.08.25.04.34.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Aug 2016 04:34:32 -0700 (PDT) From: PrasannaKumar Muralidharan To: olof@lixom.net, mpm@selenic.com, herbert@gondor.apana.org.au, linuxppc-dev@lists.ozlabs.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Cc: prasannatsmkumar@gmail.com Subject: [PATCH] hwrng: pasemi_rng.c: Migrate to managed API Date: Thu, 25 Aug 2016 17:04:16 +0530 Message-Id: <1472124856-12767-1-git-send-email-prasannatsmkumar@gmail.com> X-Mailer: git-send-email 2.5.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use devm_ioremap and devm_hwrng_register instead of ioremap and hwrng_register. This removes unregistering and error handling code. This patch is not tested with hardware as I don't have access to it. Signed-off-by: PrasannaKumar Muralidharan --- drivers/char/hw_random/pasemi-rng.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/drivers/char/hw_random/pasemi-rng.c b/drivers/char/hw_random/pasemi-rng.c index 699b725..0f03397 100644 --- a/drivers/char/hw_random/pasemi-rng.c +++ b/drivers/char/hw_random/pasemi-rng.c @@ -100,37 +100,18 @@ static int rng_probe(struct platform_device *ofdev) void __iomem *rng_regs; struct device_node *rng_np = ofdev->dev.of_node; struct resource res; - int err = 0; - err = of_address_to_resource(rng_np, 0, &res); - if (err) + if (of_address_to_resource(rng_np, 0, &res)) return -ENODEV; - rng_regs = ioremap(res.start, 0x100); - + rng_regs = devm_ioremap(&ofdev->dev, res.start, 0x100); if (!rng_regs) return -ENOMEM; pasemi_rng.priv = (unsigned long)rng_regs; pr_info("Registering PA Semi RNG\n"); - - err = hwrng_register(&pasemi_rng); - - if (err) - iounmap(rng_regs); - - return err; -} - -static int rng_remove(struct platform_device *dev) -{ - void __iomem *rng_regs = (void __iomem *)pasemi_rng.priv; - - hwrng_unregister(&pasemi_rng); - iounmap(rng_regs); - - return 0; + return devm_hwrng_register(&ofdev->dev, &pasemi_rng); } static const struct of_device_id rng_match[] = { @@ -146,7 +127,6 @@ static struct platform_driver rng_driver = { .of_match_table = rng_match, }, .probe = rng_probe, - .remove = rng_remove, }; module_platform_driver(rng_driver);