From patchwork Fri May 2 19:15:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 4105051 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6C5C09F467 for ; Fri, 2 May 2014 19:15:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 949A420373 for ; Fri, 2 May 2014 19:15:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8524320375 for ; Fri, 2 May 2014 19:15:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752742AbaEBTPg (ORCPT ); Fri, 2 May 2014 15:15:36 -0400 Received: from sauhun.de ([89.238.76.85]:43130 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752298AbaEBTPf (ORCPT ); Fri, 2 May 2014 15:15:35 -0400 Received: from p4fe24f47.dip0.t-ipconnect.de ([79.226.79.71]:47463 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1WgIvm-0007GV-AN; Fri, 02 May 2014 21:15:34 +0200 From: Wolfram Sang To: linux-i2c@vger.kernel.org Cc: Wolfram Sang , linux-sh@vger.kernel.org, Magnus Damm , Geert Uytterhoeven , Wolfram Sang Subject: [PATCH v2 05/10] i2c: sh_mobile: devm conversion, low hanging fruits Date: Fri, 2 May 2014 21:15:11 +0200 Message-Id: <1399058116-7721-6-git-send-email-wsa@the-dreams.de> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1399058116-7721-1-git-send-email-wsa@the-dreams.de> References: <1399058116-7721-1-git-send-email-wsa@the-dreams.de> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wolfram Sang Convert the easy parts to devm. irqs will be converted in a seperate patch to keep diffs readable. Signed-off-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven --- drivers/i2c/busses/i2c-sh_mobile.c | 41 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index 2e481abd50ce..c47d11493b97 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c @@ -655,45 +655,33 @@ static int sh_mobile_i2c_probe(struct platform_device *dev) struct sh_mobile_i2c_data *pd; struct i2c_adapter *adap; struct resource *res; - int size; int ret; u32 bus_speed; - pd = kzalloc(sizeof(struct sh_mobile_i2c_data), GFP_KERNEL); - if (pd == NULL) { - dev_err(&dev->dev, "cannot allocate private data\n"); + pd = devm_kzalloc(&dev->dev, sizeof(struct sh_mobile_i2c_data), GFP_KERNEL); + if (!pd) return -ENOMEM; - } - pd->clk = clk_get(&dev->dev, NULL); + pd->clk = devm_clk_get(&dev->dev, NULL); if (IS_ERR(pd->clk)) { dev_err(&dev->dev, "cannot get clock\n"); - ret = PTR_ERR(pd->clk); - goto err; + return PTR_ERR(pd->clk); } ret = sh_mobile_i2c_hook_irqs(dev, 1); if (ret) { dev_err(&dev->dev, "cannot request IRQ\n"); - goto err_clk; + return ret; } pd->dev = &dev->dev; platform_set_drvdata(dev, pd); res = platform_get_resource(dev, IORESOURCE_MEM, 0); - if (res == NULL) { - dev_err(&dev->dev, "cannot find IO resource\n"); - ret = -ENOENT; - goto err_irq; - } - size = resource_size(res); - - pd->reg = ioremap(res->start, size); - if (pd->reg == NULL) { - dev_err(&dev->dev, "cannot map IO\n"); - ret = -ENXIO; + pd->reg = devm_ioremap_resource(&dev->dev, res); + if (IS_ERR(pd->reg)) { + ret = PTR_ERR(pd->reg); goto err_irq; } @@ -710,7 +698,7 @@ static int sh_mobile_i2c_probe(struct platform_device *dev) /* The IIC blocks on SH-Mobile ARM processors * come with two new bits in ICIC. */ - if (size > 0x17) + if (resource_size(res) > 0x17) pd->flags |= IIC_FLAG_HAS_ICIC67; sh_mobile_i2c_init(pd); @@ -747,7 +735,7 @@ static int sh_mobile_i2c_probe(struct platform_device *dev) ret = i2c_add_numbered_adapter(adap); if (ret < 0) { dev_err(&dev->dev, "cannot add numbered adapter\n"); - goto err_all; + goto err_irq; } dev_info(&dev->dev, @@ -756,14 +744,8 @@ static int sh_mobile_i2c_probe(struct platform_device *dev) return 0; - err_all: - iounmap(pd->reg); err_irq: sh_mobile_i2c_hook_irqs(dev, 0); - err_clk: - clk_put(pd->clk); - err: - kfree(pd); return ret; } @@ -772,11 +754,8 @@ static int sh_mobile_i2c_remove(struct platform_device *dev) struct sh_mobile_i2c_data *pd = platform_get_drvdata(dev); i2c_del_adapter(&pd->adap); - iounmap(pd->reg); sh_mobile_i2c_hook_irqs(dev, 0); - clk_put(pd->clk); pm_runtime_disable(&dev->dev); - kfree(pd); return 0; }