From patchwork Tue Jun 30 07:45:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 6694401 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6A6289F40A for ; Tue, 30 Jun 2015 07:46:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8E31820520 for ; Tue, 30 Jun 2015 07:46:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AF80E20525 for ; Tue, 30 Jun 2015 07:46:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752463AbbF3HqF (ORCPT ); Tue, 30 Jun 2015 03:46:05 -0400 Received: from laurent.telenet-ops.be ([195.130.137.89]:36496 "EHLO laurent.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752184AbbF3HqD (ORCPT ); Tue, 30 Jun 2015 03:46:03 -0400 Received: from ayla.of.borg ([84.193.93.87]) by laurent.telenet-ops.be with bizsmtp id mXly1q01Z1t5w8s01Xlypn; Tue, 30 Jun 2015 09:46:01 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1Z9qEw-00071l-90; Tue, 30 Jun 2015 09:45:58 +0200 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1Z9qEz-0000gP-QH; Tue, 30 Jun 2015 09:46:01 +0200 From: Geert Uytterhoeven To: Linus Walleij , Alexandre Courbot , Laurent Pinchart , Simon Horman , Magnus Damm Cc: Maxime Ripard , Boris Brezillon , Benoit Parrot , linux-gpio@vger.kernel.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Geert Uytterhoeven Subject: [PATCH 6/7] pinctrl: sh-pfc: Move sh_pfc_add_gpiochip() up Date: Tue, 30 Jun 2015 09:45:26 +0200 Message-Id: <1435650327-2542-7-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1435650327-2542-1-git-send-email-geert+renesas@glider.be> References: <1435650327-2542-1-git-send-email-geert+renesas@glider.be> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move sh_pfc_add_gpiochip() to the generic helper section at the top of the file, so it can be called from the "Function GPIOs" section later. Signed-off-by: Geert Uytterhoeven Acked-by: Laurent Pinchart --- drivers/pinctrl/sh-pfc/gpio.c | 58 +++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/drivers/pinctrl/sh-pfc/gpio.c b/drivers/pinctrl/sh-pfc/gpio.c index b8929b5e2fa26c53..30654e800580524d 100644 --- a/drivers/pinctrl/sh-pfc/gpio.c +++ b/drivers/pinctrl/sh-pfc/gpio.c @@ -131,6 +131,35 @@ static int gpio_setup_data_regs(struct sh_pfc_chip *chip) return 0; } +static struct sh_pfc_chip * +sh_pfc_add_gpiochip(struct sh_pfc *pfc, int(*setup)(struct sh_pfc_chip *), + struct sh_pfc_window *mem) +{ + struct sh_pfc_chip *chip; + int ret; + + chip = devm_kzalloc(pfc->dev, sizeof(*chip), GFP_KERNEL); + if (unlikely(!chip)) + return ERR_PTR(-ENOMEM); + + chip->mem = mem; + chip->pfc = pfc; + + ret = setup(chip); + if (ret < 0) + return ERR_PTR(ret); + + ret = gpiochip_add(&chip->gpio_chip); + if (unlikely(ret < 0)) + return ERR_PTR(ret); + + dev_info(pfc->dev, "%s handling gpio %u -> %u\n", + chip->gpio_chip.label, chip->gpio_chip.base, + chip->gpio_chip.base + chip->gpio_chip.ngpio - 1); + + return chip; +} + /* ----------------------------------------------------------------------------- * Pin GPIOs */ @@ -305,35 +334,6 @@ static int gpio_function_setup(struct sh_pfc_chip *chip) * Register/unregister */ -static struct sh_pfc_chip * -sh_pfc_add_gpiochip(struct sh_pfc *pfc, int(*setup)(struct sh_pfc_chip *), - struct sh_pfc_window *mem) -{ - struct sh_pfc_chip *chip; - int ret; - - chip = devm_kzalloc(pfc->dev, sizeof(*chip), GFP_KERNEL); - if (unlikely(!chip)) - return ERR_PTR(-ENOMEM); - - chip->mem = mem; - chip->pfc = pfc; - - ret = setup(chip); - if (ret < 0) - return ERR_PTR(ret); - - ret = gpiochip_add(&chip->gpio_chip); - if (unlikely(ret < 0)) - return ERR_PTR(ret); - - dev_info(pfc->dev, "%s handling gpio %u -> %u\n", - chip->gpio_chip.label, chip->gpio_chip.base, - chip->gpio_chip.base + chip->gpio_chip.ngpio - 1); - - return chip; -} - int sh_pfc_register_gpiochip(struct sh_pfc *pfc) { struct sh_pfc_chip *chip;