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

mfd: twl6040: Switch to using gpiod API

This patch switches the dirver from legacy gpio API to a newer gpiod
API so that we can eventually drop the former.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20220926054421.1546436-4-dmitry.torokhov@gmail.com

authored by

Dmitry Torokhov and committed by
Lee Jones
3c92699a 7ca91a33

+16 -18
+13 -16
drivers/mfd/twl6040.c
··· 17 17 #include <linux/platform_device.h> 18 18 #include <linux/of.h> 19 19 #include <linux/of_irq.h> 20 - #include <linux/of_gpio.h> 21 20 #include <linux/of_platform.h> 22 - #include <linux/gpio.h> 21 + #include <linux/gpio/consumer.h> 23 22 #include <linux/delay.h> 24 23 #include <linux/i2c.h> 25 24 #include <linux/regmap.h> ··· 250 251 { 251 252 int time_left; 252 253 253 - gpio_set_value(twl6040->audpwron, 1); 254 + gpiod_set_value_cansleep(twl6040->audpwron, 1); 254 255 255 256 time_left = wait_for_completion_timeout(&twl6040->ready, 256 257 msecs_to_jiffies(144)); ··· 261 262 intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID); 262 263 if (!(intid & TWL6040_READYINT)) { 263 264 dev_err(twl6040->dev, "automatic power-up failed\n"); 264 - gpio_set_value(twl6040->audpwron, 0); 265 + gpiod_set_value_cansleep(twl6040->audpwron, 0); 265 266 return -ETIMEDOUT; 266 267 } 267 268 } ··· 289 290 /* Allow writes to the chip */ 290 291 regcache_cache_only(twl6040->regmap, false); 291 292 292 - if (gpio_is_valid(twl6040->audpwron)) { 293 + if (twl6040->audpwron) { 293 294 /* use automatic power-up sequence */ 294 295 ret = twl6040_power_up_automatic(twl6040); 295 296 if (ret) { ··· 336 337 if (--twl6040->power_count) 337 338 goto out; 338 339 339 - if (gpio_is_valid(twl6040->audpwron)) { 340 + if (twl6040->audpwron) { 340 341 /* use AUDPWRON line */ 341 - gpio_set_value(twl6040->audpwron, 0); 342 + gpiod_set_value_cansleep(twl6040->audpwron, 0); 342 343 343 344 /* power-down sequence latency */ 344 345 usleep_range(500, 700); ··· 710 711 } 711 712 712 713 /* ERRATA: Automatic power-up is not possible in ES1.0 */ 713 - if (twl6040_get_revid(twl6040) > TWL6040_REV_ES1_0) 714 - twl6040->audpwron = of_get_named_gpio(node, 715 - "ti,audpwron-gpio", 0); 716 - else 717 - twl6040->audpwron = -EINVAL; 718 - 719 - if (gpio_is_valid(twl6040->audpwron)) { 720 - ret = devm_gpio_request_one(&client->dev, twl6040->audpwron, 721 - GPIOF_OUT_INIT_LOW, "audpwron"); 714 + if (twl6040_get_revid(twl6040) > TWL6040_REV_ES1_0) { 715 + twl6040->audpwron = devm_gpiod_get_optional(&client->dev, 716 + "ti,audpwron", 717 + GPIOD_OUT_LOW); 718 + ret = PTR_ERR_OR_ZERO(twl6040->audpwron); 722 719 if (ret) 723 720 goto gpio_err; 721 + 722 + gpiod_set_consumer_name(twl6040->audpwron, "audpwron"); 724 723 725 724 /* Clear any pending interrupt */ 726 725 twl6040_reg_read(twl6040, TWL6040_REG_INTID);
+3 -2
include/linux/mfd/twl6040.h
··· 196 196 }; 197 197 198 198 struct twl6040_platform_data { 199 - int audpwron_gpio; /* audio power-on gpio */ 199 + struct gpio_desc *audpwron_gpio; /* audio power-on gpio */ 200 200 201 201 struct twl6040_codec_data *codec; 202 202 struct twl6040_vibra_data *vibra; 203 203 struct twl6040_gpo_data *gpo; 204 204 }; 205 205 206 + struct gpio_desc; 206 207 struct regmap; 207 208 struct regmap_irq_chips_data; 208 209 ··· 219 218 struct mfd_cell cells[TWL6040_CELLS]; 220 219 struct completion ready; 221 220 222 - int audpwron; 221 + struct gpio_desc *audpwron; 223 222 int power_count; 224 223 int rev; 225 224