From patchwork Fri Dec 9 21:45:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingkui Wang X-Patchwork-Id: 9469075 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 858D460586 for ; Fri, 9 Dec 2016 21:46:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76EB4285E2 for ; Fri, 9 Dec 2016 21:46:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69CFE28697; Fri, 9 Dec 2016 21:46:33 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C08A5285E2 for ; Fri, 9 Dec 2016 21:46:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932418AbcLIVqa (ORCPT ); Fri, 9 Dec 2016 16:46:30 -0500 Received: from mail-pg0-f45.google.com ([74.125.83.45]:34914 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932414AbcLIVq3 (ORCPT ); Fri, 9 Dec 2016 16:46:29 -0500 Received: by mail-pg0-f45.google.com with SMTP id p66so11740100pga.2 for ; Fri, 09 Dec 2016 13:46:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=ua9SIUqHWMbu0jCEFpmAZQwCnT2QfEvNnV4RkSJRqnY=; b=YW575la6w6/FrRb44HphijuGEEDR82DIwdWbkfppuUM/G1Eq7qAU2EYTOS+JRh23el /t5oIiVFLDLDCBckDG6Xcaw6/gpQwYlIjYLWU+2eiti0RgzBCBnpCN7+Vu/UtP7TjZ0+ kl0Jn3lE9rfw1Kr4rwuxD8BVr4mAKR8euelyv2rg69U3oqQuanskqo+Qhm7Rq1yFVcN/ PszSPm7KO7ccaphekALekZMWc7+UQj1hBpO9LmvsltUCD2Sa/LJZbTGegGCFV25Bpl03 5K5k4sb0E6DXYu8fvDFDtx8M4eym6vivJjYEqcCfiAUiYXhdUdgDjnmJuzqidG7W/RdM kENw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ua9SIUqHWMbu0jCEFpmAZQwCnT2QfEvNnV4RkSJRqnY=; b=IiW9YD1xTrlHcZwm4I+G0BdB4rvCV8XrH0KHvJmWzI3WzDxdB6em7ZlvXvHxqp+HDY cJjalGhRQgJV1JKwB7Lv69j4Iuv+GDqX0m358szJfacJi8JNvbBuCt6XDxIHrRxShwCM j0B0dsHxugF5q9xzXxYu/BB2beZV0pYearwu3anZPJfA+HVqrcacrFQ3pKl8FWb3w8dM F6txyGN6r4FcBeDF4z/kufBpXPK+4UdCagvd4ChPWSdTysH05pwWB5jC0tzS7IpxLsDO 3ugOfX6Z5ykrYfT3AQPBnDMwbDZmRq6SlLNeXhxEqhQcv2VOKwTj2s+iF6oDo9IBW5Rn OulQ== X-Gm-Message-State: AKaTC03w0paSMhALVEMVy/HgVjl6nVpVRTd0HcdQC4ALWGjmE+vYF+sZbNwpevZk14VMSPaA X-Received: by 10.98.29.205 with SMTP id d196mr86251330pfd.111.1481319988840; Fri, 09 Dec 2016 13:46:28 -0800 (PST) Received: from jkwang0.mtv.corp.google.com ([2620:0:1000:1301:78cc:e2ae:2bcf:2337]) by smtp.gmail.com with ESMTPSA id a24sm59665115pfh.57.2016.12.09.13.46.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Dec 2016 13:46:28 -0800 (PST) From: Jingkui Wang To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, Dan Murphy , Jingkui Wang , linux-kernel@vger.kernel.org Subject: [PATCH v2] drivers: Update drv260x driver Date: Fri, 9 Dec 2016 13:45:26 -0800 Message-Id: <1481319926-47706-1-git-send-email-jkwang@google.com> X-Mailer: git-send-email 2.6.6 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Update driver drv260x to use generic device properties Remove platform data and corresponding header file Signed-off-by: Jingkui Wang --- Changes in v2: - Delete unused header file drivers/input/misc/drv260x.c | 43 ++++++----------------------- include/linux/platform_data/drv260x-pdata.h | 28 ------------------- 2 files changed, 8 insertions(+), 63 deletions(-) delete mode 100644 include/linux/platform_data/drv260x-pdata.h diff --git a/drivers/input/misc/drv260x.c b/drivers/input/misc/drv260x.c index 2adfd86c..4f448ba 100644 --- a/drivers/input/misc/drv260x.c +++ b/drivers/input/misc/drv260x.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -27,7 +26,6 @@ #include #include -#include #define DRV260X_STATUS 0x0 #define DRV260X_MODE 0x1 @@ -468,52 +466,39 @@ static const struct regmap_config drv260x_regmap_config = { .cache_type = REGCACHE_NONE, }; -#ifdef CONFIG_OF -static int drv260x_parse_dt(struct device *dev, +static int drv260x_read_device_property(struct device *dev, struct drv260x_data *haptics) { - struct device_node *np = dev->of_node; unsigned int voltage; int error; - error = of_property_read_u32(np, "mode", &haptics->mode); + error = device_property_read_u32(dev, "mode", &haptics->mode); if (error) { dev_err(dev, "%s: No entry for mode\n", __func__); return error; } - error = of_property_read_u32(np, "library-sel", &haptics->library); + error = device_property_read_u32(dev, "library-sel", &haptics->library); if (error) { dev_err(dev, "%s: No entry for library selection\n", __func__); return error; } - error = of_property_read_u32(np, "vib-rated-mv", &voltage); + error = device_property_read_u32(dev, "vib-rated-mv", &voltage); if (!error) haptics->rated_voltage = drv260x_calculate_voltage(voltage); - - error = of_property_read_u32(np, "vib-overdrive-mv", &voltage); + error = device_property_read_u32(dev, "vib-overdrive-mv", &voltage); if (!error) haptics->overdrive_voltage = drv260x_calculate_voltage(voltage); return 0; } -#else -static inline int drv260x_parse_dt(struct device *dev, - struct drv260x_data *haptics) -{ - dev_err(dev, "no platform data defined\n"); - - return -EINVAL; -} -#endif static int drv260x_probe(struct i2c_client *client, const struct i2c_device_id *id) { - const struct drv260x_platform_data *pdata = dev_get_platdata(&client->dev); struct drv260x_data *haptics; int error; @@ -524,21 +509,9 @@ static int drv260x_probe(struct i2c_client *client, haptics->rated_voltage = DRV260X_DEF_OD_CLAMP_VOLT; haptics->rated_voltage = DRV260X_DEF_RATED_VOLT; - if (pdata) { - haptics->mode = pdata->mode; - haptics->library = pdata->library_selection; - if (pdata->vib_overdrive_voltage) - haptics->overdrive_voltage = drv260x_calculate_voltage(pdata->vib_overdrive_voltage); - if (pdata->vib_rated_voltage) - haptics->rated_voltage = drv260x_calculate_voltage(pdata->vib_rated_voltage); - } else if (client->dev.of_node) { - error = drv260x_parse_dt(&client->dev, haptics); - if (error) - return error; - } else { - dev_err(&client->dev, "Platform data not set\n"); - return -ENODEV; - } + error = drv260x_read_device_property(&client->dev, haptics); + if (error) + return error; if (haptics->mode < DRV260X_LRA_MODE || diff --git a/include/linux/platform_data/drv260x-pdata.h b/include/linux/platform_data/drv260x-pdata.h deleted file mode 100644 index 0a03b09..0000000 --- a/include/linux/platform_data/drv260x-pdata.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Platform data for DRV260X haptics driver family - * - * Author: Dan Murphy - * - * Copyright: (C) 2014 Texas Instruments, Inc. - * - * 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. - * - * 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. - */ - -#ifndef _LINUX_DRV260X_PDATA_H -#define _LINUX_DRV260X_PDATA_H - -struct drv260x_platform_data { - u32 library_selection; - u32 mode; - u32 vib_rated_voltage; - u32 vib_overdrive_voltage; -}; - -#endif