Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5629363pxb; Tue, 16 Feb 2021 03:40:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJywI9iphtMgPCU/+GQ8Uui1Be4iQ86b4wsczP/UnyCHGX1AeLlAJmKlKAvsSA0K1444Tmfd X-Received: by 2002:a17:906:1fd2:: with SMTP id e18mr1736433ejt.398.1613475644556; Tue, 16 Feb 2021 03:40:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613475644; cv=none; d=google.com; s=arc-20160816; b=VTRTiWD91QhQzEHeVR7PO2lWb9fJtYF713wl+8xK8l4bl3Ddkh5NQm6S6SFiFV50eb EgJ01hbG1yU3cU4PUrggdfzP5kFCr1VtoVGZRLGSoSRllhRevgSK3Z+VYO80EqG5BN6E FRVcUEcbpWgrI6pnHr7qrMwDt0ZPN2WWVevcRQkoi/4h2LONv7S82TDoyyE6TZg6jYrs CVCwH+JQFUeOiXpo+2qaVbJ4qFMzLFIQdXT2RLnMQLOJ+hp2HeNmZFBxdhGJdF6PUU5f azvrX/3lQ1uFBIxNuGllEY48Jj5HBu7nnzEVIXy4I8Vrpjv17jSaJTl9EaY6y/95glBY VKkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=a0gZ+Z/Fm6kMpGy+nnPxz/qkmMrdwL6KVR5G6ounUhk=; b=WUJU6gUVJmEQvlfFBHT8QjVIiSPCJud6Fe7NwL1T3obijjKosqqEnSxIQhFD49FyJL 29oP+E4c7jdvqcIaqCrxEYdJKXBUUJXQtdCCg+Y2c4EyT+jE4l42lKzNxx4VaOMBf+j4 1Bkm3wRiBpnO4AmhZzLRA8Ut+TdFc1vIKHAlzxJrDOPUEP+Apy10o4rc3GE9DWY3xlN4 QSHFoNEb5l9/NbSWP8wTwpfFMcPdj7UM9oZ8YFGosRwt2hfIFN2E+FVwdBgwBxyxheYX d00OC6unf9l3Ib5bhL8pVzU49gWLhw+WrcNtHT3grY0R0T7BfPP4XcJZfKXyxqf1Z6fD iQYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u18si9183112edv.166.2021.02.16.03.40.21; Tue, 16 Feb 2021 03:40:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230144AbhBPLhA (ORCPT + 99 others); Tue, 16 Feb 2021 06:37:00 -0500 Received: from mga12.intel.com ([192.55.52.136]:20158 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230247AbhBPLfB (ORCPT ); Tue, 16 Feb 2021 06:35:01 -0500 IronPort-SDR: FsgT1/laYsCT7dKnnEk7DDkC9ugP0QKctoCfKqu5h4J8F6Gey6XnaqX1rq/WCWQqFaasm6wa1o Rcs/QmCJJ5dg== X-IronPort-AV: E=McAfee;i="6000,8403,9896"; a="161998062" X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="161998062" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2021 03:32:55 -0800 IronPort-SDR: 5k19Yr/7vlAXkntq8Lmb3za2haWaSEd0pCzg8xpwFmiBXkP2PO2XKxxadV1ldL6XDJFhM/xbv7 2vhwIQUU6FAw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="438886400" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 16 Feb 2021 03:32:53 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A9892525; Tue, 16 Feb 2021 13:32:50 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Rodolfo Giometti , Ryan Govostes Subject: [PATCH v1 7/7] pps: clients: gpio: Rearrange optional stuff in pps_gpio_setup() Date: Tue, 16 Feb 2021 13:31:54 +0200 Message-Id: <20210216113154.70852-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210216113154.70852-1-andriy.shevchenko@linux.intel.com> References: <20210216113154.70852-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rearrange optional stuff in pps_gpio_setup() so it will go after mandatory one and with reduced indentation. This will increase readability of the sources. Signed-off-by: Andy Shevchenko --- drivers/pps/clients/pps-gpio.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c index b097da5a659a..35799e6401c9 100644 --- a/drivers/pps/clients/pps-gpio.c +++ b/drivers/pps/clients/pps-gpio.c @@ -110,28 +110,31 @@ static int pps_gpio_setup(struct device *dev) return dev_err_probe(dev, PTR_ERR(data->gpio_pin), "failed to request PPS GPIO\n"); + data->assert_falling_edge = + device_property_read_bool(dev, "assert-falling-edge"); + data->echo_pin = devm_gpiod_get_optional(dev, "echo", GPIOD_OUT_LOW); if (IS_ERR(data->echo_pin)) return dev_err_probe(dev, PTR_ERR(data->echo_pin), "failed to request ECHO GPIO\n"); - if (data->echo_pin) { - ret = device_property_read_u32(dev, "echo-active-ms", &value); - if (ret) { - dev_err(dev, "failed to get echo-active-ms from FW\n"); - return ret; - } - data->echo_active_ms = value; - /* sanity check on echo_active_ms */ - if (!data->echo_active_ms || data->echo_active_ms > 999) { - dev_err(dev, "echo-active-ms: %u - bad value from FW\n", - data->echo_active_ms); - return -EINVAL; - } + if (!data->echo_pin) + return 0; + + ret = device_property_read_u32(dev, "echo-active-ms", &value); + if (ret) { + dev_err(dev, "failed to get echo-active-ms from FW\n"); + return ret; } - data->assert_falling_edge = - device_property_read_bool(dev, "assert-falling-edge"); + /* sanity check on echo_active_ms */ + if (!value || value > 999) { + dev_err(dev, "echo-active-ms: %u - bad value from FW\n", value); + return -EINVAL; + } + + data->echo_active_ms = value; + return 0; } -- 2.30.0