From patchwork Wed Feb 20 11:12:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1045272 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="g9GXnWbV"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 444FMN602Bz9s71 for ; Wed, 20 Feb 2019 22:13:04 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727723AbfBTLMw (ORCPT ); Wed, 20 Feb 2019 06:12:52 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:54114 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727707AbfBTLMu (ORCPT ); Wed, 20 Feb 2019 06:12:50 -0500 Received: by mail-wm1-f68.google.com with SMTP id e74so5611346wmg.3 for ; Wed, 20 Feb 2019 03:12:49 -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=/Bf5dwgVrtAeYPaTQyE6LLHmqh5tStzzBNVA9ZQP9F0=; b=g9GXnWbVWDFrhUXPyCPVZ2tnLmjtyPd6kUlcFNSZtTIIwu7R5KAnk2FMK+34sSSNtb uv7rsFMBHENrr6DCc7EANsfez/b4ajevXz5a2RFlu8+Rb3M2sZBKSHgi2scBNbWBClfN +qxt05bIDU+F596abgw6rZG/uSuw/ckvuGT6FwXjcorWeSrw4i4QrKQRicaStbS5WRXQ ldlote89rbWpuBtB2pTM8PVJ/i1xecugXB4n3ooADHJFZB3yLMuET4ACBfD7dDolWlXq NfUMUWTm3bcffcOkXFQGa1IDfbFC07xnwgkiYG1HAv+d8/4c08jxUnAi8bFz9aBJPLyn OL8g== 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=/Bf5dwgVrtAeYPaTQyE6LLHmqh5tStzzBNVA9ZQP9F0=; b=Mbh3+0mXMuBq/yuo4MNKkR9HeQLHYbi+iSjZtuUol3OPppoVf2Dis/8Qfx81gu+M7L nngahPxq6QgY4oO0iAoET9PViikc/pe6h36cTaGZyjyPsNrvs9vlYqqk7Lgk0j4aT2qO 8T+eAA/0/oM8XKeSJPeYiqykBctLzSgrEtAOve+bKX039ECcqKlceLQHAsQnR/0uF5qP 6NBNPlXNkuecnVhmc1UdHxBRpiDbDv7J96RYIak0YhJhgCJOQ12kv/SCK00/4jJIpRMe TMUhkZWcTuw0d6D6WFSM+eJ9aGV9zycBeYU9welLJGZ1hYdlV19J1gbysKdAzAOLrIT1 dsoQ== X-Gm-Message-State: AHQUAuaXbftYl9Xy74wP+j65XsilEL57ABknPJqzmknWAQdpnP2yDoSd QWUkM3oM1KYndKDCXKrSmXEyfy3Af3Q= X-Google-Smtp-Source: AHgI3Ib/ALjnRI3t38JISI8vEaaurxG7wz7YBEXLiLD0eiuJy3OK/VZ3UyuxyGC+Tap3bsBtIqZQpA== X-Received: by 2002:a1c:a9d0:: with SMTP id s199mr6180316wme.142.1550661168549; Wed, 20 Feb 2019 03:12:48 -0800 (PST) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id c18sm22969770wre.32.2019.02.20.03.12.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Feb 2019 03:12:47 -0800 (PST) From: Bartosz Golaszewski To: Greg Kroah-Hartman , "Rafael J . Wysocki" , Keerthy , Linus Walleij , Andy Shevchenko Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 1/2] drivers: provide devm_platform_ioremap_resource() Date: Wed, 20 Feb 2019 12:12:39 +0100 Message-Id: <20190220111240.10041-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190220111240.10041-1-brgl@bgdev.pl> References: <20190220111240.10041-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 Acked-by: Greg Kroah-Hartman --- 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..f82691e1c26c 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_GPL(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 *,