From patchwork Thu Dec 8 20:17:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingkui Wang X-Patchwork-Id: 9467103 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 E3B706071E for ; Thu, 8 Dec 2016 20:18:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5591285E8 for ; Thu, 8 Dec 2016 20:18:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9D9A285FF; Thu, 8 Dec 2016 20:18:07 +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 6CD6F285E8 for ; Thu, 8 Dec 2016 20:18:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752380AbcLHUSG (ORCPT ); Thu, 8 Dec 2016 15:18:06 -0500 Received: from mail-pf0-f182.google.com ([209.85.192.182]:33936 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752057AbcLHUSF (ORCPT ); Thu, 8 Dec 2016 15:18:05 -0500 Received: by mail-pf0-f182.google.com with SMTP id c4so85157420pfb.1 for ; Thu, 08 Dec 2016 12:18:05 -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=dHsLcwtpoWxrSH0iVFtPDQTlW0ItlTi3eRpca4l10ig=; b=btBw4f3Pllk7ibp9lj+4Qqc03QSmtCseVBf26l878B7QKWjZiPCBPSQfOE/97sX7/O sS1jxfbWu/Dkkmwr++5lnge7s/cAW/VrCkY3FbcS2xTds8U3v4wCsH8s2Ufxn0KWycVF egh9QQ9LgFPEBdOS0qts2BU9pO79hXzKHJbQwq2gedjcL9dlVY7jmM+jiPqNO4Bq7ziM MiVo0Pj2cszDdgazSaAraTF9TnVgIkpn+89TBHD4nntTfWseQ3KGkGeN4xOaEud2dbod DgEFD4pOpgTnKCVbtValdn19XYeI3x9wP19XBjcvGteHYbf3d+i7QLHvYFJG+eljqw+P o4pA== 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=dHsLcwtpoWxrSH0iVFtPDQTlW0ItlTi3eRpca4l10ig=; b=Xr3wBQyrRdJzLrT0miXx2VycDZ64QPuBnsQuPWtUVKwBwEU4psvc2q69Unv5cJI+vV wvoH28jHD+dnyCaFpFZbake430SZ11iFt28zn+lVmCPDw3NiYuZ42pGp7S0urPwLs7B2 imk6ruNGC5CfYDZEOrelrPkuiD8BfNl3CpFj4caaUCqdELvpCdIzg3gWZO6dRJCxsmWJ ROm2MPmA3Gx4wCVP29hl6lDZqbtom80kzh007/NvHIn/2++DZft8CfyYRJjlYOL4a6E6 E5cNI9++si1jmI9V6UxVeVY1Z/VmEnSPrkargRPxLa0Z0PMqXHZ3w+8L6CYTGNdcV5zG T4IQ== X-Gm-Message-State: AKaTC00XEhMkr6mHZGftuLBAo7708e25+yUT8TQQJ+hCIfh/rch/JNjGg8DVZMfayvLSA9WV X-Received: by 10.99.109.6 with SMTP id i6mr134026940pgc.139.1481228284936; Thu, 08 Dec 2016 12:18:04 -0800 (PST) Received: from jkwang0.mtv.corp.google.com ([2620:0:1000:1301:9d18:5bb0:f993:6c0d]) by smtp.gmail.com with ESMTPSA id w11sm51952152pfk.75.2016.12.08.12.18.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Dec 2016 12:18:04 -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] drivers: Update drv260x driver Date: Thu, 8 Dec 2016 12:17:59 -0800 Message-Id: <1481228279-58030-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 Signed-off-by: Jingkui Wang --- drivers/input/misc/drv260x.c | 43 ++++++++----------------------------------- 1 file changed, 8 insertions(+), 35 deletions(-) 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 ||