Skip to content

Commit 1be7aa9

Browse files
linuswdtor
authored andcommitted
Input: ad7879 - drop platform data support
This driver supports configuration via platform data but absolutely nothing in the upstream kernel uses it. Since this configuration allows harmful practices such as encoding the GPIO base for the chip, delete platform data support so that no new platform using it gets introduced. Also: include the right driver header, not <linux/gpio.h>. Signed-off-by: Linus Walleij <[email protected]> Acked-by: Michael Hennerich <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent f39f868 commit 1be7aa9

File tree

2 files changed

+33
-116
lines changed

2 files changed

+33
-116
lines changed

drivers/input/touchscreen/ad7879.c

Lines changed: 33 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@
2929
#include <linux/property.h>
3030
#include <linux/regmap.h>
3131
#include <linux/slab.h>
32-
#include <linux/gpio.h>
32+
#include <linux/gpio/driver.h>
3333

3434
#include <linux/input/touchscreen.h>
35-
#include <linux/platform_data/ad7879.h>
3635
#include <linux/module.h>
3736
#include "ad7879.h"
3837

@@ -452,47 +451,36 @@ static void ad7879_gpio_set_value(struct gpio_chip *chip,
452451
mutex_unlock(&ts->mutex);
453452
}
454453

455-
static int ad7879_gpio_add(struct ad7879 *ts,
456-
const struct ad7879_platform_data *pdata)
454+
static int ad7879_gpio_add(struct ad7879 *ts)
457455
{
458-
bool gpio_export;
459-
int gpio_base;
460456
int ret = 0;
461457

462-
if (pdata) {
463-
gpio_export = pdata->gpio_export;
464-
gpio_base = pdata->gpio_base;
465-
} else {
466-
gpio_export = device_property_read_bool(ts->dev,
467-
"gpio-controller");
468-
gpio_base = -1;
469-
}
470-
471458
mutex_init(&ts->mutex);
472459

473-
if (gpio_export) {
474-
ts->gc.direction_input = ad7879_gpio_direction_input;
475-
ts->gc.direction_output = ad7879_gpio_direction_output;
476-
ts->gc.get = ad7879_gpio_get_value;
477-
ts->gc.set = ad7879_gpio_set_value;
478-
ts->gc.can_sleep = 1;
479-
ts->gc.base = gpio_base;
480-
ts->gc.ngpio = 1;
481-
ts->gc.label = "AD7879-GPIO";
482-
ts->gc.owner = THIS_MODULE;
483-
ts->gc.parent = ts->dev;
484-
485-
ret = devm_gpiochip_add_data(ts->dev, &ts->gc, ts);
486-
if (ret)
487-
dev_err(ts->dev, "failed to register gpio %d\n",
488-
ts->gc.base);
489-
}
460+
/* Do not create a chip unless flagged for it */
461+
if (!device_property_read_bool(ts->dev, "gpio-controller"))
462+
return 0;
463+
464+
ts->gc.direction_input = ad7879_gpio_direction_input;
465+
ts->gc.direction_output = ad7879_gpio_direction_output;
466+
ts->gc.get = ad7879_gpio_get_value;
467+
ts->gc.set = ad7879_gpio_set_value;
468+
ts->gc.can_sleep = 1;
469+
ts->gc.base = -1;
470+
ts->gc.ngpio = 1;
471+
ts->gc.label = "AD7879-GPIO";
472+
ts->gc.owner = THIS_MODULE;
473+
ts->gc.parent = ts->dev;
474+
475+
ret = devm_gpiochip_add_data(ts->dev, &ts->gc, ts);
476+
if (ret)
477+
dev_err(ts->dev, "failed to register gpio %d\n",
478+
ts->gc.base);
490479

491480
return ret;
492481
}
493482
#else
494-
static int ad7879_gpio_add(struct ad7879 *ts,
495-
const struct ad7879_platform_data *pdata)
483+
static int ad7879_gpio_add(struct ad7879 *ts)
496484
{
497485
return 0;
498486
}
@@ -527,7 +515,6 @@ static int ad7879_parse_dt(struct device *dev, struct ad7879 *ts)
527515
int ad7879_probe(struct device *dev, struct regmap *regmap,
528516
int irq, u16 bustype, u8 devid)
529517
{
530-
struct ad7879_platform_data *pdata = dev_get_platdata(dev);
531518
struct ad7879 *ts;
532519
struct input_dev *input_dev;
533520
int err;
@@ -542,22 +529,9 @@ int ad7879_probe(struct device *dev, struct regmap *regmap,
542529
if (!ts)
543530
return -ENOMEM;
544531

545-
if (pdata) {
546-
/* Platform data use swapped axis (backward compatibility) */
547-
ts->swap_xy = !pdata->swap_xy;
548-
549-
ts->x_plate_ohms = pdata->x_plate_ohms ? : 400;
550-
551-
ts->first_conversion_delay = pdata->first_conversion_delay;
552-
ts->acquisition_time = pdata->acquisition_time;
553-
ts->averaging = pdata->averaging;
554-
ts->pen_down_acc_interval = pdata->pen_down_acc_interval;
555-
ts->median = pdata->median;
556-
} else {
557-
err = ad7879_parse_dt(dev, ts);
558-
if (err)
559-
return err;
560-
}
532+
err = ad7879_parse_dt(dev, ts);
533+
if (err)
534+
return err;
561535

562536
input_dev = devm_input_allocate_device(dev);
563537
if (!input_dev) {
@@ -585,28 +559,13 @@ int ad7879_probe(struct device *dev, struct regmap *regmap,
585559

586560
input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
587561

588-
if (pdata) {
589-
input_set_abs_params(input_dev, ABS_X,
590-
pdata->x_min ? : 0,
591-
pdata->x_max ? : MAX_12BIT,
592-
0, 0);
593-
input_set_abs_params(input_dev, ABS_Y,
594-
pdata->y_min ? : 0,
595-
pdata->y_max ? : MAX_12BIT,
596-
0, 0);
597-
input_set_abs_params(input_dev, ABS_PRESSURE,
598-
pdata->pressure_min,
599-
pdata->pressure_max ? : ~0,
600-
0, 0);
601-
} else {
602-
input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0);
603-
input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0);
604-
input_set_capability(input_dev, EV_ABS, ABS_PRESSURE);
605-
touchscreen_parse_properties(input_dev, false, NULL);
606-
if (!input_abs_get_max(input_dev, ABS_PRESSURE)) {
607-
dev_err(dev, "Touchscreen pressure is not specified\n");
608-
return -EINVAL;
609-
}
562+
input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0);
563+
input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0);
564+
input_set_capability(input_dev, EV_ABS, ABS_PRESSURE);
565+
touchscreen_parse_properties(input_dev, false, NULL);
566+
if (!input_abs_get_max(input_dev, ABS_PRESSURE)) {
567+
dev_err(dev, "Touchscreen pressure is not specified\n");
568+
return -EINVAL;
610569
}
611570

612571
err = ad7879_write(ts, AD7879_REG_CTRL2, AD7879_RESET);
@@ -655,7 +614,7 @@ int ad7879_probe(struct device *dev, struct regmap *regmap,
655614
if (err)
656615
return err;
657616

658-
err = ad7879_gpio_add(ts, pdata);
617+
err = ad7879_gpio_add(ts);
659618
if (err)
660619
return err;
661620

include/linux/platform_data/ad7879.h

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)