From patchwork Tue Nov 24 07:06:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: saurabh X-Patchwork-Id: 7687881 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9F80E9F1D3 for ; Tue, 24 Nov 2015 07:06:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D240420839 for ; Tue, 24 Nov 2015 07:06:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 032C420629 for ; Tue, 24 Nov 2015 07:06:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751700AbbKXHG4 (ORCPT ); Tue, 24 Nov 2015 02:06:56 -0500 Received: from mail-pa0-f41.google.com ([209.85.220.41]:34373 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751616AbbKXHGz (ORCPT ); Tue, 24 Nov 2015 02:06:55 -0500 Received: by padhx2 with SMTP id hx2so12793240pad.1; Mon, 23 Nov 2015 23:06:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=/tJdkOf6AqM9JoMGsjeVampbDtv6ihLilLrxJDRYPS8=; b=YzMlLfvZdDQTQ3x1w4MiASEJlCE5jWbOP5prRHLZLTn+/BFF+s8LLxMh2mSIQMeEOw j0kAp6GW0xoHrhPCqck6m5K1w30D6QzCuQh6wEy0EwwQ80eeOlSfv7izjrf8ye81y0TB b9+Hx8SRbIFfY2iQZaCCCk5OobvyIHgUAET2w4YaOMMGyWRk8DhY3Sz+c86seRKNGkg4 xzI1vC8WO22IFXu7AT1KVitcJhfQw98zv/rOKoBOaAQyZPVl+MTmbPwTKpmyOg0/m7S4 BslhRFgYT6o6tvPgQRMwtHzBf8pY46jaPID3HQnnv0wOZ6OZjOOkF3jJOPHf38HyTxR5 5CIw== X-Received: by 10.68.106.131 with SMTP id gu3mr40628148pbb.9.1448348815527; Mon, 23 Nov 2015 23:06:55 -0800 (PST) Received: from saurabh-desktop.asia.polycom.com ([122.183.18.146]) by smtp.gmail.com with ESMTPSA id d6sm12473136pfj.82.2015.11.23.23.06.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Nov 2015 23:06:54 -0800 (PST) From: Saurabh Sengar To: dmitry.torokhov@gmail.com, marex@denx.de, viresh.kumar@linaro.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saurabh Sengar Subject: [PATCH] Input: smtpe-ts: better way of using of_property_read_u32() Date: Tue, 24 Nov 2015 12:36:38 +0530 Message-Id: <1448348798-5950-1-git-send-email-saurabh.truth@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP better way of using of_property_read_u32(), helps remove one variable and many 'if' conditions Signed-off-by: Saurabh Sengar --- drivers/input/touchscreen/stmpe-ts.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c index e414d43..51abe62 100644 --- a/drivers/input/touchscreen/stmpe-ts.c +++ b/drivers/input/touchscreen/stmpe-ts.c @@ -268,27 +268,18 @@ static void stmpe_ts_get_platform_info(struct platform_device *pdev, struct stmpe_touch *ts) { struct device_node *np = pdev->dev.of_node; - u32 val; if (np) { - if (!of_property_read_u32(np, "st,sample-time", &val)) - ts->sample_time = val; - if (!of_property_read_u32(np, "st,mod-12b", &val)) - ts->mod_12b = val; - if (!of_property_read_u32(np, "st,ref-sel", &val)) - ts->ref_sel = val; - if (!of_property_read_u32(np, "st,adc-freq", &val)) - ts->adc_freq = val; - if (!of_property_read_u32(np, "st,ave-ctrl", &val)) - ts->ave_ctrl = val; - if (!of_property_read_u32(np, "st,touch-det-delay", &val)) - ts->touch_det_delay = val; - if (!of_property_read_u32(np, "st,settling", &val)) - ts->settling = val; - if (!of_property_read_u32(np, "st,fraction-z", &val)) - ts->fraction_z = val; - if (!of_property_read_u32(np, "st,i-drive", &val)) - ts->i_drive = val; + of_property_read_u32(np, "st,sample-time", &ts->sample_time); + of_property_read_u32(np, "st,mod-12b", &ts->mod_12b); + of_property_read_u32(np, "st,ref-sel", &ts->ref_sel); + of_property_read_u32(np, "st,adc-freq", &ts->adc_freq); + of_property_read_u32(np, "st,ave-ctrl", &ts->ave_ctrl); + of_property_read_u32(np, "st,touch-det-delay", + &ts->touch_det_delay); + of_property_read_u32(np, "st,settling", &ts->settling = val); + of_property_read_u32(np, "st,fraction-z", &ts->fraction_z); + of_property_read_u32(np, "st,i-drive", &ts->i_drive); } }