From patchwork Thu Jan 19 22:48:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9527087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 67BA76045A for ; Thu, 19 Jan 2017 22:49:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A0122864D for ; Thu, 19 Jan 2017 22:49:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EB3D28672; Thu, 19 Jan 2017 22:49:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_SORBS_SPAM, RDNS_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from bombadil.infradead.org (unknown [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AE34E2864D for ; Thu, 19 Jan 2017 22:49:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cULWM-0007aa-MB; Thu, 19 Jan 2017 22:49:30 +0000 Received: from mail-pg0-f66.google.com ([74.125.83.66]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cULWI-0007EG-GV for linux-arm-kernel@lists.infradead.org; Thu, 19 Jan 2017 22:49:28 +0000 Received: by mail-pg0-f66.google.com with SMTP id 204so5177495pge.2 for ; Thu, 19 Jan 2017 14:49:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aJjMf4ztw0aL407Y8TwGC8qRSi1Z+OzXr513ghkjJ7A=; b=W8Yq+NtUQXEMpfb25xz4sm3afF+QyO+WgV7QjyaZ9lBCi6qECWV7OV4zl67Tvk6RpP Sr6ppcTfsMRk9qCJhE/8IcmZw44oRXQ09RyXOedG3lQzGKa3ESVUUuMcVsav3VtfqXpx EeSuqcmA1xplw4sSk8mE77uE4Iylqf6ZN2FKcVs35jGmynYkpEwQzcsH9syRO+aG2Y74 oJTA035NzIbYcS0em8QpFBDhzhpcpnpfYeSBhBgslm/S3oz4X1zmBCrp2OBbazy5O0Ff 4SgSnVlG5S81zSdQ9No1WBwy6SCwBdBiW7kKH1iWkGr+2VoUKjyUg+n6UHVnEmgZazTh l6AQ== 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=aJjMf4ztw0aL407Y8TwGC8qRSi1Z+OzXr513ghkjJ7A=; b=gj3cD/qgdhVJw/m0OrpV8McdpSc2KeCcHi+eUw0Uz6V+CheeCBEKTQu6KMqw2vv6cT 6WSKUsX9S2mvBGCnJFg7rHPSp2XJ8HWU/RAQuWOifcpgKegkRb2Jt9TeLO7G3Lw5VBGf yxxEXhBdgiedHAf26g7FZzfwQx0YwI8zuhda/5696YXyhNDhyv04fLP71/pUgdOlOZDI IApqD6KlSFCB52E1vXeRy+wAa2gAL2br0snlBLOTzjU5mknXqe6yLs44vxcaQigXMA4z fwsMBY1b29wc2obO+adGHd02NuuVMRTr7qpt6YLjBdrPA6A4N+F9HQIGA9dHUiIGgSdf di7Q== X-Gm-Message-State: AIkVDXK7Pu7FBRXAFB1Q5Y5dhN09Rg8dYedZ0c1DDetYOmpDl12fJDiEc2Zl+yGV8+uwdw== X-Received: by 10.99.114.19 with SMTP id n19mr13055917pgc.143.1484866085815; Thu, 19 Jan 2017 14:48:05 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([172.22.152.34]) by smtp.gmail.com with ESMTPSA id b83sm11296004pfe.12.2017.01.19.14.48.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jan 2017 14:48:05 -0800 (PST) From: Dmitry Torokhov To: linux-input@vger.kernel.org, Maxime Ripard Subject: [PATCH 2/2] Input: tca8418 - switch to using generic device properties Date: Thu, 19 Jan 2017 14:48:03 -0800 Message-Id: <20170119224803.10713-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog In-Reply-To: <20170119224803.10713-1-dmitry.torokhov@gmail.com> References: <20170119224803.10713-1-dmitry.torokhov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170119_144926_663598_25AEABB7 X-CRM114-Status: GOOD ( 19.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sylvain Lemieux , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Vladimir Zapolskiy MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Let's drop legacy platform data support (there are no users in mainline) and switch to using generic device properties, which will make the driver simpler (non-OF boards can use property sets to describe hardware). Signed-off-by: Dmitry Torokhov Reviewed-by: Maxime Ripard --- drivers/input/keyboard/tca8418_keypad.c | 90 ++++++++++----------------------- include/linux/input/tca8418_keypad.h | 44 ---------------- 2 files changed, 26 insertions(+), 108 deletions(-) delete mode 100644 include/linux/input/tca8418_keypad.h diff --git a/drivers/input/keyboard/tca8418_keypad.c b/drivers/input/keyboard/tca8418_keypad.c index 7e49b14c8b02..cf3babce9e29 100644 --- a/drivers/input/keyboard/tca8418_keypad.c +++ b/drivers/input/keyboard/tca8418_keypad.c @@ -24,18 +24,17 @@ * alternative licensing inquiries. */ -#include -#include -#include #include -#include -#include -#include -#include #include +#include #include -#include +#include +#include +#include #include +#include +#include +#include /* TCA8418 hardware limits */ #define TCA8418_MAX_ROWS 8 @@ -264,43 +263,25 @@ static int tca8418_configure(struct tca8418_keypad *keypad_data, } static int tca8418_keypad_probe(struct i2c_client *client, - const struct i2c_device_id *id) + const struct i2c_device_id *id) { struct device *dev = &client->dev; - const struct tca8418_keypad_platform_data *pdata = - dev_get_platdata(dev); struct tca8418_keypad *keypad_data; struct input_dev *input; - const struct matrix_keymap_data *keymap_data = NULL; u32 rows = 0, cols = 0; - bool rep = false; - bool irq_is_gpio = false; - int irq; int error, row_shift, max_keys; - unsigned long trigger = 0; - /* Copy the platform data */ - if (pdata) { - if (!pdata->keymap_data) { - dev_err(dev, "no keymap data defined\n"); - return -EINVAL; - } - keymap_data = pdata->keymap_data; - rows = pdata->rows; - cols = pdata->cols; - rep = pdata->rep; - irq_is_gpio = pdata->irq_is_gpio; - trigger = IRQF_TRIGGER_FALLING; - } else { - struct device_node *np = dev->of_node; - int err; - - err = matrix_keypad_parse_properties(dev, &rows, &cols); - if (err) - return err; - rep = of_property_read_bool(np, "keypad,autorepeat"); + /* Check i2c driver capabilities */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) { + dev_err(dev, "%s adapter not supported\n", + dev_driver_string(&client->adapter->dev)); + return -ENODEV; } + error = matrix_keypad_parse_properties(dev, &rows, &cols); + if (error) + return error; + if (!rows || rows > TCA8418_MAX_ROWS) { dev_err(dev, "invalid rows\n"); return -EINVAL; @@ -311,13 +292,6 @@ static int tca8418_keypad_probe(struct i2c_client *client, return -EINVAL; } - /* Check i2c driver capabilities */ - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) { - dev_err(dev, "%s adapter not supported\n", - dev_driver_string(&client->adapter->dev)); - return -ENODEV; - } - row_shift = get_count_order(cols); max_keys = rows << row_shift; @@ -347,25 +321,22 @@ static int tca8418_keypad_probe(struct i2c_client *client, input->id.product = 0x001; input->id.version = 0x0001; - error = matrix_keypad_build_keymap(keymap_data, NULL, rows, cols, - NULL, input); + error = matrix_keypad_build_keymap(NULL, NULL, rows, cols, NULL, input); if (error) { dev_err(dev, "Failed to build keymap\n"); return error; } - if (rep) + if (device_property_read_bool(dev, "keypad,autorepeat")) __set_bit(EV_REP, input->evbit); + input_set_capability(input, EV_MSC, MSC_SCAN); input_set_drvdata(input, keypad_data); - irq = client->irq; - if (irq_is_gpio) - irq = gpio_to_irq(irq); - - error = devm_request_threaded_irq(dev, irq, NULL, tca8418_irq_handler, - trigger | IRQF_SHARED | IRQF_ONESHOT, + error = devm_request_threaded_irq(dev, client->irq, + NULL, tca8418_irq_handler, + IRQF_SHARED | IRQF_ONESHOT, client->name, keypad_data); if (error) { dev_err(dev, "Unable to claim irq %d; error %d\n", @@ -384,30 +355,21 @@ static int tca8418_keypad_probe(struct i2c_client *client, } static const struct i2c_device_id tca8418_id[] = { - { TCA8418_NAME, 8418, }, + { "tca8418", 8418, }, { } }; MODULE_DEVICE_TABLE(i2c, tca8418_id); -#ifdef CONFIG_OF static const struct of_device_id tca8418_dt_ids[] = { { .compatible = "ti,tca8418", }, { } }; MODULE_DEVICE_TABLE(of, tca8418_dt_ids); -/* - * The device tree based i2c loader looks for - * "i2c:" + second_component_of(property("compatible")) - * and therefore we need an alias to be found. - */ -MODULE_ALIAS("i2c:tca8418"); -#endif - static struct i2c_driver tca8418_keypad_driver = { .driver = { - .name = TCA8418_NAME, - .of_match_table = of_match_ptr(tca8418_dt_ids), + .name = "tca8418_keypad", + .of_match_table = tca8418_dt_ids, }, .probe = tca8418_keypad_probe, .id_table = tca8418_id, diff --git a/include/linux/input/tca8418_keypad.h b/include/linux/input/tca8418_keypad.h deleted file mode 100644 index e71a85dc2cbd..000000000000 --- a/include/linux/input/tca8418_keypad.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * TCA8418 keypad platform support - * - * Copyright (C) 2011 Fuel7, Inc. All rights reserved. - * - * Author: Kyle Manna - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License v2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA. - * - * If you can't comply with GPLv2, alternative licensing terms may be - * arranged. Please contact Fuel7, Inc. (http://fuel7.com/) for proprietary - * alternative licensing inquiries. - */ - -#ifndef _TCA8418_KEYPAD_H -#define _TCA8418_KEYPAD_H - -#include -#include - -#define TCA8418_I2C_ADDR 0x34 -#define TCA8418_NAME "tca8418_keypad" - -struct tca8418_keypad_platform_data { - const struct matrix_keymap_data *keymap_data; - unsigned rows; - unsigned cols; - bool rep; - bool irq_is_gpio; -}; - -#endif