Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp301329ybb; Thu, 28 Mar 2019 02:52:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDLt7Blily45lHmn8w0ztHkKJYHKWvvZ0l1DbNgBf65D2iZe3rBGYotPzMWLJqbhA/ZaxC X-Received: by 2002:a63:2747:: with SMTP id n68mr38062289pgn.317.1553766729976; Thu, 28 Mar 2019 02:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553766729; cv=none; d=google.com; s=arc-20160816; b=FV4HKZcQqHze7mMQ3yHUPGd66JwH8tILFMGUhygJCWAh6CNr7SbQxD1ZAy6w51mUfB O5sqcOpViR3zEWDBNg+RJ6kX6z1vpjgLvFEQcF1qMcS/Xmo16tCkFX/350sfV625tEj5 IXsfrsAjeRg9SAl+GOdQZ320li1rA/AWL3uUZo+Hqir4iADJtKzT6wkeCU3L+f2Prne2 0UBfQHma7DWW3EFJRBuzg9TEJZXCeE4/3w4Q5x90xj0HBAhJg3xkLmgrPtfk2cMdcv1B GwViO5aVkpTA22+krKC4011XDqi0BQK5SofPdQX8XcEEX6At0LxGmq3JjcviW4CPczr5 Erzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=rfaELReaxsy67GEXFBzE+ZMN2j38wuvUnAbrDnhjxro=; b=VbsoozbB6vTiRMzL9Xv0hsyyxVXA0PL1gLKPk8EV61AxVG4oYOrMutOyGOhvozHhPX RBlVNsBJ+aUOHnxnWIYtjr1e4pDFPg7qO+rMDXY05KxCV33GjlA0Jm9lnoc8FKGcQUHZ xTyg30Jn6SHNyTrmOZX/rnAo/BWLn3b87hOQ5b1Lr/XN4ulXDfaX0YRVwp1Xs+Pr1CUV UCAIx5HNr4aIDiVI+vbFiItvS7JCcXfBwVbN5wEsor23ljVrScaCwNFAqD1TcQgoo0Hx Th9MMJGUUcrQmAqql1zE1p3dFGNY+n6dcklbBjLl785PFuWOO26Q8N9hYhgNT6ryEnG1 pN/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LUcdj4+C; 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 g5si20516223pgc.122.2019.03.28.02.51.53; Thu, 28 Mar 2019 02:52:09 -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=LUcdj4+C; 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 S1726522AbfC1Jt0 (ORCPT + 99 others); Thu, 28 Mar 2019 05:49:26 -0400 Received: from mail-it1-f196.google.com ([209.85.166.196]:54631 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726143AbfC1JtZ (ORCPT ); Thu, 28 Mar 2019 05:49:25 -0400 Received: by mail-it1-f196.google.com with SMTP id w18so4931216itj.4; Thu, 28 Mar 2019 02:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=rfaELReaxsy67GEXFBzE+ZMN2j38wuvUnAbrDnhjxro=; b=LUcdj4+C2Q7RA+dbe3KXPVKiRyS6YfERTAbRSA01sNlNPQaPoyuPIbLk2S+dGBgL4O P69CitIflYkSjh/5n/kEGNJ83leJDAy42zSXMMqdgnAElS12OZQZj2nhNYZOuBg1LohU 1Bz6Qapy1nps/5qP8c4N3/xuXnnw1fyXc30t7Nng8QzenQzmJaVDeNUOR6ihLLi5l9Z6 HSNPUkBKLJZBJyMuQ8CVz+Nf4Ol4ks1agksJOCZqySRR1sQ7Ee643b8A1zjGwiM4u9+K rnL+KM0vu0Nn+LLbdt+lY4FXNnZ+BjV129bM5TMJUUp9op3hvmdpgFkEDH141tR6BpN/ mYfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=rfaELReaxsy67GEXFBzE+ZMN2j38wuvUnAbrDnhjxro=; b=Aj8P1GO/X96XsFrj9Ri7KkG29WsX3lBDZvVokF3LK95vwfd223RtaYmmjezQZ/D7IB Ty876ObQttEBcwbtK5+yww96b71dG17zb73k524CwRQidNA6oMZSnh6LoIhGoJJ4qrZB fpFMbhkcO/BGJmDSNmjWurEfzIo0MgknrbgZGJmo+haOeh7J37gE4Q0RD3k2YRr6ZhRb 1TPMs/FwmW/UQTM8wGY8nFjYK76sZv6NoiGvuN+PRtzxMWVH+KsDXWBazo7qAWg2y+QL 4K9nL1pRjqOF5pGGqpGnUeedVx8zqv2bQaQ7VJpi9cgXjjmWPsGKyh23LG8otSdbqrdt SuPg== X-Gm-Message-State: APjAAAV58mWZknRa7VztOeOY/bSwjIhQrvM69Wg+9+kljwRpLX/5ay0J z7M4oJsXBElmYMIJNlHS9oc= X-Received: by 2002:a24:7542:: with SMTP id y63mr2621032itc.70.1553766564352; Thu, 28 Mar 2019 02:49:24 -0700 (PDT) Received: from sidong ([220.94.163.20]) by smtp.gmail.com with ESMTPSA id 14sm1595364ity.24.2019.03.28.02.49.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Mar 2019 02:49:23 -0700 (PDT) Date: Thu, 28 Mar 2019 09:49:14 +0000 From: Sidong Yang To: Greg Kroah-Hartman Cc: Michael Straube , Rico Schrage , Sophie Matter , Hugo Lefeuvre , Dan Carpenter , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH v2] staging: pi433: Fix rf69_set_tx_cfg() logic Message-ID: <20190328094914.GA13981@sidong> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) 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 --- v2: remove obvious comment. reordered size/value/enable sync functions. drivers/staging/pi433/pi433_if.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 53928af696a6..8fa7b3346170 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -319,6 +319,12 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi433_tx_cfg *tx_cfg) } 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; ret = rf69_enable_sync(dev->spi); if (ret < 0) return ret; @@ -348,16 +354,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