Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp732485ybi; Fri, 14 Jun 2019 02:23:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyF8sSLKkymYFdiKP5+68zoGz2Dkh6LFBoQxrTGGCivOAcrjM0/6UpbTCf6fKria/l4aWAJ X-Received: by 2002:a17:902:2983:: with SMTP id h3mr48583914plb.45.1560504238967; Fri, 14 Jun 2019 02:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560504238; cv=none; d=google.com; s=arc-20160816; b=PLcNBIe9Kzx5OMrFNPJKvtzndR3cikDs5D8Lsgy3AbLvfsmZY9byL5Do3MAFh5Xlto zkL2Z1u2ZqpTs9dswnxZk1nsxbJX0ZVTIrNH5pQ93luhwviKZo1rTdN4+rkUd7wRC7zE 2EO4feYbZTHKJ9U2dF0KInkuvHJBKTN2XBEw8oi+1rirVj9xs5anib9frOTJKSinrSEy h4Kzk8VjSRXFgLwMOGV0u+SJPFECC0kAi0mqUakhjZ/5xn3JpqMDU17xYgip3RfM+2P9 gd1WqsEzNjIMY0oDUY46w9mFaxH/L8pY4wuTYvQxapHOCaIOXJzK1xgi14Uz+cAIq3tN 4axg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature; bh=mSukfMG5aVI/SZmcS7lBnBft4rrM23o4chRXJDCaVfI=; b=GjFbYczbQbcD/R3UL+x6ndHVvd855gN18c3xpk1diMhbZVF+Nl8HW6tuJQ2MlsGEei ieL0T6WCBT9Ts9eLJ2aV9vr2Eoy+UjCpFOfIdXWgXZjPL58qnUipR1CI9zhtaTuthenX FhdFxnBI9gIm0gzcShkroBBhqWYnmGt0FvxRbxpJGoh5wu6zjJMzn4KLDyMx4VSymgey UgLF9HdCih6KMN7AzKo5kkxc2QkVCz0kUR9JXUSannsh/gfWJ//NLRHMUE/EUqF7oolE L3wFYfoKtDP6ud2nP4XntMxVBL7Wt3itylyyf4YPa+ALdzXL2m5v/VcD9zMI5qgTW50M Smrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@web.de header.s=dbaedf251592 header.b=I2EvWM35; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 30si1858544plb.30.2019.06.14.02.23.43; Fri, 14 Jun 2019 02:23:58 -0700 (PDT) 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=@web.de header.s=dbaedf251592 header.b=I2EvWM35; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726900AbfFNJXS (ORCPT + 99 others); Fri, 14 Jun 2019 05:23:18 -0400 Received: from mout.web.de ([212.227.17.12]:42991 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726083AbfFNJXS (ORCPT ); Fri, 14 Jun 2019 05:23:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1560504172; bh=SpHQ3JrOfhzaQWP30ANX8/kssmYUbD+lEDsns4CrNWw=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=I2EvWM35gKnBnKmheBgq1jp/Ag+XzAy1ytbP/i7R/wzX4eIeY8pEpCK4SPTUKuiAD h0pVXtzq9Af4rhZNaMtl5vnggAHHS+6F/2TeE+qJf8j838e0bOdrd75SY32nWm+/PR C7CQ6L5aAf8C/mvui/03xvLCNx7me0aKykAZXOrw= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from [192.168.1.2] ([93.133.126.132]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MYf78-1i5sJl3FUA-00VPjw; Fri, 14 Jun 2019 11:22:51 +0200 Subject: [PATCH] drivers: Inline code in devm_platform_ioremap_resource() from two functions To: Enrico Weigelt , Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: cocci@systeme.lip6.fr, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Shevchenko , Bartosz Golaszewski , Gilles Muller , Himanshu Jha , Linus Walleij , Masahiro Yamada , Michal Marek , Nicolas Palix References: <20190406061112.31620-1-himanshujha199640@gmail.com> <7b4fe770-dadd-80ba-2ba4-0f2bc90984ef@web.de> From: Markus Elfring Openpgp: preference=signencrypt Autocrypt: addr=Markus.Elfring@web.de; prefer-encrypt=mutual; keydata= mQINBFg2+xABEADBJW2hoUoFXVFWTeKbqqif8VjszdMkriilx90WB5c0ddWQX14h6w5bT/A8 +v43YoGpDNyhgA0w9CEhuwfZrE91GocMtjLO67TAc2i2nxMc/FJRDI0OemO4VJ9RwID6ltwt mpVJgXGKkNJ1ey+QOXouzlErVvE2fRh+KXXN1Q7fSmTJlAW9XJYHS3BDHb0uRpymRSX3O+E2 lA87C7R8qAigPDZi6Z7UmwIA83ZMKXQ5stA0lhPyYgQcM7fh7V4ZYhnR0I5/qkUoxKpqaYLp YHBczVP+Zx/zHOM0KQphOMbU7X3c1pmMruoe6ti9uZzqZSLsF+NKXFEPBS665tQr66HJvZvY GMDlntZFAZ6xQvCC1r3MGoxEC1tuEa24vPCC9RZ9wk2sY5Csbva0WwYv3WKRZZBv8eIhGMxs rcpeGShRFyZ/0BYO53wZAPV1pEhGLLxd8eLN/nEWjJE0ejakPC1H/mt5F+yQBJAzz9JzbToU 5jKLu0SugNI18MspJut8AiA1M44CIWrNHXvWsQ+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Pv0pUnW3AwtiMYngT96BevfA qlwaymjPTvH+cTXScnbydfOQW8220JQwykUe+sHRZfAF5TS2YCkQvsyf7vIpSqo/ttDk4+xc Z/wsLiWTgKlih2QYULvW61XU+mWsK8+ZlYUrRMpkauN4CJ5yTpvp+Orcz5KixHQmc5tbkLWf x0n1QFc1xxJhbzN+r9djSGGN/5IBDfUqSANC8cWzHpWaHmSuU3JSAMB/N+yQjIad2ztTckZY pwT6oxng29LzZspTYUEzMz3wK2jQHw+U66qBFk8whA7B2uAU1QdGyPgahLYSOa4XAEGb6wbI FEE= Message-ID: <032e347f-e575-c89c-fa62-473d52232735@web.de> Date: Fri, 14 Jun 2019 11:22:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:oZZikr5812fm7qJo1EfkL7bt2J1oCpuqPgZapj83jUV/9DsNYsv 0WUda4yE5NBVVkeDvjjHM/yj31jOesCycrxo6ktCIvL/R++Yo/ExkmczJqqTn5Lir/wlLKz wsTHFsB/DMeZuPDjabwLZVefP72Udt+ag+lQvrU3Lz0nNLrNMEWsIxGhLaCG/apPMhgP6K2 +17hw5Y5hHKkX0GFgW5Qw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:Dvvfi8LZ7AI=:/YZipzaeArtGwaFfdAJZrk YKr0OxA4swcWy+/Yd5hu2nxVAjoW3ve1vOELQV6xw9zer9QtjMBZGfTQpJLj5Bq1/ykJOVVVm hpqndrozTlu1FgdcpuhvYtxwLJ0kbHSmNfGJrkyzl/CuWSDPlLQbciNkldME9hXG9RIT4uAcD dxf0lUpDmZPuwQfwGG1Taz5TXO3ymQLn+o1T9WSEH2ouINVsjoTyHvOIDU/iH6nAqQ4HPuYcg ptYNmllSM3gHHVa0RVgEqUHy4jYEeCEsBmBuJ2qnkVHAIaBVDyZZAQh3+gO+yP3ddB6N63gZG hVS0c26eCT9KX3B7kuzxW19dIRY+YeOOv5h4/x0CXIWzfYz5o1ycuyEz3P5aC9fryZPGyNpOa QwRTJtZoykybi8Hz+D+sC4GlkXKBubmoJ1k4xRnGMBPD/unNCcws4Qxemq6GH0t5RReBEZ2Eg qkJ/3kPhtjGP+2zwnKIS3MGcMb2EkYQeEuRou3fjQdrRXPqabqtBby3fFKmE60WlmdDEzEbbM Bfk1q0zDUV9wltiOiycTgDMrKPS5Vw91yo1D/8xI3UX9q81kjY47NOX+ybZFm9cJAQNSuikkq OuKMYi4KKN7im3QSCFxPoOKDUdilvMw9cn0Hn5gciPJAB039jYu6j6/Dt1/pPirm5ibCjiF1a T9KJ04HeoHvqM7qGtXBnpZVjGFxJAqvGuj/iNwlwhizJaYuYX0J0el603yA8FKY4OFHAzFfFp vnWgYQBjBUf4lKNnwgwjQSO44ex607ayICDFF6WfrACbe/s8Apd7xdTe4MFcECJpfdUyDcX4k fB2oi0lLrNQ14iLXmSb7UZJsBWi6e2ZspUlgKWKdoSWGKZkgwMm7klVIbUdIDyij29XkM+9UR uQfDU/hJBQMFGEizptpN0D2zqHDQPZd94jsQL/rFffDpPGT7XFOIpDUN4KEzIO9FTNgZJeGQP Zkx0HrpZZIvS24eI4YiyHgD2xJUWcfJwcxenlD+iTCSBOfN4HmODD Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Fri, 14 Jun 2019 11:05:33 +0200 Two function calls were combined in this function implementation. Inline corresponding code so that extra error checks can be avoided here. Signed-off-by: Markus Elfring =2D-- drivers/base/platform.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 4d1729853d1a..baadca72f949 100644 =2D-- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -80,8 +80,8 @@ struct resource *platform_get_resource(struct platform_d= evice *dev, EXPORT_SYMBOL_GPL(platform_get_resource); /** - * devm_platform_ioremap_resource - call devm_ioremap_resource() for a pl= atform - * device + * devm_platform_ioremap_resource + * Achieve devm_ioremap_resource() functionality for a platform device * * @pdev: platform device to use both for memory resource lookup as well = as * resource management @@ -91,10 +91,39 @@ EXPORT_SYMBOL_GPL(platform_get_resource); void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev= , unsigned int index) { - struct resource *res; + u32 i; - res =3D platform_get_resource(pdev, IORESOURCE_MEM, index); - return devm_ioremap_resource(&pdev->dev, res); + for (i =3D 0; i < pdev->num_resources; i++) { + struct resource *res =3D &pdev->resource[i]; + + if (resource_type(res) =3D=3D IORESOURCE_MEM && index-- =3D=3D 0) { + struct device *dev =3D &pdev->dev; + resource_size_t size =3D resource_size(res); + void __iomem *dest; + + if (!devm_request_mem_region(dev, + res->start, + size, + dev_name(dev))) { + dev_err(dev, + "can't request region for resource %pR\n", + res); + return IOMEM_ERR_PTR(-EBUSY); + } + + dest =3D devm_ioremap(dev, res->start, size); + if (!dest) { + dev_err(dev, + "ioremap failed for resource %pR\n", + res); + devm_release_mem_region(dev, res->start, size); + dest =3D IOMEM_ERR_PTR(-ENOMEM); + } + + return dest; + } + } + return IOMEM_ERR_PTR(-EINVAL); } EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource); #endif /* CONFIG_HAS_IOMEM */ =2D- 2.22.0