From patchwork Sun Sep 17 11:14:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 112834 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp2564587qgf; Sun, 17 Sep 2017 04:15:02 -0700 (PDT) X-Received: by 10.99.102.131 with SMTP id a125mr24385336pgc.96.1505646902567; Sun, 17 Sep 2017 04:15:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505646902; cv=none; d=google.com; s=arc-20160816; b=jn0yxsiKS90eBtNmXa7Z1U48vxzbKtqE8K+82ULvwzXPuRDmdArpyigFcKxnj8j/+/ 5woClrRZLioznMFzkbn+lp+iwnAPlvYbe21VdHiAjBHhJw4joeQphN+XwxBNAhQhy0PA be6WztKP5jXyZkjSLDgOwKgjM9EseQOJnIdXAglLKDmkhtSTIf6+NUjzJXudL55UKZw6 jIx+dHSM/m7aPeC2Lm0ZhOdxO+cHorTZd/G+NB9lJTKJvaezNBTeyA4857q/m3O902G9 r151nEP39QF2WaAl+mCSbQONVaLt36l9dTPxSrcwlvCHDouExlZtHaK2PEaSgX/KNgD2 Yv/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=gnkdEvM/zjHdeTKWjRkus8tJrTKd0X0H2DwC58nNBUk=; b=vy6VC0qGN9IFwRWYskROPS7BBoDz9AD9KYpSFWEoyzs1aU/JHw0fwE9MgCu4geaLby XyDGZbYwh4QbG3Fe7F1DnxxECV8HkeQ/VaIOsYHS3QLLMLMqfRm2QXq2lMSl7afrzOD9 1CPWWiPzEZWu/ZFP6K4sc7vRw/x0R+nd0ZPzmE0w/PgayjNB6a2bDgtdq9QOPKPwk91G JnZFL4VcQbIFBmhDaVWOqo3eYePtYCiCrkmCVm6m21GOBfdkMl86X76zsBIYuantRfES /OLJ+3fZvZmSOUFxPlEVZs66FkuTy0D2A569I0qrab5i6uL/lnfws/xurpLzymZkduzk bkXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=gv7HX8lh; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k195si3206825pgc.507.2017.09.17.04.15.02 for ; Sun, 17 Sep 2017 04:15:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=gv7HX8lh; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750824AbdIQLPB (ORCPT ); Sun, 17 Sep 2017 07:15:01 -0400 Received: from mail-lf0-f47.google.com ([209.85.215.47]:43201 "EHLO mail-lf0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750803AbdIQLPA (ORCPT ); Sun, 17 Sep 2017 07:15:00 -0400 Received: by mail-lf0-f47.google.com with SMTP id c80so5677546lfh.0 for ; Sun, 17 Sep 2017 04:15:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3BZyeBd4dbXU93u6C56RJsCwZiRh4Tsz5RyygO1mo04=; b=gv7HX8lhZnaxvmJX/YZjpccnvaCGuZtsfetNegHQhVgwaND2KdfSVYFJRxPIMCU1Tf s7/WoSxuZxaYD8+sJ2wDCGQtq44132fNNeGWlwDhTnmI2Q/Ov3A5iw9jxGKSP0E/qmMA 9TSFrzk3IcbIiZsYsGSOvKDlkphrriQUwxcmQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3BZyeBd4dbXU93u6C56RJsCwZiRh4Tsz5RyygO1mo04=; b=PRqr8YH63gcP+jgwpT4svo4mmKVSKOKA8aRQvSRwrncnegaVhW0jFzGKFMZ6FhXvRm MPfhQFnBTTf3TyxUko9Rjp3xZZ4HIdoTyA5/YlN5ELQP14QNMc4EreA2KZcZ/KQCKmnl bKgl/QT6ZPv7hUycCgW/yybwXzhgq/NO4AwB9D0+x54lseuaMAD7nXTIQaxtCInNG+7u yCsdCm98POzpIzv9AGSQWkcu8Xx7VCTEWJn+J4yT2s0vSuGX0kOwwUAabbE4dz43qPmT CfCvYeoSxEkutbCWgqj63cdlUc564pEJUXzmhCJ8wZamWY3nwEE93lrJtPJYV6ZICtvw 92OA== X-Gm-Message-State: AHPjjUgcug4gys5/jSkZjTTdVNJ2wL1te8t0L1SEsWKerAiaCj5Sr3/N N1aAPJnLeWwVecaa X-Google-Smtp-Source: AOwi7QB4A7iXenrXQ/v2dL/Dwco+SI1fEYtDXjsQC48fYZlxdAHJE0+NBYtvJwN5s5qJp7vThZ4/xA== X-Received: by 10.46.43.142 with SMTP id r14mr7156173ljr.159.1505646899242; Sun, 17 Sep 2017 04:14:59 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-2209e055.014-348-6c756e10.cust.bredbandsbolaget.se. [85.224.9.34]) by smtp.gmail.com with ESMTPSA id h83sm1007069lfi.16.2017.09.17.04.14.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 17 Sep 2017 04:14:58 -0700 (PDT) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org, Hans-Christian Noren Egtvedt Cc: Linus Walleij Subject: [PATCH 1/5] input: mouse: Kill off platform data for GPIO mouse Date: Sun, 17 Sep 2017 13:14:41 +0200 Message-Id: <20170917111445.30880-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170917111445.30880-1-linus.walleij@linaro.org> References: <20170917111445.30880-1-linus.walleij@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This is not used much: git grep gpio_mouse_platform_data shows that absolutely nothing in the kernel defines this platform data. It could be argued that the driver should be deleted. But that is a bit harsh I think since it seems generally useful. So this patch starts a series which repurposes it to be used with hardware nodes from device tree or ACPI. This first patch simply localize the platform data header and allocates a dummy platform data. Yes: this patch leaves the driver in a pretty useless state, but since nothing is instantiating this driver, it doesn't make it more useless than it already is. Later patches makes use of the driver. Signed-off-by: Linus Walleij --- drivers/input/mouse/gpio_mouse.c | 59 +++++++++++++++++++++++++++++++++----- include/linux/gpio_mouse.h | 61 ---------------------------------------- 2 files changed, 52 insertions(+), 68 deletions(-) delete mode 100644 include/linux/gpio_mouse.h -- 2.13.5 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c index ced07391304b..dcaba1e4fffb 100644 --- a/drivers/input/mouse/gpio_mouse.c +++ b/drivers/input/mouse/gpio_mouse.c @@ -12,8 +12,54 @@ #include #include #include -#include +#define GPIO_MOUSE_POLARITY_ACT_HIGH 0x00 +#define GPIO_MOUSE_POLARITY_ACT_LOW 0x01 + +#define GPIO_MOUSE_PIN_UP 0 +#define GPIO_MOUSE_PIN_DOWN 1 +#define GPIO_MOUSE_PIN_LEFT 2 +#define GPIO_MOUSE_PIN_RIGHT 3 +#define GPIO_MOUSE_PIN_BLEFT 4 +#define GPIO_MOUSE_PIN_BMIDDLE 5 +#define GPIO_MOUSE_PIN_BRIGHT 6 +#define GPIO_MOUSE_PIN_MAX 7 + +/** + * struct gpio_mouse_platform_data + * @scan_ms: integer in ms specifying the scan periode. + * @polarity: Pin polarity, active high or low. + * @up: GPIO line for up value. + * @down: GPIO line for down value. + * @left: GPIO line for left value. + * @right: GPIO line for right value. + * @bleft: GPIO line for left button. + * @bmiddle: GPIO line for middle button. + * @bright: GPIO line for right button. + * @pins: GPIO line numbers used for the mouse. + * + * This struct must be added to the platform_device in the board code. + * It is used by the gpio_mouse driver to setup GPIO lines and to + * calculate mouse movement. + */ +struct gpio_mouse_platform_data { + int scan_ms; + int polarity; + + union { + struct { + int up; + int down; + int left; + int right; + + int bleft; + int bmiddle; + int bright; + }; + int pins[GPIO_MOUSE_PIN_MAX]; + }; +}; /* * Timer function which is run every scan_ms ms when the device is opened. @@ -47,17 +93,16 @@ static void gpio_mouse_scan(struct input_polled_dev *dev) static int gpio_mouse_probe(struct platform_device *pdev) { - struct gpio_mouse_platform_data *pdata = dev_get_platdata(&pdev->dev); + struct device *dev = &pdev->dev; + struct gpio_mouse_platform_data *pdata; struct input_polled_dev *input_poll; struct input_dev *input; int pin, i; int error; - if (!pdata) { - dev_err(&pdev->dev, "no platform data\n"); - error = -ENXIO; - goto out; - } + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return -ENOMEM; if (pdata->scan_ms < 0) { dev_err(&pdev->dev, "invalid scan time\n"); diff --git a/include/linux/gpio_mouse.h b/include/linux/gpio_mouse.h deleted file mode 100644 index 44ed7aa14d85..000000000000 --- a/include/linux/gpio_mouse.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Driver for simulating a mouse on GPIO lines. - * - * Copyright (C) 2007 Atmel Corporation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef _GPIO_MOUSE_H -#define _GPIO_MOUSE_H - -#define GPIO_MOUSE_POLARITY_ACT_HIGH 0x00 -#define GPIO_MOUSE_POLARITY_ACT_LOW 0x01 - -#define GPIO_MOUSE_PIN_UP 0 -#define GPIO_MOUSE_PIN_DOWN 1 -#define GPIO_MOUSE_PIN_LEFT 2 -#define GPIO_MOUSE_PIN_RIGHT 3 -#define GPIO_MOUSE_PIN_BLEFT 4 -#define GPIO_MOUSE_PIN_BMIDDLE 5 -#define GPIO_MOUSE_PIN_BRIGHT 6 -#define GPIO_MOUSE_PIN_MAX 7 - -/** - * struct gpio_mouse_platform_data - * @scan_ms: integer in ms specifying the scan periode. - * @polarity: Pin polarity, active high or low. - * @up: GPIO line for up value. - * @down: GPIO line for down value. - * @left: GPIO line for left value. - * @right: GPIO line for right value. - * @bleft: GPIO line for left button. - * @bmiddle: GPIO line for middle button. - * @bright: GPIO line for right button. - * - * This struct must be added to the platform_device in the board code. - * It is used by the gpio_mouse driver to setup GPIO lines and to - * calculate mouse movement. - */ -struct gpio_mouse_platform_data { - int scan_ms; - int polarity; - - union { - struct { - int up; - int down; - int left; - int right; - - int bleft; - int bmiddle; - int bright; - }; - int pins[GPIO_MOUSE_PIN_MAX]; - }; -}; - -#endif /* _GPIO_MOUSE_H */ From patchwork Sun Sep 17 11:14:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 112835 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp2564634qgf; Sun, 17 Sep 2017 04:15:04 -0700 (PDT) X-Received: by 10.98.101.4 with SMTP id z4mr17034831pfb.6.1505646904595; Sun, 17 Sep 2017 04:15:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505646904; cv=none; d=google.com; s=arc-20160816; b=af0PFHlbBlnYoWguMKbENGS0TO9Vp9Dgx5n5+Gz14JavUiFVZJUGDLmZXcGZur0ABa FjqGdxC9QeUIGFztYtTLnUjZ35kSFKtQ8yV5YqGhqK1vFM3aG/JrT/Wwi8oYttCbqouJ iq0xmzu7XMrsnk6rZO5PFQLOnBMwy8aQT/7JgQs8kd2i+MkdpQQpPBiH3VYAfB5Tr56A T/LyNYdvRljn3YSruh4GCcUomaZkbLKoLVLDtTS4RgRlgCxX0WV0T0FqROvNQBbzMRMf fDBiTDHZsyCMm9t9SVdby8NveavQ4z8Fr5ZLR3SkgnXmGWWBQLSWJ/eSu1j/LhePRVcT v8bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=qpG5qhNuNu7pmok1/vbol2HpXfWKASl5UyNztHlUcs4=; b=cig/abKaXfGNBIQE5gzsX9tywoCOCd1JSCoywGRIY5Z7Z5/6B9eRENFhvJXDyMlrR7 /V5h5KynnGhKYRRfkC5/S+KbMuoEQozpbkHAnZUZXdpnLH5EGuhA3XGmvV25O8NllkT2 xyL61Y8ne8PahS98b40921JKdwyLdtDRImWsNUC53FMa/WyU/AQOK3YJ+J4TbDHC6WPc V/yXvxEp5cjY29DEpQbHVHekoKSIdvE9qM6DamOLuMWmE391uMEJrpNeYAnJQ9AFIq3j dJKQrhZUuquGA5TQTo81flVZNyNVbggMEAG/d1oajg9DmF7yCRb7cc+AfTvhVdLoU0P5 UNDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kuK8XDRn; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k195si3206825pgc.507.2017.09.17.04.15.04 for ; Sun, 17 Sep 2017 04:15:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kuK8XDRn; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750803AbdIQLPD (ORCPT ); Sun, 17 Sep 2017 07:15:03 -0400 Received: from mail-lf0-f43.google.com ([209.85.215.43]:54131 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750793AbdIQLPD (ORCPT ); Sun, 17 Sep 2017 07:15:03 -0400 Received: by mail-lf0-f43.google.com with SMTP id k9so5652040lfe.10 for ; Sun, 17 Sep 2017 04:15:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EdVR2duwb53s0pWO62hSBrmUQnUJhGMagabVabXNh7Q=; b=kuK8XDRnnxF7rA+hyZ6rKlZZwLdo8CdpMzbB53YApaJaS5LVCt8qkb13cmz/SiGjx+ stWSSG5Ain5VtrYUqsmWbehH4B8J6ffv2EaBleb+nE8I+auhOVZPDM05tWr7ab3vLWUE uQ0ywygfgUA9zIqLBAs4pRLSgishC3V04UzYM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EdVR2duwb53s0pWO62hSBrmUQnUJhGMagabVabXNh7Q=; b=hFhoFRpcqBD8bN8+h/+ZO8mB09bhPYjrmMhtUYaI26ZChHVA8L/iXODxHvwY4rZ17q dvYFALTT/qWJceSa+F/31rMrJ0zxmlM5/yhIMVfMFENZyEezNAj4hvfuWU9ObCD6m+/f tJDQIqFl34BHJP9cpdoXBGjR56EnR5NEL4y64/TATx+M020zE0ZuGshJFx1zTvtjvAgy W2WQJL+CK72PUaGw42wWl7ovr6XFQLF8CAhajH0mtpv6xYrK0MtvcTdSSrb0dcyv7HWh mZD+1KDsLmY4tWh6e5Vb6UnVqv01AjtYIPraCQHBA3ctL6HnhKpFjExoXRLgM8/AkzSw eYMA== X-Gm-Message-State: AHPjjUiZwGkyb5GQoymCP8+C9d0/3RnWkDzBpS9MAbdNyDgAN7ME5Lu2 IXTaAD/LZke46y5UXDCVJg== X-Google-Smtp-Source: AOwi7QC+34aB8BHH6qMmscB08U2BhcQ6cAKTvHROaPiliz4HEinvDdVLyMgNnBhS7MDlHDLoBgeuuA== X-Received: by 10.46.13.18 with SMTP id 18mr12193645ljn.25.1505646901344; Sun, 17 Sep 2017 04:15:01 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-2209e055.014-348-6c756e10.cust.bredbandsbolaget.se. [85.224.9.34]) by smtp.gmail.com with ESMTPSA id h83sm1007069lfi.16.2017.09.17.04.15.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 17 Sep 2017 04:15:00 -0700 (PDT) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org, Hans-Christian Noren Egtvedt Cc: Linus Walleij Subject: [PATCH 2/5] input: mouse: Rename GPIO mouse variables Date: Sun, 17 Sep 2017 13:14:42 +0200 Message-Id: <20170917111445.30880-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170917111445.30880-1-linus.walleij@linaro.org> References: <20170917111445.30880-1-linus.walleij@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use more apropriate names for the "platform data" which is now just a simple state container for the GPIO mouse. Signed-off-by: Linus Walleij --- drivers/input/mouse/gpio_mouse.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) -- 2.13.5 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c index dcaba1e4fffb..d1914bb3531f 100644 --- a/drivers/input/mouse/gpio_mouse.c +++ b/drivers/input/mouse/gpio_mouse.c @@ -26,7 +26,7 @@ #define GPIO_MOUSE_PIN_MAX 7 /** - * struct gpio_mouse_platform_data + * struct gpio_mouse * @scan_ms: integer in ms specifying the scan periode. * @polarity: Pin polarity, active high or low. * @up: GPIO line for up value. @@ -42,7 +42,7 @@ * It is used by the gpio_mouse driver to setup GPIO lines and to * calculate mouse movement. */ -struct gpio_mouse_platform_data { +struct gpio_mouse { int scan_ms; int polarity; @@ -67,7 +67,7 @@ struct gpio_mouse_platform_data { */ static void gpio_mouse_scan(struct input_polled_dev *dev) { - struct gpio_mouse_platform_data *gpio = dev->private; + struct gpio_mouse *gpio = dev->private; struct input_dev *input = dev->input; int x, y; @@ -94,24 +94,24 @@ static void gpio_mouse_scan(struct input_polled_dev *dev) static int gpio_mouse_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct gpio_mouse_platform_data *pdata; + struct gpio_mouse *gmouse; struct input_polled_dev *input_poll; struct input_dev *input; int pin, i; int error; - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) + gmouse = devm_kzalloc(dev, sizeof(*gmouse), GFP_KERNEL); + if (!gmouse) return -ENOMEM; - if (pdata->scan_ms < 0) { + if (gmouse->scan_ms < 0) { dev_err(&pdev->dev, "invalid scan time\n"); error = -EINVAL; goto out; } for (i = 0; i < GPIO_MOUSE_PIN_MAX; i++) { - pin = pdata->pins[i]; + pin = gmouse->pins[i]; if (pin < 0) { @@ -148,9 +148,9 @@ static int gpio_mouse_probe(struct platform_device *pdev) platform_set_drvdata(pdev, input_poll); /* set input-polldev handlers */ - input_poll->private = pdata; + input_poll->private = gmouse; input_poll->poll = gpio_mouse_scan; - input_poll->poll_interval = pdata->scan_ms; + input_poll->poll_interval = gmouse->scan_ms; input = input_poll->input; input->name = pdev->name; @@ -159,11 +159,11 @@ static int gpio_mouse_probe(struct platform_device *pdev) input_set_capability(input, EV_REL, REL_X); input_set_capability(input, EV_REL, REL_Y); - if (pdata->bleft >= 0) + if (gmouse->bleft >= 0) input_set_capability(input, EV_KEY, BTN_LEFT); - if (pdata->bmiddle >= 0) + if (gmouse->bmiddle >= 0) input_set_capability(input, EV_KEY, BTN_MIDDLE); - if (pdata->bright >= 0) + if (gmouse->bright >= 0) input_set_capability(input, EV_KEY, BTN_RIGHT); error = input_register_polled_device(input_poll); @@ -173,10 +173,10 @@ static int gpio_mouse_probe(struct platform_device *pdev) } dev_dbg(&pdev->dev, "%d ms scan time, buttons: %s%s%s\n", - pdata->scan_ms, - pdata->bleft < 0 ? "" : "left ", - pdata->bmiddle < 0 ? "" : "middle ", - pdata->bright < 0 ? "" : "right"); + gmouse->scan_ms, + gmouse->bleft < 0 ? "" : "left ", + gmouse->bmiddle < 0 ? "" : "middle ", + gmouse->bright < 0 ? "" : "right"); return 0; @@ -185,7 +185,7 @@ static int gpio_mouse_probe(struct platform_device *pdev) out_free_gpios: while (--i >= 0) { - pin = pdata->pins[i]; + pin = gmouse->pins[i]; if (pin) gpio_free(pin); } @@ -196,14 +196,14 @@ static int gpio_mouse_probe(struct platform_device *pdev) static int gpio_mouse_remove(struct platform_device *pdev) { struct input_polled_dev *input = platform_get_drvdata(pdev); - struct gpio_mouse_platform_data *pdata = input->private; + struct gpio_mouse *gmouse = input->private; int pin, i; input_unregister_polled_device(input); input_free_polled_device(input); for (i = 0; i < GPIO_MOUSE_PIN_MAX; i++) { - pin = pdata->pins[i]; + pin = gmouse->pins[i]; if (pin >= 0) gpio_free(pin); } From patchwork Sun Sep 17 11:14:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 112837 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp2564684qgf; Sun, 17 Sep 2017 04:15:09 -0700 (PDT) X-Received: by 10.99.95.71 with SMTP id t68mr28973620pgb.432.1505646909381; Sun, 17 Sep 2017 04:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505646909; cv=none; d=google.com; s=arc-20160816; b=F0oXenmzU76Piavi/xB4OJel//GSEo46wAisYZfcX5AR22CfL9dkGWJovs80IjJoio SHuNFrKxFqEi16LCAAhDk5N8YWQVRbodyHCIztENMUqitYPs4jziIbStdolvXbIPTRea Acbzhp55pcGHmMHpIa96TPw3UHHAd9ybkxxRzqpayRHqT0hH5dT+FlLYxiPClex9V8pl 2UqOdL1Nrj8xzFItcsy9Bm20dCZr0n/F///zSNcyikRHdaiC/Qscy7smJXN5I5m4xmBR Pjz9s8i/OvPsfxTWDm6r/dtDeqSjKRQ2d/mIKXyDM4li34wR6boHnRgyzXMczarzJtTF gY0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=3FUXika7pzodtkSmCnfK6pYjxn2uLy3EFesP7NupQCk=; b=TZ/HvH4XAtH6awTJkLj8FFWuyZp2PNHmCV6qv3ySoVg6fWEXLwNXk6UkbdL4c+Z56k stfzD/laMAl6QFksJm99RPr+x0TsNVQoK2tt/t+8g2fZuycaErkuvQvPKJa0I+6gjwdC nohEAUTNa+cf8fq2clm7fUY0347s/i7KAOoywCMP4/vRIOYphI0ueupV2F5Lmem90GyQ +0wIn1Qbyf0DIusS9C4Jon589YT/XrEjB/wLTsolrYPTjj2zwbGXyzs0r+hQBwTiiPn7 n13aTBV4R2y1SYmtaWHzV4N291nRaObpO1IB3EA/BQHgt3LIesotIdVdPynVHzyxx26b xovQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Z8Np/j8k; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s18si1203814plp.783.2017.09.17.04.15.09 for ; Sun, 17 Sep 2017 04:15:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Z8Np/j8k; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750995AbdIQLPI (ORCPT ); Sun, 17 Sep 2017 07:15:08 -0400 Received: from mail-lf0-f52.google.com ([209.85.215.52]:43206 "EHLO mail-lf0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750860AbdIQLPH (ORCPT ); Sun, 17 Sep 2017 07:15:07 -0400 Received: by mail-lf0-f52.google.com with SMTP id c80so5677662lfh.0 for ; Sun, 17 Sep 2017 04:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Td1mttxSZVlk8nvoWALBhYXonq/FUBb1N2+xysFNTok=; b=Z8Np/j8kCpqPMVxdlVwgx2ipDgYHpKrAIhM9zjdzFodlR4IQfpCv2Ckt4T+b4zc8xK Sy7hq1I/LlrTQOsLqTss+U6QvBXAeh0LOJT0HzWOUy0FERmmximE3kAG68REJCJlknpR lrw3yCVdLgwfYDW7pEAzaMeXGHlug/FfYwBHY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Td1mttxSZVlk8nvoWALBhYXonq/FUBb1N2+xysFNTok=; b=HRzptGr473vdiY9S+hoPRIs2cHmo9kpXCvt9TTYBECvhkRX/EFRskAwAUKLu9fv2Pp zBvUwauBq5i6zLBkpuUKyF0Mb76qwBowa5TSy8dOEv2d5RKeisF7vXXjFCANrOOSSlwI 0lxW+sWDtX7lPyQp+oaQTcVo9n5ixnjr0IXKDPr3zUNv5TdTDnJCk+5dYzx+GC4Mmlwk icCsF/AyC/sciUO9jiZTaNirFj/vcOHkuDP41GnbjYtUFRql7IVqWVhF+iEeOQ6OMTmE qhnbZ02mcSNIvBPBy8/412tvYff+tvyKJQU4OCHaCKrITWZxmFFTdpjrR3niZn7R32HK d4gA== X-Gm-Message-State: AHPjjUg23sBcgXlRLYvOHfpUxgrNMt9+B+B41O3eSAhO6xXpKJUQ3qGB JQHdD2jloGNjhd9s X-Google-Smtp-Source: ADKCNb7K5K3KwWaviVEpPpQ7/18A5OMeNLywaV8N52Abxx6459y2/IpMfmugMO2kaS2qnIoor4kAtA== X-Received: by 10.46.23.24 with SMTP id l24mr12658092lje.92.1505646906019; Sun, 17 Sep 2017 04:15:06 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-2209e055.014-348-6c756e10.cust.bredbandsbolaget.se. [85.224.9.34]) by smtp.gmail.com with ESMTPSA id h83sm1007069lfi.16.2017.09.17.04.15.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 17 Sep 2017 04:15:05 -0700 (PDT) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org, Hans-Christian Noren Egtvedt Cc: Linus Walleij Subject: [PATCH 4/5] input: mouse: Convert GPIO mouse to use descriptors Date: Sun, 17 Sep 2017 13:14:44 +0200 Message-Id: <20170917111445.30880-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170917111445.30880-1-linus.walleij@linaro.org> References: <20170917111445.30880-1-linus.walleij@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This converts the GPIO mouse to use descriptors and fwnode properties. The polarity settings go out the window since GPIO descriptor already know about polarity so this should be configured in device tree or ACPI or similar. Set scanning interval by default to 50ms if not found as a property on the device. Signed-off-by: Linus Walleij --- drivers/input/mouse/gpio_mouse.c | 171 ++++++++++++++------------------------- 1 file changed, 60 insertions(+), 111 deletions(-) -- 2.13.5 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c index d1914bb3531f..7bd2a8ac6e6e 100644 --- a/drivers/input/mouse/gpio_mouse.c +++ b/drivers/input/mouse/gpio_mouse.c @@ -2,6 +2,7 @@ * Driver for simulating a mouse on GPIO lines. * * Copyright (C) 2007 Atmel Corporation + * Copyright (C) 2017 Linus Walleij * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -11,24 +12,12 @@ #include #include #include -#include - -#define GPIO_MOUSE_POLARITY_ACT_HIGH 0x00 -#define GPIO_MOUSE_POLARITY_ACT_LOW 0x01 - -#define GPIO_MOUSE_PIN_UP 0 -#define GPIO_MOUSE_PIN_DOWN 1 -#define GPIO_MOUSE_PIN_LEFT 2 -#define GPIO_MOUSE_PIN_RIGHT 3 -#define GPIO_MOUSE_PIN_BLEFT 4 -#define GPIO_MOUSE_PIN_BMIDDLE 5 -#define GPIO_MOUSE_PIN_BRIGHT 6 -#define GPIO_MOUSE_PIN_MAX 7 +#include +#include /** * struct gpio_mouse - * @scan_ms: integer in ms specifying the scan periode. - * @polarity: Pin polarity, active high or low. + * @scan_ms: the scan interval in milliseconds. * @up: GPIO line for up value. * @down: GPIO line for down value. * @left: GPIO line for left value. @@ -36,29 +25,20 @@ * @bleft: GPIO line for left button. * @bmiddle: GPIO line for middle button. * @bright: GPIO line for right button. - * @pins: GPIO line numbers used for the mouse. * * This struct must be added to the platform_device in the board code. * It is used by the gpio_mouse driver to setup GPIO lines and to * calculate mouse movement. */ struct gpio_mouse { - int scan_ms; - int polarity; - - union { - struct { - int up; - int down; - int left; - int right; - - int bleft; - int bmiddle; - int bright; - }; - int pins[GPIO_MOUSE_PIN_MAX]; - }; + u32 scan_ms; + struct gpio_desc *up; + struct gpio_desc *down; + struct gpio_desc *left; + struct gpio_desc *right; + struct gpio_desc *bleft; + struct gpio_desc *bmiddle; + struct gpio_desc *bright; }; /* @@ -71,20 +51,18 @@ static void gpio_mouse_scan(struct input_polled_dev *dev) struct input_dev *input = dev->input; int x, y; - if (gpio->bleft >= 0) + if (!IS_ERR(gpio->bleft)) input_report_key(input, BTN_LEFT, - gpio_get_value(gpio->bleft) ^ gpio->polarity); - if (gpio->bmiddle >= 0) + gpiod_get_value(gpio->bleft)); + if (!IS_ERR(gpio->bmiddle)) input_report_key(input, BTN_MIDDLE, - gpio_get_value(gpio->bmiddle) ^ gpio->polarity); - if (gpio->bright >= 0) + gpiod_get_value(gpio->bmiddle)); + if (!IS_ERR(gpio->bright)) input_report_key(input, BTN_RIGHT, - gpio_get_value(gpio->bright) ^ gpio->polarity); + gpiod_get_value(gpio->bright)); - x = (gpio_get_value(gpio->right) ^ gpio->polarity) - - (gpio_get_value(gpio->left) ^ gpio->polarity); - y = (gpio_get_value(gpio->down) ^ gpio->polarity) - - (gpio_get_value(gpio->up) ^ gpio->polarity); + x = gpiod_get_value(gpio->right) - gpiod_get_value(gpio->left); + y = gpiod_get_value(gpio->down) - gpiod_get_value(gpio->up); input_report_rel(input, REL_X, x); input_report_rel(input, REL_Y, y); @@ -97,52 +75,45 @@ static int gpio_mouse_probe(struct platform_device *pdev) struct gpio_mouse *gmouse; struct input_polled_dev *input_poll; struct input_dev *input; - int pin, i; - int error; + int ret; gmouse = devm_kzalloc(dev, sizeof(*gmouse), GFP_KERNEL); if (!gmouse) return -ENOMEM; - if (gmouse->scan_ms < 0) { - dev_err(&pdev->dev, "invalid scan time\n"); - error = -EINVAL; - goto out; - } - - for (i = 0; i < GPIO_MOUSE_PIN_MAX; i++) { - pin = gmouse->pins[i]; - - if (pin < 0) { - - if (i <= GPIO_MOUSE_PIN_RIGHT) { - /* Mouse direction is required. */ - dev_err(&pdev->dev, - "missing GPIO for directions\n"); - error = -EINVAL; - goto out_free_gpios; - } - - if (i == GPIO_MOUSE_PIN_BLEFT) - dev_dbg(&pdev->dev, "no left button defined\n"); - - } else { - error = gpio_request(pin, "gpio_mouse"); - if (error) { - dev_err(&pdev->dev, "fail %d pin (%d idx)\n", - pin, i); - goto out_free_gpios; - } - - gpio_direction_input(pin); - } + /* Assign some default scanning time */ + ret = device_property_read_u32(dev, "scan-interval", + &gmouse->scan_ms); + if (ret || (gmouse->scan_ms == 0)) { + dev_err(dev, "invalid scan time, set to 50 ms\n"); + gmouse->scan_ms = 50; } - input_poll = input_allocate_polled_device(); + /* + * These are compulsory GPIOs so bail out if any of them are + * not found. + */ + gmouse->up = devm_gpiod_get(dev, "up", GPIOD_IN); + if (IS_ERR(gmouse->up)) + return PTR_ERR(gmouse->up); + gmouse->down = devm_gpiod_get(dev, "down", GPIOD_IN); + if (IS_ERR(gmouse->down)) + return PTR_ERR(gmouse->down); + gmouse->left = devm_gpiod_get(dev, "left", GPIOD_IN); + if (IS_ERR(gmouse->left)) + return PTR_ERR(gmouse->left); + gmouse->right = devm_gpiod_get(dev, "right", GPIOD_IN); + if (IS_ERR(gmouse->right)) + return PTR_ERR(gmouse->right); + + gmouse->bleft = devm_gpiod_get(dev, "button-left", GPIOD_IN); + gmouse->bmiddle = devm_gpiod_get(dev, "button-middle", GPIOD_IN); + gmouse->bright = devm_gpiod_get(dev, "button-right", GPIOD_IN); + + input_poll = devm_input_allocate_polled_device(dev); if (!input_poll) { - dev_err(&pdev->dev, "not enough memory for input device\n"); - error = -ENOMEM; - goto out_free_gpios; + dev_err(dev, "not enough memory for input device\n"); + return -ENOMEM; } platform_set_drvdata(pdev, input_poll); @@ -166,48 +137,26 @@ static int gpio_mouse_probe(struct platform_device *pdev) if (gmouse->bright >= 0) input_set_capability(input, EV_KEY, BTN_RIGHT); - error = input_register_polled_device(input_poll); - if (error) { - dev_err(&pdev->dev, "could not register input device\n"); - goto out_free_polldev; + ret = input_register_polled_device(input_poll); + if (ret) { + dev_err(dev, "could not register input device\n"); + return ret; } - dev_dbg(&pdev->dev, "%d ms scan time, buttons: %s%s%s\n", - gmouse->scan_ms, - gmouse->bleft < 0 ? "" : "left ", - gmouse->bmiddle < 0 ? "" : "middle ", - gmouse->bright < 0 ? "" : "right"); + dev_dbg(dev, "%d ms scan time, buttons: %s%s%s\n", + gmouse->scan_ms, + IS_ERR(gmouse->bleft) ? "" : "left ", + IS_ERR(gmouse->bmiddle) ? "" : "middle ", + IS_ERR(gmouse->bright) ? "" : "right"); return 0; - - out_free_polldev: - input_free_polled_device(input_poll); - - out_free_gpios: - while (--i >= 0) { - pin = gmouse->pins[i]; - if (pin) - gpio_free(pin); - } - out: - return error; } static int gpio_mouse_remove(struct platform_device *pdev) { struct input_polled_dev *input = platform_get_drvdata(pdev); - struct gpio_mouse *gmouse = input->private; - int pin, i; input_unregister_polled_device(input); - input_free_polled_device(input); - - for (i = 0; i < GPIO_MOUSE_PIN_MAX; i++) { - pin = gmouse->pins[i]; - if (pin >= 0) - gpio_free(pin); - } - return 0; } From patchwork Sun Sep 17 11:14:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 112838 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp2564706qgf; Sun, 17 Sep 2017 04:15:11 -0700 (PDT) X-Received: by 10.84.230.229 with SMTP id e92mr33557215plk.259.1505646910945; Sun, 17 Sep 2017 04:15:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505646910; cv=none; d=google.com; s=arc-20160816; b=mDu1hHJ1qz8PvTVnMcE+IV/gcVxYwMyuB5IWFMG8Mb1K+o/ZZNnvbJrdKKYabAgZQv MmUyyMKcaAtiy4cZN7XBAouu0cqcPr2r25KI5F4msg5wqcW7maegbbSkFMLFbWz1jJrh 0tdIolrikztyNkkBxvRRe+9R6Naj/Cz/YcWRwidAyo138LivOFo2iKMT8SdLzumRUTOg uG/Fei9WRuSsKyiDXxhdLWx1GrK8vx+3r+sC6vui0Q4jmjjrlSRIK15NXIsIACXVXaOy 6nzIWGBwnNoKDQIaU/O/utXBdGp8Ftcf0dC9931DVkl126NdFRBrSlHh+f6OR5aUgIou +Izg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=xwo31OF/JuUhI2g/0AIDC3Zhxh+XJM2gpihzSwXbxP0=; b=s9dtKwOIRSryTlB9WwPTjVNTlcmkA5uRBYFhPyGGmwxgctUZTyVa/q3gHGc6yYvXfv LO73iIx8G0B/B2w07ZsazKi3Hl+SERtFFMtnjt83l8XQuAJf2qjsqQ+T1W/ombhsh/vj Sp9TUlOcNXmy8/0XBhjHnkAbvSm6SaO6a60uh833Gwfnnh7VAvyI7EINMhi77iiT8tcQ 2mHSdu7vjAA6FO7Iy+mIdFZR0f0+jSMVPBGVSHaen1dFzTNYGW5NHTuo0whLHeMtPyKn AdLnl9mqI7mBfSAyVd3T2JEvMQysym2efJ/RgI5xr5f0GuMD6fDBqbby/4oM05oy7kAW o04Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ji0WLULF; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s18si1203814plp.783.2017.09.17.04.15.10 for ; Sun, 17 Sep 2017 04:15:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ji0WLULF; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751239AbdIQLPK (ORCPT ); Sun, 17 Sep 2017 07:15:10 -0400 Received: from mail-lf0-f44.google.com ([209.85.215.44]:54136 "EHLO mail-lf0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750885AbdIQLPJ (ORCPT ); Sun, 17 Sep 2017 07:15:09 -0400 Received: by mail-lf0-f44.google.com with SMTP id k9so5652128lfe.10 for ; Sun, 17 Sep 2017 04:15:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hO17tlTOQ1LOlKKn/CQjeqz+oGeGllO7H1HElcrN9gc=; b=ji0WLULFyHunFe9yBnidbBxTBTpAkicnxZ+sJ4qSC6tob4hxqXXdUmzXofKlhOsytQ Skjx1lxI7Z8ZGJf9tJlA0Ad0t3CBax5MFc3fDTKiEiJeL53nMM79sUP3xbEmNfrq12aG xyS8RA0DjZiPdAikS+yaP4AIbGdTXHFrgf5L0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hO17tlTOQ1LOlKKn/CQjeqz+oGeGllO7H1HElcrN9gc=; b=NAR+JwT6vDVggPVRPSEgCgGqhOh7483XlqrZ2QeLCYEKaxEAssCHQSHuzlSDphCg7P pNwYHJjst/Sy1qW1B+DGS6i+G2nHk8X/mlhnG8bxQ+9jtpP2zpQdvOi1xFM8wHGsrTfi /3z548tzzeu+9QaKGnabbiyMyz5ZjyH9mQUhyXxynIGePVQZHvLozFRJKlqZJH8SFCht 4LPD/VAqz0JIKlhksoYu8bB92oCTlOpKaZVRjIbeY3w7Xsva5zML0QPKG2TB/CDV7LxD okSk2goKRcHcp9HSn1WqkYAdKHRuT7gWog7SABZXTF8MzYR79JygB9Ayb7YcokW/AIKZ /Akg== X-Gm-Message-State: AHPjjUhwF/HsQ4tA/KJv0BuDRyfOb9UtlAGYQDem8ohrJ7duIRViy1GX uvObzyy46ToqFqPa X-Google-Smtp-Source: AOwi7QBZx1TC6LeaGaF13JeJk+3zEynLj8OmGKoTg+yj1fyQU16jyOM/8YFZJ1AGdPjzSCVi8CkuSw== X-Received: by 10.46.2.139 with SMTP id y11mr6665871lje.183.1505646908376; Sun, 17 Sep 2017 04:15:08 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-2209e055.014-348-6c756e10.cust.bredbandsbolaget.se. [85.224.9.34]) by smtp.gmail.com with ESMTPSA id h83sm1007069lfi.16.2017.09.17.04.15.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 17 Sep 2017 04:15:07 -0700 (PDT) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org, Hans-Christian Noren Egtvedt Cc: Linus Walleij Subject: [PATCH 5/5] input: mouse: Add device tree probing to GPIO mouse Date: Sun, 17 Sep 2017 13:14:45 +0200 Message-Id: <20170917111445.30880-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170917111445.30880-1-linus.walleij@linaro.org> References: <20170917111445.30880-1-linus.walleij@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This makes the GPIO mouse probe nicely from the device tree if found in a tree. As the driver uses device properties it can easily be amended to also probe from ACPI devices. Signed-off-by: Linus Walleij --- drivers/input/mouse/gpio_mouse.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.13.5 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c index 7bd2a8ac6e6e..bf748efb270a 100644 --- a/drivers/input/mouse/gpio_mouse.c +++ b/drivers/input/mouse/gpio_mouse.c @@ -14,6 +14,7 @@ #include #include #include +#include /** * struct gpio_mouse @@ -160,11 +161,18 @@ static int gpio_mouse_remove(struct platform_device *pdev) return 0; } +static const struct of_device_id gpio_mouse_of_match[] = { + { .compatible = "gpio-mouse", }, + { }, +}; +MODULE_DEVICE_TABLE(of, gpio_mouse_of_match); + static struct platform_driver gpio_mouse_device_driver = { .probe = gpio_mouse_probe, .remove = gpio_mouse_remove, .driver = { .name = "gpio_mouse", + .of_match_table = gpio_mouse_of_match, } }; module_platform_driver(gpio_mouse_device_driver); @@ -173,4 +181,3 @@ MODULE_AUTHOR("Hans-Christian Egtvedt "); MODULE_DESCRIPTION("GPIO mouse driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:gpio_mouse"); /* work with hotplug and coldplug */ -