Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: olpc_dcon: olpc_dcon_xo_1.c: Switch to the gpio descriptor interface

Use the gpiod interface instead of the deprecated old non-descriptor
interface in olpc_dcon_xo_1.c.

Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Nishad Kamdar and committed by
Greg Kroah-Hartman
2159fb37 01c5c561

+46 -42
+46 -42
drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
··· 11 11 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 12 12 13 13 #include <linux/cs5535.h> 14 - #include <linux/gpio.h> 14 + #include <linux/gpio/consumer.h> 15 15 #include <linux/delay.h> 16 + #include <linux/i2c.h> 16 17 #include <asm/olpc.h> 17 18 18 19 #include "olpc_dcon.h" 19 20 21 + enum dcon_gpios { 22 + OLPC_DCON_STAT0, 23 + OLPC_DCON_STAT1, 24 + OLPC_DCON_IRQ, 25 + OLPC_DCON_LOAD, 26 + OLPC_DCON_BLANK, 27 + }; 28 + 29 + struct dcon_gpio { 30 + const char *name; 31 + unsigned long flags; 32 + }; 33 + 34 + static const struct dcon_gpio gpios_asis[] = { 35 + [OLPC_DCON_STAT0] = { .name = "dcon_stat0", .flags = GPIOD_ASIS }, 36 + [OLPC_DCON_STAT1] = { .name = "dcon_stat1", .flags = GPIOD_ASIS }, 37 + [OLPC_DCON_IRQ] = { .name = "dcon_irq", .flags = GPIOD_ASIS }, 38 + [OLPC_DCON_LOAD] = { .name = "dcon_load", .flags = GPIOD_ASIS }, 39 + [OLPC_DCON_BLANK] = { .name = "dcon_blank", .flags = GPIOD_ASIS }, 40 + }; 41 + 42 + struct gpio_desc *gpios[5]; 43 + 20 44 static int dcon_init_xo_1(struct dcon_priv *dcon) 21 45 { 22 46 unsigned char lob; 47 + int ret, i; 48 + struct dcon_gpio *pin = &gpios_asis[0]; 23 49 24 - if (gpio_request(OLPC_GPIO_DCON_STAT0, "OLPC-DCON")) { 25 - pr_err("failed to request STAT0 GPIO\n"); 26 - return -EIO; 27 - } 28 - if (gpio_request(OLPC_GPIO_DCON_STAT1, "OLPC-DCON")) { 29 - pr_err("failed to request STAT1 GPIO\n"); 30 - goto err_gp_stat1; 31 - } 32 - if (gpio_request(OLPC_GPIO_DCON_IRQ, "OLPC-DCON")) { 33 - pr_err("failed to request IRQ GPIO\n"); 34 - goto err_gp_irq; 35 - } 36 - if (gpio_request(OLPC_GPIO_DCON_LOAD, "OLPC-DCON")) { 37 - pr_err("failed to request LOAD GPIO\n"); 38 - goto err_gp_load; 39 - } 40 - if (gpio_request(OLPC_GPIO_DCON_BLANK, "OLPC-DCON")) { 41 - pr_err("failed to request BLANK GPIO\n"); 42 - goto err_gp_blank; 50 + for (i = 0; i < ARRAY_SIZE(gpios_asis); i++) { 51 + gpios[i] = devm_gpiod_get(&dcon->client->dev, pin[i].name, 52 + pin[i].flags); 53 + if (IS_ERR(gpios[i])) { 54 + ret = PTR_ERR(gpios[i]); 55 + pr_err("failed to request %s GPIO: %d\n", pin[i].name, 56 + ret); 57 + return ret; 58 + } 43 59 } 44 60 45 61 /* Turn off the event enable for GPIO7 just to be safe */ ··· 77 61 dcon->pending_src = dcon->curr_src; 78 62 79 63 /* Set the directions for the GPIO pins */ 80 - gpio_direction_input(OLPC_GPIO_DCON_STAT0); 81 - gpio_direction_input(OLPC_GPIO_DCON_STAT1); 82 - gpio_direction_input(OLPC_GPIO_DCON_IRQ); 83 - gpio_direction_input(OLPC_GPIO_DCON_BLANK); 84 - gpio_direction_output(OLPC_GPIO_DCON_LOAD, 85 - dcon->curr_src == DCON_SOURCE_CPU); 64 + gpiod_direction_input(gpios[OLPC_DCON_STAT0]); 65 + gpiod_direction_input(gpios[OLPC_DCON_STAT1]); 66 + gpiod_direction_input(gpios[OLPC_DCON_IRQ]); 67 + gpiod_direction_input(gpios[OLPC_DCON_BLANK]); 68 + gpiod_direction_output(gpios[OLPC_DCON_LOAD], 69 + dcon->curr_src == DCON_SOURCE_CPU); 86 70 87 71 /* Set up the interrupt mappings */ 88 72 ··· 100 84 /* Register the interrupt handler */ 101 85 if (request_irq(DCON_IRQ, &dcon_interrupt, 0, "DCON", dcon)) { 102 86 pr_err("failed to request DCON's irq\n"); 103 - goto err_req_irq; 87 + return -EIO; 104 88 } 105 89 106 90 /* Clear INV_EN for GPIO7 (DCONIRQ) */ ··· 141 125 cs5535_gpio_set(OLPC_GPIO_DCON_BLANK, GPIO_EVENTS_ENABLE); 142 126 143 127 return 0; 144 - 145 - err_req_irq: 146 - gpio_free(OLPC_GPIO_DCON_BLANK); 147 - err_gp_blank: 148 - gpio_free(OLPC_GPIO_DCON_LOAD); 149 - err_gp_load: 150 - gpio_free(OLPC_GPIO_DCON_IRQ); 151 - err_gp_irq: 152 - gpio_free(OLPC_GPIO_DCON_STAT1); 153 - err_gp_stat1: 154 - gpio_free(OLPC_GPIO_DCON_STAT0); 155 - return -EIO; 156 128 } 157 129 158 130 static void dcon_wiggle_xo_1(void) ··· 184 180 185 181 static void dcon_set_dconload_1(int val) 186 182 { 187 - gpio_set_value(OLPC_GPIO_DCON_LOAD, val); 183 + gpiod_set_value(gpios[OLPC_DCON_LOAD], val); 188 184 } 189 185 190 186 static int dcon_read_status_xo_1(u8 *status) 191 187 { 192 - *status = gpio_get_value(OLPC_GPIO_DCON_STAT0); 193 - *status |= gpio_get_value(OLPC_GPIO_DCON_STAT1) << 1; 188 + *status = gpiod_get_value(gpios[OLPC_DCON_STAT0]); 189 + *status |= gpiod_get_value(gpios[OLPC_DCON_STAT1]) << 1; 194 190 195 191 /* Clear the negative edge status for GPIO7 */ 196 192 cs5535_gpio_set(OLPC_GPIO_DCON_IRQ, GPIO_NEGATIVE_EDGE_STS);