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

spi: pxa2xx: Convert to GPIO descriptor API where possible

We still need to request/free GPIOs passed via the legacy path of
pxa2xx_spi_chip::gpio_cs, but we can use the gpiod API otherwise.

Consistently use the descriptor API instead of the legacy one.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Jan Kiszka and committed by
Mark Brown
c18d925f d35f2dc9

+17 -17
+16 -16
drivers/spi/spi-pxa2xx.c
··· 402 402 return; 403 403 } 404 404 405 - if (gpio_is_valid(chip->gpio_cs)) { 406 - gpio_set_value(chip->gpio_cs, chip->gpio_cs_inverted); 405 + if (chip->gpiod_cs) { 406 + gpiod_set_value(chip->gpiod_cs, chip->gpio_cs_inverted); 407 407 return; 408 408 } 409 409 ··· 424 424 return; 425 425 } 426 426 427 - if (gpio_is_valid(chip->gpio_cs)) { 428 - gpio_set_value(chip->gpio_cs, !chip->gpio_cs_inverted); 427 + if (chip->gpiod_cs) { 428 + gpiod_set_value(chip->gpiod_cs, !chip->gpio_cs_inverted); 429 429 return; 430 430 } 431 431 ··· 1213 1213 struct pxa2xx_spi_chip *chip_info) 1214 1214 { 1215 1215 struct driver_data *drv_data = spi_master_get_devdata(spi->master); 1216 + struct gpio_desc *gpiod; 1216 1217 int err = 0; 1217 1218 1218 1219 if (chip == NULL) 1219 1220 return 0; 1220 1221 1221 1222 if (drv_data->cs_gpiods) { 1222 - struct gpio_desc *gpiod; 1223 - 1224 1223 gpiod = drv_data->cs_gpiods[spi->chip_select]; 1225 1224 if (gpiod) { 1226 - chip->gpio_cs = desc_to_gpio(gpiod); 1225 + chip->gpiod_cs = gpiod; 1227 1226 chip->gpio_cs_inverted = spi->mode & SPI_CS_HIGH; 1228 1227 gpiod_set_value(gpiod, chip->gpio_cs_inverted); 1229 1228 } ··· 1236 1237 /* NOTE: setup() can be called multiple times, possibly with 1237 1238 * different chip_info, release previously requested GPIO 1238 1239 */ 1239 - if (gpio_is_valid(chip->gpio_cs)) 1240 - gpio_free(chip->gpio_cs); 1240 + if (chip->gpiod_cs) { 1241 + gpio_free(desc_to_gpio(chip->gpiod_cs)); 1242 + chip->gpiod_cs = NULL; 1243 + } 1241 1244 1242 1245 /* If (*cs_control) is provided, ignore GPIO chip select */ 1243 1246 if (chip_info->cs_control) { ··· 1255 1254 return err; 1256 1255 } 1257 1256 1258 - chip->gpio_cs = chip_info->gpio_cs; 1257 + gpiod = gpio_to_desc(chip_info->gpio_cs); 1258 + chip->gpiod_cs = gpiod; 1259 1259 chip->gpio_cs_inverted = spi->mode & SPI_CS_HIGH; 1260 1260 1261 - err = gpio_direction_output(chip->gpio_cs, 1262 - !chip->gpio_cs_inverted); 1261 + err = gpiod_direction_output(gpiod, !chip->gpio_cs_inverted); 1263 1262 } 1264 1263 1265 1264 return err; ··· 1318 1317 } 1319 1318 1320 1319 chip->frm = spi->chip_select; 1321 - } else 1322 - chip->gpio_cs = -1; 1320 + } 1323 1321 chip->enable_dma = drv_data->master_info->enable_dma; 1324 1322 chip->timeout = TIMOUT_DFLT; 1325 1323 } ··· 1416 1416 return; 1417 1417 1418 1418 if (drv_data->ssp_type != CE4100_SSP && !drv_data->cs_gpiods && 1419 - gpio_is_valid(chip->gpio_cs)) 1420 - gpio_free(chip->gpio_cs); 1419 + chip->gpiod_cs) 1420 + gpio_free(desc_to_gpio(chip->gpiod_cs)); 1421 1421 1422 1422 kfree(chip); 1423 1423 }
+1 -1
drivers/spi/spi-pxa2xx.h
··· 83 83 u16 lpss_tx_threshold; 84 84 u8 enable_dma; 85 85 union { 86 - int gpio_cs; 86 + struct gpio_desc *gpiod_cs; 87 87 unsigned int frm; 88 88 }; 89 89 int gpio_cs_inverted;