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

Configure Feed

Select the types of activity you want to include in your feed.

nfc: st95hf: Switch to using gpiod API

This updates the driver to gpiod API, and removes yet another use of
of_get_named_gpio().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240326175836.1418718-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Andy Shevchenko and committed by
Jakub Kicinski
b7b1c590 b125f3eb

+11 -16
+11 -16
drivers/nfc/st95hf/core.c
··· 7 7 */ 8 8 9 9 #include <linux/err.h> 10 - #include <linux/gpio.h> 10 + #include <linux/gpio/consumer.h> 11 11 #include <linux/init.h> 12 12 #include <linux/interrupt.h> 13 13 #include <linux/irq.h> 14 14 #include <linux/module.h> 15 15 #include <linux/netdevice.h> 16 16 #include <linux/nfc.h> 17 - #include <linux/of_gpio.h> 18 17 #include <linux/of.h> 19 18 #include <linux/property.h> 20 19 #include <linux/regulator/consumer.h> ··· 195 196 * for spi communication between st95hf and host. 196 197 * @ddev: nfc digital device object. 197 198 * @nfcdev: nfc device object. 198 - * @enable_gpio: gpio used to enable st95hf transceiver. 199 + * @enable_gpiod: gpio used to enable st95hf transceiver. 199 200 * @complete_cb_arg: structure to store various context information 200 201 * that is passed from nfc requesting thread to the threaded ISR. 201 202 * @st95hf_supply: regulator "consumer" for NFC device. ··· 218 219 struct st95hf_spi_context spicontext; 219 220 struct nfc_digital_dev *ddev; 220 221 struct nfc_dev *nfcdev; 221 - unsigned int enable_gpio; 222 + struct gpio_desc *enable_gpiod; 222 223 struct st95_digital_cmd_complete_arg complete_cb_arg; 223 224 struct regulator *st95hf_supply; 224 225 unsigned char sendrcv_trflag; ··· 450 451 static void st95hf_send_st95enable_negativepulse(struct st95hf_context *st95con) 451 452 { 452 453 /* First make irq_in pin high */ 453 - gpio_set_value(st95con->enable_gpio, HIGH); 454 + gpiod_set_value(st95con->enable_gpiod, HIGH); 454 455 455 456 /* wait for 1 milisecond */ 456 457 usleep_range(1000, 2000); 457 458 458 459 /* Make irq_in pin low */ 459 - gpio_set_value(st95con->enable_gpio, LOW); 460 + gpiod_set_value(st95con->enable_gpiod, LOW); 460 461 461 462 /* wait for minimum interrupt pulse to make st95 active */ 462 463 usleep_range(1000, 2000); 463 464 464 465 /* At end make it high */ 465 - gpio_set_value(st95con->enable_gpio, HIGH); 466 + gpiod_set_value(st95con->enable_gpiod, HIGH); 466 467 } 467 468 468 469 /* ··· 1062 1063 1063 1064 static int st95hf_probe(struct spi_device *nfc_spi_dev) 1064 1065 { 1066 + struct device *dev = &nfc_spi_dev->dev; 1065 1067 int ret; 1066 1068 1067 1069 struct st95hf_context *st95context; ··· 1108 1108 */ 1109 1109 dev_set_drvdata(&nfc_spi_dev->dev, spicontext); 1110 1110 1111 - st95context->enable_gpio = 1112 - of_get_named_gpio(nfc_spi_dev->dev.of_node, 1113 - "enable-gpio", 1114 - 0); 1115 - if (!gpio_is_valid(st95context->enable_gpio)) { 1111 + st95context->enable_gpiod = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH); 1112 + if (IS_ERR(st95context->enable_gpiod)) { 1113 + ret = PTR_ERR(st95context->enable_gpiod); 1116 1114 dev_err(&nfc_spi_dev->dev, "No valid enable gpio\n"); 1117 - ret = st95context->enable_gpio; 1118 1115 goto err_disable_regulator; 1119 1116 } 1120 1117 1121 - ret = devm_gpio_request_one(&nfc_spi_dev->dev, st95context->enable_gpio, 1122 - GPIOF_DIR_OUT | GPIOF_INIT_HIGH, 1123 - "enable_gpio"); 1118 + ret = gpiod_set_consumer_name(st95context->enable_gpiod, "enable_gpio"); 1124 1119 if (ret) 1125 1120 goto err_disable_regulator; 1126 1121