From patchwork Mon Feb 5 08:23:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ludovic Desroches X-Patchwork-Id: 10199993 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A34BD60247 for ; Mon, 5 Feb 2018 08:25:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9165928674 for ; Mon, 5 Feb 2018 08:25:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 861522868C; Mon, 5 Feb 2018 08:25:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0EF3228674 for ; Mon, 5 Feb 2018 08:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=XEHva6pBO9AG8tCV8bUVynSbpC6ctvpggyyMWu+qB3w=; b=PX+muBoRtImrU6 XnBcRBE34tWmk5EhNdE/7YeNFvo1TeGIGdpHoBHNwMwdnC4Cvg6AmOM+xK+al1utYLbTLvJtRCAhR Q6KDyQXd+WK9ufxY/LavBGopcApuzu/brseQaG8HjxCQkOq0XwUsmjfy9vID9N2mARFJnp9NuDEHM LeElQS914EIgaTWFE5QHRB1EGA5iDdZPZhSAltcBXLSBh6YFPTnsHLS0wt3i9DbWloX+/Ex9DaI1b RJgrkz++oKPJHH9Ttj0e7Vm0DJLebSq2DkDuHuKOqaxhXDhgEhvzzl6k+/KZnUZ8KwtmmhHaAcSXu +dCl3/wKCJv3VjJLRCXw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eic5g-00019R-A4; Mon, 05 Feb 2018 08:25:28 +0000 Received: from esa2.microchip.iphmx.com ([68.232.149.84]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eic5a-0000t5-KU for linux-arm-kernel@lists.infradead.org; Mon, 05 Feb 2018 08:25:26 +0000 X-IronPort-AV: E=Sophos;i="5.46,464,1511852400"; d="scan'208";a="11064009" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 05 Feb 2018 01:25:10 -0700 Received: from ibiza.rfo.atmel.com (10.10.76.4) by chn-sv-exch07.mchp-main.com (10.10.76.108) with Microsoft SMTP Server id 14.3.352.0; Mon, 5 Feb 2018 01:25:09 -0700 From: Ludovic Desroches To: , , Subject: [PATCH] video: fbdev: convert to use GPIO descriptors Date: Mon, 5 Feb 2018 09:23:35 +0100 Message-ID: <20180205082335.5727-1-ludovic.desroches@microchip.com> X-Mailer: git-send-email 2.12.2 MIME-Version: 1.0 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: b.zolnierkie@samsung.com, linus.walleij@linaro.org, linux-kernel@vger.kernel.org, Ludovic Desroches , alexandre.belloni@free-electrons.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use GPIO descriptors instead of relying on the old method. Signed-off-by: Ludovic Desroches Acked-by: Nicolas Ferre Reviewed-by: Linus Walleij --- drivers/video/fbdev/atmel_lcdfb.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/video/fbdev/atmel_lcdfb.c b/drivers/video/fbdev/atmel_lcdfb.c index 3dee267d7c75..ef3d4198014f 100644 --- a/drivers/video/fbdev/atmel_lcdfb.c +++ b/drivers/video/fbdev/atmel_lcdfb.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -61,8 +62,7 @@ struct atmel_lcdfb_info { }; struct atmel_lcdfb_power_ctrl_gpio { - int gpio; - int active_low; + struct gpio_desc *gpiod; struct list_head list; }; @@ -1018,7 +1018,7 @@ static void atmel_lcdfb_power_control_gpio(struct atmel_lcdfb_pdata *pdata, int struct atmel_lcdfb_power_ctrl_gpio *og; list_for_each_entry(og, &pdata->pwr_gpios, list) - gpio_set_value(og->gpio, on); + gpiod_set_value(og->gpiod, on); } static int atmel_lcdfb_of_init(struct atmel_lcdfb_info *sinfo) @@ -1031,11 +1031,11 @@ static int atmel_lcdfb_of_init(struct atmel_lcdfb_info *sinfo) struct device_node *display_np; struct device_node *timings_np; struct display_timings *timings; - enum of_gpio_flags flags; struct atmel_lcdfb_power_ctrl_gpio *og; bool is_gpio_power = false; int ret = -ENOENT; - int i, gpio; + int i; + struct gpio_desc *gpiod; sinfo->config = (struct atmel_lcdfb_config*) of_match_device(atmel_lcdfb_dt_ids, dev)->data; @@ -1072,28 +1072,22 @@ static int atmel_lcdfb_of_init(struct atmel_lcdfb_info *sinfo) INIT_LIST_HEAD(&pdata->pwr_gpios); ret = -ENOMEM; - for (i = 0; i < of_gpio_named_count(display_np, "atmel,power-control-gpio"); i++) { - gpio = of_get_named_gpio_flags(display_np, "atmel,power-control-gpio", - i, &flags); - if (gpio < 0) + for (i = 0; i < gpiod_count(dev, "atmel,power-control"); i++) { + gpiod = devm_gpiod_get_index_optional(dev, + "atmel,power-control", i, GPIOD_ASIS); + if (!gpiod) continue; og = devm_kzalloc(dev, sizeof(*og), GFP_KERNEL); if (!og) goto put_display_node; - og->gpio = gpio; - og->active_low = flags & OF_GPIO_ACTIVE_LOW; + og->gpiod = gpiod; is_gpio_power = true; - ret = devm_gpio_request(dev, gpio, "lcd-power-control-gpio"); - if (ret) { - dev_err(dev, "request gpio %d failed\n", gpio); - goto put_display_node; - } - ret = gpio_direction_output(gpio, og->active_low); + ret = gpiod_direction_output(gpiod, gpiod_is_active_low(gpiod)); if (ret) { - dev_err(dev, "set direction output gpio %d failed\n", gpio); + dev_err(dev, "set direction output gpio atmel,power-control[%d] failed\n", i); goto put_display_node; } list_add(&og->list, &pdata->pwr_gpios);