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 *, From patchwork Wed Feb 20 11:12:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1045271 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="A2WsQ99n"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 444FMM5YKtz9s5c for ; Wed, 20 Feb 2019 22:13:03 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726209AbfBTLNC (ORCPT ); Wed, 20 Feb 2019 06:13:02 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:54534 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727721AbfBTLMw (ORCPT ); Wed, 20 Feb 2019 06:12:52 -0500 Received: by mail-wm1-f68.google.com with SMTP id a62so6206259wmh.4 for ; Wed, 20 Feb 2019 03:12:50 -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=A2WsQ99nTNxk2DvdpKBcLgTQ6phol5QkP5nDsbzEu1AfRT3Lb4D6+M50rFaG+uW63M j+hVQ4QSL7Q1pRbvkpJN/IWLiUN5kFVOMAnyBl1ECjUFiwIwEHGWv2Abbv5tzzxfGRId d47Kb+lBLKZIP76G1z/2Lyhs63l65H9OH2I08oeSfMmp62CnuJrESzVIx1V2DyvAl1+m +bYgyv9/ExQYpG7RRew+C9jzL4/QxEHlAeR7jun+FLZ6htOqroxdQGkOTl2arBUtnbVZ nqyJT34uUvvhuPJEmkMZ95ha3VmE0r85rFRUykx2GCZy54zKhpvEkN5ijF+HU/ZuWXs7 bUig== 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=hhCJS69YF+GYWappYFMab6ThPrMEzqahTwL5Ptxju6557GkXTapLREgCTxoecLJwW9 E6pZtPBJfAfTw6MKFlaUlC6e8k8KL0kF31iOael5icykaicgX5sJo1/rhCWNnq7gymyQ AmL1tlGoGNm6SZy9sQPSs0X2Gn0fUsJUczMS6+4/wRM8qxLK7EWlfo2EN+Yu1RFCuoX1 XyCQedpVeGe4dyeKLT8VhlYHfQ6I5e6ZwaiyRAfWoaAayjkPG25hHzFRE77TFeKrB9Nk NMavMBaoVVPqK+deQ8a7wiuEVnFw3QcVyXaHhykFKIT0YPz6lyAsBG1gpdRqhGqWkxny uEKA== X-Gm-Message-State: AHQUAubKGnJ1IGJY3hYTsg+GMQ2N+bH/opHXVEw0VCL0h4BZJFpsNfzj hWMkf3NKIp2t88qMTz86479QWA== X-Google-Smtp-Source: AHgI3IbDAqZ3ugDZeFPszLr/bYipvH7gDKtGdO7ryf/W4BSUHYVfTgawMy/7Lk7xOviDBqT6PVbsRA== X-Received: by 2002:a1c:cb86:: with SMTP id b128mr6125906wmg.46.1550661169996; Wed, 20 Feb 2019 03:12:49 -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.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Feb 2019 03:12:49 -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 2/2] gpio: davinci: use devm_platform_ioremap_resource() Date: Wed, 20 Feb 2019 12:12:40 +0100 Message-Id: <20190220111240.10041-3-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 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);