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

ata: sata_highbank: Convert to use GPIO descriptors

This pure device tree driver is simple to convert to use
just GPIO descriptors instead of GPIO numbers. So let's
just do it.

Cc: Mark Langsdorf <mlangsdo@redhat.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Linus Walleij and committed by
Jens Axboe
83a7faac 3e216263

+16 -19
+16 -19
drivers/ata/sata_highbank.c
··· 31 31 #include <linux/interrupt.h> 32 32 #include <linux/delay.h> 33 33 #include <linux/export.h> 34 - #include <linux/gpio.h> 35 - #include <linux/of_gpio.h> 34 + #include <linux/gpio/consumer.h> 36 35 37 36 #include "ahci.h" 38 37 ··· 84 85 /* number of extra clocks that the SGPIO PIC controller expects */ 85 86 u32 pre_clocks; 86 87 u32 post_clocks; 87 - unsigned sgpio_gpio[SGPIO_PINS]; 88 + struct gpio_desc *sgpio_gpiod[SGPIO_PINS]; 88 89 u32 sgpio_pattern; 89 90 u32 port_to_sgpio[SGPIO_PORTS]; 90 91 }; ··· 130 131 */ 131 132 static void ecx_led_cycle_clock(struct ecx_plat_data *pdata) 132 133 { 133 - gpio_set_value(pdata->sgpio_gpio[SCLOCK], 1); 134 + gpiod_set_value(pdata->sgpio_gpiod[SCLOCK], 1); 134 135 udelay(50); 135 - gpio_set_value(pdata->sgpio_gpio[SCLOCK], 0); 136 + gpiod_set_value(pdata->sgpio_gpiod[SCLOCK], 0); 136 137 udelay(50); 137 138 } 138 139 ··· 163 164 for (i = 0; i < pdata->pre_clocks; i++) 164 165 ecx_led_cycle_clock(pdata); 165 166 166 - gpio_set_value(pdata->sgpio_gpio[SLOAD], 1); 167 + gpiod_set_value(pdata->sgpio_gpiod[SLOAD], 1); 167 168 ecx_led_cycle_clock(pdata); 168 - gpio_set_value(pdata->sgpio_gpio[SLOAD], 0); 169 + gpiod_set_value(pdata->sgpio_gpiod[SLOAD], 0); 169 170 /* 170 171 * bit-bang out the SGPIO pattern, by consuming a bit and then 171 172 * clocking it out. 172 173 */ 173 174 for (i = 0; i < (SGPIO_SIGNALS * pdata->n_ports); i++) { 174 - gpio_set_value(pdata->sgpio_gpio[SDATA], sgpio_out & 1); 175 + gpiod_set_value(pdata->sgpio_gpiod[SDATA], sgpio_out & 1); 175 176 sgpio_out >>= 1; 176 177 ecx_led_cycle_clock(pdata); 177 178 } ··· 192 193 struct device_node *np = dev->of_node; 193 194 struct ecx_plat_data *pdata = hpriv->plat_data; 194 195 int i; 195 - int err; 196 196 197 197 for (i = 0; i < SGPIO_PINS; i++) { 198 - err = of_get_named_gpio(np, "calxeda,sgpio-gpio", i); 199 - if (err < 0) 200 - return; 198 + struct gpio_desc *gpiod; 201 199 202 - pdata->sgpio_gpio[i] = err; 203 - err = gpio_request(pdata->sgpio_gpio[i], "CX SGPIO"); 204 - if (err) { 205 - pr_err("sata_highbank gpio_request %d failed: %d\n", 206 - i, err); 207 - return; 200 + gpiod = devm_gpiod_get_index(dev, "calxeda,sgpio", i, 201 + GPIOD_OUT_HIGH); 202 + if (IS_ERR(gpiod)) { 203 + dev_err(dev, "failed to get GPIO %d\n", i); 204 + continue; 208 205 } 209 - gpio_direction_output(pdata->sgpio_gpio[i], 1); 206 + gpiod_set_consumer_name(gpiod, "CX SGPIO"); 207 + 208 + pdata->sgpio_gpiod[i] = gpiod; 210 209 } 211 210 of_property_read_u32_array(np, "calxeda,led-order", 212 211 pdata->port_to_sgpio,