From patchwork Fri Feb 15 15:25:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1042952 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="TOgggReB"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 441HC04B8yz9s4Z for ; Sat, 16 Feb 2019 02:25:32 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726541AbfBOPZa (ORCPT ); Fri, 15 Feb 2019 10:25:30 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37780 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732832AbfBOPZU (ORCPT ); Fri, 15 Feb 2019 10:25:20 -0500 Received: by mail-wr1-f66.google.com with SMTP id c8so10744342wrs.4 for ; Fri, 15 Feb 2019 07:25:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z2674JCCrS9ITncu8th674o5gf1yN0RXwfPoyp/h8nM=; b=TOgggReBQ7YFwVJQsEWDGzCJaaD1AnAVozGNy0bvhHFOM+NCF3CMY2Ifa4K9xxqTpD 0aOjxC6hngHY8KWVTp5aMuSe4hXVDcsvSqUMog9hOB3huB+Iq8Uq4MRLnRmh4CMtE+3i JezdTJZG09qgAlyDPOcPsylQ0Ue39VCGF0hk3czv3H679p+4z5HEeC7yYPuE5e1Gd2jn X/KviqrEB6+PfUI5Gw9LHGMR5KpHEfbctm0+0vEOnDi4oRFoxPaE4/JEKbeUCVyWX/pv +3oeUvY2UBV0gZwgglrNDghcAwhbdIFiAYjLqTxDOJuRQm1vDqoeY0wyfBBAYgBX0eid jrsQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z2674JCCrS9ITncu8th674o5gf1yN0RXwfPoyp/h8nM=; b=RtLsMT12jy7RSdZ/oUfe5rG5K4oaBxAzVxSPAm1bPDUV+blB12sPFGlEDfh8qXBFjG Ziy7TvEMRCgDv61Rd98rWDDIf0gnLA5sF/9/BERorPTFiCbhWOi6GiNJcc02UZBbBOQ5 w8nNfiGwhEIjYJiyCDXD680k82I0v9Tklp3qWgU1kGkJntALPuuD0fVfMEfMBcBwFOdO vd3h/IqXFXhOdy11TfgCHkc1h4LBAvZ3BN8sUal3jFvqe82Gy2a2FPqZvO1nV//kFBAz HNOmPFQ6l6+8wSQFq5Qp6w+A2mOnFfR2x0Zi1w5klgvn24xQI/tQxszX3RYFHIeV4BVC EoCA== X-Gm-Message-State: AHQUAuYL+msz47x/Vkfmg2comgWoA1Spq9fnU2rY1aXtGXnDqJGO7HFJ oG83u+3t9/la8+atjLq7SkWY6w== X-Google-Smtp-Source: AHgI3IbsIGofMuWx/ozKHTufDMCzmmS9hoA3NmXbN0u977ok5e5byljrKHNMuHJhXKCy3ILqjWCzDQ== X-Received: by 2002:a5d:68c2:: with SMTP id p2mr6462464wrw.23.1550244318453; Fri, 15 Feb 2019 07:25:18 -0800 (PST) Received: from localhost.localdomain (aputeaux-684-1-7-43.w90-86.abo.wanadoo.fr. [90.86.124.43]) by smtp.gmail.com with ESMTPSA id y5sm1904337wmg.31.2019.02.15.07.25.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 07:25:17 -0800 (PST) From: Bartosz Golaszewski To: Greg Kroah-Hartman , "Rafael J . Wysocki" , Keerthy , Linus Walleij Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 1/2] drivers: provide devm_platform_ioremap_resource() Date: Fri, 15 Feb 2019 16:25:06 +0100 Message-Id: <20190215152507.31066-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190215152507.31066-1-brgl@bgdev.pl> References: <20190215152507.31066-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski There are currently 1200+ instances of using platform_get_resource() and devm_ioremap_resource() together in the kernel tree. This patch wraps these two calls in a single helper. Thanks to that we don't have to declare a local variable for struct resource * and can omit the redundant argument for resource type. We also have one function call less. Signed-off-by: Bartosz Golaszewski --- drivers/base/platform.c | 18 ++++++++++++++++++ include/linux/platform_device.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 1c958eb33ef4..14400a63cc81 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -79,6 +79,24 @@ struct resource *platform_get_resource(struct platform_device *dev, } EXPORT_SYMBOL_GPL(platform_get_resource); +/** + * devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform + * device + * + * @pdev: platform device to use both for memory resource lookup as well as + * resource managemend + * @index: resource index + */ +void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev, + unsigned int index) +{ + struct resource *res; + + res = platform_get_resource(pdev, IORESOURCE_MEM, index); + return devm_ioremap_resource(&pdev->dev, res); +} +EXPORT_SYMBOL(devm_platform_ioremap_resource); + /** * platform_get_irq - get an IRQ for a device * @dev: platform device diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index c7c081dc6034..b126b73ed8ef 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -52,6 +52,9 @@ extern struct device platform_bus; extern void arch_setup_pdev_archdata(struct platform_device *); extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int); +extern void __iomem * +devm_platform_ioremap_resource(struct platform_device *pdev, + unsigned int index); extern int platform_get_irq(struct platform_device *, unsigned int); extern int platform_irq_count(struct platform_device *); extern struct resource *platform_get_resource_byname(struct platform_device *, From patchwork Fri Feb 15 15:25:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1042951 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="d/h0ERZW"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 441HBr62g4z9s5c for ; Sat, 16 Feb 2019 02:25:24 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732791AbfBOPZX (ORCPT ); Fri, 15 Feb 2019 10:25:23 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:50754 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726766AbfBOPZV (ORCPT ); Fri, 15 Feb 2019 10:25:21 -0500 Received: by mail-wm1-f66.google.com with SMTP id x7so10258993wmj.0 for ; Fri, 15 Feb 2019 07:25:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1lfqJzHdcjA20Q30XeL0tcyEj0lgU0X5EuBNLTHV4pc=; b=d/h0ERZWKXp4REc8nmbVASzZDJaeMj9gc4lq98tpyMgsmLH3pDj/UIilglcb1PpeHl G0L82i2AZZ8X0RfPjT9n5XuPj2yyMaOT4B6YEBdorlXLABI3n3nvS+8r2sA5xQbV8hi5 xHVz8pakGx1UODt1Ool4e68LRvsihHQewzzeFAI6ASgnIeverIMmzFZFZ79UgenIZraP /bbyBmnk3d/tevqwz2dAgA/iorQIYolezE/3ChdFVWDzDmH3EHrKXEhOhsPz0oGeouPr sLvRdwo2EhJWHR2HruzrpcGwrZEAgV/2WIwXKJbsRDoWPXWr9IXLtupUWpm5MQsPmqJj qJTQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=1lfqJzHdcjA20Q30XeL0tcyEj0lgU0X5EuBNLTHV4pc=; b=UxRF7x5K8+iEmkQp795hcqJbl5b/RepRYTGSe682jBfmDpJrV+UG+tNvD1Kc122rWe ehDo3iEiMWVFHGk7sUOytau92Rsp43Bc2+dfmYORph/3kxw/LvlzCFfmf+MNCafwG3ll BoWw4/FbR4gLN1wE5uEoowZ9baFyv/dbcBXW9bg88wbtXbhWKczG3XejOELHJ7t/kQdu gLIpTEqg9iIZy9EYvQqwTkRygI8k5d01qabU/bf03PdeF8tPQWnsU+NEwhCsBkZ3a4hm t9rrStojT39OhAK/KsIK8ztzMG3Vcjt3YOiGn1MxhxRpQEXyjibhV5IhoqaK8VWv4jZO Pw8A== X-Gm-Message-State: AHQUAuZRmVLuhc9CBhYRPqtKsSBmAxFqnGUsrTk9x00+Y31La5fInZrm Flc71tzsVD70YzZyqya2DaNwGw== X-Google-Smtp-Source: AHgI3IaD6o8KRxqbx1iwGop9lbPLonPTqOcj4j5CrTevs4ua1VvaWaR5wLVBPkv5emX0QnZceUpskA== X-Received: by 2002:a1c:7903:: with SMTP id l3mr7372371wme.22.1550244319449; Fri, 15 Feb 2019 07:25:19 -0800 (PST) Received: from localhost.localdomain (aputeaux-684-1-7-43.w90-86.abo.wanadoo.fr. [90.86.124.43]) by smtp.gmail.com with ESMTPSA id y5sm1904337wmg.31.2019.02.15.07.25.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 07:25:18 -0800 (PST) From: Bartosz Golaszewski To: Greg Kroah-Hartman , "Rafael J . Wysocki" , Keerthy , Linus Walleij Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 2/2] gpio: davinci: use devm_platform_ioremap_resource() Date: Fri, 15 Feb 2019 16:25:07 +0100 Message-Id: <20190215152507.31066-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190215152507.31066-1-brgl@bgdev.pl> References: <20190215152507.31066-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski Use the new helper that wraps the calls to platform_get_resource() and devm_ioremap_resource() together. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-davinci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index bdb29e51b417..188b8e5c8e67 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -198,7 +198,6 @@ static int davinci_gpio_probe(struct platform_device *pdev) struct davinci_gpio_controller *chips; struct davinci_gpio_platform_data *pdata; struct device *dev = &pdev->dev; - struct resource *res; pdata = davinci_gpio_get_pdata(pdev); if (!pdata) { @@ -236,8 +235,7 @@ static int davinci_gpio_probe(struct platform_device *pdev) if (!chips) return -ENOMEM; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - gpio_base = devm_ioremap_resource(dev, res); + gpio_base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(gpio_base)) return PTR_ERR(gpio_base);