From patchwork Mon Sep 25 16:34:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 114174 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp2803760qgf; Mon, 25 Sep 2017 09:34:42 -0700 (PDT) X-Received: by 10.101.86.79 with SMTP id m15mr8205903pgs.157.1506357281919; Mon, 25 Sep 2017 09:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506357281; cv=none; d=google.com; s=arc-20160816; b=JM0m6VDtreQ7tGmlLQ5M9LD2W0bTIqGl18LPvhqXSgJcDoewMItjUhuJK+INQ6A7Jv iMQpByBVhwhZfVszIkYi9/b0LLZJd3e5uqz8kI2FnemQPRFXi62le/GG6ONE+avQSsz9 FAbLAusr3Vtj3m429r7W/i6eOlEFc8fGpU/gxlJakHZxwmRhssnpxV8WG3WysqVAaMON exB3+KyA/teMwW36ReX5w5DW3J4ylAaQBfb6jmi+KVXrmIWOYyox5RFQhKPs0u8Z4gC2 Tkmh0JeydEvTxCqHCt74imbvGXAN910H6AQUBBxRUGihJuMsIYudNHqsMHSiXMObaclU QDIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=PViTOxUjsJjWigeNy2JSTtWQ+OVnjqEFT1nvDqFpKPg=; b=CTDi0Cy3bvLjedzzH0BD2C4Z2LMDtWzVOxj6IDrN/1Qaknzf3xtaHcTQsJ/5mQXfCW G03tcrSl2m/gvoUr2fvW3chUadoo3RvLG8bMUZ5eU/bqwT029w88YtfThRS/1OlDEpqj CuDBtt4GYKgwqLqT+xOuoDF1FchoGnEshA6WS+uCrUQUzbE/KaJ3SKUpCrWMCxlIMojv 8cMAG8GlTekA3z/KlzDRmHLbDXAy6EN9LtBPRP9EphK12m5aYLRcDyNtjmKnmWWTMBFg m190753RqkG/x7bOFwmxQwjgJaLoi1Nv+3NywgWRj13GsxbxmS+CAQGFlONASKulwZAG SgwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Jrbz93ce; 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 r7si4373999ple.652.2017.09.25.09.34.41 for ; Mon, 25 Sep 2017 09:34:41 -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=Jrbz93ce; 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 S965161AbdIYQek (ORCPT ); Mon, 25 Sep 2017 12:34:40 -0400 Received: from mail-pg0-f47.google.com ([74.125.83.47]:52314 "EHLO mail-pg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964935AbdIYQej (ORCPT ); Mon, 25 Sep 2017 12:34:39 -0400 Received: by mail-pg0-f47.google.com with SMTP id i195so4264750pgd.9 for ; Mon, 25 Sep 2017 09:34:39 -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; bh=0dDQVrgElU7wFnPSTJX0s5kxTVGvFUv3I8ofiYNIqGE=; b=Jrbz93cettaSxmNackcxXBNInTPNhV4YQuwQ61tDYAYSDAkvERx2R/V/BO+215BGWI bdjeWLGJ7t2ICzpvM0GC96wcALZ6UcKsE5yX4eBAmr7PPNRwP9AhNDl58llYX4xwhP/Z +hQAsSVVKXvvHdFU4ZqtD60UG0PHtIOYxh1vE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0dDQVrgElU7wFnPSTJX0s5kxTVGvFUv3I8ofiYNIqGE=; b=SmENlu4opt2jeF6txd4bIlRZXles3mAxhVZU5DH58Wiiu/rXUL4KLbMTng4BdidN4e 3o+9bUksHY4EPxQto12fDdi1yYA0rR39uh4xc2iHj474hcx/OA/3a9YR9wJ9LlLcaDyg yBF/07V278sTiEED63l35vetVnyAIjrUB7MYYWq2hSdoE2tPGUqp1I/RAd65M71Y2Fwu eVfHyM8MBz3hP+RgNWk3nAOXJoZxzLc0GYfUgWgecLArMISacIOmUcyC3i+DLHw+G28X ciQLRxV75fPWIicjjcLvIdwm7ljIYxBFcGeHBjnJ3ppUPC7SHJDXSstLM082Ks6oDzO0 cj9A== X-Gm-Message-State: AHPjjUgrNZ63fSuB3RE2xS5n6eOFN5u8yQnKcZy5MOjHAOOO/EBDk6Uq SMf5Ui4sg10qJZtM0/Ua6eSBpA== X-Google-Smtp-Source: AOwi7QAtXyagAdiAwgrNP65sWzz+htwBIpaI6+ieOkkpdho7L/SAOZXB21yT4vQ516pZirTgm/VPhQ== X-Received: by 10.98.144.89 with SMTP id a86mr8033534pfe.64.1506357279282; Mon, 25 Sep 2017 09:34:39 -0700 (PDT) Received: from localhost.localdomain ([70.35.39.2]) by smtp.gmail.com with ESMTPSA id j1sm12004413pfc.169.2017.09.25.09.34.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Sep 2017 09:34:38 -0700 (PDT) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: Hans-Christian Noren Egtvedt , Linus Walleij Subject: [PATCH 1/5 v2] input: mouse: Kill off platform data for GPIO mouse Date: Mon, 25 Sep 2017 18:34:26 +0200 Message-Id: <20170925163430.22397-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.5 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. Acked-by: Hans-Christian Noren Egtvedt Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Collect Hand-Christian's ACK --- 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 Mon Sep 25 16:34:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 114175 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp2803833qgf; Mon, 25 Sep 2017 09:34:46 -0700 (PDT) X-Received: by 10.99.124.67 with SMTP id l3mr8047202pgn.296.1506357286337; Mon, 25 Sep 2017 09:34:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506357286; cv=none; d=google.com; s=arc-20160816; b=h8AfuD4DngmsiPY6awYBcMPbdLeLR49Xq+ZfOYXHXN6I67zFnC6pxhKZv93dcC/dQ9 74K6+bai69zMmVbrkjDZccjlmarDvYqutNBDj2Zfbjp8bGPxNQuyR5+4m7XUOciz9we6 YeMgy/NNtc9kHCejbubY3ZZ/KesO/UyDY0iMlk8DtxIElf4MVkeLSwbjowWbj6GW/vSV PERkLb115f+USdYhZ6CC78RkKkf40G8WVkE+jxRbT0hqiRVo4qo0CtwHt8V6au+TsmXM wBkAPKBPf90YSX0HtmJeXC5DfGn9s+6C2kdipWceDBkcM9gNx31IKQOt8QmYWor1/n3I D0xg== 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=++WXVuk/eGYEkxr5LB5txQk0BtE4Q2fKOmN/nsC0QJ4=; b=rv0fBLZVYOh5U+VqFSA6qTLcfHNArOzp4QlxKjgdu20XrQ5aCTKARn9lH/Ingw4NIL BmuK6bsDeScqMpwKKD07wYkBOgoElHapXmH3DveEkBP2JboXGfPQPNfGhHIVq6YQgQmE CSPrIlD0zq3oBXx4jT3yTN9YO+qi0UyzpU4BnadVI9WWz9rBIEV6GHHNGyA+GlmSGOj3 98LwTzoqeiwYZcSDxiSMXt4JU7LqIqjuZE11N9yFx66KtUZ4BpGy9hvqMKDFULIBv5PF cnYIpK+71gXFRZEOlWe/TbCW9EgOlGqz9XNZDYQH6OHBsy0RuMrQLUF8MO9KPD/mOWFs MbGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=dWC1uVcy; 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 y11si3806375pfi.187.2017.09.25.09.34.46 for ; Mon, 25 Sep 2017 09:34:46 -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=dWC1uVcy; 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 S965158AbdIYQen (ORCPT ); Mon, 25 Sep 2017 12:34:43 -0400 Received: from mail-pg0-f49.google.com ([74.125.83.49]:48085 "EHLO mail-pg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965206AbdIYQem (ORCPT ); Mon, 25 Sep 2017 12:34:42 -0400 Received: by mail-pg0-f49.google.com with SMTP id d8so4269949pgt.4 for ; Mon, 25 Sep 2017 09:34:42 -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=q9kWirE1j7bgWzMMXfN0WB65WOr/Lq+22gcPQtKhpSU=; b=dWC1uVcyXqojHIy9SBhCLdrRlt9++JDT3c+tsLe/65Jiq/TmJ1jJSqzth8yzhm7Hre gOx8u3gVBi65LnqBeG5pmcgLxQGQSDT4BRZI5ADK1aVjwCg/yOOlwC9iwEZnkCrhntNH kqVXVSwegAdPECSuvG9b+Cq9MtYRiPb9A6Tig= 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=q9kWirE1j7bgWzMMXfN0WB65WOr/Lq+22gcPQtKhpSU=; b=WFnF0hGStKqTRA1xqWS/JRigMI0vsGbTpyixNEzOGmo0TjJ+nKn1IKMZWt9+3z/zSg 4bnjTKckMQrxu85fQGeSG+3r+x7sxylt5H35n97H9C+INK1zph1gE+hrv2ltcbRk//5+ otAELcVAmbNqdG21Z5X7rWY8FIQiAmX8Y0PjMrOPhv3Uz9bxxekdYjje/WUaYBykkh5G JqRm47VSxqzvYJ8g70vMw4lojhUaD/lGTt9x+BIOnkJG11jVDx5puXPmeE9573OIeZ7K rivCrQ3SOHNQLgxetxcC25UvZKIssrbnyhqdBRoTsqNVV9FkQ30eHTt+TxdQcDEPPKwD r/bA== X-Gm-Message-State: AHPjjUjNhm0iM7CWa4S4s3g/o1J+a2mDxFc0RNAoaGOUWdXqajquyhU5 5p5ABESbZ4/DpArVsLS/+FvWRA== X-Google-Smtp-Source: AOwi7QCwSnZFCHiC80uEL5ojQulusnSSrWKIaNFxXbjYiSs7ohYsBbAh3gtElEozL1MhFEcHz70ikA== X-Received: by 10.98.78.203 with SMTP id c194mr8216962pfb.152.1506357281852; Mon, 25 Sep 2017 09:34:41 -0700 (PDT) Received: from localhost.localdomain ([70.35.39.2]) by smtp.gmail.com with ESMTPSA id j1sm12004413pfc.169.2017.09.25.09.34.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Sep 2017 09:34:40 -0700 (PDT) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: Hans-Christian Noren Egtvedt , Linus Walleij Subject: [PATCH 2/5 v2] input: mouse: Rename GPIO mouse variables Date: Mon, 25 Sep 2017 18:34:27 +0200 Message-Id: <20170925163430.22397-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170925163430.22397-1-linus.walleij@linaro.org> References: <20170925163430.22397-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. Acked-by: Hans-Christian Noren Egtvedt Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Collect Hand-Christian's ACK. --- 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 Mon Sep 25 16:34:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 114177 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp2803879qgf; Mon, 25 Sep 2017 09:34:50 -0700 (PDT) X-Received: by 10.84.192.37 with SMTP id b34mr7989982pld.279.1506357290854; Mon, 25 Sep 2017 09:34:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506357290; cv=none; d=google.com; s=arc-20160816; b=wTGCzyr5bcwMPCJr88scruGZGMEme5PwEKwM7ERs8UnUlJDbnpoZObFFZEp27S+5u1 U+zbHWcWgBxgHqYjzzbdLuu65TN0mB7RRLqwxO/y20llVu0U/TzI3C5Tvf2gzARP6FVl WYF8eOQOkC7oKN99x8SFpQeJXu9Bn0OD3KAR9ydRTmbVZFHhus9irH6A2Btb/yp1jHlM NHGlRUhD/exH7GnwsKcpggXUD/GPryHI/MmQNKeOt8yvz6WaEddarlGsDc8ADRQBuKKz U+DcDDzD4n69XG+tvTyzPXvlVkYA+UzzuraT+4eM9PytL0nqnJ0uYu42cs6JUuw8VW1R 7S7g== 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=CgL0MLNfnx0hSdxef7KyAKhgwQlFtHM2oEdoHL2TcKI=; b=SpSk3LbOwrGBxI4dCycIXwC1uVvTuqutM0FUftHfGROx4/4+h9Q1MSoTaQ+LLKtnyh qIjmrsQuOAPHsJGl3tjUxgfkrl1hAUtfAIDIXq/cy6gfdbsHf2obivXOA9oRgTMqYTm0 j7W37VEDurm6ily47SK1DwgVReWVH37ECdO7WxeC607qDeTBvw4nYNWYcXhlHEg2xltm b8WXppuPkikuKb7uCSiMHDvAN3K9Nyb32eUBuwGRmAilCdbd/r06AUK4duYAboOfw9Mt TCyuJvvlBYiiGSCh18c47DWrs+1w/v8GHKaamuxCkj35xc3fTVR2cCyPKkOSYI/tKJ4T M/kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=gaFhQvxR; 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 y11si3806375pfi.187.2017.09.25.09.34.50 for ; Mon, 25 Sep 2017 09:34:50 -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=gaFhQvxR; 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 S965230AbdIYQes (ORCPT ); Mon, 25 Sep 2017 12:34:48 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:49501 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965206AbdIYQer (ORCPT ); Mon, 25 Sep 2017 12:34:47 -0400 Received: by mail-pf0-f172.google.com with SMTP id l188so4055778pfc.6 for ; Mon, 25 Sep 2017 09:34:47 -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=0qxUrOo3xze9BrzFxe7dRxUl2Rdq7h0yJalnEdvOz/w=; b=gaFhQvxRxkaTBfEjsAYYriuVD2ciJPlrPRwQOiYCAyFEjxMtsnNAwCZdaKl/Upgfgp uKqryyZnhFLsy+1kacWpAxq9YzEBgnsm8k9dwA9GG+lUVkEsEgPc0ing/rUJ0Tj+WEet B7qpwkiGn/5V4udN250qzLumr0LaiVAAyFBgI= 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=0qxUrOo3xze9BrzFxe7dRxUl2Rdq7h0yJalnEdvOz/w=; b=V4Sc34i+u05qbUvff9sEph8uT2jsVr6/2Q4zeT+k5W62cDiSOUpibT7dY9wP/zaD5A jv5NYO5eXH1ebtgsVMsOeagVP0ycG/Jj5SKAaH8DHZDoysPR3Vmk7nBwWmGWE+/WoPd6 ZVKJm6k1g1VUWULhI2UKZ9ROhtgm2J0ZVrfwVLd1efVLciYJV7JtWqOw9juWgsD5/1pc mf0vHxebCvNLW69GOB1z3UsU7ZmfccNmzUDnp/ZsFgSNsv0wsM4iMI6LwP8HfHfTY0W7 meOQ0M4DifbIMtVUAw5wkLfnUw2lMTNDeFkU/Rm9tIBHrTafSjFAEmzcuYtIaDNwRFkL AXpg== X-Gm-Message-State: AHPjjUi276iI0wViinpe6ZOOatwolRGMDXC2NIgTxn3hn1wauLxjUMS7 PYcY53RmgMWW25/AlFKH+RaVhg== X-Google-Smtp-Source: AOwi7QDe0BWfzfJ7hEYdj1v4zaz4Qhwqg9g4+aLzXEZFZmfAFLTVByeLTKeXDFxf9VQgbQPen5gk6g== X-Received: by 10.99.138.73 with SMTP id y70mr8443162pgd.317.1506357286873; Mon, 25 Sep 2017 09:34:46 -0700 (PDT) Received: from localhost.localdomain ([70.35.39.2]) by smtp.gmail.com with ESMTPSA id j1sm12004413pfc.169.2017.09.25.09.34.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Sep 2017 09:34:45 -0700 (PDT) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: Hans-Christian Noren Egtvedt , Linus Walleij Subject: [PATCH 4/5 v2] input: mouse: Convert GPIO mouse to use descriptors Date: Mon, 25 Sep 2017 18:34:29 +0200 Message-Id: <20170925163430.22397-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170925163430.22397-1-linus.walleij@linaro.org> References: <20170925163430.22397-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. Acked-by: Hans-Christian Noren Egtvedt Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Collect Hans-Christian's ACK - Use devm_gpiod_get_optional() on the buttons. - Check button optional descriptors with IS_ERR() and handle errors properly. - If a button gpiod is !NULL it is valid - Since we are using devm_* to allocate the input device, the .remove() function is not needed at all, so removed it. --- drivers/input/mouse/gpio_mouse.c | 193 ++++++++++++++------------------------- 1 file changed, 69 insertions(+), 124 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..4f3c9ca7b821 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 (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 (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 (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,51 @@ 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; + /* Assign some default scanning time */ + ret = device_property_read_u32(dev, "scan-interval-ms", + &gmouse->scan_ms); + if (ret || (gmouse->scan_ms == 0)) { + dev_err(dev, "invalid scan time, set to 50 ms\n"); + gmouse->scan_ms = 50; } - 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); - } - } - - 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_optional(dev, "button-left", GPIOD_IN); + if (IS_ERR(gmouse->bleft)) + return PTR_ERR(gmouse->bleft); + gmouse->bmiddle = devm_gpiod_get_optional(dev, "button-middle", GPIOD_IN); + if (IS_ERR(gmouse->bmiddle)) + return PTR_ERR(gmouse->bmiddle); + gmouse->bright = devm_gpiod_get_optional(dev, "button-right", GPIOD_IN); + if (IS_ERR(gmouse->bright)) + return PTR_ERR(gmouse->bright); + + 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); @@ -159,61 +136,30 @@ 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 (gmouse->bleft >= 0) + if (gmouse->bleft) input_set_capability(input, EV_KEY, BTN_LEFT); - if (gmouse->bmiddle >= 0) + if (gmouse->bmiddle) input_set_capability(input, EV_KEY, BTN_MIDDLE); - if (gmouse->bright >= 0) + if (gmouse->bright) 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; - } - - 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"); - - 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); + ret = input_register_polled_device(input_poll); + if (ret) { + dev_err(dev, "could not register input device\n"); + return ret; } - 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); - } + dev_dbg(dev, "%d ms scan time, buttons: %s%s%s\n", + gmouse->scan_ms, + gmouse->bleft ? "" : "left ", + gmouse->bmiddle ? "" : "middle ", + gmouse->bright ? "" : "right"); return 0; } static struct platform_driver gpio_mouse_device_driver = { .probe = gpio_mouse_probe, - .remove = gpio_mouse_remove, .driver = { .name = "gpio_mouse", } @@ -224,4 +170,3 @@ MODULE_AUTHOR("Hans-Christian Egtvedt "); MODULE_DESCRIPTION("GPIO mouse driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:gpio_mouse"); /* work with hotplug and coldplug */ - From patchwork Mon Sep 25 16:34:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 114178 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp2803890qgf; Mon, 25 Sep 2017 09:34:51 -0700 (PDT) X-Received: by 10.84.130.67 with SMTP id 61mr8334250plc.131.1506357291566; Mon, 25 Sep 2017 09:34:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506357291; cv=none; d=google.com; s=arc-20160816; b=LwsyB/kz32Fi13e1ymrGVsEg+yPfRfiJ+QZDEASVtkDfd2HEGYI/nBcGVABQAHWI1a i5GSY4/cwc/+y+xytd2OYwysE+FAr6ae/Maj9kltVyGaYJPwu01k1dcp4a1ireV30IsA RaHqvniAaHFPD6sJLFbOaY3j+Te4EzwkZaFZQNbRtaEbOGqQLidqtL7nPNqJIi9IdkCb Hw5V5o7LRFm4C04Q0xc+TuKiSEx+DpKTlyoJulkvFmVkUNN0htIiiacFn2UpeEr9OtbN NBHIDJxemt920UHl0cUmhfLtzXLVY3mwRB3k2Ej/RhLjkwh1KhWk1nLzxTnRYMo9Hk1x yb2g== 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=reUsx2YhdOTP5n11a5CbLFdPIdfmJFwg9M6sPddDqok=; b=Hm3ZityVA0fDYugYLszM+R6IM5yqoduGwzjt4DA8Ng+2D+dulMLD4hwI6i8CQmOWjW SO1KCdfAq/f5+CmFiUOcQ/Odcwq8Zf+8tZ/jFfq7Y7YXHgSw07Sx6ifCcG8bn3DtKb5C Le12wojnCHFtRzrsjUaxS94qcD+/6f2wts67fiHHGt5esosY2A6DAVRtwQ5JCrpzc9XQ De299rqaqD8cSQuE5zE8MRvjj4fhkqA6a0sC3hiMhLeQLvVzO3+KxxLwYAB1yA3KSRIu pQ9jWfi9YrsfBpklP3aOhIPjra3MK1DybIo5kzWZRCdu8RRWVP50a/g5BsncindNjh73 0c+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HjDh7Cbs; 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 y11si3806375pfi.187.2017.09.25.09.34.51 for ; Mon, 25 Sep 2017 09:34:51 -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=HjDh7Cbs; 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 S965231AbdIYQeu (ORCPT ); Mon, 25 Sep 2017 12:34:50 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:50369 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965206AbdIYQet (ORCPT ); Mon, 25 Sep 2017 12:34:49 -0400 Received: by mail-pf0-f169.google.com with SMTP id m63so4054076pfk.7 for ; Mon, 25 Sep 2017 09:34:49 -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=CqHt+crU/CQj4wtAR52OG9Vzb/KE8OHN58XPAOZNeJo=; b=HjDh7CbsGIGWCbxW7rOYqcwI9mx1X06tJGxf2ydPsM//x3Ixf33TFSNwkbQwiLkDon IM5Ficju45G4IanUpCTdcw0GtpQfV8Z/ry3JhVzoOlVWMje2lR52Q2QFdno0Tp2gYq6R LeFRdjcERi0fGD3v96JteXB1EGJnxNCZjLSc0= 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=CqHt+crU/CQj4wtAR52OG9Vzb/KE8OHN58XPAOZNeJo=; b=on2wbbzYVyigVe4p0i5p3T0ZwWvjWZJxffu4L4dVQmHJNpQjMKlDU3LXVtd68cqBXn DrYdyvdVqbt2fOaTRbrc76uPOb534CWkO2kuM9h6NSprGz+OTEDDacIaaQGwsMaFYys6 Kci/OqcA93xMu0J23i4d5XVwq+6C2Io3JYDp8P1JlY/vkVrPoSlN0ZMnJ87Ge5GHq9l3 lBatM81wTOCZHBS43HbKVArmUNQvGlEjvN5qL9ZoFfKmhC7q4Q4SGl9MKEx/OMMnQEwY TsrceJncCPtSY/CyL+Sef4EW/qjyrEP87XePCoAvIBsDWjntIHw12T5ciJoQBdKHPI4j 9AMQ== X-Gm-Message-State: AHPjjUiu/pUqB5PSSKk48qx2KZjTm3UVzUiEPMctibOQ40ZLZpibPL45 1wKd5TIb5Qm6/8z8RW3g2un1vg== X-Google-Smtp-Source: AOwi7QDHkJ8eBJ4C8Nkd/i4jY5ywVj+d8jbF36UV5PsLS2f36yargdJcMouCH8soT/3GfybMxdrd2Q== X-Received: by 10.99.114.29 with SMTP id n29mr8238344pgc.218.1506357288816; Mon, 25 Sep 2017 09:34:48 -0700 (PDT) Received: from localhost.localdomain ([70.35.39.2]) by smtp.gmail.com with ESMTPSA id j1sm12004413pfc.169.2017.09.25.09.34.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Sep 2017 09:34:48 -0700 (PDT) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: Hans-Christian Noren Egtvedt , Linus Walleij Subject: [PATCH 5/5 v2] input: mouse: Add device tree probing to GPIO mouse Date: Mon, 25 Sep 2017 18:34:30 +0200 Message-Id: <20170925163430.22397-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170925163430.22397-1-linus.walleij@linaro.org> References: <20170925163430.22397-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. Acked-by: Hans-Christian Noren Egtvedt Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Collect Hans-Christian's ACK - Rebase on the other changes. --- drivers/input/mouse/gpio_mouse.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 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 4f3c9ca7b821..deefe0df56b4 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 @@ -158,10 +159,17 @@ static int gpio_mouse_probe(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, .driver = { .name = "gpio_mouse", + .of_match_table = gpio_mouse_of_match, } }; module_platform_driver(gpio_mouse_device_driver);