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 *,