From patchwork Wed Nov 14 00:22:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 151013 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5063341ljp; Tue, 13 Nov 2018 16:25:05 -0800 (PST) X-Google-Smtp-Source: AJdET5cxqwnMEKwb0js+JrOflwtJDlNckOdSxJxRg8tAAXxq6mRhUOqun81kIXjSPkzbP8JMQHZf X-Received: by 2002:a63:2e02:: with SMTP id u2mr6849213pgu.9.1542155105479; Tue, 13 Nov 2018 16:25:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542155105; cv=none; d=google.com; s=arc-20160816; b=apLrBX7unrqq58qxazDWUlwgSt7bA990F/XONklzpCE/kdRk8it5aAON238uZCRAab qlYYMWq+bQ38xgvLTD31ooCYJNWQJ8mAOPKOCrUVFipmDlr8yICroB4cGR5Yz1baMjys 3BjI5YMFdh9YqRBGellWQavykO6zZSYMvmVKZMqY59Wn/9iZbXdchYevywrkidmRXVQZ ShpYNTcqna3G8+s9Tk1c8/pRXMkW1ASxQgK6MHAkB6dQJJZ+21rboBeyB3k8hzrcqoSj 9yxZRjEXYeAREU+Z1oB0KxxYnybnQ/Hh3Tiz6Pc3feWCMjBhnjoWNbEXoeSjIwyRuBul sZQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=rhh/NezU4OGlUsuwPdvmODJCsAxkIUHuM2jrgzKu+z0=; b=B/Ztdgcg8zXneYBQUiEaJ6itzD5rWADWnkzDCdmoXMEqgpRwOlmHWoSSfd5ccXfg7W GKdokQERV76Gs8zvqzeoW+gWtRwezuP//EbVrCdvtOgKGDfYcCpxiijQSIGld1OSg1WF LYfY6vj5ATCdG6tRs5RLGI4ALda5D7a2zqZJTn2Xe6GpMof05UzQ4szq+i7IVfYSzQ5h dMHYho9s8LU4nuPrl3mRgPPRZxpSMvdmiAA57lV+wvjsT72EF21muMXBmOfjJSjOqqeO 7FO64s0H4BYoXgnXVqrPwJ/R6UXdjg+k6tDXHAXu+73k3QdRvwjxlO3BhCmSAjWoy7Ph hH2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T05DxR35; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12-v6si11932561plg.114.2018.11.13.16.25.05 for ; Tue, 13 Nov 2018 16:25:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T05DxR35; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727065AbeKNKZs (ORCPT ); Wed, 14 Nov 2018 05:25:48 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:34704 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726937AbeKNKZs (ORCPT ); Wed, 14 Nov 2018 05:25:48 -0500 Received: by mail-lf1-f68.google.com with SMTP id p6so10244707lfc.1 for ; Tue, 13 Nov 2018 16:25:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=rhh/NezU4OGlUsuwPdvmODJCsAxkIUHuM2jrgzKu+z0=; b=T05DxR35qZ6GIfdWMx4d4avy29ba1Quc8kh/u9kpGM3CJMA7mV0Au97uMhD5PuW7+n mgMR6lJz7Fy/PPm2/4O8W7n4Sgsc6ZNcx26USVngzjsme9z0lNPiokb0N37+hXdBFvI3 8NnZgVPGWcLRxRNMje0+NdR8yRr+T8eBu2CUA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=rhh/NezU4OGlUsuwPdvmODJCsAxkIUHuM2jrgzKu+z0=; b=eYATrLXD1rJkn8HXjfM5M2HX8TyRBYM5roVmGUcV+0jE5iBZND+1kpnP66W51PLlbU vx3iv9dl3LEoU2b0TprxaSp/qi1mVf7QNk0oG6p9zp/pZKz3OyD15tJ2C7z4TwmWLAV4 5biWfC6/qggFECwjmsN9aJXPk82jfuetDU6T4bCQGL8dn+JEbKYbiZ53aTtBC3ja0E1D /JdIk3ZVC7l78mP+pzqRcsKGcZ+3SvaYaxJwVA4zanczeViZVZ6gQ48Gl1rgh62H+w+B rTzzhx3phcn1bNGkMoyt9QJHmtwOc8MGlEWEeRx4MIvpKuS1Ky5Pol5en3L8LriuiInz 9zig== X-Gm-Message-State: AGRZ1gJYyUS5cu6gTihjWPw0P/gMhR5mzR7uNWZT4eR6ou9uYkR+UCPV 9F6afeTze1Q+hH/BQu1BxHbLEA== X-Received: by 2002:a19:9c92:: with SMTP id f140mr3930849lfe.41.1542155101022; Tue, 13 Nov 2018 16:25:01 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id l63sm3621236lfl.76.2018.11.13.16.24.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Nov 2018 16:24:59 -0800 (PST) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: Linus Walleij , Michael Hennerich Subject: [PATCH] Input: ad7879: Drop platform data support Date: Wed, 14 Nov 2018 01:22:54 +0100 Message-Id: <20181114002254.20333-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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 . Cc: Michael Hennerich Signed-off-by: Linus Walleij --- drivers/input/touchscreen/ad7879.c | 107 +++++++++------------------ include/linux/platform_data/ad7879.h | 42 ----------- 2 files changed, 33 insertions(+), 116 deletions(-) delete mode 100644 include/linux/platform_data/ad7879.h -- 2.17.2 Acked-by: Michael Hennerich diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c index 6bad23ee47a1..2aae880c8aa6 100644 --- a/drivers/input/touchscreen/ad7879.c +++ b/drivers/input/touchscreen/ad7879.c @@ -29,10 +29,9 @@ #include #include #include -#include +#include #include -#include #include #include "ad7879.h" @@ -452,47 +451,36 @@ static void ad7879_gpio_set_value(struct gpio_chip *chip, mutex_unlock(&ts->mutex); } -static int ad7879_gpio_add(struct ad7879 *ts, - const struct ad7879_platform_data *pdata) +static int ad7879_gpio_add(struct ad7879 *ts) { - bool gpio_export; - int gpio_base; int ret = 0; - if (pdata) { - gpio_export = pdata->gpio_export; - gpio_base = pdata->gpio_base; - } else { - gpio_export = device_property_read_bool(ts->dev, - "gpio-controller"); - gpio_base = -1; - } - mutex_init(&ts->mutex); - if (gpio_export) { - ts->gc.direction_input = ad7879_gpio_direction_input; - ts->gc.direction_output = ad7879_gpio_direction_output; - ts->gc.get = ad7879_gpio_get_value; - ts->gc.set = ad7879_gpio_set_value; - ts->gc.can_sleep = 1; - ts->gc.base = gpio_base; - ts->gc.ngpio = 1; - ts->gc.label = "AD7879-GPIO"; - ts->gc.owner = THIS_MODULE; - ts->gc.parent = ts->dev; - - ret = devm_gpiochip_add_data(ts->dev, &ts->gc, ts); - if (ret) - dev_err(ts->dev, "failed to register gpio %d\n", - ts->gc.base); - } + /* Do not create a chip unless flagged for it */ + if (!device_property_read_bool(ts->dev, "gpio-controller")) + return 0; + + ts->gc.direction_input = ad7879_gpio_direction_input; + ts->gc.direction_output = ad7879_gpio_direction_output; + ts->gc.get = ad7879_gpio_get_value; + ts->gc.set = ad7879_gpio_set_value; + ts->gc.can_sleep = 1; + ts->gc.base = -1; + ts->gc.ngpio = 1; + ts->gc.label = "AD7879-GPIO"; + ts->gc.owner = THIS_MODULE; + ts->gc.parent = ts->dev; + + ret = devm_gpiochip_add_data(ts->dev, &ts->gc, ts); + if (ret) + dev_err(ts->dev, "failed to register gpio %d\n", + ts->gc.base); return ret; } #else -static int ad7879_gpio_add(struct ad7879 *ts, - const struct ad7879_platform_data *pdata) +static int ad7879_gpio_add(struct ad7879 *ts) { return 0; } @@ -527,7 +515,6 @@ static int ad7879_parse_dt(struct device *dev, struct ad7879 *ts) int ad7879_probe(struct device *dev, struct regmap *regmap, int irq, u16 bustype, u8 devid) { - struct ad7879_platform_data *pdata = dev_get_platdata(dev); struct ad7879 *ts; struct input_dev *input_dev; int err; @@ -542,22 +529,9 @@ int ad7879_probe(struct device *dev, struct regmap *regmap, if (!ts) return -ENOMEM; - if (pdata) { - /* Platform data use swapped axis (backward compatibility) */ - ts->swap_xy = !pdata->swap_xy; - - ts->x_plate_ohms = pdata->x_plate_ohms ? : 400; - - ts->first_conversion_delay = pdata->first_conversion_delay; - ts->acquisition_time = pdata->acquisition_time; - ts->averaging = pdata->averaging; - ts->pen_down_acc_interval = pdata->pen_down_acc_interval; - ts->median = pdata->median; - } else { - err = ad7879_parse_dt(dev, ts); - if (err) - return err; - } + err = ad7879_parse_dt(dev, ts); + if (err) + return err; input_dev = devm_input_allocate_device(dev); if (!input_dev) { @@ -585,28 +559,13 @@ int ad7879_probe(struct device *dev, struct regmap *regmap, input_set_capability(input_dev, EV_KEY, BTN_TOUCH); - if (pdata) { - input_set_abs_params(input_dev, ABS_X, - pdata->x_min ? : 0, - pdata->x_max ? : MAX_12BIT, - 0, 0); - input_set_abs_params(input_dev, ABS_Y, - pdata->y_min ? : 0, - pdata->y_max ? : MAX_12BIT, - 0, 0); - input_set_abs_params(input_dev, ABS_PRESSURE, - pdata->pressure_min, - pdata->pressure_max ? : ~0, - 0, 0); - } else { - input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0); - input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0); - input_set_capability(input_dev, EV_ABS, ABS_PRESSURE); - touchscreen_parse_properties(input_dev, false, NULL); - if (!input_abs_get_max(input_dev, ABS_PRESSURE)) { - dev_err(dev, "Touchscreen pressure is not specified\n"); - return -EINVAL; - } + input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0); + input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0); + input_set_capability(input_dev, EV_ABS, ABS_PRESSURE); + touchscreen_parse_properties(input_dev, false, NULL); + if (!input_abs_get_max(input_dev, ABS_PRESSURE)) { + dev_err(dev, "Touchscreen pressure is not specified\n"); + return -EINVAL; } err = ad7879_write(ts, AD7879_REG_CTRL2, AD7879_RESET); @@ -655,7 +614,7 @@ int ad7879_probe(struct device *dev, struct regmap *regmap, if (err) return err; - err = ad7879_gpio_add(ts, pdata); + err = ad7879_gpio_add(ts); if (err) return err; diff --git a/include/linux/platform_data/ad7879.h b/include/linux/platform_data/ad7879.h deleted file mode 100644 index 6655cc8453ac..000000000000 --- a/include/linux/platform_data/ad7879.h +++ /dev/null @@ -1,42 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* linux/platform_data/ad7879.h */ - -/* Touchscreen characteristics vary between boards and models. The - * platform_data for the device's "struct device" holds this information. - * - * It's OK if the min/max values are zero. - */ -struct ad7879_platform_data { - u16 model; /* 7879 */ - u16 x_plate_ohms; - u16 x_min, x_max; - u16 y_min, y_max; - u16 pressure_min, pressure_max; - - bool swap_xy; /* swap x and y axes */ - - /* [0..255] 0=OFF Starts at 1=550us and goes - * all the way to 9.440ms in steps of 35us. - */ - u8 pen_down_acc_interval; - /* [0..15] Starts at 0=128us and goes all the - * way to 4.096ms in steps of 128us. - */ - u8 first_conversion_delay; - /* [0..3] 0 = 2us, 1 = 4us, 2 = 8us, 3 = 16us */ - u8 acquisition_time; - /* [0..3] Average X middle samples 0 = 2, 1 = 4, 2 = 8, 3 = 16 */ - u8 averaging; - /* [0..3] Perform X measurements 0 = OFF, - * 1 = 4, 2 = 8, 3 = 16 (median > averaging) - */ - u8 median; - /* 1 = AUX/VBAT/GPIO export GPIO to gpiolib - * requires CONFIG_GPIOLIB - */ - bool gpio_export; - /* identifies the first GPIO number handled by this chip; - * or, if negative, requests dynamic ID allocation. - */ - s32 gpio_base; -};