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.

Input: auo-pixcir-ts - switch to using gpiod API

This switches the driver to gpiod API and drops uses of of_get_gpio() API.

Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/r/20220914141428.2201784-2-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+20 -27
+20 -27
drivers/input/touchscreen/auo-pixcir-ts.c
··· 10 10 * Copyright (c) 2008 QUALCOMM USA, INC. 11 11 */ 12 12 13 + #include <linux/err.h> 13 14 #include <linux/kernel.h> 14 15 #include <linux/module.h> 15 16 #include <linux/interrupt.h> ··· 20 19 #include <linux/i2c.h> 21 20 #include <linux/mutex.h> 22 21 #include <linux/delay.h> 23 - #include <linux/gpio.h> 22 + #include <linux/gpio/consumer.h> 24 23 #include <linux/of.h> 25 - #include <linux/of_gpio.h> 26 24 27 25 /* 28 26 * Coordinate calculation: ··· 112 112 struct auo_pixcir_ts { 113 113 struct i2c_client *client; 114 114 struct input_dev *input; 115 - int gpio_int; 116 - int gpio_rst; 115 + struct gpio_desc *gpio_int; 116 + struct gpio_desc *gpio_rst; 117 117 char phys[32]; 118 118 119 119 unsigned int x_max; ··· 193 193 194 194 /* check for up event in touch touch_ind_mode */ 195 195 if (ts->touch_ind_mode) { 196 - if (gpio_get_value(ts->gpio_int) == 0) { 196 + if (gpiod_get_value_cansleep(ts->gpio_int) == 0) { 197 197 input_mt_sync(ts->input); 198 198 input_report_key(ts->input, BTN_TOUCH, 0); 199 199 input_sync(ts->input); ··· 482 482 if (!np) 483 483 return -ENOENT; 484 484 485 - ts->gpio_int = of_get_gpio(np, 0); 486 - if (!gpio_is_valid(ts->gpio_int)) { 487 - dev_err(dev, "failed to get interrupt gpio\n"); 488 - return -EINVAL; 489 - } 490 - 491 - ts->gpio_rst = of_get_gpio(np, 1); 492 - if (!gpio_is_valid(ts->gpio_rst)) { 493 - dev_err(dev, "failed to get reset gpio\n"); 494 - return -EINVAL; 495 - } 496 - 497 485 if (of_property_read_u32(np, "x-size", &ts->x_max)) { 498 486 dev_err(dev, "failed to get x-size property\n"); 499 487 return -EINVAL; ··· 505 517 { 506 518 struct auo_pixcir_ts *ts = data; 507 519 508 - gpio_set_value(ts->gpio_rst, 0); 520 + gpiod_set_value_cansleep(ts->gpio_rst, 1); 509 521 } 510 522 511 523 static int auo_pixcir_probe(struct i2c_client *client, ··· 566 578 567 579 input_set_drvdata(ts->input, ts); 568 580 569 - error = devm_gpio_request_one(&client->dev, ts->gpio_int, 570 - GPIOF_DIR_IN, "auo_pixcir_ts_int"); 581 + ts->gpio_int = devm_gpiod_get_index(&client->dev, NULL, 0, GPIOD_IN); 582 + error = PTR_ERR_OR_ZERO(ts->gpio_int); 571 583 if (error) { 572 - dev_err(&client->dev, "request of gpio %d failed, %d\n", 573 - ts->gpio_int, error); 584 + dev_err(&client->dev, 585 + "request of int gpio failed: %d\n", error); 574 586 return error; 575 587 } 576 588 577 - error = devm_gpio_request_one(&client->dev, ts->gpio_rst, 578 - GPIOF_DIR_OUT | GPIOF_INIT_HIGH, 579 - "auo_pixcir_ts_rst"); 589 + gpiod_set_consumer_name(ts->gpio_int, "auo_pixcir_ts_int"); 590 + 591 + /* Take the chip out of reset */ 592 + ts->gpio_rst = devm_gpiod_get_index(&client->dev, NULL, 1, 593 + GPIOD_OUT_LOW); 594 + error = PTR_ERR_OR_ZERO(ts->gpio_rst); 580 595 if (error) { 581 - dev_err(&client->dev, "request of gpio %d failed, %d\n", 582 - ts->gpio_rst, error); 596 + dev_err(&client->dev, 597 + "request of reset gpio failed: %d\n", error); 583 598 return error; 584 599 } 600 + 601 + gpiod_set_consumer_name(ts->gpio_rst, "auo_pixcir_ts_rst"); 585 602 586 603 error = devm_add_action_or_reset(&client->dev, auo_pixcir_reset, ts); 587 604 if (error) {