From patchwork Fri Jan 9 15:19:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rojhalat Ibrahim X-Patchwork-Id: 427144 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C96D51400D5 for ; Sat, 10 Jan 2015 02:28:07 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758111AbbAIP16 (ORCPT ); Fri, 9 Jan 2015 10:27:58 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:42398 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757725AbbAIP1z (ORCPT ); Fri, 9 Jan 2015 10:27:55 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3kJp945sKnz3hjqd; Fri, 9 Jan 2015 16:27:52 +0100 (CET) Received: from mail.dmz.schenk (host-82-135-47-202.customer.m-online.net [82.135.47.202]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS id 3kJp940G71zvh2R; Fri, 9 Jan 2015 16:27:52 +0100 (CET) Received: from gwhaus.rt.schenk (gwhaus.rt.schenk [172.22.0.4]) by mail.dmz.schenk (Postfix) with SMTP id B68F616117C; Fri, 9 Jan 2015 16:27:51 +0100 (CET) Received: from pcimr.localnet (pcimr.rt.schenk [172.22.10.20]) by gwhaus.rt.schenk (Postfix) with ESMTP id 9ECC6240849; Fri, 9 Jan 2015 16:27:51 +0100 (CET) From: Rojhalat Ibrahim To: "linux-gpio@vger.kernel.org" Cc: Alexandre Courbot , Linus Walleij , David Miller , netdev@vger.kernel.org Subject: [PATCH 2/2] mdio-mux-gpio: use new gpiod_get_array and gpiod_put_array functions Date: Fri, 09 Jan 2015 16:19:52 +0100 Message-ID: <13407316.QPemVgjPDO@pcimr> User-Agent: KMail/4.14.3 (Linux/3.13.6; KDE/4.14.3; x86_64; ; ) MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Use the new gpiod_get_array and gpiod_put_array functions for obtaining and disposing of GPIO descriptors. Signed-off-by: Rojhalat Ibrahim --- This patch depends on my previous patch "gpiolib: add gpiod_get_array and gpiod_put_array functions". drivers/net/phy/mdio-mux-gpio.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/phy/mdio-mux-gpio.c b/drivers/net/phy/mdio-mux-gpio.c index 1eaf81e..35c37da 100644 --- a/drivers/net/phy/mdio-mux-gpio.c +++ b/drivers/net/phy/mdio-mux-gpio.c @@ -47,7 +47,6 @@ static int mdio_mux_gpio_probe(struct platform_device *pdev) { struct mdio_mux_gpio_state *s; int num_gpios; - unsigned int n; int r; if (!pdev->dev.of_node) @@ -63,16 +62,10 @@ static int mdio_mux_gpio_probe(struct platform_device *pdev) s->num_gpios = num_gpios; - for (n = 0; n < num_gpios; ) { - struct gpio_desc *gpio = gpiod_get_index(&pdev->dev, NULL, n, - GPIOD_OUT_LOW); - if (IS_ERR(gpio)) { - r = PTR_ERR(gpio); - goto err; - } - s->gpio[n] = gpio; - n++; - } + r = gpiod_get_array(&pdev->dev, NULL, s->gpio, num_gpios, + GPIOD_OUT_LOW); + if (r != num_gpios) + return r; r = mdio_mux_init(&pdev->dev, mdio_mux_gpio_switch_fn, &s->mux_handle, s); @@ -80,22 +73,17 @@ static int mdio_mux_gpio_probe(struct platform_device *pdev) if (r == 0) { pdev->dev.platform_data = s; return 0; + } else { + gpiod_put_array(s->gpio, num_gpios); + return r; } -err: - while (n) { - n--; - gpiod_put(s->gpio[n]); - } - return r; } static int mdio_mux_gpio_remove(struct platform_device *pdev) { - unsigned int n; struct mdio_mux_gpio_state *s = dev_get_platdata(&pdev->dev); mdio_mux_uninit(s->mux_handle); - for (n = 0; n < s->num_gpios; n++) - gpiod_put(s->gpio[n]); + gpiod_put_array(s->gpio, s->num_gpios); return 0; }