From 9d41cbe23db0a3c51c0b28db987a6898f5d1255c Mon Sep 17 00:00:00 2001 From: Mukesh Ojha Date: Tue, 16 Jul 2019 09:26:56 +0200 Subject: Input: fsl-imx25-tcq - use devm_platform_ioremap_resource() devm_platform_ioremap_resource() internally have platform_get_resource() and devm_ioremap_resource() in it. So instead of calling them separately use devm_platform_ioremap_resource() directly. Signed-off-by: Mukesh Ojha Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/fsl-imx25-tcq.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/fsl-imx25-tcq.c b/drivers/input/touchscreen/fsl-imx25-tcq.c index 1d6c8f490b40..b66df8ab89f2 100644 --- a/drivers/input/touchscreen/fsl-imx25-tcq.c +++ b/drivers/input/touchscreen/fsl-imx25-tcq.c @@ -503,7 +503,6 @@ static int mx25_tcq_probe(struct platform_device *pdev) struct input_dev *idev; struct mx25_tcq_priv *priv; struct mx25_tsadc *tsadc = dev_get_drvdata(dev->parent); - struct resource *res; void __iomem *mem; int error; @@ -512,8 +511,7 @@ static int mx25_tcq_probe(struct platform_device *pdev) return -ENOMEM; priv->dev = dev; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - mem = devm_ioremap_resource(dev, res); + mem = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(mem)) return PTR_ERR(mem); -- cgit v1.2.3-59-g8ed1b From 46bec7a918715d3b0e8d22e5e99d3245c1097c65 Mon Sep 17 00:00:00 2001 From: Mukesh Ojha Date: Tue, 16 Jul 2019 09:27:22 +0200 Subject: Input: mxs-lradc-ts - use devm_platform_ioremap_resource() devm_platform_ioremap_resource() internally have platform_get_resource() and devm_ioremap_resource() in it. So instead of calling them separately use devm_platform_ioremap_resource() directly. Signed-off-by: Mukesh Ojha Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/mxs-lradc-ts.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/mxs-lradc-ts.c b/drivers/input/touchscreen/mxs-lradc-ts.c index 593b8d3e90b5..9e36fee38d61 100644 --- a/drivers/input/touchscreen/mxs-lradc-ts.c +++ b/drivers/input/touchscreen/mxs-lradc-ts.c @@ -606,7 +606,6 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev) struct device_node *node = dev->parent->of_node; struct mxs_lradc *lradc = dev_get_drvdata(dev->parent); struct mxs_lradc_ts *ts; - struct resource *iores; int ret, irq, virq, i; u32 ts_wires = 0, adapt; @@ -620,12 +619,9 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev) ts->dev = dev; spin_lock_init(&ts->lock); - iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!iores) - return -EINVAL; - ts->base = devm_ioremap(dev, iores->start, resource_size(iores)); - if (!ts->base) - return -ENOMEM; + ts->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(ts->base)) + return PTR_ERR(ts->base); ret = of_property_read_u32(node, "fsl,lradc-touchscreen-wires", &ts_wires); -- cgit v1.2.3-59-g8ed1b From 9601fa8fa9feb90afdddab345d942e33aa505835 Mon Sep 17 00:00:00 2001 From: Mukesh Ojha Date: Tue, 16 Jul 2019 09:34:13 +0200 Subject: Input: sun4i-ts - use devm_platform_ioremap_resource() devm_platform_ioremap_resource() internally have platform_get_resource() and devm_ioremap_resource() in it. So instead of calling them separately use devm_platform_ioremap_resource() directly. Signed-off-by: Mukesh Ojha Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/sun4i-ts.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/sun4i-ts.c b/drivers/input/touchscreen/sun4i-ts.c index 92f6e1ae23a2..4e83e96bb73f 100644 --- a/drivers/input/touchscreen/sun4i-ts.c +++ b/drivers/input/touchscreen/sun4i-ts.c @@ -300,8 +300,7 @@ static int sun4i_ts_probe(struct platform_device *pdev) input_set_drvdata(ts->input, ts); } - ts->base = devm_ioremap_resource(dev, - platform_get_resource(pdev, IORESOURCE_MEM, 0)); + ts->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(ts->base)) return PTR_ERR(ts->base); -- cgit v1.2.3-59-g8ed1b From f8890bd2875bf9d6aca4cd7fbf246364dbeb8a0f Mon Sep 17 00:00:00 2001 From: Mukesh Ojha Date: Tue, 16 Jul 2019 09:34:39 +0200 Subject: Input: ts4800-ts - use devm_platform_ioremap_resource() devm_platform_ioremap_resource() internally have platform_get_resource() and devm_ioremap_resource() in it. So instead of calling them separately use devm_platform_ioremap_resource() directly. Signed-off-by: Mukesh Ojha Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/ts4800-ts.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/ts4800-ts.c b/drivers/input/touchscreen/ts4800-ts.c index fed73eeb47b3..5b4f5362c67b 100644 --- a/drivers/input/touchscreen/ts4800-ts.c +++ b/drivers/input/touchscreen/ts4800-ts.c @@ -148,7 +148,6 @@ static int ts4800_ts_probe(struct platform_device *pdev) { struct input_polled_dev *poll_dev; struct ts4800_ts *ts; - struct resource *res; int error; ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL); @@ -159,8 +158,7 @@ static int ts4800_ts_probe(struct platform_device *pdev) if (error) return error; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - ts->base = devm_ioremap_resource(&pdev->dev, res); + ts->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(ts->base)) return PTR_ERR(ts->base); -- cgit v1.2.3-59-g8ed1b From a2f99330c50bb89fe2625d374fdf22f021163b55 Mon Sep 17 00:00:00 2001 From: Marco Felsch Date: Fri, 9 Aug 2019 07:40:00 -0700 Subject: Input: ads7846 - add support for general touchscreen bindings A few vendor specific bindings are now covered by common bindings. Let the driver parse the common bindings to make use of common inverting and swapping mechnism. Aslo make use of touchscreen_report_pos() to ensure the correct inverting-swapping order. The vendor specific properties are used as default (backward compatibility) and gets overwritten by common bindings. Signed-off-by: Marco Felsch Reviewed-by: Rob Herring Signed-off-by: Dmitry Torokhov --- .../bindings/input/touchscreen/ads7846.txt | 29 ++++++++++++----- drivers/input/touchscreen/ads7846.c | 38 +++++++++++++++++----- 2 files changed, 51 insertions(+), 16 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt b/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt index ce540ddac902..81f6bda97d3c 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt @@ -32,7 +32,6 @@ Optional properties: (ADS7846). ti,keep-vref-on set to keep vref on for differential measurements as well - ti,swap-xy swap x and y axis ti,settle-delay-usec Settling time of the analog signals; a function of Vcc and the capacitance on the X/Y drivers. If set to non-zero, @@ -51,13 +50,6 @@ Optional properties: in Ohms (u16). ti,x-min Minimum value on the X axis (u16). ti,y-min Minimum value on the Y axis (u16). - ti,x-max Maximum value on the X axis (u16). - ti,y-max Maximum value on the Y axis (u16). - ti,pressure-min Minimum reported pressure value - (threshold) - u16. - ti,pressure-max Maximum reported pressure value (u16). - ti,debounce-max Max number of additional readings per - sample (u16). ti,debounce-tol Tolerance used for filtering (u16). ti,debounce-rep Additional consecutive good readings required after the first two (u16). @@ -67,7 +59,28 @@ Optional properties: line is connected to. wakeup-source use any event on touchscreen as wakeup event. (Legacy property support: "linux,wakeup") + touchscreen-size-x General touchscreen binding, see [1]. + touchscreen-size-y General touchscreen binding, see [1]. + touchscreen-max-pressure General touchscreen binding, see [1]. + touchscreen-min-pressure General touchscreen binding, see [1]. + touchscreen-average-samples General touchscreen binding, see [1]. + touchscreen-inverted-x General touchscreen binding, see [1]. + touchscreen-inverted-y General touchscreen binding, see [1]. + touchscreen-swapped-x-y General touchscreen binding, see [1]. + +[1] All general touchscreen properties are described in + Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt. +Deprecated properties: + + ti,swap-xy swap x and y axis + ti,x-max Maximum value on the X axis (u16). + ti,y-max Maximum value on the Y axis (u16). + ti,pressure-min Minimum reported pressure value + (threshold) - u16. + ti,pressure-max Maximum reported pressure value (u16). + ti,debounce-max Max number of additional readings per + sample (u16). Example for a TSC2046 chip connected to an McSPI controller of an OMAP SoC:: diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index accbbe8d2966..51ddb204ca1b 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -129,6 +130,8 @@ struct ads7846 { u16 penirq_recheck_delay_usecs; + struct touchscreen_properties core_prop; + struct mutex lock; bool stopped; /* P: lock */ bool disabled; /* P: lock */ @@ -823,17 +826,13 @@ static void ads7846_report_state(struct ads7846 *ts) if (Rt) { struct input_dev *input = ts->input; - if (ts->swap_xy) - swap(x, y); - if (!ts->pendown) { input_report_key(input, BTN_TOUCH, 1); ts->pendown = true; dev_vdbg(&ts->spi->dev, "DOWN\n"); } - input_report_abs(input, ABS_X, x); - input_report_abs(input, ABS_Y, y); + touchscreen_report_pos(input, &ts->core_prop, x, y, false); input_report_abs(input, ABS_PRESSURE, ts->pressure_max - Rt); input_sync(input); @@ -1185,6 +1184,7 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev) struct ads7846_platform_data *pdata; struct device_node *node = dev->of_node; const struct of_device_id *match; + u32 value; if (!node) { dev_err(dev, "Device does not have associated DT data\n"); @@ -1223,10 +1223,18 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev) of_property_read_u16(node, "ti,x-max", &pdata->x_max); of_property_read_u16(node, "ti,y-max", &pdata->y_max); + /* + * touchscreen-max-pressure gets parsed during + * touchscreen_parse_properties() + */ of_property_read_u16(node, "ti,pressure-min", &pdata->pressure_min); + if (!of_property_read_u32(node, "touchscreen-min-pressure", &value)) + pdata->pressure_min = (u16) value; of_property_read_u16(node, "ti,pressure-max", &pdata->pressure_max); of_property_read_u16(node, "ti,debounce-max", &pdata->debounce_max); + if (!of_property_read_u32(node, "touchscreen-average-samples", &value)) + pdata->debounce_max = (u16) value; of_property_read_u16(node, "ti,debounce-tol", &pdata->debounce_tol); of_property_read_u16(node, "ti,debounce-rep", &pdata->debounce_rep); @@ -1309,10 +1317,7 @@ static int ads7846_probe(struct spi_device *spi) ts->model = pdata->model ? : 7846; ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100; ts->x_plate_ohms = pdata->x_plate_ohms ? : 400; - ts->pressure_max = pdata->pressure_max ? : ~0; - ts->vref_mv = pdata->vref_mv; - ts->swap_xy = pdata->swap_xy; if (pdata->filter != NULL) { if (pdata->filter_init != NULL) { @@ -1364,6 +1369,23 @@ static int ads7846_probe(struct spi_device *spi) input_set_abs_params(input_dev, ABS_PRESSURE, pdata->pressure_min, pdata->pressure_max, 0, 0); + /* + * Parse common framework properties. Must be done here to ensure the + * correct behaviour in case of using the legacy vendor bindings. The + * general binding value overrides the vendor specific one. + */ + touchscreen_parse_properties(ts->input, false, &ts->core_prop); + ts->pressure_max = input_abs_get_max(input_dev, ABS_PRESSURE) ? : ~0; + + /* + * Check if legacy ti,swap-xy binding is used instead of + * touchscreen-swapped-x-y + */ + if (!ts->core_prop.swap_x_y && pdata->swap_xy) { + swap(input_dev->absinfo[ABS_X], input_dev->absinfo[ABS_Y]); + ts->core_prop.swap_x_y = true; + } + ads7846_setup_spi_msg(ts, pdata); ts->reg = regulator_get(&spi->dev, "vcc"); -- cgit v1.2.3-59-g8ed1b From 6bd744b723d229ac38eeea2cf0717d8cd2858032 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 9 Aug 2019 14:56:02 -0700 Subject: Input: remove w90x900 touchscreen driver The ARM w90x900 platform is getting removed, so this driver is obsolete. Signed-off-by: Arnd Bergmann Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/Kconfig | 9 - drivers/input/touchscreen/Makefile | 1 - drivers/input/touchscreen/w90p910_ts.c | 331 --------------------------------- 3 files changed, 341 deletions(-) delete mode 100644 drivers/input/touchscreen/w90p910_ts.c (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index fb91f2d4049e..46ad9090493b 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1112,15 +1112,6 @@ config TOUCHSCREEN_TSC2007_IIO or ambient light monitoring), temperature and raw input values. -config TOUCHSCREEN_W90X900 - tristate "W90P910 touchscreen driver" - depends on ARCH_W90X900 - help - Say Y here if you have a W90P910 based touchscreen. - - To compile this driver as a module, choose M here: the - module will be called w90p910_ts. - config TOUCHSCREEN_PCAP tristate "Motorola PCAP touchscreen" depends on EZX_PCAP diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 084a596a0c8b..94c6162409b3 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -102,7 +102,6 @@ wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713) += wm9713.o obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE) += mainstone-wm97xx.o obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += zylonite-wm97xx.o -obj-$(CONFIG_TOUCHSCREEN_W90X900) += w90p910_ts.o obj-$(CONFIG_TOUCHSCREEN_SX8654) += sx8654.o obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o obj-$(CONFIG_TOUCHSCREEN_ZET6223) += zet6223.o diff --git a/drivers/input/touchscreen/w90p910_ts.c b/drivers/input/touchscreen/w90p910_ts.c deleted file mode 100644 index 7893d7fa398c..000000000000 --- a/drivers/input/touchscreen/w90p910_ts.c +++ /dev/null @@ -1,331 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2008 Nuvoton technology corporation. - * - * Wan ZongShun - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* ADC controller bit defines */ -#define ADC_DELAY 0xf00 -#define ADC_DOWN 0x01 -#define ADC_TSC_Y (0x01 << 8) -#define ADC_TSC_X (0x00 << 8) -#define TSC_FOURWIRE (~(0x03 << 1)) -#define ADC_CLK_EN (0x01 << 28) /* ADC clock enable */ -#define ADC_READ_CON (0x01 << 12) -#define ADC_CONV (0x01 << 13) -#define ADC_SEMIAUTO (0x01 << 14) -#define ADC_WAITTRIG (0x03 << 14) -#define ADC_RST1 (0x01 << 16) -#define ADC_RST0 (0x00 << 16) -#define ADC_EN (0x01 << 17) -#define ADC_INT (0x01 << 18) -#define WT_INT (0x01 << 20) -#define ADC_INT_EN (0x01 << 21) -#define LVD_INT_EN (0x01 << 22) -#define WT_INT_EN (0x01 << 23) -#define ADC_DIV (0x04 << 1) /* div = 6 */ - -enum ts_state { - TS_WAIT_NEW_PACKET, /* We are waiting next touch report */ - TS_WAIT_X_COORD, /* We are waiting for ADC to report X coord */ - TS_WAIT_Y_COORD, /* We are waiting for ADC to report Y coord */ - TS_IDLE, /* Input device is closed, don't do anything */ -}; - -struct w90p910_ts { - struct input_dev *input; - struct timer_list timer; - struct clk *clk; - int irq_num; - void __iomem *ts_reg; - spinlock_t lock; - enum ts_state state; -}; - -static void w90p910_report_event(struct w90p910_ts *w90p910_ts, bool down) -{ - struct input_dev *dev = w90p910_ts->input; - - if (down) { - input_report_abs(dev, ABS_X, - __raw_readl(w90p910_ts->ts_reg + 0x0c)); - input_report_abs(dev, ABS_Y, - __raw_readl(w90p910_ts->ts_reg + 0x10)); - } - - input_report_key(dev, BTN_TOUCH, down); - input_sync(dev); -} - -static void w90p910_prepare_x_reading(struct w90p910_ts *w90p910_ts) -{ - unsigned long ctlreg; - - __raw_writel(ADC_TSC_X, w90p910_ts->ts_reg + 0x04); - ctlreg = __raw_readl(w90p910_ts->ts_reg); - ctlreg &= ~(ADC_WAITTRIG | WT_INT | WT_INT_EN); - ctlreg |= ADC_SEMIAUTO | ADC_INT_EN | ADC_CONV; - __raw_writel(ctlreg, w90p910_ts->ts_reg); - - w90p910_ts->state = TS_WAIT_X_COORD; -} - -static void w90p910_prepare_y_reading(struct w90p910_ts *w90p910_ts) -{ - unsigned long ctlreg; - - __raw_writel(ADC_TSC_Y, w90p910_ts->ts_reg + 0x04); - ctlreg = __raw_readl(w90p910_ts->ts_reg); - ctlreg &= ~(ADC_WAITTRIG | ADC_INT | WT_INT_EN); - ctlreg |= ADC_SEMIAUTO | ADC_INT_EN | ADC_CONV; - __raw_writel(ctlreg, w90p910_ts->ts_reg); - - w90p910_ts->state = TS_WAIT_Y_COORD; -} - -static void w90p910_prepare_next_packet(struct w90p910_ts *w90p910_ts) -{ - unsigned long ctlreg; - - ctlreg = __raw_readl(w90p910_ts->ts_reg); - ctlreg &= ~(ADC_INT | ADC_INT_EN | ADC_SEMIAUTO | ADC_CONV); - ctlreg |= ADC_WAITTRIG | WT_INT_EN; - __raw_writel(ctlreg, w90p910_ts->ts_reg); - - w90p910_ts->state = TS_WAIT_NEW_PACKET; -} - -static irqreturn_t w90p910_ts_interrupt(int irq, void *dev_id) -{ - struct w90p910_ts *w90p910_ts = dev_id; - unsigned long flags; - - spin_lock_irqsave(&w90p910_ts->lock, flags); - - switch (w90p910_ts->state) { - case TS_WAIT_NEW_PACKET: - /* - * The controller only generates interrupts when pen - * is down. - */ - del_timer(&w90p910_ts->timer); - w90p910_prepare_x_reading(w90p910_ts); - break; - - - case TS_WAIT_X_COORD: - w90p910_prepare_y_reading(w90p910_ts); - break; - - case TS_WAIT_Y_COORD: - w90p910_report_event(w90p910_ts, true); - w90p910_prepare_next_packet(w90p910_ts); - mod_timer(&w90p910_ts->timer, jiffies + msecs_to_jiffies(100)); - break; - - case TS_IDLE: - break; - } - - spin_unlock_irqrestore(&w90p910_ts->lock, flags); - - return IRQ_HANDLED; -} - -static void w90p910_check_pen_up(struct timer_list *t) -{ - struct w90p910_ts *w90p910_ts = from_timer(w90p910_ts, t, timer); - unsigned long flags; - - spin_lock_irqsave(&w90p910_ts->lock, flags); - - if (w90p910_ts->state == TS_WAIT_NEW_PACKET && - !(__raw_readl(w90p910_ts->ts_reg + 0x04) & ADC_DOWN)) { - - w90p910_report_event(w90p910_ts, false); - } - - spin_unlock_irqrestore(&w90p910_ts->lock, flags); -} - -static int w90p910_open(struct input_dev *dev) -{ - struct w90p910_ts *w90p910_ts = input_get_drvdata(dev); - unsigned long val; - - /* enable the ADC clock */ - clk_enable(w90p910_ts->clk); - - __raw_writel(ADC_RST1, w90p910_ts->ts_reg); - msleep(1); - __raw_writel(ADC_RST0, w90p910_ts->ts_reg); - msleep(1); - - /* set delay and screen type */ - val = __raw_readl(w90p910_ts->ts_reg + 0x04); - __raw_writel(val & TSC_FOURWIRE, w90p910_ts->ts_reg + 0x04); - __raw_writel(ADC_DELAY, w90p910_ts->ts_reg + 0x08); - - w90p910_ts->state = TS_WAIT_NEW_PACKET; - wmb(); - - /* set trigger mode */ - val = __raw_readl(w90p910_ts->ts_reg); - val |= ADC_WAITTRIG | ADC_DIV | ADC_EN | WT_INT_EN; - __raw_writel(val, w90p910_ts->ts_reg); - - return 0; -} - -static void w90p910_close(struct input_dev *dev) -{ - struct w90p910_ts *w90p910_ts = input_get_drvdata(dev); - unsigned long val; - - /* disable trigger mode */ - - spin_lock_irq(&w90p910_ts->lock); - - w90p910_ts->state = TS_IDLE; - - val = __raw_readl(w90p910_ts->ts_reg); - val &= ~(ADC_WAITTRIG | ADC_DIV | ADC_EN | WT_INT_EN | ADC_INT_EN); - __raw_writel(val, w90p910_ts->ts_reg); - - spin_unlock_irq(&w90p910_ts->lock); - - /* Now that interrupts are shut off we can safely delete timer */ - del_timer_sync(&w90p910_ts->timer); - - /* stop the ADC clock */ - clk_disable(w90p910_ts->clk); -} - -static int w90x900ts_probe(struct platform_device *pdev) -{ - struct w90p910_ts *w90p910_ts; - struct input_dev *input_dev; - struct resource *res; - int err; - - w90p910_ts = kzalloc(sizeof(struct w90p910_ts), GFP_KERNEL); - input_dev = input_allocate_device(); - if (!w90p910_ts || !input_dev) { - err = -ENOMEM; - goto fail1; - } - - w90p910_ts->input = input_dev; - w90p910_ts->state = TS_IDLE; - spin_lock_init(&w90p910_ts->lock); - timer_setup(&w90p910_ts->timer, w90p910_check_pen_up, 0); - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - err = -ENXIO; - goto fail1; - } - - if (!request_mem_region(res->start, resource_size(res), - pdev->name)) { - err = -EBUSY; - goto fail1; - } - - w90p910_ts->ts_reg = ioremap(res->start, resource_size(res)); - if (!w90p910_ts->ts_reg) { - err = -ENOMEM; - goto fail2; - } - - w90p910_ts->clk = clk_get(&pdev->dev, NULL); - if (IS_ERR(w90p910_ts->clk)) { - err = PTR_ERR(w90p910_ts->clk); - goto fail3; - } - - input_dev->name = "W90P910 TouchScreen"; - input_dev->phys = "w90p910ts/event0"; - input_dev->id.bustype = BUS_HOST; - input_dev->id.vendor = 0x0005; - input_dev->id.product = 0x0001; - input_dev->id.version = 0x0100; - input_dev->dev.parent = &pdev->dev; - input_dev->open = w90p910_open; - input_dev->close = w90p910_close; - - input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); - input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); - - input_set_abs_params(input_dev, ABS_X, 0, 0x400, 0, 0); - input_set_abs_params(input_dev, ABS_Y, 0, 0x400, 0, 0); - - input_set_drvdata(input_dev, w90p910_ts); - - w90p910_ts->irq_num = platform_get_irq(pdev, 0); - if (request_irq(w90p910_ts->irq_num, w90p910_ts_interrupt, - 0, "w90p910ts", w90p910_ts)) { - err = -EBUSY; - goto fail4; - } - - err = input_register_device(w90p910_ts->input); - if (err) - goto fail5; - - platform_set_drvdata(pdev, w90p910_ts); - - return 0; - -fail5: free_irq(w90p910_ts->irq_num, w90p910_ts); -fail4: clk_put(w90p910_ts->clk); -fail3: iounmap(w90p910_ts->ts_reg); -fail2: release_mem_region(res->start, resource_size(res)); -fail1: input_free_device(input_dev); - kfree(w90p910_ts); - return err; -} - -static int w90x900ts_remove(struct platform_device *pdev) -{ - struct w90p910_ts *w90p910_ts = platform_get_drvdata(pdev); - struct resource *res; - - free_irq(w90p910_ts->irq_num, w90p910_ts); - del_timer_sync(&w90p910_ts->timer); - iounmap(w90p910_ts->ts_reg); - - clk_put(w90p910_ts->clk); - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - release_mem_region(res->start, resource_size(res)); - - input_unregister_device(w90p910_ts->input); - kfree(w90p910_ts); - - return 0; -} - -static struct platform_driver w90x900ts_driver = { - .probe = w90x900ts_probe, - .remove = w90x900ts_remove, - .driver = { - .name = "nuc900-ts", - }, -}; -module_platform_driver(w90x900ts_driver); - -MODULE_AUTHOR("Wan ZongShun "); -MODULE_DESCRIPTION("w90p910 touch screen driver!"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:nuc900-ts"); -- cgit v1.2.3-59-g8ed1b From 104c995fd6ab7c2bdb275a54334123184fd2efb2 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 12 Aug 2019 00:00:16 -0700 Subject: Input: hideep - switch to use device_property_count_u32() Use use device_property_count_u32() directly, that makes code neater. Signed-off-by: Andy Shevchenko Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/hideep.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/hideep.c b/drivers/input/touchscreen/hideep.c index 84fbbf415c43..ddad4a82a5e5 100644 --- a/drivers/input/touchscreen/hideep.c +++ b/drivers/input/touchscreen/hideep.c @@ -811,8 +811,7 @@ static int hideep_init_input(struct hideep_ts *ts) if (error) return error; - ts->key_num = device_property_read_u32_array(dev, "linux,keycodes", - NULL, 0); + ts->key_num = device_property_count_u32(dev, "linux,keycodes"); if (ts->key_num > HIDEEP_KEY_MAX) { dev_err(dev, "too many keys defined: %d\n", ts->key_num); -- cgit v1.2.3-59-g8ed1b From 9ed05c94f20d504b6f0653ae981d171a801ae707 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 12 Aug 2019 00:00:35 -0700 Subject: Input: atmel_mxt_ts - switch to use device_property_count_u32() Use use device_property_count_u32() directly, that makes code neater. Signed-off-by: Andy Shevchenko Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/atmel_mxt_ts.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 4a5f482cf1af..24c4b691b1c9 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -2990,8 +2990,7 @@ static int mxt_parse_device_properties(struct mxt_data *data) int error; if (device_property_present(dev, keymap_property)) { - n_keys = device_property_read_u32_array(dev, keymap_property, - NULL, 0); + n_keys = device_property_count_u32(dev, keymap_property); if (n_keys <= 0) { error = n_keys < 0 ? n_keys : -EINVAL; dev_err(dev, "invalid/malformed '%s' property: %d\n", -- cgit v1.2.3-59-g8ed1b From 042cc4c778e1aa56f83ebe44b6f959c204861f08 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 12 Aug 2019 00:05:21 -0700 Subject: Input: edt-ft5x06 - no need to check return value of debugfs_create functions When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Signed-off-by: Greg Kroah-Hartman Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/edt-ft5x06.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index 3cc4341bbdff..5525f1fb1526 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -764,8 +764,6 @@ edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data *tsdata, const char *debugfs_name) { tsdata->debug_dir = debugfs_create_dir(debugfs_name, NULL); - if (!tsdata->debug_dir) - return; debugfs_create_u16("num_x", S_IRUSR, tsdata->debug_dir, &tsdata->num_x); debugfs_create_u16("num_y", S_IRUSR, tsdata->debug_dir, &tsdata->num_y); -- cgit v1.2.3-59-g8ed1b From 0bec8b7e5ca1a629f26173691526432f9d7cf8c1 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Wed, 14 Aug 2019 10:46:38 -0700 Subject: Input: remove dev_err() usage after platform_get_irq() We don't need dev_err() messages when platform_get_irq() fails now that platform_get_irq() prints an error message itself when something goes wrong. Let's remove these prints with a simple semantic patch. // @@ expression ret; struct platform_device *E; @@ ret = ( platform_get_irq(E, ...) | platform_get_irq_byname(E, ...) ); if ( \( ret < 0 \| ret <= 0 \) ) { ( -if (ret != -EPROBE_DEFER) -{ ... -dev_err(...); -... } | ... -dev_err(...); ) ... } // While we're here, remove braces on if statements that only have one statement (manually). Signed-off-by: Stephen Boyd Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/bcm-keypad.c | 4 +--- drivers/input/keyboard/davinci_keyscan.c | 1 - drivers/input/keyboard/imx_keypad.c | 4 +--- drivers/input/keyboard/lpc32xx-keys.c | 4 +--- drivers/input/keyboard/nomadik-ske-keypad.c | 4 +--- drivers/input/keyboard/nspire-keypad.c | 4 +--- drivers/input/keyboard/opencores-kbd.c | 4 +--- drivers/input/keyboard/pmic8xxx-keypad.c | 8 ++------ drivers/input/keyboard/pxa27x_keypad.c | 4 +--- drivers/input/keyboard/pxa930_rotary.c | 4 +--- drivers/input/keyboard/sh_keysc.c | 4 +--- drivers/input/keyboard/snvs_pwrkey.c | 4 +--- drivers/input/keyboard/spear-keyboard.c | 4 +--- drivers/input/keyboard/st-keyscan.c | 4 +--- drivers/input/keyboard/tegra-kbc.c | 4 +--- drivers/input/misc/88pm80x_onkey.c | 1 - drivers/input/misc/88pm860x_onkey.c | 4 +--- drivers/input/misc/ab8500-ponkey.c | 8 ++------ drivers/input/misc/axp20x-pek.c | 10 ++-------- drivers/input/misc/da9055_onkey.c | 5 +---- drivers/input/misc/da9063_onkey.c | 7 ++----- drivers/input/misc/e3x0-button.c | 10 ++-------- drivers/input/misc/hisi_powerkey.c | 8 ++------ drivers/input/misc/max8925_onkey.c | 8 ++------ drivers/input/misc/pm8941-pwrkey.c | 4 +--- drivers/input/misc/rk805-pwrkey.c | 8 ++------ drivers/input/misc/stpmic1_onkey.c | 10 ++-------- drivers/input/misc/tps65218-pwrbutton.c | 4 +--- drivers/input/misc/twl6040-vibra.c | 4 +--- drivers/input/mouse/pxa930_trkball.c | 4 +--- drivers/input/serio/arc_ps2.c | 4 +--- drivers/input/serio/ps2-gpio.c | 2 -- drivers/input/touchscreen/88pm860x-ts.c | 4 +--- drivers/input/touchscreen/bcm_iproc_tsc.c | 4 +--- drivers/input/touchscreen/fsl-imx25-tcq.c | 4 +--- drivers/input/touchscreen/imx6ul_tsc.c | 8 ++------ drivers/input/touchscreen/lpc32xx_ts.c | 4 +--- 37 files changed, 44 insertions(+), 142 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/keyboard/bcm-keypad.c b/drivers/input/keyboard/bcm-keypad.c index e1cf63ee148f..2b771c3a5578 100644 --- a/drivers/input/keyboard/bcm-keypad.c +++ b/drivers/input/keyboard/bcm-keypad.c @@ -413,10 +413,8 @@ static int bcm_kp_probe(struct platform_device *pdev) bcm_kp_stop(kp); kp->irq = platform_get_irq(pdev, 0); - if (kp->irq < 0) { - dev_err(&pdev->dev, "no IRQ specified\n"); + if (kp->irq < 0) return -EINVAL; - } error = devm_request_threaded_irq(&pdev->dev, kp->irq, NULL, bcm_kp_isr_thread, diff --git a/drivers/input/keyboard/davinci_keyscan.c b/drivers/input/keyboard/davinci_keyscan.c index 1d94928db922..f489cd585b33 100644 --- a/drivers/input/keyboard/davinci_keyscan.c +++ b/drivers/input/keyboard/davinci_keyscan.c @@ -192,7 +192,6 @@ static int __init davinci_ks_probe(struct platform_device *pdev) davinci_ks->irq = platform_get_irq(pdev, 0); if (davinci_ks->irq < 0) { - dev_err(dev, "no key scan irq\n"); error = davinci_ks->irq; goto fail2; } diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c index 97500a2de2d5..5a46d113e909 100644 --- a/drivers/input/keyboard/imx_keypad.c +++ b/drivers/input/keyboard/imx_keypad.c @@ -430,10 +430,8 @@ static int imx_keypad_probe(struct platform_device *pdev) } irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "no irq defined in platform data\n"); + if (irq < 0) return irq; - } input_dev = devm_input_allocate_device(&pdev->dev); if (!input_dev) { diff --git a/drivers/input/keyboard/lpc32xx-keys.c b/drivers/input/keyboard/lpc32xx-keys.c index a34e3271b0c9..348af2aeb5de 100644 --- a/drivers/input/keyboard/lpc32xx-keys.c +++ b/drivers/input/keyboard/lpc32xx-keys.c @@ -172,10 +172,8 @@ static int lpc32xx_kscan_probe(struct platform_device *pdev) } irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "failed to get platform irq\n"); + if (irq < 0) return -EINVAL; - } kscandat = devm_kzalloc(&pdev->dev, sizeof(*kscandat), GFP_KERNEL); diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c index fa265fdce2c4..608446e14614 100644 --- a/drivers/input/keyboard/nomadik-ske-keypad.c +++ b/drivers/input/keyboard/nomadik-ske-keypad.c @@ -235,10 +235,8 @@ static int __init ske_keypad_probe(struct platform_device *pdev) } irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "failed to get keypad irq\n"); + if (irq < 0) return -EINVAL; - } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { diff --git a/drivers/input/keyboard/nspire-keypad.c b/drivers/input/keyboard/nspire-keypad.c index 57eac91ecd76..63d5e488137d 100644 --- a/drivers/input/keyboard/nspire-keypad.c +++ b/drivers/input/keyboard/nspire-keypad.c @@ -165,10 +165,8 @@ static int nspire_keypad_probe(struct platform_device *pdev) int error; irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "failed to get keypad irq\n"); + if (irq < 0) return -EINVAL; - } keypad = devm_kzalloc(&pdev->dev, sizeof(struct nspire_keypad), GFP_KERNEL); diff --git a/drivers/input/keyboard/opencores-kbd.c b/drivers/input/keyboard/opencores-kbd.c index 159346cb4060..b0ea387414c1 100644 --- a/drivers/input/keyboard/opencores-kbd.c +++ b/drivers/input/keyboard/opencores-kbd.c @@ -49,10 +49,8 @@ static int opencores_kbd_probe(struct platform_device *pdev) } irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "missing board IRQ resource\n"); + if (irq < 0) return -EINVAL; - } opencores_kbd = devm_kzalloc(&pdev->dev, sizeof(*opencores_kbd), GFP_KERNEL); diff --git a/drivers/input/keyboard/pmic8xxx-keypad.c b/drivers/input/keyboard/pmic8xxx-keypad.c index d529768a1d06..91d5811d6f0e 100644 --- a/drivers/input/keyboard/pmic8xxx-keypad.c +++ b/drivers/input/keyboard/pmic8xxx-keypad.c @@ -544,16 +544,12 @@ static int pmic8xxx_kp_probe(struct platform_device *pdev) } kp->key_sense_irq = platform_get_irq(pdev, 0); - if (kp->key_sense_irq < 0) { - dev_err(&pdev->dev, "unable to get keypad sense irq\n"); + if (kp->key_sense_irq < 0) return kp->key_sense_irq; - } kp->key_stuck_irq = platform_get_irq(pdev, 1); - if (kp->key_stuck_irq < 0) { - dev_err(&pdev->dev, "unable to get keypad stuck irq\n"); + if (kp->key_stuck_irq < 0) return kp->key_stuck_irq; - } kp->input->name = "PMIC8XXX keypad"; kp->input->phys = "pmic8xxx_keypad/input0"; diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c index 39023664d2f2..7e65708b25a4 100644 --- a/drivers/input/keyboard/pxa27x_keypad.c +++ b/drivers/input/keyboard/pxa27x_keypad.c @@ -727,10 +727,8 @@ static int pxa27x_keypad_probe(struct platform_device *pdev) return -EINVAL; irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "failed to get keypad irq\n"); + if (irq < 0) return -ENXIO; - } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { diff --git a/drivers/input/keyboard/pxa930_rotary.c b/drivers/input/keyboard/pxa930_rotary.c index 585e7765cbf0..f7414091d94e 100644 --- a/drivers/input/keyboard/pxa930_rotary.c +++ b/drivers/input/keyboard/pxa930_rotary.c @@ -89,10 +89,8 @@ static int pxa930_rotary_probe(struct platform_device *pdev) int err; irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "no irq for rotary controller\n"); + if (irq < 0) return -ENXIO; - } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c index 08ba41a81f14..27ad73f43451 100644 --- a/drivers/input/keyboard/sh_keysc.c +++ b/drivers/input/keyboard/sh_keysc.c @@ -181,10 +181,8 @@ static int sh_keysc_probe(struct platform_device *pdev) } irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "failed to get irq\n"); + if (irq < 0) goto err0; - } priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (priv == NULL) { diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c index 5342d8d45f81..e76b7a400a1c 100644 --- a/drivers/input/keyboard/snvs_pwrkey.c +++ b/drivers/input/keyboard/snvs_pwrkey.c @@ -118,10 +118,8 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev) pdata->wakeup = of_property_read_bool(np, "wakeup-source"); pdata->irq = platform_get_irq(pdev, 0); - if (pdata->irq < 0) { - dev_err(&pdev->dev, "no irq defined in platform data\n"); + if (pdata->irq < 0) return -EINVAL; - } regmap_update_bits(pdata->snvs, SNVS_LPCR_REG, SNVS_LPCR_DEP_EN, SNVS_LPCR_DEP_EN); diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c index 7d25fa338ab4..9b8d78f87253 100644 --- a/drivers/input/keyboard/spear-keyboard.c +++ b/drivers/input/keyboard/spear-keyboard.c @@ -191,10 +191,8 @@ static int spear_kbd_probe(struct platform_device *pdev) int error; irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "not able to get irq for the device\n"); + if (irq < 0) return irq; - } kbd = devm_kzalloc(&pdev->dev, sizeof(*kbd), GFP_KERNEL); if (!kbd) { diff --git a/drivers/input/keyboard/st-keyscan.c b/drivers/input/keyboard/st-keyscan.c index f097128b93fe..27562cd67fb6 100644 --- a/drivers/input/keyboard/st-keyscan.c +++ b/drivers/input/keyboard/st-keyscan.c @@ -187,10 +187,8 @@ static int keyscan_probe(struct platform_device *pdev) keyscan_stop(keypad_data); keypad_data->irq = platform_get_irq(pdev, 0); - if (keypad_data->irq < 0) { - dev_err(&pdev->dev, "no IRQ specified\n"); + if (keypad_data->irq < 0) return -EINVAL; - } error = devm_request_irq(&pdev->dev, keypad_data->irq, keyscan_isr, 0, pdev->name, keypad_data); diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c index a37a7a9e9171..d34d6947960f 100644 --- a/drivers/input/keyboard/tegra-kbc.c +++ b/drivers/input/keyboard/tegra-kbc.c @@ -631,10 +631,8 @@ static int tegra_kbc_probe(struct platform_device *pdev) return -EINVAL; kbc->irq = platform_get_irq(pdev, 0); - if (kbc->irq < 0) { - dev_err(&pdev->dev, "failed to get keyboard IRQ\n"); + if (kbc->irq < 0) return -ENXIO; - } kbc->idev = devm_input_allocate_device(&pdev->dev); if (!kbc->idev) { diff --git a/drivers/input/misc/88pm80x_onkey.c b/drivers/input/misc/88pm80x_onkey.c index 45a09497f680..51c8a326fd06 100644 --- a/drivers/input/misc/88pm80x_onkey.c +++ b/drivers/input/misc/88pm80x_onkey.c @@ -77,7 +77,6 @@ static int pm80x_onkey_probe(struct platform_device *pdev) info->irq = platform_get_irq(pdev, 0); if (info->irq < 0) { - dev_err(&pdev->dev, "No IRQ resource!\n"); err = -EINVAL; goto out; } diff --git a/drivers/input/misc/88pm860x_onkey.c b/drivers/input/misc/88pm860x_onkey.c index cc87443aa2ee..685995cad73f 100644 --- a/drivers/input/misc/88pm860x_onkey.c +++ b/drivers/input/misc/88pm860x_onkey.c @@ -64,10 +64,8 @@ static int pm860x_onkey_probe(struct platform_device *pdev) int irq, ret; irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "No IRQ resource!\n"); + if (irq < 0) return -EINVAL; - } info = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_onkey_info), GFP_KERNEL); diff --git a/drivers/input/misc/ab8500-ponkey.c b/drivers/input/misc/ab8500-ponkey.c index 12b18a8db315..ea3b8292acdd 100644 --- a/drivers/input/misc/ab8500-ponkey.c +++ b/drivers/input/misc/ab8500-ponkey.c @@ -55,16 +55,12 @@ static int ab8500_ponkey_probe(struct platform_device *pdev) int error; irq_dbf = platform_get_irq_byname(pdev, "ONKEY_DBF"); - if (irq_dbf < 0) { - dev_err(&pdev->dev, "No IRQ for ONKEY_DBF, error=%d\n", irq_dbf); + if (irq_dbf < 0) return irq_dbf; - } irq_dbr = platform_get_irq_byname(pdev, "ONKEY_DBR"); - if (irq_dbr < 0) { - dev_err(&pdev->dev, "No IRQ for ONKEY_DBR, error=%d\n", irq_dbr); + if (irq_dbr < 0) return irq_dbr; - } ponkey = devm_kzalloc(&pdev->dev, sizeof(struct ab8500_ponkey), GFP_KERNEL); diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c index 235925b28772..17c1cca74498 100644 --- a/drivers/input/misc/axp20x-pek.c +++ b/drivers/input/misc/axp20x-pek.c @@ -229,20 +229,14 @@ static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek, int error; axp20x_pek->irq_dbr = platform_get_irq_byname(pdev, "PEK_DBR"); - if (axp20x_pek->irq_dbr < 0) { - dev_err(&pdev->dev, "No IRQ for PEK_DBR, error=%d\n", - axp20x_pek->irq_dbr); + if (axp20x_pek->irq_dbr < 0) return axp20x_pek->irq_dbr; - } axp20x_pek->irq_dbr = regmap_irq_get_virq(axp20x->regmap_irqc, axp20x_pek->irq_dbr); axp20x_pek->irq_dbf = platform_get_irq_byname(pdev, "PEK_DBF"); - if (axp20x_pek->irq_dbf < 0) { - dev_err(&pdev->dev, "No IRQ for PEK_DBF, error=%d\n", - axp20x_pek->irq_dbf); + if (axp20x_pek->irq_dbf < 0) return axp20x_pek->irq_dbf; - } axp20x_pek->irq_dbf = regmap_irq_get_virq(axp20x->regmap_irqc, axp20x_pek->irq_dbf); diff --git a/drivers/input/misc/da9055_onkey.c b/drivers/input/misc/da9055_onkey.c index a4ff4782e605..7a0d3a1d503c 100644 --- a/drivers/input/misc/da9055_onkey.c +++ b/drivers/input/misc/da9055_onkey.c @@ -76,11 +76,8 @@ static int da9055_onkey_probe(struct platform_device *pdev) int irq, err; irq = platform_get_irq_byname(pdev, "ONKEY"); - if (irq < 0) { - dev_err(&pdev->dev, - "Failed to get an IRQ for input device, %d\n", irq); + if (irq < 0) return -EINVAL; - } onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL); if (!onkey) { diff --git a/drivers/input/misc/da9063_onkey.c b/drivers/input/misc/da9063_onkey.c index fd355cf59397..dace8577fa43 100644 --- a/drivers/input/misc/da9063_onkey.c +++ b/drivers/input/misc/da9063_onkey.c @@ -248,11 +248,8 @@ static int da9063_onkey_probe(struct platform_device *pdev) } irq = platform_get_irq_byname(pdev, "ONKEY"); - if (irq < 0) { - error = irq; - dev_err(&pdev->dev, "Failed to get platform IRQ: %d\n", error); - return error; - } + if (irq < 0) + return irq; error = devm_request_threaded_irq(&pdev->dev, irq, NULL, da9063_onkey_irq_handler, diff --git a/drivers/input/misc/e3x0-button.c b/drivers/input/misc/e3x0-button.c index 4d7217f43888..e2fde6e1553f 100644 --- a/drivers/input/misc/e3x0-button.c +++ b/drivers/input/misc/e3x0-button.c @@ -65,18 +65,12 @@ static int e3x0_button_probe(struct platform_device *pdev) int error; irq_press = platform_get_irq_byname(pdev, "press"); - if (irq_press < 0) { - dev_err(&pdev->dev, "No IRQ for 'press', error=%d\n", - irq_press); + if (irq_press < 0) return irq_press; - } irq_release = platform_get_irq_byname(pdev, "release"); - if (irq_release < 0) { - dev_err(&pdev->dev, "No IRQ for 'release', error=%d\n", - irq_release); + if (irq_release < 0) return irq_release; - } input = devm_input_allocate_device(&pdev->dev); if (!input) diff --git a/drivers/input/misc/hisi_powerkey.c b/drivers/input/misc/hisi_powerkey.c index dee6245f38d7..d3c293a95d32 100644 --- a/drivers/input/misc/hisi_powerkey.c +++ b/drivers/input/misc/hisi_powerkey.c @@ -90,12 +90,8 @@ static int hi65xx_powerkey_probe(struct platform_device *pdev) for (i = 0; i < ARRAY_SIZE(hi65xx_irq_info); i++) { irq = platform_get_irq_byname(pdev, hi65xx_irq_info[i].name); - if (irq < 0) { - error = irq; - dev_err(dev, "couldn't get irq %s: %d\n", - hi65xx_irq_info[i].name, error); - return error; - } + if (irq < 0) + return irq; error = devm_request_any_context_irq(dev, irq, hi65xx_irq_info[i].handler, diff --git a/drivers/input/misc/max8925_onkey.c b/drivers/input/misc/max8925_onkey.c index 7c49b8d23894..ffab4a490c75 100644 --- a/drivers/input/misc/max8925_onkey.c +++ b/drivers/input/misc/max8925_onkey.c @@ -71,16 +71,12 @@ static int max8925_onkey_probe(struct platform_device *pdev) int irq[2], error; irq[0] = platform_get_irq(pdev, 0); - if (irq[0] < 0) { - dev_err(&pdev->dev, "No IRQ resource!\n"); + if (irq[0] < 0) return -EINVAL; - } irq[1] = platform_get_irq(pdev, 1); - if (irq[1] < 0) { - dev_err(&pdev->dev, "No IRQ resource!\n"); + if (irq[1] < 0) return -EINVAL; - } info = devm_kzalloc(&pdev->dev, sizeof(struct max8925_onkey_info), GFP_KERNEL); diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c index 017f81a66658..cf8104454e74 100644 --- a/drivers/input/misc/pm8941-pwrkey.c +++ b/drivers/input/misc/pm8941-pwrkey.c @@ -205,10 +205,8 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev) return error; pwrkey->irq = platform_get_irq(pdev, 0); - if (pwrkey->irq < 0) { - dev_err(&pdev->dev, "failed to get irq\n"); + if (pwrkey->irq < 0) return pwrkey->irq; - } error = regmap_read(pwrkey->regmap, pwrkey->baseaddr + PON_REV2, &pwrkey->revision); diff --git a/drivers/input/misc/rk805-pwrkey.c b/drivers/input/misc/rk805-pwrkey.c index 4a6d4a5746e5..3fb64dbda1a2 100644 --- a/drivers/input/misc/rk805-pwrkey.c +++ b/drivers/input/misc/rk805-pwrkey.c @@ -53,16 +53,12 @@ static int rk805_pwrkey_probe(struct platform_device *pdev) input_set_capability(pwr, EV_KEY, KEY_POWER); fall_irq = platform_get_irq(pdev, 0); - if (fall_irq < 0) { - dev_err(&pdev->dev, "Can't get fall irq: %d\n", fall_irq); + if (fall_irq < 0) return fall_irq; - } rise_irq = platform_get_irq(pdev, 1); - if (rise_irq < 0) { - dev_err(&pdev->dev, "Can't get rise irq: %d\n", rise_irq); + if (rise_irq < 0) return rise_irq; - } err = devm_request_any_context_irq(&pwr->dev, fall_irq, pwrkey_fall_irq, diff --git a/drivers/input/misc/stpmic1_onkey.c b/drivers/input/misc/stpmic1_onkey.c index 7b49c9997df7..d8dc2f2f8000 100644 --- a/drivers/input/misc/stpmic1_onkey.c +++ b/drivers/input/misc/stpmic1_onkey.c @@ -61,18 +61,12 @@ static int stpmic1_onkey_probe(struct platform_device *pdev) return -ENOMEM; onkey->irq_falling = platform_get_irq_byname(pdev, "onkey-falling"); - if (onkey->irq_falling < 0) { - dev_err(dev, "failed: request IRQ onkey-falling %d\n", - onkey->irq_falling); + if (onkey->irq_falling < 0) return onkey->irq_falling; - } onkey->irq_rising = platform_get_irq_byname(pdev, "onkey-rising"); - if (onkey->irq_rising < 0) { - dev_err(dev, "failed: request IRQ onkey-rising %d\n", - onkey->irq_rising); + if (onkey->irq_rising < 0) return onkey->irq_rising; - } if (!device_property_read_u32(dev, "power-off-time-sec", &val)) { if (val > 0 && val <= 16) { diff --git a/drivers/input/misc/tps65218-pwrbutton.c b/drivers/input/misc/tps65218-pwrbutton.c index a4455bb12ae0..f011447c44fb 100644 --- a/drivers/input/misc/tps65218-pwrbutton.c +++ b/drivers/input/misc/tps65218-pwrbutton.c @@ -124,10 +124,8 @@ static int tps6521x_pb_probe(struct platform_device *pdev) device_init_wakeup(dev, true); irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(dev, "No IRQ resource!\n"); + if (irq < 0) return -EINVAL; - } error = devm_request_threaded_irq(dev, irq, NULL, tps6521x_pb_irq, IRQF_TRIGGER_RISING | diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c index 93235a007d07..bf6644927630 100644 --- a/drivers/input/misc/twl6040-vibra.c +++ b/drivers/input/misc/twl6040-vibra.c @@ -272,10 +272,8 @@ static int twl6040_vibra_probe(struct platform_device *pdev) } info->irq = platform_get_irq(pdev, 0); - if (info->irq < 0) { - dev_err(info->dev, "invalid irq\n"); + if (info->irq < 0) return -EINVAL; - } error = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, twl6040_vib_irq_handler, diff --git a/drivers/input/mouse/pxa930_trkball.c b/drivers/input/mouse/pxa930_trkball.c index 87bac8cff6f7..41acde60b60f 100644 --- a/drivers/input/mouse/pxa930_trkball.c +++ b/drivers/input/mouse/pxa930_trkball.c @@ -147,10 +147,8 @@ static int pxa930_trkball_probe(struct platform_device *pdev) int irq, error; irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "failed to get trkball irq\n"); + if (irq < 0) return -ENXIO; - } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { diff --git a/drivers/input/serio/arc_ps2.c b/drivers/input/serio/arc_ps2.c index 443194a2b9e3..0af9fba5d16d 100644 --- a/drivers/input/serio/arc_ps2.c +++ b/drivers/input/serio/arc_ps2.c @@ -187,10 +187,8 @@ static int arc_ps2_probe(struct platform_device *pdev) int error, id, i; irq = platform_get_irq_byname(pdev, "arc_ps2_irq"); - if (irq < 0) { - dev_err(&pdev->dev, "no IRQ defined\n"); + if (irq < 0) return -EINVAL; - } arc_ps2 = devm_kzalloc(&pdev->dev, sizeof(struct arc_ps2_data), GFP_KERNEL); diff --git a/drivers/input/serio/ps2-gpio.c b/drivers/input/serio/ps2-gpio.c index e0f18469d01b..8970b49ea09a 100644 --- a/drivers/input/serio/ps2-gpio.c +++ b/drivers/input/serio/ps2-gpio.c @@ -369,8 +369,6 @@ static int ps2_gpio_probe(struct platform_device *pdev) drvdata->irq = platform_get_irq(pdev, 0); if (drvdata->irq < 0) { - dev_err(dev, "failed to get irq from platform resource: %d\n", - drvdata->irq); error = drvdata->irq; goto err_free_serio; } diff --git a/drivers/input/touchscreen/88pm860x-ts.c b/drivers/input/touchscreen/88pm860x-ts.c index 1d1bbc8da949..81a3ea4b9a3d 100644 --- a/drivers/input/touchscreen/88pm860x-ts.c +++ b/drivers/input/touchscreen/88pm860x-ts.c @@ -185,10 +185,8 @@ static int pm860x_touch_probe(struct platform_device *pdev) int irq, ret, res_x = 0, data = 0; irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "No IRQ resource!\n"); + if (irq < 0) return -EINVAL; - } if (pm860x_touch_dt_init(pdev, chip, &res_x)) { if (pdata) { diff --git a/drivers/input/touchscreen/bcm_iproc_tsc.c b/drivers/input/touchscreen/bcm_iproc_tsc.c index 4d11b27c7c43..7de1fd24ce36 100644 --- a/drivers/input/touchscreen/bcm_iproc_tsc.c +++ b/drivers/input/touchscreen/bcm_iproc_tsc.c @@ -489,10 +489,8 @@ static int iproc_ts_probe(struct platform_device *pdev) /* get interrupt */ irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "platform_get_irq failed: %d\n", irq); + if (irq < 0) return irq; - } error = devm_request_irq(&pdev->dev, irq, iproc_touchscreen_interrupt, diff --git a/drivers/input/touchscreen/fsl-imx25-tcq.c b/drivers/input/touchscreen/fsl-imx25-tcq.c index b66df8ab89f2..60a7246c5157 100644 --- a/drivers/input/touchscreen/fsl-imx25-tcq.c +++ b/drivers/input/touchscreen/fsl-imx25-tcq.c @@ -526,10 +526,8 @@ static int mx25_tcq_probe(struct platform_device *pdev) } priv->irq = platform_get_irq(pdev, 0); - if (priv->irq <= 0) { - dev_err(dev, "Failed to get IRQ\n"); + if (priv->irq <= 0) return priv->irq; - } idev = devm_input_allocate_device(dev); if (!idev) { diff --git a/drivers/input/touchscreen/imx6ul_tsc.c b/drivers/input/touchscreen/imx6ul_tsc.c index e04eecd65bbb..9ed258854349 100644 --- a/drivers/input/touchscreen/imx6ul_tsc.c +++ b/drivers/input/touchscreen/imx6ul_tsc.c @@ -430,16 +430,12 @@ static int imx6ul_tsc_probe(struct platform_device *pdev) } tsc_irq = platform_get_irq(pdev, 0); - if (tsc_irq < 0) { - dev_err(&pdev->dev, "no tsc irq resource?\n"); + if (tsc_irq < 0) return tsc_irq; - } adc_irq = platform_get_irq(pdev, 1); - if (adc_irq < 0) { - dev_err(&pdev->dev, "no adc irq resource?\n"); + if (adc_irq < 0) return adc_irq; - } err = devm_request_threaded_irq(tsc->dev, tsc_irq, NULL, tsc_irq_fn, IRQF_ONESHOT, diff --git a/drivers/input/touchscreen/lpc32xx_ts.c b/drivers/input/touchscreen/lpc32xx_ts.c index 567ed64b5392..b2cd9472e2d1 100644 --- a/drivers/input/touchscreen/lpc32xx_ts.c +++ b/drivers/input/touchscreen/lpc32xx_ts.c @@ -212,10 +212,8 @@ static int lpc32xx_ts_probe(struct platform_device *pdev) } irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "Can't get interrupt resource\n"); + if (irq < 0) return irq; - } tsc = kzalloc(sizeof(*tsc), GFP_KERNEL); input = input_allocate_device(); -- cgit v1.2.3-59-g8ed1b From 2da9d2b5b9d64cf5228dd3fb4d1220ff3fec8440 Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Fri, 16 Aug 2019 15:07:15 -0700 Subject: Input: wacom_w8001 - allocate additional space for 'phys' GCC warns that the output of our call to 'snprintf' in 'w8001_connect' may be truncated since both 'serio->phys' and 'w8001->phys' are 32 bytes in length. Increase the amount of space allocated for the latter to compensate. Signed-off-by: Jason Gerecke Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/wacom_w8001.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c index 3715d1eace92..691285ace228 100644 --- a/drivers/input/touchscreen/wacom_w8001.c +++ b/drivers/input/touchscreen/wacom_w8001.c @@ -27,6 +27,8 @@ MODULE_AUTHOR("Jaya Kumar "); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); +#define W8001_MAX_PHYS 42 + #define W8001_MAX_LENGTH 13 #define W8001_LEAD_MASK 0x80 #define W8001_LEAD_BYTE 0x80 @@ -89,7 +91,7 @@ struct w8001 { unsigned char response_type; unsigned char response[W8001_MAX_LENGTH]; unsigned char data[W8001_MAX_LENGTH]; - char phys[32]; + char phys[W8001_MAX_PHYS]; int type; unsigned int pktlen; u16 max_touch_x; -- cgit v1.2.3-59-g8ed1b From a1b70a44b80af641a441937803cb8251e8e6d8e3 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 8 Aug 2019 11:03:59 -0700 Subject: Input: bu21013_ts - convert to use GPIO descriptors This driver can use GPIO descriptors rather than GPIO numbers without any problems, convert it. Name the field variables after the actual pins on the chip rather than the "reset" and "touch" names from the devicetree bindings that are vaguely inaccurate. No in-tree users pass GPIO numbers in platform data so drop this. Descriptor tables can be used to get these GPIOs from a board file if need be. Signed-off-by: Linus Walleij Signed-off-by: Dmitry Torokhov --- .../bindings/input/touchscreen/bu21013.txt | 5 +- drivers/input/touchscreen/bu21013_ts.c | 86 ++++++++++------------ include/linux/input/bu21013.h | 4 - 3 files changed, 41 insertions(+), 54 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt b/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt index 56d835242af2..43899fc36ecf 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt @@ -2,10 +2,11 @@ Required properties: - compatible : "rohm,bu21013_tp" - - reg : I2C device address + - reg : I2C device address + - reset-gpios : GPIO pin enabling (selecting) chip (CS) Optional properties: - - touch-gpio : GPIO pin registering a touch event + - touch-gpios : GPIO pin registering a touch event - -supply : Phandle to a regulator supply - rohm,touch-max-x : Maximum outward permitted limit in the X axis - rohm,touch-max-y : Maximum outward permitted limit in the Y axis diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index 1d703e230ac3..c20f86f98ffc 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c @@ -14,11 +14,9 @@ #include #include #include -#include +#include #include -#include -#define PEN_DOWN_INTR 0 #define MAX_FINGERS 2 #define RESET_DELAY 30 #define PENUP_TIMEOUT (10) @@ -143,8 +141,9 @@ * @touch_stopped: touch stop flag * @chip: pointer to the touch panel controller * @in_dev: pointer to the input device structure - * @intr_pin: interrupt pin value * @regulator: pointer to the Regulator used for touch screen + * @cs_gpiod: chip select GPIO line + * @int_gpiod: touch interrupt GPIO line * * Touch panel device data structure */ @@ -154,8 +153,9 @@ struct bu21013_ts_data { const struct bu21013_platform_device *chip; struct input_dev *in_dev; struct regulator *regulator; + struct gpio_desc *cs_gpiod; + struct gpio_desc *int_gpiod; unsigned int irq; - unsigned int intr_pin; bool touch_stopped; }; @@ -257,20 +257,21 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data) { struct bu21013_ts_data *data = device_data; struct i2c_client *i2c = data->client; + int keep_polling; int retval; do { retval = bu21013_do_touch_report(data); if (retval < 0) { dev_err(&i2c->dev, "bu21013_do_touch_report failed\n"); - return IRQ_NONE; + break; } - data->intr_pin = gpio_get_value(data->chip->touch_pin); - if (data->intr_pin == PEN_DOWN_INTR) + keep_polling = gpiod_get_value(data->int_gpiod); + if (keep_polling) wait_event_timeout(data->wait, data->touch_stopped, msecs_to_jiffies(2)); - } while (!data->intr_pin && !data->touch_stopped); + } while (keep_polling && !data->touch_stopped); return IRQ_HANDLED; } @@ -425,28 +426,6 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data) free_irq(bu21013_data->irq, bu21013_data); } -/** - * bu21013_cs_disable() - deconfigures the touch panel controller - * @bu21013_data: device structure pointer - * - * This function is used to deconfigure the chip selection - * for touch panel controller. - */ -static void bu21013_cs_disable(struct bu21013_ts_data *bu21013_data) -{ - int error; - - error = gpio_direction_output(bu21013_data->chip->cs_pin, 0); - if (error < 0) - dev_warn(&bu21013_data->client->dev, - "%s: gpio direction failed, error: %d\n", - __func__, error); - else - gpio_set_value(bu21013_data->chip->cs_pin, 0); - - gpio_free(bu21013_data->chip->cs_pin); -} - #ifdef CONFIG_OF static const struct bu21013_platform_device * bu21013_parse_dt(struct device *dev) @@ -471,9 +450,6 @@ bu21013_parse_dt(struct device *dev) of_property_read_u32(np, "rohm,touch-max-x", &pdata->touch_x_max); of_property_read_u32(np, "rohm,touch-max-y", &pdata->touch_y_max); - pdata->touch_pin = of_get_named_gpio(np, "touch-gpio", 0); - pdata->cs_pin = of_get_named_gpio(np, "reset-gpio", 0); - pdata->ext_clk = false; return pdata; @@ -516,11 +492,6 @@ static int bu21013_probe(struct i2c_client *client, return PTR_ERR(pdata); } - if (!gpio_is_valid(pdata->touch_pin)) { - dev_err(&client->dev, "invalid touch_pin supplied\n"); - return -EINVAL; - } - bu21013_data = kzalloc(sizeof(struct bu21013_ts_data), GFP_KERNEL); in_dev = input_allocate_device(); if (!bu21013_data || !in_dev) { @@ -529,16 +500,26 @@ static int bu21013_probe(struct i2c_client *client, goto err_free_mem; } + /* Named "INT" on the chip, DT binding is "touch" */ + bu21013_data->int_gpiod = gpiod_get(&client->dev, "touch", GPIOD_IN); + error = PTR_ERR_OR_ZERO(bu21013_data->int_gpiod); + if (error) { + if (error != -EPROBE_DEFER) + dev_err(&client->dev, "failed to get INT GPIO\n"); + goto err_free_mem; + } + gpiod_set_consumer_name(bu21013_data->int_gpiod, "BU21013 INT"); + bu21013_data->in_dev = in_dev; bu21013_data->chip = pdata; bu21013_data->client = client; - bu21013_data->irq = gpio_to_irq(pdata->touch_pin); + bu21013_data->irq = gpiod_to_irq(bu21013_data->int_gpiod); bu21013_data->regulator = regulator_get(&client->dev, "avdd"); if (IS_ERR(bu21013_data->regulator)) { dev_err(&client->dev, "regulator_get failed\n"); error = PTR_ERR(bu21013_data->regulator); - goto err_free_mem; + goto err_put_int_gpio; } error = regulator_enable(bu21013_data->regulator); @@ -550,13 +531,16 @@ static int bu21013_probe(struct i2c_client *client, bu21013_data->touch_stopped = false; init_waitqueue_head(&bu21013_data->wait); - /* configure the gpio pins */ - error = gpio_request_one(pdata->cs_pin, GPIOF_OUT_INIT_HIGH, - "touchp_reset"); - if (error < 0) { - dev_err(&client->dev, "Unable to request gpio reset_pin\n"); + /* Named "CS" on the chip, DT binding is "reset" */ + bu21013_data->cs_gpiod = gpiod_get(&client->dev, "reset", + GPIOD_OUT_HIGH); + error = PTR_ERR_OR_ZERO(bu21013_data->cs_gpiod); + if (error) { + if (error != -EPROBE_DEFER) + dev_err(&client->dev, "failed to get CS GPIO\n"); goto err_disable_regulator; } + gpiod_set_consumer_name(bu21013_data->cs_gpiod, "BU21013 CS"); /* configure the touch panel controller */ error = bu21013_init_chip(bu21013_data); @@ -604,11 +588,14 @@ static int bu21013_probe(struct i2c_client *client, err_free_irq: bu21013_free_irq(bu21013_data); err_cs_disable: - bu21013_cs_disable(bu21013_data); + gpiod_set_value(bu21013_data->cs_gpiod, 0); + gpiod_put(bu21013_data->cs_gpiod); err_disable_regulator: regulator_disable(bu21013_data->regulator); err_put_regulator: regulator_put(bu21013_data->regulator); +err_put_int_gpio: + gpiod_put(bu21013_data->int_gpiod); err_free_mem: input_free_device(in_dev); kfree(bu21013_data); @@ -628,13 +615,16 @@ static int bu21013_remove(struct i2c_client *client) bu21013_free_irq(bu21013_data); - bu21013_cs_disable(bu21013_data); + gpiod_set_value(bu21013_data->cs_gpiod, 0); + gpiod_put(bu21013_data->cs_gpiod); input_unregister_device(bu21013_data->in_dev); regulator_disable(bu21013_data->regulator); regulator_put(bu21013_data->regulator); + gpiod_put(bu21013_data->int_gpiod); + kfree(bu21013_data); return 0; diff --git a/include/linux/input/bu21013.h b/include/linux/input/bu21013.h index 7e5b7e978e8a..58b1a9d44443 100644 --- a/include/linux/input/bu21013.h +++ b/include/linux/input/bu21013.h @@ -11,8 +11,6 @@ * struct bu21013_platform_device - Handle the platform data * @touch_x_max: touch x max * @touch_y_max: touch y max - * @cs_pin: chip select pin - * @touch_pin: touch gpio pin * @ext_clk: external clock flag * @x_flip: x flip flag * @y_flip: y flip flag @@ -23,8 +21,6 @@ struct bu21013_platform_device { int touch_x_max; int touch_y_max; - unsigned int cs_pin; - unsigned int touch_pin; bool ext_clk; bool x_flip; bool y_flip; -- cgit v1.2.3-59-g8ed1b From a866781e84dd022dde5d307093555e65c31277de Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Thu, 8 Aug 2019 14:19:36 -0700 Subject: Input: bu21013_ts - rename some variables "bu21013_data" and "struct bu21013_ts_data" are a tad long, let's call them "ts" and "struct bu21013_ts". Also rename retval to error in bu21013_init_chip() and adjust formatting; i2c_smbus_write_byte_data() returns negative on error and 0 on success, so we simply test if whether erro is 0 or not. Tested-by: Linus Walleij Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/bu21013_ts.c | 376 +++++++++++++++++---------------- 1 file changed, 190 insertions(+), 186 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index c20f86f98ffc..e9cb020ed725 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c @@ -135,7 +135,7 @@ #define DRIVER_TP "bu21013_tp" /** - * struct bu21013_ts_data - touch panel data structure + * struct bu21013_ts - touch panel data structure * @client: pointer to the i2c client * @wait: variable to wait_queue_head_t structure * @touch_stopped: touch stop flag @@ -147,7 +147,7 @@ * * Touch panel device data structure */ -struct bu21013_ts_data { +struct bu21013_ts { struct i2c_client *client; wait_queue_head_t wait; const struct bu21013_platform_device *chip; @@ -161,34 +161,35 @@ struct bu21013_ts_data { /** * bu21013_read_block_data(): read the touch co-ordinates - * @data: bu21013_ts_data structure pointer + * @data: bu21013_ts structure pointer * @buf: byte pointer * * Read the touch co-ordinates using i2c read block into buffer * and returns integer. */ -static int bu21013_read_block_data(struct bu21013_ts_data *data, u8 *buf) +static int bu21013_read_block_data(struct bu21013_ts *ts, u8 *buf) { int ret, i; for (i = 0; i < I2C_RETRY_COUNT; i++) { - ret = i2c_smbus_read_i2c_block_data - (data->client, BU21013_SENSORS_BTN_0_7_REG, - LENGTH_OF_BUFFER, buf); + ret = i2c_smbus_read_i2c_block_data(ts->client, + BU21013_SENSORS_BTN_0_7_REG, + LENGTH_OF_BUFFER, buf); if (ret == LENGTH_OF_BUFFER) return 0; } + return -EINVAL; } /** * bu21013_do_touch_report(): Get the touch co-ordinates - * @data: bu21013_ts_data structure pointer + * @data: bu21013_ts structure pointer * * Get the touch co-ordinates from touch sensor registers and writes * into device structure and returns integer. */ -static int bu21013_do_touch_report(struct bu21013_ts_data *data) +static int bu21013_do_touch_report(struct bu21013_ts *ts) { u8 buf[LENGTH_OF_BUFFER]; unsigned int pos_x[2], pos_y[2]; @@ -196,10 +197,7 @@ static int bu21013_do_touch_report(struct bu21013_ts_data *data) int finger_down_count = 0; int i; - if (data == NULL) - return -EINVAL; - - if (bu21013_read_block_data(data, buf) < 0) + if (bu21013_read_block_data(ts, buf) < 0) return -EINVAL; has_x_sensors = hweight32(buf[0] & BU21013_SENSORS_EN_0_7); @@ -227,21 +225,21 @@ static int bu21013_do_touch_report(struct bu21013_ts_data *data) } for (i = 0; i < finger_down_count; i++) { - if (data->chip->x_flip) - pos_x[i] = data->chip->touch_x_max - pos_x[i]; - if (data->chip->y_flip) - pos_y[i] = data->chip->touch_y_max - pos_y[i]; + if (ts->chip->x_flip) + pos_x[i] = ts->chip->touch_x_max - pos_x[i]; + if (ts->chip->y_flip) + pos_y[i] = ts->chip->touch_y_max - pos_y[i]; - input_report_abs(data->in_dev, + input_report_abs(ts->in_dev, ABS_MT_POSITION_X, pos_x[i]); - input_report_abs(data->in_dev, + input_report_abs(ts->in_dev, ABS_MT_POSITION_Y, pos_y[i]); - input_mt_sync(data->in_dev); + input_mt_sync(ts->in_dev); } } else - input_mt_sync(data->in_dev); + input_mt_sync(ts->in_dev); - input_sync(data->in_dev); + input_sync(ts->in_dev); return 0; } @@ -255,23 +253,22 @@ static int bu21013_do_touch_report(struct bu21013_ts_data *data) */ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data) { - struct bu21013_ts_data *data = device_data; - struct i2c_client *i2c = data->client; + struct bu21013_ts *ts = device_data; int keep_polling; - int retval; + int error; do { - retval = bu21013_do_touch_report(data); - if (retval < 0) { - dev_err(&i2c->dev, "bu21013_do_touch_report failed\n"); + error = bu21013_do_touch_report(ts); + if (error) { + dev_err(&ts->client->dev, "%s failed\n", __func__); break; } - keep_polling = gpiod_get_value(data->int_gpiod); + keep_polling = gpiod_get_value(ts->int_gpiod); if (keep_polling) - wait_event_timeout(data->wait, data->touch_stopped, + wait_event_timeout(ts->wait, ts->touch_stopped, msecs_to_jiffies(2)); - } while (keep_polling && !data->touch_stopped); + } while (keep_polling && !ts->touch_stopped); return IRQ_HANDLED; } @@ -283,130 +280,138 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data) * This function is used to power on * the bu21013 controller and returns integer. */ -static int bu21013_init_chip(struct bu21013_ts_data *data) +static int bu21013_init_chip(struct bu21013_ts *ts) { - int retval; - struct i2c_client *i2c = data->client; + struct i2c_client *client = ts->client; + int error; - retval = i2c_smbus_write_byte_data(i2c, BU21013_RESET_REG, - BU21013_RESET_ENABLE); - if (retval < 0) { - dev_err(&i2c->dev, "BU21013_RESET reg write failed\n"); - return retval; + error = i2c_smbus_write_byte_data(client, BU21013_RESET_REG, + BU21013_RESET_ENABLE); + if (error) { + dev_err(&client->dev, "BU21013_RESET reg write failed\n"); + return error; } msleep(RESET_DELAY); - retval = i2c_smbus_write_byte_data(i2c, BU21013_SENSOR_0_7_REG, - BU21013_SENSORS_EN_0_7); - if (retval < 0) { - dev_err(&i2c->dev, "BU21013_SENSOR_0_7 reg write failed\n"); - return retval; + error = i2c_smbus_write_byte_data(client, BU21013_SENSOR_0_7_REG, + BU21013_SENSORS_EN_0_7); + if (error) { + dev_err(&client->dev, "BU21013_SENSOR_0_7 reg write failed\n"); + return error; } - retval = i2c_smbus_write_byte_data(i2c, BU21013_SENSOR_8_15_REG, - BU21013_SENSORS_EN_8_15); - if (retval < 0) { - dev_err(&i2c->dev, "BU21013_SENSOR_8_15 reg write failed\n"); - return retval; + error = i2c_smbus_write_byte_data(client, BU21013_SENSOR_8_15_REG, + BU21013_SENSORS_EN_8_15); + if (error) { + dev_err(&client->dev, "BU21013_SENSOR_8_15 reg write failed\n"); + return error; } - retval = i2c_smbus_write_byte_data(i2c, BU21013_SENSOR_16_23_REG, - BU21013_SENSORS_EN_16_23); - if (retval < 0) { - dev_err(&i2c->dev, "BU21013_SENSOR_16_23 reg write failed\n"); - return retval; + error = i2c_smbus_write_byte_data(client, BU21013_SENSOR_16_23_REG, + BU21013_SENSORS_EN_16_23); + if (error) { + dev_err(&client->dev, "BU21013_SENSOR_16_23 reg write failed\n"); + return error; } - retval = i2c_smbus_write_byte_data(i2c, BU21013_POS_MODE1_REG, - (BU21013_POS_MODE1_0 | BU21013_POS_MODE1_1)); - if (retval < 0) { - dev_err(&i2c->dev, "BU21013_POS_MODE1 reg write failed\n"); - return retval; + error = i2c_smbus_write_byte_data(client, BU21013_POS_MODE1_REG, + BU21013_POS_MODE1_0 | + BU21013_POS_MODE1_1); + if (error) { + dev_err(&client->dev, "BU21013_POS_MODE1 reg write failed\n"); + return error; } - retval = i2c_smbus_write_byte_data(i2c, BU21013_POS_MODE2_REG, - (BU21013_POS_MODE2_ZERO | BU21013_POS_MODE2_AVG1 | - BU21013_POS_MODE2_AVG2 | BU21013_POS_MODE2_EN_RAW | - BU21013_POS_MODE2_MULTI)); - if (retval < 0) { - dev_err(&i2c->dev, "BU21013_POS_MODE2 reg write failed\n"); - return retval; + error = i2c_smbus_write_byte_data(client, BU21013_POS_MODE2_REG, + BU21013_POS_MODE2_ZERO | + BU21013_POS_MODE2_AVG1 | + BU21013_POS_MODE2_AVG2 | + BU21013_POS_MODE2_EN_RAW | + BU21013_POS_MODE2_MULTI); + if (error) { + dev_err(&client->dev, "BU21013_POS_MODE2 reg write failed\n"); + return error; } - if (data->chip->ext_clk) - retval = i2c_smbus_write_byte_data(i2c, BU21013_CLK_MODE_REG, - (BU21013_CLK_MODE_EXT | BU21013_CLK_MODE_CALIB)); + if (ts->chip->ext_clk) + error = i2c_smbus_write_byte_data(client, BU21013_CLK_MODE_REG, + BU21013_CLK_MODE_EXT | + BU21013_CLK_MODE_CALIB); else - retval = i2c_smbus_write_byte_data(i2c, BU21013_CLK_MODE_REG, - (BU21013_CLK_MODE_DIV | BU21013_CLK_MODE_CALIB)); - if (retval < 0) { - dev_err(&i2c->dev, "BU21013_CLK_MODE reg write failed\n"); - return retval; + error = i2c_smbus_write_byte_data(client, BU21013_CLK_MODE_REG, + BU21013_CLK_MODE_DIV | + BU21013_CLK_MODE_CALIB); + if (error) { + dev_err(&client->dev, "BU21013_CLK_MODE reg write failed\n"); + return error; } - retval = i2c_smbus_write_byte_data(i2c, BU21013_IDLE_REG, - (BU21013_IDLET_0 | BU21013_IDLE_INTERMIT_EN)); - if (retval < 0) { - dev_err(&i2c->dev, "BU21013_IDLE reg write failed\n"); - return retval; + error = i2c_smbus_write_byte_data(client, BU21013_IDLE_REG, + BU21013_IDLET_0 | + BU21013_IDLE_INTERMIT_EN); + if (error) { + dev_err(&client->dev, "BU21013_IDLE reg write failed\n"); + return error; } - retval = i2c_smbus_write_byte_data(i2c, BU21013_INT_MODE_REG, - BU21013_INT_MODE_LEVEL); - if (retval < 0) { - dev_err(&i2c->dev, "BU21013_INT_MODE reg write failed\n"); - return retval; + error = i2c_smbus_write_byte_data(client, BU21013_INT_MODE_REG, + BU21013_INT_MODE_LEVEL); + if (error) { + dev_err(&client->dev, "BU21013_INT_MODE reg write failed\n"); + return error; } - retval = i2c_smbus_write_byte_data(i2c, BU21013_FILTER_REG, - (BU21013_DELTA_0_6 | - BU21013_FILTER_EN)); - if (retval < 0) { - dev_err(&i2c->dev, "BU21013_FILTER reg write failed\n"); - return retval; + error = i2c_smbus_write_byte_data(client, BU21013_FILTER_REG, + BU21013_DELTA_0_6 | + BU21013_FILTER_EN); + if (error) { + dev_err(&client->dev, "BU21013_FILTER reg write failed\n"); + return error; } - retval = i2c_smbus_write_byte_data(i2c, BU21013_TH_ON_REG, - BU21013_TH_ON_5); - if (retval < 0) { - dev_err(&i2c->dev, "BU21013_TH_ON reg write failed\n"); - return retval; + error = i2c_smbus_write_byte_data(client, BU21013_TH_ON_REG, + BU21013_TH_ON_5); + if (error) { + dev_err(&client->dev, "BU21013_TH_ON reg write failed\n"); + return error; } - retval = i2c_smbus_write_byte_data(i2c, BU21013_TH_OFF_REG, - BU21013_TH_OFF_4 | BU21013_TH_OFF_3); - if (retval < 0) { - dev_err(&i2c->dev, "BU21013_TH_OFF reg write failed\n"); - return retval; + error = i2c_smbus_write_byte_data(client, BU21013_TH_OFF_REG, + BU21013_TH_OFF_4 | BU21013_TH_OFF_3); + if (error) { + dev_err(&client->dev, "BU21013_TH_OFF reg write failed\n"); + return error; } - retval = i2c_smbus_write_byte_data(i2c, BU21013_GAIN_REG, - (BU21013_GAIN_0 | BU21013_GAIN_1)); - if (retval < 0) { - dev_err(&i2c->dev, "BU21013_GAIN reg write failed\n"); - return retval; + error = i2c_smbus_write_byte_data(client, BU21013_GAIN_REG, + BU21013_GAIN_0 | BU21013_GAIN_1); + if (error) { + dev_err(&client->dev, "BU21013_GAIN reg write failed\n"); + return error; } - retval = i2c_smbus_write_byte_data(i2c, BU21013_OFFSET_MODE_REG, - BU21013_OFFSET_MODE_DEFAULT); - if (retval < 0) { - dev_err(&i2c->dev, "BU21013_OFFSET_MODE reg write failed\n"); - return retval; + error = i2c_smbus_write_byte_data(client, BU21013_OFFSET_MODE_REG, + BU21013_OFFSET_MODE_DEFAULT); + if (error) { + dev_err(&client->dev, "BU21013_OFFSET_MODE reg write failed\n"); + return error; } - retval = i2c_smbus_write_byte_data(i2c, BU21013_XY_EDGE_REG, - (BU21013_X_EDGE_0 | BU21013_X_EDGE_2 | - BU21013_Y_EDGE_1 | BU21013_Y_EDGE_3)); - if (retval < 0) { - dev_err(&i2c->dev, "BU21013_XY_EDGE reg write failed\n"); - return retval; + error = i2c_smbus_write_byte_data(client, BU21013_XY_EDGE_REG, + BU21013_X_EDGE_0 | + BU21013_X_EDGE_2 | + BU21013_Y_EDGE_1 | + BU21013_Y_EDGE_3); + if (error) { + dev_err(&client->dev, "BU21013_XY_EDGE reg write failed\n"); + return error; } - retval = i2c_smbus_write_byte_data(i2c, BU21013_DONE_REG, - BU21013_DONE); - if (retval < 0) { - dev_err(&i2c->dev, "BU21013_REG_DONE reg write failed\n"); - return retval; + error = i2c_smbus_write_byte_data(client, BU21013_DONE_REG, + BU21013_DONE); + if (error) { + dev_err(&client->dev, "BU21013_REG_DONE reg write failed\n"); + return error; } return 0; @@ -414,16 +419,16 @@ static int bu21013_init_chip(struct bu21013_ts_data *data) /** * bu21013_free_irq() - frees IRQ registered for touchscreen - * @bu21013_data: device structure pointer + * @ts: device structure pointer * * This function signals interrupt thread to stop processing and * frees interrupt. */ -static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data) +static void bu21013_free_irq(struct bu21013_ts *ts) { - bu21013_data->touch_stopped = true; - wake_up(&bu21013_data->wait); - free_irq(bu21013_data->irq, bu21013_data); + ts->touch_stopped = true; + wake_up(&ts->wait); + free_irq(ts->irq, ts); } #ifdef CONFIG_OF @@ -476,12 +481,12 @@ static int bu21013_probe(struct i2c_client *client, { const struct bu21013_platform_device *pdata = dev_get_platdata(&client->dev); - struct bu21013_ts_data *bu21013_data; + struct bu21013_ts *ts; struct input_dev *in_dev; int error; if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA)) { + I2C_FUNC_SMBUS_BYTE_DATA)) { dev_err(&client->dev, "i2c smbus byte data not supported\n"); return -EIO; } @@ -492,58 +497,57 @@ static int bu21013_probe(struct i2c_client *client, return PTR_ERR(pdata); } - bu21013_data = kzalloc(sizeof(struct bu21013_ts_data), GFP_KERNEL); + ts = kzalloc(sizeof(*ts), GFP_KERNEL); in_dev = input_allocate_device(); - if (!bu21013_data || !in_dev) { + if (!ts || !in_dev) { dev_err(&client->dev, "device memory alloc failed\n"); error = -ENOMEM; goto err_free_mem; } /* Named "INT" on the chip, DT binding is "touch" */ - bu21013_data->int_gpiod = gpiod_get(&client->dev, "touch", GPIOD_IN); - error = PTR_ERR_OR_ZERO(bu21013_data->int_gpiod); + ts->int_gpiod = gpiod_get(&client->dev, "touch", GPIOD_IN); + error = PTR_ERR_OR_ZERO(ts->int_gpiod); if (error) { if (error != -EPROBE_DEFER) dev_err(&client->dev, "failed to get INT GPIO\n"); goto err_free_mem; } - gpiod_set_consumer_name(bu21013_data->int_gpiod, "BU21013 INT"); + gpiod_set_consumer_name(ts->int_gpiod, "BU21013 INT"); - bu21013_data->in_dev = in_dev; - bu21013_data->chip = pdata; - bu21013_data->client = client; - bu21013_data->irq = gpiod_to_irq(bu21013_data->int_gpiod); + ts->in_dev = in_dev; + ts->chip = pdata; + ts->client = client; + ts->irq = gpiod_to_irq(ts->int_gpiod); - bu21013_data->regulator = regulator_get(&client->dev, "avdd"); - if (IS_ERR(bu21013_data->regulator)) { + ts->regulator = regulator_get(&client->dev, "avdd"); + if (IS_ERR(ts->regulator)) { dev_err(&client->dev, "regulator_get failed\n"); - error = PTR_ERR(bu21013_data->regulator); + error = PTR_ERR(ts->regulator); goto err_put_int_gpio; } - error = regulator_enable(bu21013_data->regulator); + error = regulator_enable(ts->regulator); if (error < 0) { dev_err(&client->dev, "regulator enable failed\n"); goto err_put_regulator; } - bu21013_data->touch_stopped = false; - init_waitqueue_head(&bu21013_data->wait); + ts->touch_stopped = false; + init_waitqueue_head(&ts->wait); /* Named "CS" on the chip, DT binding is "reset" */ - bu21013_data->cs_gpiod = gpiod_get(&client->dev, "reset", - GPIOD_OUT_HIGH); - error = PTR_ERR_OR_ZERO(bu21013_data->cs_gpiod); + ts->cs_gpiod = gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH); + error = PTR_ERR_OR_ZERO(ts->cs_gpiod); if (error) { if (error != -EPROBE_DEFER) dev_err(&client->dev, "failed to get CS GPIO\n"); goto err_disable_regulator; } - gpiod_set_consumer_name(bu21013_data->cs_gpiod, "BU21013 CS"); + gpiod_set_consumer_name(ts->cs_gpiod, "BU21013 CS"); /* configure the touch panel controller */ - error = bu21013_init_chip(bu21013_data); + error = bu21013_init_chip(ts); if (error) { dev_err(&client->dev, "error in bu21013 config\n"); goto err_cs_disable; @@ -558,19 +562,19 @@ static int bu21013_probe(struct i2c_client *client, __set_bit(EV_KEY, in_dev->evbit); __set_bit(EV_ABS, in_dev->evbit); - input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0, - pdata->touch_x_max, 0, 0); - input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0, - pdata->touch_y_max, 0, 0); - input_set_drvdata(in_dev, bu21013_data); + input_set_abs_params(in_dev, ABS_MT_POSITION_X, + 0, pdata->touch_x_max, 0, 0); + input_set_abs_params(in_dev, ABS_MT_POSITION_Y, + 0, pdata->touch_y_max, 0, 0); + input_set_drvdata(in_dev, ts); - error = request_threaded_irq(bu21013_data->irq, NULL, bu21013_gpio_irq, + error = request_threaded_irq(ts->irq, NULL, bu21013_gpio_irq, IRQF_TRIGGER_FALLING | IRQF_SHARED | IRQF_ONESHOT, - DRIVER_TP, bu21013_data); + DRIVER_TP, ts); if (error) { dev_err(&client->dev, "request irq %d failed\n", - bu21013_data->irq); + ts->irq); goto err_cs_disable; } @@ -581,24 +585,24 @@ static int bu21013_probe(struct i2c_client *client, } device_init_wakeup(&client->dev, pdata->wakeup); - i2c_set_clientdata(client, bu21013_data); + i2c_set_clientdata(client, ts); return 0; err_free_irq: - bu21013_free_irq(bu21013_data); + bu21013_free_irq(ts); err_cs_disable: - gpiod_set_value(bu21013_data->cs_gpiod, 0); - gpiod_put(bu21013_data->cs_gpiod); + gpiod_set_value(ts->cs_gpiod, 0); + gpiod_put(ts->cs_gpiod); err_disable_regulator: - regulator_disable(bu21013_data->regulator); + regulator_disable(ts->regulator); err_put_regulator: - regulator_put(bu21013_data->regulator); + regulator_put(ts->regulator); err_put_int_gpio: - gpiod_put(bu21013_data->int_gpiod); + gpiod_put(ts->int_gpiod); err_free_mem: input_free_device(in_dev); - kfree(bu21013_data); + kfree(ts); return error; } @@ -611,21 +615,21 @@ err_free_mem: */ static int bu21013_remove(struct i2c_client *client) { - struct bu21013_ts_data *bu21013_data = i2c_get_clientdata(client); + struct bu21013_ts *ts = i2c_get_clientdata(client); - bu21013_free_irq(bu21013_data); + bu21013_free_irq(ts); - gpiod_set_value(bu21013_data->cs_gpiod, 0); - gpiod_put(bu21013_data->cs_gpiod); + gpiod_set_value(ts->cs_gpiod, 0); + gpiod_put(ts->cs_gpiod); - input_unregister_device(bu21013_data->in_dev); + input_unregister_device(ts->in_dev); - regulator_disable(bu21013_data->regulator); - regulator_put(bu21013_data->regulator); + regulator_disable(ts->regulator); + regulator_put(ts->regulator); - gpiod_put(bu21013_data->int_gpiod); + gpiod_put(ts->int_gpiod); - kfree(bu21013_data); + kfree(ts); return 0; } @@ -640,16 +644,16 @@ static int bu21013_remove(struct i2c_client *client) */ static int bu21013_suspend(struct device *dev) { - struct bu21013_ts_data *bu21013_data = dev_get_drvdata(dev); - struct i2c_client *client = bu21013_data->client; + struct bu21013_ts *ts = dev_get_drvdata(dev); + struct i2c_client *client = ts->client; - bu21013_data->touch_stopped = true; + ts->touch_stopped = true; if (device_may_wakeup(&client->dev)) - enable_irq_wake(bu21013_data->irq); + enable_irq_wake(ts->irq); else - disable_irq(bu21013_data->irq); + disable_irq(ts->irq); - regulator_disable(bu21013_data->regulator); + regulator_disable(ts->regulator); return 0; } @@ -663,28 +667,28 @@ static int bu21013_suspend(struct device *dev) */ static int bu21013_resume(struct device *dev) { - struct bu21013_ts_data *bu21013_data = dev_get_drvdata(dev); - struct i2c_client *client = bu21013_data->client; + struct bu21013_ts *ts = dev_get_drvdata(dev); + struct i2c_client *client = ts->client; int retval; - retval = regulator_enable(bu21013_data->regulator); + retval = regulator_enable(ts->regulator); if (retval < 0) { dev_err(&client->dev, "bu21013 regulator enable failed\n"); return retval; } - retval = bu21013_init_chip(bu21013_data); + retval = bu21013_init_chip(ts); if (retval < 0) { dev_err(&client->dev, "bu21013 controller config failed\n"); return retval; } - bu21013_data->touch_stopped = false; + ts->touch_stopped = false; if (device_may_wakeup(&client->dev)) - disable_irq_wake(bu21013_data->irq); + disable_irq_wake(ts->irq); else - enable_irq(bu21013_data->irq); + enable_irq(ts->irq); return 0; } -- cgit v1.2.3-59-g8ed1b From 0570bab054106f68533dcb0de2e64c48b15d7b9f Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Thu, 8 Aug 2019 15:53:43 -0700 Subject: Input: bu21013_ts - annotate supend/resume methods as __maybe_unused Instead if #ifdef-ing out suspend and resume methods, let's mark them as __maybe_unused to get better compile time coverage. Tested-by: Linus Walleij Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/bu21013_ts.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index e9cb020ed725..0bdadd24296f 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c @@ -634,7 +634,6 @@ static int bu21013_remove(struct i2c_client *client) return 0; } -#ifdef CONFIG_PM /** * bu21013_suspend() - suspend the touch screen controller * @dev: pointer to device structure @@ -642,7 +641,7 @@ static int bu21013_remove(struct i2c_client *client) * This function is used to suspend the * touch panel controller and returns integer */ -static int bu21013_suspend(struct device *dev) +static int __maybe_unused bu21013_suspend(struct device *dev) { struct bu21013_ts *ts = dev_get_drvdata(dev); struct i2c_client *client = ts->client; @@ -665,7 +664,7 @@ static int bu21013_suspend(struct device *dev) * This function is used to resume the touch panel * controller and returns integer. */ -static int bu21013_resume(struct device *dev) +static int __maybe_unused bu21013_resume(struct device *dev) { struct bu21013_ts *ts = dev_get_drvdata(dev); struct i2c_client *client = ts->client; @@ -693,11 +692,7 @@ static int bu21013_resume(struct device *dev) return 0; } -static const struct dev_pm_ops bu21013_dev_pm_ops = { - .suspend = bu21013_suspend, - .resume = bu21013_resume, -}; -#endif +static SIMPLE_DEV_PM_OPS(bu21013_dev_pm_ops, bu21013_suspend, bu21013_resume); static const struct i2c_device_id bu21013_id[] = { { DRIVER_TP, 0 }, @@ -708,9 +703,7 @@ MODULE_DEVICE_TABLE(i2c, bu21013_id); static struct i2c_driver bu21013_driver = { .driver = { .name = DRIVER_TP, -#ifdef CONFIG_PM .pm = &bu21013_dev_pm_ops, -#endif }, .probe = bu21013_probe, .remove = bu21013_remove, -- cgit v1.2.3-59-g8ed1b From a5ee351d5bc7c9e0abdbc3d345a503cc07d0623f Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Thu, 8 Aug 2019 16:02:43 -0700 Subject: Input: bu21013_ts - remove useless comments The comments for individual functions in the driver do not provide any additional information beyond what function names indicate. Tested-by: Linus Walleij Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/bu21013_ts.c | 61 ++-------------------------------- 1 file changed, 2 insertions(+), 59 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index 0bdadd24296f..a5230f6ea5f0 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c @@ -159,14 +159,6 @@ struct bu21013_ts { bool touch_stopped; }; -/** - * bu21013_read_block_data(): read the touch co-ordinates - * @data: bu21013_ts structure pointer - * @buf: byte pointer - * - * Read the touch co-ordinates using i2c read block into buffer - * and returns integer. - */ static int bu21013_read_block_data(struct bu21013_ts *ts, u8 *buf) { int ret, i; @@ -182,13 +174,6 @@ static int bu21013_read_block_data(struct bu21013_ts *ts, u8 *buf) return -EINVAL; } -/** - * bu21013_do_touch_report(): Get the touch co-ordinates - * @data: bu21013_ts structure pointer - * - * Get the touch co-ordinates from touch sensor registers and writes - * into device structure and returns integer. - */ static int bu21013_do_touch_report(struct bu21013_ts *ts) { u8 buf[LENGTH_OF_BUFFER]; @@ -243,14 +228,7 @@ static int bu21013_do_touch_report(struct bu21013_ts *ts) return 0; } -/** - * bu21013_gpio_irq() - gpio thread function for touch interrupt - * @irq: irq value - * @device_data: void pointer - * - * This gpio thread function for touch interrupt - * and returns irqreturn_t. - */ + static irqreturn_t bu21013_gpio_irq(int irq, void *device_data) { struct bu21013_ts *ts = device_data; @@ -273,13 +251,6 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data) return IRQ_HANDLED; } -/** - * bu21013_init_chip() - power on sequence for the bu21013 controller - * @data: device structure pointer - * - * This function is used to power on - * the bu21013 controller and returns integer. - */ static int bu21013_init_chip(struct bu21013_ts *ts) { struct i2c_client *client = ts->client; @@ -468,14 +439,6 @@ bu21013_parse_dt(struct device *dev) } #endif -/** - * bu21013_probe() - initializes the i2c-client touchscreen driver - * @client: i2c client structure pointer - * @id: i2c device id pointer - * - * This function used to initializes the i2c-client touchscreen - * driver and returns integer. - */ static int bu21013_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -606,13 +569,7 @@ err_free_mem: return error; } -/** - * bu21013_remove() - removes the i2c-client touchscreen driver - * @client: i2c client structure pointer - * - * This function uses to remove the i2c-client - * touchscreen driver and returns integer. - */ + static int bu21013_remove(struct i2c_client *client) { struct bu21013_ts *ts = i2c_get_clientdata(client); @@ -634,13 +591,6 @@ static int bu21013_remove(struct i2c_client *client) return 0; } -/** - * bu21013_suspend() - suspend the touch screen controller - * @dev: pointer to device structure - * - * This function is used to suspend the - * touch panel controller and returns integer - */ static int __maybe_unused bu21013_suspend(struct device *dev) { struct bu21013_ts *ts = dev_get_drvdata(dev); @@ -657,13 +607,6 @@ static int __maybe_unused bu21013_suspend(struct device *dev) return 0; } -/** - * bu21013_resume() - resume the touch screen controller - * @dev: pointer to device structure - * - * This function is used to resume the touch panel - * controller and returns integer. - */ static int __maybe_unused bu21013_resume(struct device *dev) { struct bu21013_ts *ts = dev_get_drvdata(dev); -- cgit v1.2.3-59-g8ed1b From caeb1aae283f9b93d92400b1cb0395bdfd0d586c Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Thu, 8 Aug 2019 14:28:48 -0700 Subject: Input: bu21013_ts - convert to using managed resources This allows trimming error unwinding and device removal handling. Tested-by: Linus Walleij Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/bu21013_ts.c | 182 +++++++++++++++------------------ 1 file changed, 84 insertions(+), 98 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index a5230f6ea5f0..2b8538a63945 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c @@ -137,7 +137,6 @@ /** * struct bu21013_ts - touch panel data structure * @client: pointer to the i2c client - * @wait: variable to wait_queue_head_t structure * @touch_stopped: touch stop flag * @chip: pointer to the touch panel controller * @in_dev: pointer to the input device structure @@ -149,7 +148,6 @@ */ struct bu21013_ts { struct i2c_client *client; - wait_queue_head_t wait; const struct bu21013_platform_device *chip; struct input_dev *in_dev; struct regulator *regulator; @@ -242,11 +240,13 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data) break; } + if (unlikely(ts->touch_stopped)) + break; + keep_polling = gpiod_get_value(ts->int_gpiod); if (keep_polling) - wait_event_timeout(ts->wait, ts->touch_stopped, - msecs_to_jiffies(2)); - } while (keep_polling && !ts->touch_stopped); + usleep_range(2000, 2500); + } while (keep_polling); return IRQ_HANDLED; } @@ -388,20 +388,6 @@ static int bu21013_init_chip(struct bu21013_ts *ts) return 0; } -/** - * bu21013_free_irq() - frees IRQ registered for touchscreen - * @ts: device structure pointer - * - * This function signals interrupt thread to stop processing and - * frees interrupt. - */ -static void bu21013_free_irq(struct bu21013_ts *ts) -{ - ts->touch_stopped = true; - wake_up(&ts->wait); - free_irq(ts->irq, ts); -} - #ifdef CONFIG_OF static const struct bu21013_platform_device * bu21013_parse_dt(struct device *dev) @@ -439,6 +425,20 @@ bu21013_parse_dt(struct device *dev) } #endif +static void bu21013_power_off(void *_ts) +{ + struct bu21013_ts *ts = _ts; + + regulator_disable(ts->regulator); +} + +static void bu21013_disable_chip(void *_ts) +{ + struct bu21013_ts *ts = _ts; + + gpiod_set_value(ts->cs_gpiod, 0); +} + static int bu21013_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -460,133 +460,119 @@ static int bu21013_probe(struct i2c_client *client, return PTR_ERR(pdata); } - ts = kzalloc(sizeof(*ts), GFP_KERNEL); - in_dev = input_allocate_device(); - if (!ts || !in_dev) { + ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); + if (!ts) + return -ENOMEM; + + ts->chip = pdata; + ts->client = client; + + in_dev = devm_input_allocate_device(&client->dev); + if (!in_dev) { dev_err(&client->dev, "device memory alloc failed\n"); - error = -ENOMEM; - goto err_free_mem; + return -ENOMEM; } + ts->in_dev = in_dev; - /* Named "INT" on the chip, DT binding is "touch" */ - ts->int_gpiod = gpiod_get(&client->dev, "touch", GPIOD_IN); - error = PTR_ERR_OR_ZERO(ts->int_gpiod); - if (error) { - if (error != -EPROBE_DEFER) - dev_err(&client->dev, "failed to get INT GPIO\n"); - goto err_free_mem; - } - gpiod_set_consumer_name(ts->int_gpiod, "BU21013 INT"); + /* register the device to input subsystem */ + in_dev->name = DRIVER_TP; + in_dev->id.bustype = BUS_I2C; - ts->in_dev = in_dev; - ts->chip = pdata; - ts->client = client; - ts->irq = gpiod_to_irq(ts->int_gpiod); + __set_bit(EV_SYN, in_dev->evbit); + __set_bit(EV_KEY, in_dev->evbit); + __set_bit(EV_ABS, in_dev->evbit); + + input_set_abs_params(in_dev, ABS_MT_POSITION_X, + 0, pdata->touch_x_max, 0, 0); + input_set_abs_params(in_dev, ABS_MT_POSITION_Y, + 0, pdata->touch_y_max, 0, 0); + input_set_drvdata(in_dev, ts); - ts->regulator = regulator_get(&client->dev, "avdd"); + ts->regulator = devm_regulator_get(&client->dev, "avdd"); if (IS_ERR(ts->regulator)) { dev_err(&client->dev, "regulator_get failed\n"); - error = PTR_ERR(ts->regulator); - goto err_put_int_gpio; + return PTR_ERR(ts->regulator); } error = regulator_enable(ts->regulator); - if (error < 0) { + if (error) { dev_err(&client->dev, "regulator enable failed\n"); - goto err_put_regulator; + return error; } - ts->touch_stopped = false; - init_waitqueue_head(&ts->wait); + error = devm_add_action_or_reset(&client->dev, bu21013_power_off, ts); + if (error) { + dev_err(&client->dev, "failed to install power off handler\n"); + return error; + } /* Named "CS" on the chip, DT binding is "reset" */ - ts->cs_gpiod = gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH); + ts->cs_gpiod = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH); error = PTR_ERR_OR_ZERO(ts->cs_gpiod); if (error) { if (error != -EPROBE_DEFER) dev_err(&client->dev, "failed to get CS GPIO\n"); - goto err_disable_regulator; + return error; } gpiod_set_consumer_name(ts->cs_gpiod, "BU21013 CS"); + error = devm_add_action_or_reset(&client->dev, + bu21013_disable_chip, ts); + if (error) { + dev_err(&client->dev, + "failed to install chip disable handler\n"); + return error; + } + + /* Named "INT" on the chip, DT binding is "touch" */ + ts->int_gpiod = devm_gpiod_get(&client->dev, "touch", GPIOD_IN); + error = PTR_ERR_OR_ZERO(ts->int_gpiod); + if (error) { + if (error != -EPROBE_DEFER) + dev_err(&client->dev, "failed to get INT GPIO\n"); + return error; + } + gpiod_set_consumer_name(ts->int_gpiod, "BU21013 INT"); + /* configure the touch panel controller */ error = bu21013_init_chip(ts); if (error) { dev_err(&client->dev, "error in bu21013 config\n"); - goto err_cs_disable; + return error; } - /* register the device to input subsystem */ - in_dev->name = DRIVER_TP; - in_dev->id.bustype = BUS_I2C; - in_dev->dev.parent = &client->dev; - - __set_bit(EV_SYN, in_dev->evbit); - __set_bit(EV_KEY, in_dev->evbit); - __set_bit(EV_ABS, in_dev->evbit); - - input_set_abs_params(in_dev, ABS_MT_POSITION_X, - 0, pdata->touch_x_max, 0, 0); - input_set_abs_params(in_dev, ABS_MT_POSITION_Y, - 0, pdata->touch_y_max, 0, 0); - input_set_drvdata(in_dev, ts); - - error = request_threaded_irq(ts->irq, NULL, bu21013_gpio_irq, - IRQF_TRIGGER_FALLING | IRQF_SHARED | - IRQF_ONESHOT, - DRIVER_TP, ts); + ts->irq = gpiod_to_irq(ts->int_gpiod); + error = devm_request_threaded_irq(&client->dev, ts->irq, + NULL, bu21013_gpio_irq, + IRQF_TRIGGER_FALLING | + IRQF_SHARED | + IRQF_ONESHOT, + DRIVER_TP, ts); if (error) { dev_err(&client->dev, "request irq %d failed\n", ts->irq); - goto err_cs_disable; + return error; } error = input_register_device(in_dev); if (error) { dev_err(&client->dev, "failed to register input device\n"); - goto err_free_irq; + return error; } device_init_wakeup(&client->dev, pdata->wakeup); i2c_set_clientdata(client, ts); return 0; - -err_free_irq: - bu21013_free_irq(ts); -err_cs_disable: - gpiod_set_value(ts->cs_gpiod, 0); - gpiod_put(ts->cs_gpiod); -err_disable_regulator: - regulator_disable(ts->regulator); -err_put_regulator: - regulator_put(ts->regulator); -err_put_int_gpio: - gpiod_put(ts->int_gpiod); -err_free_mem: - input_free_device(in_dev); - kfree(ts); - - return error; } static int bu21013_remove(struct i2c_client *client) { struct bu21013_ts *ts = i2c_get_clientdata(client); - bu21013_free_irq(ts); - - gpiod_set_value(ts->cs_gpiod, 0); - gpiod_put(ts->cs_gpiod); - - input_unregister_device(ts->in_dev); - - regulator_disable(ts->regulator); - regulator_put(ts->regulator); - - gpiod_put(ts->int_gpiod); - - kfree(ts); + /* Make sure IRQ will exit quickly even if there is contact */ + ts->touch_stopped = true; + /* The resources will be freed by devm */ return 0; } -- cgit v1.2.3-59-g8ed1b From 1eb7b4cacc01771ae42fcbc5ae9a4bc1d13c1dbc Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Thu, 8 Aug 2019 12:09:43 -0700 Subject: Input: bu21013_ts - remove support for platform data There are no current users of the platform data in the tree, and any new users should either use device tree, or static device properties to describe the device. This change drop the platform data definition and handling and moves the driver over to generic device properties API. We also drop support for the external clock. If it is needed we will have to extend the bindings to supply the clock reference and handle it properly in the driver. Also, wakeup setting should be coming from I2C client. Tested-by: Linus Walleij Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/bu21013_ts.c | 109 +++++++++++---------------------- include/linux/input/bu21013.h | 30 --------- 2 files changed, 37 insertions(+), 102 deletions(-) delete mode 100644 include/linux/input/bu21013.h (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index 2b8538a63945..f3b3e4c72c84 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c @@ -4,18 +4,18 @@ * Author: Naveen Kumar G for ST-Ericsson */ -#include +#include #include -#include +#include #include -#include #include -#include -#include -#include +#include +#include #include -#include -#include +#include +#include +#include +#include #define MAX_FINGERS 2 #define RESET_DELAY 30 @@ -137,23 +137,32 @@ /** * struct bu21013_ts - touch panel data structure * @client: pointer to the i2c client - * @touch_stopped: touch stop flag - * @chip: pointer to the touch panel controller * @in_dev: pointer to the input device structure * @regulator: pointer to the Regulator used for touch screen * @cs_gpiod: chip select GPIO line * @int_gpiod: touch interrupt GPIO line + * @irq: interrupt number the device is using + * @touch_x_max: maximum X coordinate reported by the device + * @touch_y_max: maximum Y coordinate reported by the device + * @x_flip: indicates that the driver should invert X coordinate before + * reporting + * @y_flip: indicates that the driver should invert Y coordinate before + * reporting + * @touch_stopped: touch stop flag * * Touch panel device data structure */ struct bu21013_ts { struct i2c_client *client; - const struct bu21013_platform_device *chip; struct input_dev *in_dev; struct regulator *regulator; struct gpio_desc *cs_gpiod; struct gpio_desc *int_gpiod; unsigned int irq; + u32 touch_x_max; + u32 touch_y_max; + bool x_flip; + bool y_flip; bool touch_stopped; }; @@ -208,10 +217,10 @@ static int bu21013_do_touch_report(struct bu21013_ts *ts) } for (i = 0; i < finger_down_count; i++) { - if (ts->chip->x_flip) - pos_x[i] = ts->chip->touch_x_max - pos_x[i]; - if (ts->chip->y_flip) - pos_y[i] = ts->chip->touch_y_max - pos_y[i]; + if (ts->x_flip) + pos_x[i] = ts->touch_x_max - pos_x[i]; + if (ts->y_flip) + pos_y[i] = ts->touch_y_max - pos_y[i]; input_report_abs(ts->in_dev, ABS_MT_POSITION_X, pos_x[i]); @@ -304,14 +313,9 @@ static int bu21013_init_chip(struct bu21013_ts *ts) return error; } - if (ts->chip->ext_clk) - error = i2c_smbus_write_byte_data(client, BU21013_CLK_MODE_REG, - BU21013_CLK_MODE_EXT | - BU21013_CLK_MODE_CALIB); - else - error = i2c_smbus_write_byte_data(client, BU21013_CLK_MODE_REG, - BU21013_CLK_MODE_DIV | - BU21013_CLK_MODE_CALIB); + error = i2c_smbus_write_byte_data(client, BU21013_CLK_MODE_REG, + BU21013_CLK_MODE_DIV | + BU21013_CLK_MODE_CALIB); if (error) { dev_err(&client->dev, "BU21013_CLK_MODE reg write failed\n"); return error; @@ -388,43 +392,6 @@ static int bu21013_init_chip(struct bu21013_ts *ts) return 0; } -#ifdef CONFIG_OF -static const struct bu21013_platform_device * -bu21013_parse_dt(struct device *dev) -{ - struct device_node *np = dev->of_node; - struct bu21013_platform_device *pdata; - - if (!np) { - dev_err(dev, "no device tree or platform data\n"); - return ERR_PTR(-EINVAL); - } - - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return ERR_PTR(-ENOMEM); - - pdata->y_flip = pdata->x_flip = false; - - pdata->x_flip = of_property_read_bool(np, "rohm,flip-x"); - pdata->y_flip = of_property_read_bool(np, "rohm,flip-y"); - - of_property_read_u32(np, "rohm,touch-max-x", &pdata->touch_x_max); - of_property_read_u32(np, "rohm,touch-max-y", &pdata->touch_y_max); - - pdata->ext_clk = false; - - return pdata; -} -#else -static inline const struct bu21013_platform_device * -bu21013_parse_dt(struct device *dev) -{ - dev_err(dev, "no platform data available\n"); - return ERR_PTR(-EINVAL); -} -#endif - static void bu21013_power_off(void *_ts) { struct bu21013_ts *ts = _ts; @@ -442,8 +409,6 @@ static void bu21013_disable_chip(void *_ts) static int bu21013_probe(struct i2c_client *client, const struct i2c_device_id *id) { - const struct bu21013_platform_device *pdata = - dev_get_platdata(&client->dev); struct bu21013_ts *ts; struct input_dev *in_dev; int error; @@ -454,19 +419,20 @@ static int bu21013_probe(struct i2c_client *client, return -EIO; } - if (!pdata) { - pdata = bu21013_parse_dt(&client->dev); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - } - ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); if (!ts) return -ENOMEM; - ts->chip = pdata; ts->client = client; + ts->x_flip = device_property_read_bool(&client->dev, "rohm,flip-x"); + ts->y_flip = device_property_read_bool(&client->dev, "rohm,flip-y"); + + device_property_read_u32(&client->dev, "rohm,touch-max-x", + &ts->touch_x_max); + device_property_read_u32(&client->dev, "rohm,touch-max-y", + &ts->touch_y_max); + in_dev = devm_input_allocate_device(&client->dev); if (!in_dev) { dev_err(&client->dev, "device memory alloc failed\n"); @@ -483,9 +449,9 @@ static int bu21013_probe(struct i2c_client *client, __set_bit(EV_ABS, in_dev->evbit); input_set_abs_params(in_dev, ABS_MT_POSITION_X, - 0, pdata->touch_x_max, 0, 0); + 0, ts->touch_x_max, 0, 0); input_set_abs_params(in_dev, ABS_MT_POSITION_Y, - 0, pdata->touch_y_max, 0, 0); + 0, ts->touch_y_max, 0, 0); input_set_drvdata(in_dev, ts); ts->regulator = devm_regulator_get(&client->dev, "avdd"); @@ -560,7 +526,6 @@ static int bu21013_probe(struct i2c_client *client, return error; } - device_init_wakeup(&client->dev, pdata->wakeup); i2c_set_clientdata(client, ts); return 0; diff --git a/include/linux/input/bu21013.h b/include/linux/input/bu21013.h deleted file mode 100644 index 58b1a9d44443..000000000000 --- a/include/linux/input/bu21013.h +++ /dev/null @@ -1,30 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (C) ST-Ericsson SA 2010 - * Author: Naveen Kumar G for ST-Ericsson - */ - -#ifndef _BU21013_H -#define _BU21013_H - -/** - * struct bu21013_platform_device - Handle the platform data - * @touch_x_max: touch x max - * @touch_y_max: touch y max - * @ext_clk: external clock flag - * @x_flip: x flip flag - * @y_flip: y flip flag - * @wakeup: wakeup flag - * - * This is used to handle the platform data - */ -struct bu21013_platform_device { - int touch_x_max; - int touch_y_max; - bool ext_clk; - bool x_flip; - bool y_flip; - bool wakeup; -}; - -#endif -- cgit v1.2.3-59-g8ed1b From db3e34d4036db59cbacc1bff1c622b23d85b766b Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Fri, 9 Aug 2019 10:07:06 -0700 Subject: Input: bu21013_ts - use interrupt from I2C client Instead of trying to map INT GPIO to interrupt, let's use one supplied by I2C client. If there is none - bail. This will also allow us to treat INT GPIO as optional, as per the binding. Tested-by: Linus Walleij Signed-off-by: Dmitry Torokhov --- .../bindings/input/touchscreen/bu21013.txt | 6 +++- drivers/input/touchscreen/bu21013_ts.c | 35 ++++++++++++---------- 2 files changed, 24 insertions(+), 17 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt b/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt index 43899fc36ecf..7ddb5de8343d 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt @@ -4,6 +4,8 @@ Required properties: - compatible : "rohm,bu21013_tp" - reg : I2C device address - reset-gpios : GPIO pin enabling (selecting) chip (CS) + - interrupt-parent : the phandle for the gpio controller + - interrupts : (gpio) interrupt to which the chip is connected Optional properties: - touch-gpios : GPIO pin registering a touch event @@ -19,7 +21,9 @@ Example: bu21013_tp@5c { compatible = "rohm,bu21013_tp"; reg = <0x5c>; - touch-gpio = <&gpio2 20 0x4>; + interrupt-parent = <&gpio2>; + interrupts <&20 IRQ_TYPE_LEVEL_LOW>; + touch-gpio = <&gpio2 20 GPIO_ACTIVE_LOW>; avdd-supply = <&ab8500_ldo_aux1_reg>; rohm,touch-max-x = <384>; diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index f3b3e4c72c84..77ef0275c447 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c @@ -141,7 +141,6 @@ * @regulator: pointer to the Regulator used for touch screen * @cs_gpiod: chip select GPIO line * @int_gpiod: touch interrupt GPIO line - * @irq: interrupt number the device is using * @touch_x_max: maximum X coordinate reported by the device * @touch_y_max: maximum Y coordinate reported by the device * @x_flip: indicates that the driver should invert X coordinate before @@ -158,7 +157,6 @@ struct bu21013_ts { struct regulator *regulator; struct gpio_desc *cs_gpiod; struct gpio_desc *int_gpiod; - unsigned int irq; u32 touch_x_max; u32 touch_y_max; bool x_flip; @@ -252,7 +250,8 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data) if (unlikely(ts->touch_stopped)) break; - keep_polling = gpiod_get_value(ts->int_gpiod); + keep_polling = ts->int_gpiod ? + gpiod_get_value(ts->int_gpiod) : false; if (keep_polling) usleep_range(2000, 2500); } while (keep_polling); @@ -419,6 +418,11 @@ static int bu21013_probe(struct i2c_client *client, return -EIO; } + if (!client->irq) { + dev_err(&client->dev, "No IRQ set up\n"); + return -EINVAL; + } + ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); if (!ts) return -ENOMEM; @@ -491,14 +495,17 @@ static int bu21013_probe(struct i2c_client *client, } /* Named "INT" on the chip, DT binding is "touch" */ - ts->int_gpiod = devm_gpiod_get(&client->dev, "touch", GPIOD_IN); + ts->int_gpiod = devm_gpiod_get_optional(&client->dev, + "touch", GPIOD_IN); error = PTR_ERR_OR_ZERO(ts->int_gpiod); if (error) { if (error != -EPROBE_DEFER) dev_err(&client->dev, "failed to get INT GPIO\n"); return error; } - gpiod_set_consumer_name(ts->int_gpiod, "BU21013 INT"); + + if (ts->int_gpiod) + gpiod_set_consumer_name(ts->int_gpiod, "BU21013 INT"); /* configure the touch panel controller */ error = bu21013_init_chip(ts); @@ -507,16 +514,12 @@ static int bu21013_probe(struct i2c_client *client, return error; } - ts->irq = gpiod_to_irq(ts->int_gpiod); - error = devm_request_threaded_irq(&client->dev, ts->irq, + error = devm_request_threaded_irq(&client->dev, client->irq, NULL, bu21013_gpio_irq, - IRQF_TRIGGER_FALLING | - IRQF_SHARED | - IRQF_ONESHOT, - DRIVER_TP, ts); + IRQF_ONESHOT, DRIVER_TP, ts); if (error) { dev_err(&client->dev, "request irq %d failed\n", - ts->irq); + client->irq); return error; } @@ -549,9 +552,9 @@ static int __maybe_unused bu21013_suspend(struct device *dev) ts->touch_stopped = true; if (device_may_wakeup(&client->dev)) - enable_irq_wake(ts->irq); + enable_irq_wake(client->irq); else - disable_irq(ts->irq); + disable_irq(client->irq); regulator_disable(ts->regulator); @@ -579,9 +582,9 @@ static int __maybe_unused bu21013_resume(struct device *dev) ts->touch_stopped = false; if (device_may_wakeup(&client->dev)) - disable_irq_wake(ts->irq); + disable_irq_wake(client->irq); else - enable_irq(ts->irq); + enable_irq(client->irq); return 0; } -- cgit v1.2.3-59-g8ed1b From 18aa4d6b67483b4dac08a537f6c4fc943eea5386 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Thu, 8 Aug 2019 17:41:12 -0700 Subject: Input: bu21013_ts - fix suspend when wake source If the touchscreen is configured as wakeup source we should not be cutting off power to it. Also, now that the driver relies on I2C client to supply IRQ, we do not need to explicitly enable and disable IRQ for wakeup: if device is created as wakeup source, I2C core will mark interrupt as wakeup one. Tested-by: Linus Walleij Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/bu21013_ts.c | 48 +++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index 77ef0275c447..e617847ece65 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c @@ -547,44 +547,44 @@ static int bu21013_remove(struct i2c_client *client) static int __maybe_unused bu21013_suspend(struct device *dev) { - struct bu21013_ts *ts = dev_get_drvdata(dev); - struct i2c_client *client = ts->client; + struct i2c_client *client = to_i2c_client(dev); + struct bu21013_ts *ts = i2c_get_clientdata(client); ts->touch_stopped = true; - if (device_may_wakeup(&client->dev)) - enable_irq_wake(client->irq); - else - disable_irq(client->irq); + mb(); + disable_irq(client->irq); - regulator_disable(ts->regulator); + if (!device_may_wakeup(&client->dev)) + regulator_disable(ts->regulator); return 0; } static int __maybe_unused bu21013_resume(struct device *dev) { - struct bu21013_ts *ts = dev_get_drvdata(dev); - struct i2c_client *client = ts->client; - int retval; + struct i2c_client *client = to_i2c_client(dev); + struct bu21013_ts *ts = i2c_get_clientdata(client); + int error; - retval = regulator_enable(ts->regulator); - if (retval < 0) { - dev_err(&client->dev, "bu21013 regulator enable failed\n"); - return retval; - } + if (!device_may_wakeup(&client->dev)) { + error = regulator_enable(ts->regulator); + if (error) { + dev_err(&client->dev, + "failed to re-enable regulator when resuming\n"); + return error; + } - retval = bu21013_init_chip(ts); - if (retval < 0) { - dev_err(&client->dev, "bu21013 controller config failed\n"); - return retval; + error = bu21013_init_chip(ts); + if (error) { + dev_err(&client->dev, + "failed to reinitialize chip when resuming\n"); + return error; + } } ts->touch_stopped = false; - - if (device_may_wakeup(&client->dev)) - disable_irq_wake(client->irq); - else - enable_irq(client->irq); + mb(); + enable_irq(client->irq); return 0; } -- cgit v1.2.3-59-g8ed1b From 307ec663f6c3e9a0a80c7092a1dea6e09debc127 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Fri, 9 Aug 2019 12:08:14 -0700 Subject: Input: bu21013_ts - switch to using MT-B (slotted) protocol MT-B protocol is more efficient and everyone expects it. We use in-kernel tracking to identify contacts. Tested-by: Linus Walleij Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/bu21013_ts.c | 80 ++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 37 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index e617847ece65..2bff3f3f4464 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -181,11 +182,13 @@ static int bu21013_read_block_data(struct bu21013_ts *ts, u8 *buf) static int bu21013_do_touch_report(struct bu21013_ts *ts) { - u8 buf[LENGTH_OF_BUFFER]; - unsigned int pos_x[2], pos_y[2]; - bool has_x_sensors, has_y_sensors; - int finger_down_count = 0; - int i; + struct input_dev *input = ts->in_dev; + struct input_mt_pos pos[MAX_FINGERS]; + int slots[MAX_FINGERS]; + u8 buf[LENGTH_OF_BUFFER]; + bool has_x_sensors, has_y_sensors; + int finger_down_count = 0; + int i; if (bu21013_read_block_data(ts, buf) < 0) return -EINVAL; @@ -197,39 +200,38 @@ static int bu21013_do_touch_report(struct bu21013_ts *ts) return 0; for (i = 0; i < MAX_FINGERS; i++) { - const u8 *p = &buf[4 * i + 3]; - unsigned int x = p[0] << SHIFT_2 | (p[1] & MASK_BITS); - unsigned int y = p[2] << SHIFT_2 | (p[3] & MASK_BITS); - if (x == 0 || y == 0) + const u8 *data = &buf[4 * i + 3]; + struct input_mt_pos *p = &pos[finger_down_count]; + + p->x = data[0] << SHIFT_2 | (data[1] & MASK_BITS); + p->y = data[2] << SHIFT_2 | (data[3] & MASK_BITS); + if (p->x == 0 || p->y == 0) continue; - pos_x[finger_down_count] = x; - pos_y[finger_down_count] = y; + finger_down_count++; + + if (ts->x_flip) + p->x = ts->touch_x_max - p->x; + if (ts->y_flip) + p->y = ts->touch_y_max - p->y; } - if (finger_down_count) { - if (finger_down_count == 2 && - (abs(pos_x[0] - pos_x[1]) < DELTA_MIN || - abs(pos_y[0] - pos_y[1]) < DELTA_MIN)) { - return 0; - } + if (finger_down_count == 2 && + (abs(pos[0].x - pos[1].x) < DELTA_MIN || + abs(pos[0].y - pos[1].y) < DELTA_MIN)) { + return 0; + } - for (i = 0; i < finger_down_count; i++) { - if (ts->x_flip) - pos_x[i] = ts->touch_x_max - pos_x[i]; - if (ts->y_flip) - pos_y[i] = ts->touch_y_max - pos_y[i]; - - input_report_abs(ts->in_dev, - ABS_MT_POSITION_X, pos_x[i]); - input_report_abs(ts->in_dev, - ABS_MT_POSITION_Y, pos_y[i]); - input_mt_sync(ts->in_dev); - } - } else - input_mt_sync(ts->in_dev); + input_mt_assign_slots(input, slots, pos, finger_down_count, DELTA_MIN); + for (i = 0; i < finger_down_count; i++) { + input_mt_slot(input, slots[i]); + input_mt_report_slot_state(input, MT_TOOL_FINGER, true); + input_report_abs(input, ABS_MT_POSITION_X, pos[i].x); + input_report_abs(input, ABS_MT_POSITION_Y, pos[i].y); + } - input_sync(ts->in_dev); + input_mt_sync_frame(input); + input_sync(input); return 0; } @@ -443,20 +445,24 @@ static int bu21013_probe(struct i2c_client *client, return -ENOMEM; } ts->in_dev = in_dev; + input_set_drvdata(in_dev, ts); /* register the device to input subsystem */ in_dev->name = DRIVER_TP; in_dev->id.bustype = BUS_I2C; - __set_bit(EV_SYN, in_dev->evbit); - __set_bit(EV_KEY, in_dev->evbit); - __set_bit(EV_ABS, in_dev->evbit); - input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0, ts->touch_x_max, 0, 0); input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0, ts->touch_y_max, 0, 0); - input_set_drvdata(in_dev, ts); + + error = input_mt_init_slots(in_dev, MAX_FINGERS, + INPUT_MT_DIRECT | INPUT_MT_TRACK | + INPUT_MT_DROP_UNUSED); + if (error) { + dev_err(&client->dev, "failed to initialize MT slots"); + return error; + } ts->regulator = devm_regulator_get(&client->dev, "avdd"); if (IS_ERR(ts->regulator)) { -- cgit v1.2.3-59-g8ed1b From 4b6253fa736494346bab381114611e358afae545 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Fri, 9 Aug 2019 12:50:15 -0700 Subject: Input: bu21013_ts - switch to using standard touchscreen properties This switches the driver over to the standard touchscreen properties for coordinate transformation, while keeping old bindings working as well. Tested-by: Linus Walleij Signed-off-by: Dmitry Torokhov --- .../bindings/input/touchscreen/bu21013.txt | 16 +++++-- drivers/input/touchscreen/bu21013_ts.c | 54 +++++++++++++--------- 2 files changed, 46 insertions(+), 24 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt b/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt index 7ddb5de8343d..da4c9d8b99b1 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt @@ -10,6 +10,16 @@ Required properties: Optional properties: - touch-gpios : GPIO pin registering a touch event - -supply : Phandle to a regulator supply + - touchscreen-size-x : General touchscreen binding, see [1]. + - touchscreen-size-y : General touchscreen binding, see [1]. + - touchscreen-inverted-x : General touchscreen binding, see [1]. + - touchscreen-inverted-y : General touchscreen binding, see [1]. + - touchscreen-swapped-x-y : General touchscreen binding, see [1]. + +[1] All general touchscreen properties are described in + Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt. + +Deprecated properties: - rohm,touch-max-x : Maximum outward permitted limit in the X axis - rohm,touch-max-y : Maximum outward permitted limit in the Y axis - rohm,flip-x : Flip touch coordinates on the X axis @@ -26,8 +36,8 @@ Example: touch-gpio = <&gpio2 20 GPIO_ACTIVE_LOW>; avdd-supply = <&ab8500_ldo_aux1_reg>; - rohm,touch-max-x = <384>; - rohm,touch-max-y = <704>; - rohm,flip-y; + touchscreen-size-x = <384>; + touchscreen-size-y = <704>; + touchscreen-inverted-y; }; }; diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index 2bff3f3f4464..2f1f0d7607f8 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -139,6 +140,7 @@ * struct bu21013_ts - touch panel data structure * @client: pointer to the i2c client * @in_dev: pointer to the input device structure + * @props: the device coordinate transformation properties * @regulator: pointer to the Regulator used for touch screen * @cs_gpiod: chip select GPIO line * @int_gpiod: touch interrupt GPIO line @@ -155,6 +157,7 @@ struct bu21013_ts { struct i2c_client *client; struct input_dev *in_dev; + struct touchscreen_properties props; struct regulator *regulator; struct gpio_desc *cs_gpiod; struct gpio_desc *int_gpiod; @@ -201,19 +204,13 @@ static int bu21013_do_touch_report(struct bu21013_ts *ts) for (i = 0; i < MAX_FINGERS; i++) { const u8 *data = &buf[4 * i + 3]; - struct input_mt_pos *p = &pos[finger_down_count]; + unsigned int x, y; - p->x = data[0] << SHIFT_2 | (data[1] & MASK_BITS); - p->y = data[2] << SHIFT_2 | (data[3] & MASK_BITS); - if (p->x == 0 || p->y == 0) - continue; - - finger_down_count++; - - if (ts->x_flip) - p->x = ts->touch_x_max - p->x; - if (ts->y_flip) - p->y = ts->touch_y_max - p->y; + x = data[0] << SHIFT_2 | (data[1] & MASK_BITS); + y = data[2] << SHIFT_2 | (data[3] & MASK_BITS); + if (x != 0 && y != 0) + touchscreen_set_mt_pos(&pos[finger_down_count++], + &ts->props, x, y); } if (finger_down_count == 2 && @@ -412,6 +409,8 @@ static int bu21013_probe(struct i2c_client *client, { struct bu21013_ts *ts; struct input_dev *in_dev; + struct input_absinfo *info; + u32 max_x = 0, max_y = 0; int error; if (!i2c_check_functionality(client->adapter, @@ -434,11 +433,6 @@ static int bu21013_probe(struct i2c_client *client, ts->x_flip = device_property_read_bool(&client->dev, "rohm,flip-x"); ts->y_flip = device_property_read_bool(&client->dev, "rohm,flip-y"); - device_property_read_u32(&client->dev, "rohm,touch-max-x", - &ts->touch_x_max); - device_property_read_u32(&client->dev, "rohm,touch-max-y", - &ts->touch_y_max); - in_dev = devm_input_allocate_device(&client->dev); if (!in_dev) { dev_err(&client->dev, "device memory alloc failed\n"); @@ -451,10 +445,28 @@ static int bu21013_probe(struct i2c_client *client, in_dev->name = DRIVER_TP; in_dev->id.bustype = BUS_I2C; - input_set_abs_params(in_dev, ABS_MT_POSITION_X, - 0, ts->touch_x_max, 0, 0); - input_set_abs_params(in_dev, ABS_MT_POSITION_Y, - 0, ts->touch_y_max, 0, 0); + device_property_read_u32(&client->dev, "rohm,touch-max-x", &max_x); + device_property_read_u32(&client->dev, "rohm,touch-max-y", &max_y); + + input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0, max_x, 0, 0); + input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0, max_y, 0, 0); + + touchscreen_parse_properties(in_dev, true, &ts->props); + + /* Adjust for the legacy "flip" properties, if present */ + if (!ts->props.invert_x && + device_property_read_bool(&client->dev, "rohm,flip-x")) { + info = &in_dev->absinfo[ABS_MT_POSITION_X]; + info->maximum -= info->minimum; + info->minimum = 0; + } + + if (!ts->props.invert_y && + device_property_read_bool(&client->dev, "rohm,flip-y")) { + info = &in_dev->absinfo[ABS_MT_POSITION_Y]; + info->maximum -= info->minimum; + info->minimum = 0; + } error = input_mt_init_slots(in_dev, MAX_FINGERS, INPUT_MT_DIRECT | INPUT_MT_TRACK | -- cgit v1.2.3-59-g8ed1b