Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5069071img; Wed, 27 Mar 2019 01:12:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxscBuOcJsOvKR9euRXuugtkUrFg3mTwSwTl43PzpC4RrgXTdvDWPrRPlHtOYEbLgKpkb9x X-Received: by 2002:aa7:8092:: with SMTP id v18mr18567363pff.35.1553674347942; Wed, 27 Mar 2019 01:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553674347; cv=none; d=google.com; s=arc-20160816; b=tAaMnilGfA8M6YABmyjBKVbrzfDBvrhLhGcOtuI2MpDkKsD8D3eLVY1uS/zJB0obG3 afTJ7ksEDhmQwF7lvSYa5/Z3n+zShC2yYp/+JNVqYh8/qh7Wi+nF1PAuzO8ct7LHhgLn b+CQ/Gt5Eu/lclT566jLU3x9ie9r61ZKUkZY0z1ymVJCmChtqdMFhM8o97IaGaZ3eI87 f5zk7z7eeXo/KasI7qnWFspaEhxPCeJdbK3Z2+sSYOvc7bZUj+hMMVRs06VR6croqekO KcOwZs0886XLLQyw/7PoyTtBEgMgppomMQTvePXNh8O/84v43VOUxzS5a3Xedd2D1XH9 AAsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=5xIaxSWXWv+BY7u3XIDDZCXSsuWmT0gj1RNn3WeT6jo=; b=Snq4T1By7iOOyHJF8fe+O5Kmv41i4NzO4pubY7AaKO1nJtyz0tUERY/MdozDvGT3K8 xneKkzetn9iw7SxJTQJZ0bS9iuVOBCMTiANNLI7n8UKLZ5yNQU1TvFgHdphoZK8HMZpC NdfWNjOp1pAnP5Yc4OUgbfGgaq87ANHw6aSJohsx5AjQ6AyQeFCrrbXhuAxiNxZVVYvE tFa8hUTa8WcFLh+6aTKjKVSHC5PB2ifJbC3gilEusUl2fMGuogr8wQRLNjcnz7Bilx3m aa7N0wnYoq2bmGdCZSnYRz7MgUEchjFK2KYU+6f1jpOhxDPJy9K9AO/OxK5XTry89aE8 lKJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QDUkbUGq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k16si17863819pfj.174.2019.03.27.01.12.11; Wed, 27 Mar 2019 01:12:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QDUkbUGq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726108AbfC0ILa (ORCPT + 99 others); Wed, 27 Mar 2019 04:11:30 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40137 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725763AbfC0ILa (ORCPT ); Wed, 27 Mar 2019 04:11:30 -0400 Received: by mail-pf1-f194.google.com with SMTP id c207so9356149pfc.7 for ; Wed, 27 Mar 2019 01:11:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=5xIaxSWXWv+BY7u3XIDDZCXSsuWmT0gj1RNn3WeT6jo=; b=QDUkbUGqhpo4mh26u6+6fJDLRi51HRBGNv0mnS7OcMbzOuIlaFRuKc9qh/JTpiP2oR +dNJjTzuZKSip2oL5sSVFNmwMMJEBlTGz7F9i5J94LUb9QzWEz5LEIvjOpImpRwCGkn0 DaSRosFNuElqdewtOD2flq+aPQ5qbcdLl8OogFnsPedk0d8BWi4xQSZ3YtWpzgdAjZSM MGrUkmZmLEtGiVMAZ/YMWpCrennhk3E/+RzGb6MBHZFuRXX8Z7x82XPersQ4untPeX+J iHTS8c0emg0xZpD/V3D1ZzmwS4aiJ91GoqqRikCL/Hqf0ktPdGMyPurit+xm59PliXUy SqBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5xIaxSWXWv+BY7u3XIDDZCXSsuWmT0gj1RNn3WeT6jo=; b=uAHz2Wx8G6q5myBJ01Deu8+gKLOsAAywiM5sesfcMiUrBWrTMQOD/sgpWbwsv+Pury T7I3EKNEFf1R3k2tJae+VAFEw9HPePWjxQHb1/8Nu60oGJaVgrBRC+9pCaDNTqbJCBle 4GD1J7rDjabLcJi7NRGRcWwZj0l+FQrNqeh9F0LRiIlZHhzrN0g2ZHLOdur6wqbFV8Yw RDq4FyLKpH/devichJZp6ph75mxYfHpvbIeoTE5qIiFC/7BGmOad0mXQt1of4/B18PiC iK6MoaF3nJ+17hPRuBcTiNkVgjkY2Xgh6ORd7343ekWnV5VQX69tUVK7kqkMqjJve+KV K1fA== X-Gm-Message-State: APjAAAWgJ89F5u899/4pi2mLTxwKAr2kgaK/Za1fJjXWcC5rkXZ1vctC rWGjBxuHf3Mg0mpMKl4VvnU= X-Received: by 2002:a63:e10b:: with SMTP id z11mr29626167pgh.46.1553674289531; Wed, 27 Mar 2019 01:11:29 -0700 (PDT) Received: from localhost.localdomain ([220.94.163.20]) by smtp.gmail.com with ESMTPSA id f9sm25852488pfd.10.2019.03.27.01.11.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Mar 2019 01:11:28 -0700 (PDT) From: Sidong Yang To: Greg Kroah-Hartman Cc: Sidong Yang , Michael Straube , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging: pi433: Fix rf69_set_tx_cfg() logic Date: Wed, 27 Mar 2019 08:11:20 +0000 Message-Id: <20190327081120.11152-1-realwakka@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Moved code to configure sync to where check enable_sync option before. There is no need to check enable_sync twice. Configuring sync should be executed immediately after enabling sync. Signed-off-by: Sidong Yang --- drivers/staging/pi433/pi433_if.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 53928af696a6..0a48d6cb9547 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -318,10 +318,17 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi433_tx_cfg *tx_cfg) return ret; } + /* configure sync, if enabled */ if (tx_cfg->enable_sync == OPTION_ON) { ret = rf69_enable_sync(dev->spi); if (ret < 0) return ret; + ret = rf69_set_sync_size(dev->spi, tx_cfg->sync_length); + if (ret < 0) + return ret; + ret = rf69_set_sync_values(dev->spi, tx_cfg->sync_pattern); + if (ret < 0) + return ret; } else { ret = rf69_disable_sync(dev->spi); if (ret < 0) @@ -348,16 +355,6 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi433_tx_cfg *tx_cfg) return ret; } - /* configure sync, if enabled */ - if (tx_cfg->enable_sync == OPTION_ON) { - ret = rf69_set_sync_size(dev->spi, tx_cfg->sync_length); - if (ret < 0) - return ret; - ret = rf69_set_sync_values(dev->spi, tx_cfg->sync_pattern); - if (ret < 0) - return ret; - } - return 0; } -- 2.17.1