From patchwork Sun Dec 11 07:22:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9469687 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 DA2E360760 for ; Sun, 11 Dec 2016 07:22:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC58828402 for ; Sun, 11 Dec 2016 07:22:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D9D828414; Sun, 11 Dec 2016 07:22:57 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID, T_TVD_MIME_EPI 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 9B01E28402 for ; Sun, 11 Dec 2016 07:22:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752435AbcLKHWz (ORCPT ); Sun, 11 Dec 2016 02:22:55 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35250 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752275AbcLKHWy (ORCPT ); Sun, 11 Dec 2016 02:22:54 -0500 Received: by mail-pg0-f67.google.com with SMTP id p66so7236736pga.2; Sat, 10 Dec 2016 23:22:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XMgRxCDPxwgLIDxNDB5Fyhsr6jUwzkFIwuzOZDxDW9I=; b=PqCkBb+d+E1F5pQuhcfZ62Scv/VIHF95sBfZCG7xr0+Ak6dHUO6v4HGsX7cICoPd8w swsHX1i0zAmaeyEHDDOmqz9Ptni/1ocwHRR7kPNMMXKMaNzC234n9hRmQch2LgA0eAzs w2X+UoxdgCRPPBRJLEytfo73MHhYTmpNtlCQaT6TxzvnJ4RtwK3ZeYVWiF4OCJfnVBX0 SbP89vbrf5ifrw3YZfsu7kFmOzw+E8AiDk3VHXLhLCQCVcAbzJUb7Z1WJrcsRthdnmXi Y/scLhzRkPfo2WleG8sAK2pnCJeA5JYyYslD03ETh+j0KLL+D2NUq1q0B0VANS76Z3mb IXSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=XMgRxCDPxwgLIDxNDB5Fyhsr6jUwzkFIwuzOZDxDW9I=; b=PF/OjTroKDvanMs8Mvt3VtRlsopo3RKvXEXwP9KCdiuzeIRJK6poD++vwMCjKA5xpE TfhbyVRtDSCkJEIt8rBnPsGLXC7PQdxMaxwPYl1gQzExgBCyv++ejf7pMBGGVxqtuTmq i2VuhA6ojCdgTc5/ZY3g7JM/TG/lSJob/5GFFG2VWm7+cnD1fRciC1oMppMvWiu1Fev/ 72cSSRtVlcxBHOxqxogR4UTTOmU0o/Vi/unhgvXswjx5gzn6v3trgp7sGsSvhQnfZBRm OSy8fTnkIJvur3Wqj2rD4Cf9HtIW85RlEzFvlql1iyWLzabJY/cSfA91hmkSYctCp1sX lmLQ== X-Gm-Message-State: AKaTC02LwOpf3UPkLKyo10hCQQVGwPIq3+UraukwQG3T2XEgfY59BfV9hBkqr3Rc2QOUTw== X-Received: by 10.84.213.23 with SMTP id f23mr173120138pli.59.1481440973055; Sat, 10 Dec 2016 23:22:53 -0800 (PST) Received: from dtor-ws ([2620:0:1000:1311:15ac:abf1:7d17:cd34]) by smtp.gmail.com with ESMTPSA id f3sm31630121pga.45.2016.12.10.23.22.51 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sat, 10 Dec 2016 23:22:52 -0800 (PST) Date: Sat, 10 Dec 2016 23:22:50 -0800 From: Dmitry Torokhov To: Jingkui Wang Cc: linux-input@vger.kernel.org, Dan Murphy , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] drivers: Update drv260x driver Message-ID: <20161211072250.GA39300@dtor-ws> References: <1481319926-47706-1-git-send-email-jkwang@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1481319926-47706-1-git-send-email-jkwang@google.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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 Hi Jingkui, On Fri, Dec 09, 2016 at 01:45:26PM -0800, Jingkui Wang wrote: > Update driver drv260x to use generic device properties > Remove platform data and corresponding header file Please next time come up with more descriptive subject than "drivers: Update drv260x driver": when scanning commit messages person shoudl be able to gauge whether the change is interesting or not. > -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; > } Now that platform code is gone there it makes no sense separating reading properties from validating the settings. Does the following version look OK to you (it needs a patch introducing temporary in probe() function, you'll find it attached)? Thanks. Input: drv260x - use temporary for &client->dev From: Dmitry Torokhov Let's introduce a temporary for "client->dev" is probe() as we use it quite a few times and "dev" is shorter. Signed-off-by: Dmitry Torokhov --- drivers/input/misc/drv260x.c | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/drivers/input/misc/drv260x.c b/drivers/input/misc/drv260x.c index 9789d4f..18c266c 100644 --- a/drivers/input/misc/drv260x.c +++ b/drivers/input/misc/drv260x.c @@ -514,10 +514,11 @@ 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 device *dev = &client->dev; struct drv260x_data *haptics; int error; - haptics = devm_kzalloc(&client->dev, sizeof(*haptics), GFP_KERNEL); + haptics = devm_kzalloc(dev, sizeof(*haptics), GFP_KERNEL); if (!haptics) return -ENOMEM; @@ -536,22 +537,20 @@ static int drv260x_probe(struct i2c_client *client, if (error) return error; } else { - dev_err(&client->dev, "Platform data not set\n"); + dev_err(dev, "Platform data not set\n"); return -ENODEV; } if (haptics->mode < DRV260X_LRA_MODE || haptics->mode > DRV260X_ERM_MODE) { - dev_err(&client->dev, - "Vibrator mode is invalid: %i\n", - haptics->mode); + dev_err(dev, "Vibrator mode is invalid: %i\n", haptics->mode); return -EINVAL; } if (haptics->library < DRV260X_LIB_EMPTY || haptics->library > DRV260X_ERM_LIB_F) { - dev_err(&client->dev, + dev_err(dev, "Library value is invalid: %i\n", haptics->library); return -EINVAL; } @@ -559,40 +558,37 @@ static int drv260x_probe(struct i2c_client *client, if (haptics->mode == DRV260X_LRA_MODE && haptics->library != DRV260X_LIB_EMPTY && haptics->library != DRV260X_LIB_LRA) { - dev_err(&client->dev, - "LRA Mode with ERM Library mismatch\n"); + dev_err(dev, "LRA Mode with ERM Library mismatch\n"); return -EINVAL; } if (haptics->mode == DRV260X_ERM_MODE && (haptics->library == DRV260X_LIB_EMPTY || haptics->library == DRV260X_LIB_LRA)) { - dev_err(&client->dev, - "ERM Mode with LRA Library mismatch\n"); + dev_err(dev, "ERM Mode with LRA Library mismatch\n"); return -EINVAL; } - haptics->regulator = devm_regulator_get(&client->dev, "vbat"); + haptics->regulator = devm_regulator_get(dev, "vbat"); if (IS_ERR(haptics->regulator)) { error = PTR_ERR(haptics->regulator); - dev_err(&client->dev, - "unable to get regulator, error: %d\n", error); + dev_err(dev, "unable to get regulator, error: %d\n", error); return error; } - haptics->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable", + haptics->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIGH); if (IS_ERR(haptics->enable_gpio)) return PTR_ERR(haptics->enable_gpio); - haptics->input_dev = devm_input_allocate_device(&client->dev); + haptics->input_dev = devm_input_allocate_device(dev); if (!haptics->input_dev) { dev_err(&client->dev, "Failed to allocate input device\n"); return -ENOMEM; } haptics->input_dev->name = "drv260x:haptics"; - haptics->input_dev->dev.parent = client->dev.parent; + haptics->input_dev->dev.parent = dev->parent; haptics->input_dev->close = drv260x_close; input_set_drvdata(haptics->input_dev, haptics); input_set_capability(haptics->input_dev, EV_FF, FF_RUMBLE); @@ -600,8 +596,7 @@ static int drv260x_probe(struct i2c_client *client, error = input_ff_create_memless(haptics->input_dev, NULL, drv260x_haptics_play); if (error) { - dev_err(&client->dev, "input_ff_create() failed: %d\n", - error); + dev_err(dev, "input_ff_create() failed: %d\n", error); return error; } @@ -613,21 +608,19 @@ static int drv260x_probe(struct i2c_client *client, haptics->regmap = devm_regmap_init_i2c(client, &drv260x_regmap_config); if (IS_ERR(haptics->regmap)) { error = PTR_ERR(haptics->regmap); - dev_err(&client->dev, "Failed to allocate register map: %d\n", - error); + dev_err(dev, "Failed to allocate register map: %d\n", error); return error; } error = drv260x_init(haptics); if (error) { - dev_err(&client->dev, "Device init failed: %d\n", error); + dev_err(dev, "Device init failed: %d\n", error); return error; } error = input_register_device(haptics->input_dev); if (error) { - dev_err(&client->dev, "couldn't register input device: %d\n", - error); + dev_err(dev, "couldn't register input device: %d\n", error); return error; }