Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1542464imu; Mon, 5 Nov 2018 23:45:22 -0800 (PST) X-Google-Smtp-Source: AJdET5fEAo12ZHbOL1VGekT+p8y8tgInfVHk2Zf1UTjIy3ZIwqtrx1FfT3OSi9j8BGVFOzz+HzME X-Received: by 2002:a17:902:6e17:: with SMTP id u23-v6mr25722215plk.127.1541490322160; Mon, 05 Nov 2018 23:45:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541490322; cv=none; d=google.com; s=arc-20160816; b=pXYEm7uh1N8qufFZqsH/HBNZP1nQzevitKKSZD5JS6eHqzSMthhK+4bfK+2kGrXxg6 ynh/aeRP4uKwXIdQRfJSKk4A9918N8fOChJiBZff0XH+3HPAEl1l5wQGHVbiYB3lGtQ2 GR25DkX0imH4LNC+xsD3w5FHn9HeLzHTkhrl+Af8x4se5kk8qIzeeJQzCM0tgZyroxVm oIUpSInNK0N8xyLDYklwIG5vwPI9b1PfiXXfu3HnXbkr12ENUOUXjHUBDvo7WZSvm/4e X0+HowVwSfm7lhCWy3uoeQyMYM/IOjHw7j3Ea3tEDGdUPHldDz9nC6+Ze/fPXIM1xw4f 8bgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=SCpJ6RVpEnYtweiTsmGmpe4XCeoJ4KBxnaS6gQ4EMy4=; b=xqmM0T2SGGBNIqVQ95PjBvbRPs7XW5hFcP9Moi3fv35Wg33k0rvHwqk073lv64vPf5 AahC6dUDdybaEtJ8UrQ+daavWL2b4f647K/tgLQ2nCFfdDNQtOfrOS1KXubd71v9jQZC V28vnrRcP9qBU85R0VJ1ki6xOfhPj61t73gleIFCKn7b5z9LGaSSQmUnjFFmTmxEqaRH w3XB3F5Wa0dWxA9HPCTrzN+rlf9SAJBkyCsKs13aFKrxc7yo+YxhlDqC1hWU84R8xzOo o3EWA+HpjoVEnP0iKeGHO3pHEK8f96wiFV+wZ4N4aQN3CtK8LGKG86i5uSFDeQXFI1O3 PXBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="r12s/Zq4"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z7-v6si45090747pgc.343.2018.11.05.23.45.06; Mon, 05 Nov 2018 23:45:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="r12s/Zq4"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729656AbeKFRHX (ORCPT + 99 others); Tue, 6 Nov 2018 12:07:23 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:41711 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726863AbeKFRHX (ORCPT ); Tue, 6 Nov 2018 12:07:23 -0500 Received: by mail-pl1-f194.google.com with SMTP id p16-v6so5767696plr.8 for ; Mon, 05 Nov 2018 23:43:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=SCpJ6RVpEnYtweiTsmGmpe4XCeoJ4KBxnaS6gQ4EMy4=; b=r12s/Zq4efIbn5N7piIs8sW+jhO8EUCmy56iS8/dD0OR+a/opB01l4+YsJjcTXEFg0 MWPusBAE2Tax8fiCE9GMD0SiVTP8gOKEmQn/UQASKSMqLmw2Zk5Vl6x910il5jkG2jmR BmT1LpgOTaw2DyAX8UdyPtBtj+lPg4qzunYy5UXYLS+6vOGV2Dzkyu1/DeUU5lm4f6ud PQ51KJTKP1LwJbb2kwxtRIFRU8KKcOFtK5V57ZvxBP3Y01WdXkmyNsD2rXXnFNFfOR1v 2aFMa4e3DjWlUsb9igUVaxAU2kngRUBYb4wHc0hvaesXaFWXG0mPBymMdd3sQV7zpwxd t4GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=SCpJ6RVpEnYtweiTsmGmpe4XCeoJ4KBxnaS6gQ4EMy4=; b=BLwhzIXSnjvxcK2Hx52lKfGxDJNZ9lR+4a6FB5QugaesvYUYcJvL3ypmeTgj1Vd1VF e5S1RMREgM+XW2nHiNc5eBrNHY+s/WY+Dz4lHyhZAqkCWeolPIYeUOmVKseqmKqpSx1e sYRNC8pqZR0lBKjUSGN4ViEynY6H6/9GGTHLR1Dvp5oDVNN1yxofQ+aFUALCw5awEAR4 K/TMSldaVglNyWFzHu4tNM9q1hc2Jb6RiKTXnjFmxemWN45oH8rF/TXoMDE2F91XJkKh AC6dIkHl4fEczWivWPYtvLMr2MByHYM4WGhCMjq1JSWgubqHq70OCKmhvEuEhgJggb40 +Eew== X-Gm-Message-State: AGRZ1gIN46qiNP3+ju83KHjSA6yi8JS+4gCa79orXZkd+vxTBiFWIpW8 uKKdyp8dFtDS7f3gwI2FlW8= X-Received: by 2002:a17:902:20ca:: with SMTP id v10-v6mr25703494plg.182.1541490207315; Mon, 05 Nov 2018 23:43:27 -0800 (PST) Received: from nishad ([2401:4900:1883:eed:7998:219b:665e:21b1]) by smtp.gmail.com with ESMTPSA id k26sm1617385pgf.65.2018.11.05.23.43.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Nov 2018 23:43:26 -0800 (PST) Date: Tue, 6 Nov 2018 13:13:19 +0530 From: Nishad Kamdar To: Greg Kroah-Hartman Cc: Jens Frederich , Daniel Drake , Jon Nettleton , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] staging: olpc_dcon: olpc_dcon_xo_1.c: Switch to the gpio descriptor interface Message-ID: <20181106074314.GA11430@nishad> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the gpiod interface instead of the deprecated old non-descriptor interface in olpc_dcon_xo_1.c. --- Changes in v3: - Resolve a few compilation errors. Changes in v2: - Resolve a few compilation errors. - Add a level of indirection to read and write gpios. Signed-off-by: Nishad Kamdar --- drivers/staging/olpc_dcon/olpc_dcon_xo_1.c | 90 +++++++++++----------- 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c index ff145d493e1b..80b8d4153414 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c +++ b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c @@ -11,35 +11,51 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -#include +#include #include +#include #include #include "olpc_dcon.h" +enum dcon_gpios { + OLPC_DCON_STAT0, + OLPC_DCON_STAT1, + OLPC_DCON_IRQ, + OLPC_DCON_LOAD, + OLPC_DCON_BLANK, +}; + +struct dcon_gpio { + const char *name; + unsigned long flags; +}; + +static const struct dcon_gpio gpios_asis[] = { + [OLPC_DCON_STAT0] = { .name = "dcon_stat0", .flags = GPIOD_ASIS }, + [OLPC_DCON_STAT1] = { .name = "dcon_stat1", .flags = GPIOD_ASIS }, + [OLPC_DCON_IRQ] = { .name = "dcon_irq", .flags = GPIOD_ASIS }, + [OLPC_DCON_LOAD] = { .name = "dcon_load", .flags = GPIOD_ASIS }, + [OLPC_DCON_BLANK] = { .name = "dcon_blank", .flags = GPIOD_ASIS }, +}; + +struct gpio_desc *gpios[5]; + static int dcon_init_xo_1(struct dcon_priv *dcon) { unsigned char lob; - - if (gpio_request(OLPC_GPIO_DCON_STAT0, "OLPC-DCON")) { - pr_err("failed to request STAT0 GPIO\n"); - return -EIO; - } - if (gpio_request(OLPC_GPIO_DCON_STAT1, "OLPC-DCON")) { - pr_err("failed to request STAT1 GPIO\n"); - goto err_gp_stat1; - } - if (gpio_request(OLPC_GPIO_DCON_IRQ, "OLPC-DCON")) { - pr_err("failed to request IRQ GPIO\n"); - goto err_gp_irq; - } - if (gpio_request(OLPC_GPIO_DCON_LOAD, "OLPC-DCON")) { - pr_err("failed to request LOAD GPIO\n"); - goto err_gp_load; - } - if (gpio_request(OLPC_GPIO_DCON_BLANK, "OLPC-DCON")) { - pr_err("failed to request BLANK GPIO\n"); - goto err_gp_blank; + int ret, i; + struct dcon_gpio *pin = &gpios_asis[0]; + + for (i = 0; i < ARRAY_SIZE(gpios_asis); i++) { + gpios[i] = devm_gpiod_get(&dcon->client->dev, pin[i].name, + pin[i].flags); + if (IS_ERR(gpios[i])) { + ret = PTR_ERR(gpios[i]); + pr_err("failed to request %s GPIO: %d\n", pin[i].name, + ret); + return ret; + } } /* Turn off the event enable for GPIO7 just to be safe */ @@ -61,12 +77,12 @@ static int dcon_init_xo_1(struct dcon_priv *dcon) dcon->pending_src = dcon->curr_src; /* Set the directions for the GPIO pins */ - gpio_direction_input(OLPC_GPIO_DCON_STAT0); - gpio_direction_input(OLPC_GPIO_DCON_STAT1); - gpio_direction_input(OLPC_GPIO_DCON_IRQ); - gpio_direction_input(OLPC_GPIO_DCON_BLANK); - gpio_direction_output(OLPC_GPIO_DCON_LOAD, - dcon->curr_src == DCON_SOURCE_CPU); + gpiod_direction_input(gpios[OLPC_DCON_STAT0]); + gpiod_direction_input(gpios[OLPC_DCON_STAT1]); + gpiod_direction_input(gpios[OLPC_DCON_IRQ]); + gpiod_direction_input(gpios[OLPC_DCON_BLANK]); + gpiod_direction_output(gpios[OLPC_DCON_LOAD], + dcon->curr_src == DCON_SOURCE_CPU); /* Set up the interrupt mappings */ @@ -84,7 +100,7 @@ static int dcon_init_xo_1(struct dcon_priv *dcon) /* Register the interrupt handler */ if (request_irq(DCON_IRQ, &dcon_interrupt, 0, "DCON", dcon)) { pr_err("failed to request DCON's irq\n"); - goto err_req_irq; + return -EIO; } /* Clear INV_EN for GPIO7 (DCONIRQ) */ @@ -125,18 +141,6 @@ static int dcon_init_xo_1(struct dcon_priv *dcon) cs5535_gpio_set(OLPC_GPIO_DCON_BLANK, GPIO_EVENTS_ENABLE); return 0; - -err_req_irq: - gpio_free(OLPC_GPIO_DCON_BLANK); -err_gp_blank: - gpio_free(OLPC_GPIO_DCON_LOAD); -err_gp_load: - gpio_free(OLPC_GPIO_DCON_IRQ); -err_gp_irq: - gpio_free(OLPC_GPIO_DCON_STAT1); -err_gp_stat1: - gpio_free(OLPC_GPIO_DCON_STAT0); - return -EIO; } static void dcon_wiggle_xo_1(void) @@ -180,13 +184,13 @@ static void dcon_wiggle_xo_1(void) static void dcon_set_dconload_1(int val) { - gpio_set_value(OLPC_GPIO_DCON_LOAD, val); + gpiod_set_value(gpios[OLPC_DCON_LOAD], val); } static int dcon_read_status_xo_1(u8 *status) { - *status = gpio_get_value(OLPC_GPIO_DCON_STAT0); - *status |= gpio_get_value(OLPC_GPIO_DCON_STAT1) << 1; + *status = gpiod_get_value(gpios[OLPC_DCON_STAT0]); + *status |= gpiod_get_value(gpios[OLPC_DCON_STAT1]) << 1; /* Clear the negative edge status for GPIO7 */ cs5535_gpio_set(OLPC_GPIO_DCON_IRQ, GPIO_NEGATIVE_EDGE_STS); -- 2.17.1