From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72A05C433E4 for ; Thu, 23 Jul 2020 10:17:58 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 413532065F for ; Thu, 23 Jul 2020 10:17:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Tu6uEV/s" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 413532065F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6tZ/JamqMSq8bg6UG6ItMUJBytlrJ1/RoJ2UOu66Pjg=; b=Tu6uEV/sH9bvfJqYbyG96ZQ15 P+ZEOSwQmeama3ua5kayfcCzgFnHhMgAOoe/cNt47/420YdBt3ZAK5d+Ip6i94pHpeZ39nWNVRU6k NP4ScdMcYPLIOBPBF9PexX6judCPdV614B5BHLPOwSkOhe+7cVCI+k/DrfGKxZnlaLQtny61siRYw UZxSOpmf88enAaZ10kogGY/e03JkLLCGqkogBRob+j1Nbq+o1kCAZKy2kpXXAgeJAGRkh+lpFPnDt ZNG1CKtSz3NURHH4aCFgX538dLMLkPh/kCon0TTZm9pIsAdjqkwRlq2ASz3LcxXQYLXl/fr8Ax9+I OwvOUTTcw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyYHJ-000609-Gb; Thu, 23 Jul 2020 10:16:41 +0000 Received: from mail-ej1-f65.google.com ([209.85.218.65]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyYHH-0005zY-Eo; Thu, 23 Jul 2020 10:16:40 +0000 Received: by mail-ej1-f65.google.com with SMTP id a1so5753643ejg.12; Thu, 23 Jul 2020 03:16:39 -0700 (PDT) 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=dnWqbbfyoTOE1v2/nsDrkVQKi2TdYuhkczsrtV9Tj/A=; b=aoPWDnDOQ6hDWs7Bo/nBxg4oPOLatLDllUtbIuiKx2NhpXamQf//V+kSKB42sFgUSO fytJpcToDjk7AnOl/lv5sAm75gzW7lwqUsNiiB0FCdnFhv0Ea5DKK2LsNxiIPBFub10H ZgQL1hqEWZttV8ThAFOQ8JuKqCe/XHtUV4+kb5MBwGb8SBJ+cvx/zqdOmoTAuzhTqBvM tz7Xo0cwBnCXhrGtPe8XBLFmfFKfY8V7j7KC4bgQ4It5HA28fccg96yZQvRTn9qnUP+G DlLeRF4F3TukOv8T0zom5GvED+zUZITXEuJVWHTQQk/TWyi5qZ2Rwiz9g5+J9MJof9EU OG1A== X-Gm-Message-State: AOAM532O3KFgg2Z1b69fIQ1XZxQkBdhXRMAztroY3L5XqW1KVKJ1+ItO dsJtZID2QXZwxKmyQOI4vU0= X-Google-Smtp-Source: ABdhPJxFOO+eX3VP5KW+75n2zsTc3LGcB7+QqfGOKNwpQ7g2yIGn/n4uVf5RddsxBNhVVCNRNqRwLw== X-Received: by 2002:a17:906:2e83:: with SMTP id o3mr3639213eji.261.1595499398253; Thu, 23 Jul 2020 03:16:38 -0700 (PDT) Received: from kozik-lap ([194.230.155.213]) by smtp.googlemail.com with ESMTPSA id ah1sm841926ejc.43.2020.07.23.03.16.36 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Jul 2020 03:16:37 -0700 (PDT) Date: Thu, 23 Jul 2020 12:16:34 +0200 From: Krzysztof Kozlowski To: Arnd Bergmann Subject: Re: [PATCH 19/23] memory: omap-gpmc: Enclose macro statements in do-while Message-ID: <20200723101634.GD30472@kozik-lap> References: <20200723073744.13400-1-krzk@kernel.org> <20200723073744.13400-20-krzk@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200723_061639_538768_4C10AB8B X-CRM114-Status: GOOD ( 23.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , List-Id: Cc: Florian Fainelli , "open list:TEGRA ARCHITECTURE SUPPORT" , linux-omap , Tony Lindgren , Greg Kroah-Hartman , "moderated list:ARM/Mediatek SoC..." , "linux-kernel@vger.kernel.org" , Vladimir Zapolskiy , Matthias Brugger , SoC Team , arm-soc , bcm-kernel-feedback-list , Markus Mayer , Santosh Shilimkar , Olof Johansson , Thierry Reding , Andrew Morton , Jonathan Hunter , Linus Torvalds , Linux ARM , Roger Quadros Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jul 23, 2020 at 11:09:40AM +0200, Arnd Bergmann wrote: > On Thu, Jul 23, 2020 at 9:39 AM Krzysztof Kozlowski wrote: > > > > do-while is a preferred way for complex macros because of safety > > reasons. This fixes checkpatch error: > > > > ERROR: Macros starting with if should be enclosed by a do - while > > loop to avoid possible if/else logic defects > > > > Signed-off-by: Krzysztof Kozlowski > > This is an improvement, but the macro still has other issues that > are just as bad as the one you address: > > - Using the # operator to avoid the "" in the invocation seems confusing I guess it was useful for debugging. > - it implicitly uses the 'cs' and 't' variables of the calling function instead > of passing them as arguments. Actually another reason to convert it to just a function. > - it calls 'return -1' in a function that otherwise uses errno-style > return codes, so this gets interpreted as EPERM "Operation not > permitted". The users of this macro also do it (gpmc_cs_set_timings()) so this wrong practice is consistent with the driver. :) > > I would probably just open-code the entire thing and remove the > macro like: > > ret = 0; > ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 0, 3, 0, t->cs_on, > GPMC_CD_FCLK, "cs_on"); > ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 8, 12, 0, > t->cs_rd_off, GPMC_CD_FCLK, "cs_rd_off"); > ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 16, 20, 0, > t->cs_wr_off, GPMC_CD_FCLK, "cs_wr_off); > ... > if (ret) > return -ENXIO;a I like this approach because it also removes the 'return' from macro which is not desired. > > Of maybe leave the macro, but remove the if/return part and use > the "ret |= GPMC_SET_ONE(...)" trick to avoid some of the problems. I could probably then keep it as a function. This would be the safest and remove most of the problems here. Best regards, Krzysztof _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel